mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
fixed edit community
This commit is contained in:
@ -42,6 +42,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
double canvasHeight = 1000;
|
||||
List<SpaceModel> spaces = [];
|
||||
List<Connection> connections = [];
|
||||
late TextEditingController _nameController;
|
||||
bool isEditingName = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -49,6 +51,15 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
spaces = widget.spaces.isNotEmpty ? flattenSpaces(widget.spaces) : [];
|
||||
connections = widget.spaces.isNotEmpty ? createConnections(widget.spaces) : [];
|
||||
_adjustCanvasSizeForSpaces();
|
||||
_nameController = TextEditingController(
|
||||
text: widget.selectedCommunity?.name ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -176,9 +187,59 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
if (widget.selectedCommunity != null)
|
||||
Text(
|
||||
widget.selectedCommunity?.name ?? '',
|
||||
style: const TextStyle(fontSize: 16, color: ColorsManager.blackColor),
|
||||
Row(
|
||||
children: [
|
||||
// Show Text widget when not editing
|
||||
if (!isEditingName)
|
||||
Text(
|
||||
widget.selectedCommunity?.name ?? '',
|
||||
style: const TextStyle(fontSize: 16, color: ColorsManager.blackColor),
|
||||
),
|
||||
if (isEditingName) // Show TextField when editing
|
||||
SizedBox(
|
||||
width: 200, // Adjusted width to make TextField visible
|
||||
child: TextField(
|
||||
controller: _nameController,
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
isDense: true, // Reduce the height of the TextField
|
||||
),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: ColorsManager.blackColor,
|
||||
),
|
||||
onSubmitted: (value) {
|
||||
context.read<SpaceManagementBloc>().add(
|
||||
UpdateCommunityEvent(
|
||||
communityUuid: widget.selectedCommunity!.uuid,
|
||||
name: value,
|
||||
),
|
||||
);
|
||||
setState(() {
|
||||
widget.selectedCommunity?.name = value; // Update the name
|
||||
isEditingName = false; // Exit edit mode
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
if (!isEditingName)
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isEditingName = !isEditingName; // Toggle edit mode
|
||||
});
|
||||
if (isEditingName) {
|
||||
_nameController.text = widget.selectedCommunity?.name ?? ''; // Pre-fill
|
||||
}
|
||||
},
|
||||
child: SvgPicture.asset(
|
||||
Assets.iconEdit, // Path to the edit icon SVG asset
|
||||
width: 16,
|
||||
height: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
Reference in New Issue
Block a user