diff --git a/lib/pages/spaces_management/widgets/community_structure_widget.dart b/lib/pages/spaces_management/widgets/community_structure_widget.dart index b23bb040..6123d25c 100644 --- a/lib/pages/spaces_management/widgets/community_structure_widget.dart +++ b/lib/pages/spaces_management/widgets/community_structure_widget.dart @@ -209,7 +209,8 @@ class _CommunityStructureAreaState extends State { Center( child: AddSpaceButton( onTap: () { - _showCreateSpaceDialog(screenSize); + _showCreateSpaceDialog(screenSize, + canvasHeight: canvasHeight, canvasWidth: canvasWidth); }, ), ), @@ -259,7 +260,11 @@ class _CommunityStructureAreaState extends State { } void _showCreateSpaceDialog(Size screenSize, - {Offset? position, int? parentIndex, String? direction}) { + {Offset? position, + int? parentIndex, + String? direction, + double? canvasWidth, + double? canvasHeight}) { showDialog( context: context, builder: (BuildContext context) { @@ -268,11 +273,8 @@ class _CommunityStructureAreaState extends State { onCreateSpace: (String name, String icon, List selectedProducts) { setState(() { // Set the first space in the center or use passed position - Offset centerPosition = position ?? - Offset( - screenSize.width / 2 - 75, // Center horizontally - screenSize.height / 2 - 50, // Slightly above the center vertically - ); + + Offset centerPosition = position ?? _getCenterPosition(screenSize); SpaceModel newSpace = SpaceModel( name: name, icon: icon, @@ -476,7 +478,6 @@ class _CommunityStructureAreaState extends State { bool _isHighlightedSpace(SpaceModel space) { if (widget.selectedSpace == null) return true; if (space == widget.selectedSpace) return true; - if (widget.selectedSpace?.parent?.name == space.name && widget.selectedSpace?.parent?.position == space.position) return true; if (widget.selectedSpace?.children.contains(space) == true) return true; @@ -502,4 +503,11 @@ class _CommunityStructureAreaState extends State { return connection.startSpace == widget.selectedSpace || connection.endSpace == widget.selectedSpace; } + + Offset _getCenterPosition(Size screenSize) { + return Offset( + screenSize.width / 2 - 260, + screenSize.height / 2 - 200, + ); + } }