diff --git a/lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart index 8e8cbe8f..4d470c55 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/community_structure_widget.dart @@ -137,7 +137,7 @@ class _CommunityStructureAreaState extends State { selectedSpace: widget.selectedSpace, onDelete: _onDelete, onDuplicate: () => {_onDuplicate(context)}, - onEdit: () => {}, + onEdit: () => {_showEditSpaceDialog()}, onEditName: () { setState(() { isEditingName = !isEditingName; @@ -214,9 +214,6 @@ class _CommunityStructureAreaState extends State { opacity: isHighlighted ? 1.0 : 0.3, child: SpaceContainerWidget( index: index, - onDoubleTap: () { - _showEditSpaceDialog(spaces[index]); - }, onTap: () { _selectSpace(context, spaces[index]); }, @@ -342,40 +339,43 @@ class _CommunityStructureAreaState extends State { ); } - void _showEditSpaceDialog(SpaceModel space) { - showDialog( - context: context, - builder: (BuildContext context) { - return CreateSpaceDialog( - products: widget.products, - spaceModels: widget.spaceModels, - name: space.name, - icon: space.icon, - editSpace: space, - isEdit: true, - onCreateSpace: (String name, - String icon, - List selectedProducts, - SpaceTemplateModel? spaceModel, - List? subspaces, - List? tags) { - setState(() { - // Update the space's properties - space.name = name; - space.icon = icon; - space.spaceModel = spaceModel; - space.subspaces = subspaces; - space.tags = tags; + void _showEditSpaceDialog() { + if (widget.selectedSpace != null) { + showDialog( + context: context, + builder: (BuildContext context) { + return CreateSpaceDialog( + products: widget.products, + spaceModels: widget.spaceModels, + name: widget.selectedSpace!.name, + icon: widget.selectedSpace!.icon, + editSpace: widget.selectedSpace, + isEdit: true, + onCreateSpace: (String name, + String icon, + List selectedProducts, + SpaceTemplateModel? spaceModel, + List? subspaces, + List? tags) { + setState(() { + // Update the space's properties + widget.selectedSpace!.name = name; + widget.selectedSpace!.icon = icon; + widget.selectedSpace!.spaceModel = spaceModel; + widget.selectedSpace!.subspaces = subspaces; + widget.selectedSpace!.tags = tags; - if (space.status != SpaceStatus.newSpace) { - space.status = SpaceStatus.modified; // Mark as modified - } - }); - }, - key: Key(space.name), - ); - }, - ); + if (widget.selectedSpace!.status != SpaceStatus.newSpace) { + widget.selectedSpace!.status = + SpaceStatus.modified; // Mark as modified + } + }); + }, + key: Key(widget.selectedSpace!.name), + ); + }, + ); + } } void _handleHoverChanged(int index, bool isHovered) {