diff --git a/lib/pages/spaces_management/view/sidebar_widget.dart b/lib/pages/spaces_management/view/sidebar_widget.dart index 7bdcdb7a..2056c148 100644 --- a/lib/pages/spaces_management/view/sidebar_widget.dart +++ b/lib/pages/spaces_management/view/sidebar_widget.dart @@ -4,6 +4,7 @@ import 'package:syncrow_web/common/custom_expansion_tile.dart'; import 'package:syncrow_web/common/search_bar.dart'; import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; import 'package:syncrow_web/pages/spaces_management/view/community_tile.dart'; +import 'package:syncrow_web/pages/spaces_management/view/dialogs/create_community_dialog.dart'; import 'package:syncrow_web/utils/color_manager.dart'; import 'package:syncrow_web/utils/constants/assets.dart'; import 'package:syncrow_web/utils/style.dart'; @@ -40,13 +41,29 @@ class _SidebarWidgetState extends State { // Helper function to log the spaces and their children void _logSpaces(List spaces, int level) { for (SpaceModel space in spaces) { - debugPrint('${' ' * level}Space: ${space.name}, UUID: ${space.uuid}, Has children: ${space.children.isNotEmpty}'); + debugPrint( + '${' ' * level}Space: ${space.name}, UUID: ${space.uuid}, Has children: ${space.children.isNotEmpty}'); if (space.children.isNotEmpty) { _logSpaces(space.children, level + 1); } } } + void _showCreateCommunityDialog() { + showDialog( + context: context, + builder: (context) => CreateCommunityDialog( + onCreateCommunity: (String communityName) { + setState(() { + debugPrint("hello"); + + // You can update the communitySpaces map here + }); + }, + ), + ); + } + // Function to filter communities based on the search query Map> _filterCommunities() { if (_searchQuery.isEmpty) { @@ -57,8 +74,8 @@ class _SidebarWidgetState extends State { final filteredCommunitySpaces = >{}; widget.communitySpaces.forEach((communityName, spaces) { if (communityName.toLowerCase().contains(_searchQuery.toLowerCase()) || - spaces.any((space) => - _containsQuery(space, _searchQuery.toLowerCase()))) { + spaces.any( + (space) => _containsQuery(space, _searchQuery.toLowerCase()))) { filteredCommunitySpaces[communityName] = spaces; } }); @@ -101,7 +118,7 @@ class _SidebarWidgetState extends State { ), GestureDetector( onTap: () { - // Handle add button action + _showCreateCommunityDialog(); }, child: Container( width: 30, @@ -135,7 +152,8 @@ class _SidebarWidgetState extends State { Expanded( child: ListView( children: filteredCommunities.keys.map((communityName) { - return _buildCommunityTile(communityName, filteredCommunities[communityName]!); + return _buildCommunityTile( + communityName, filteredCommunities[communityName]!); }).toList(), ), ), @@ -147,12 +165,14 @@ class _SidebarWidgetState extends State { Widget _buildCommunityTile(String communityName, List spaces) { bool hasChildren = spaces.isNotEmpty; - debugPrint('Building CommunityTile for $communityName, hasChildren: $hasChildren'); + debugPrint( + 'Building CommunityTile for $communityName, hasChildren: $hasChildren'); return CommunityTile( title: communityName, isExpanded: _expandedTiles[communityName] ?? false, onExpansionChanged: (String title, bool expanded) { - debugPrint('CommunityTile onExpansionChanged called for $title, expanded: $expanded'); + debugPrint( + 'CommunityTile onExpansionChanged called for $title, expanded: $expanded'); _handleExpansionChange(title, expanded); }, children: hasChildren @@ -162,16 +182,20 @@ class _SidebarWidgetState extends State { } Widget _buildSpaceTile(SpaceModel space) { - debugPrint('Building SpaceTile for ${space.name}, hasChildren: ${space.children.isNotEmpty}'); + debugPrint( + 'Building SpaceTile for ${space.name}, hasChildren: ${space.children.isNotEmpty}'); return CustomExpansionTile( title: space.name, isExpanded: _expandedTiles[space.uuid] ?? false, onExpansionChanged: (bool expanded) { - debugPrint('SpaceTile onExpansionChanged called for ${space.name}, expanded: $expanded'); + debugPrint( + 'SpaceTile onExpansionChanged called for ${space.name}, expanded: $expanded'); _handleExpansionChange(space.uuid, expanded); }, children: space.children.isNotEmpty - ? space.children.map((childSpace) => _buildSpaceTile(childSpace)).toList() + ? space.children + .map((childSpace) => _buildSpaceTile(childSpace)) + .toList() : [], // Recursively render child spaces if available ); }