diff --git a/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart b/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart index 17566da7..e4a5d14d 100644 --- a/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart +++ b/lib/pages/spaces_management/all_spaces/widgets/sidebar_widget.dart @@ -36,7 +36,8 @@ class _SidebarWidgetState extends State { @override void initState() { super.initState(); - _selectedId = widget.selectedSpaceUuid; // Initialize with the passed selected space UUID + _selectedId = + widget.selectedSpaceUuid; // Initialize with the passed selected space UUID } @override @@ -61,8 +62,8 @@ class _SidebarWidgetState extends State { return widget.communities.where((community) { final containsQueryInCommunity = community.name.toLowerCase().contains(_searchQuery.toLowerCase()); - final containsQueryInSpaces = - community.spaces.any((space) => _containsQuery(space, _searchQuery.toLowerCase())); + final containsQueryInSpaces = community.spaces + .any((space) => _containsQuery(space, _searchQuery.toLowerCase())); return containsQueryInCommunity || containsQueryInSpaces; }).toList(); @@ -71,8 +72,8 @@ class _SidebarWidgetState extends State { // Helper function to determine if any space or its children match the search query bool _containsQuery(SpaceModel space, String query) { final matchesSpace = space.name.toLowerCase().contains(query); - final matchesChildren = - space.children.any((child) => _containsQuery(child, query)); // Recursive check for children + final matchesChildren = space.children.any( + (child) => _containsQuery(child, query)); // Recursive check for children // If the space or any of its children match the query, expand this space if (matchesSpace || matchesChildren) { @@ -106,7 +107,8 @@ class _SidebarWidgetState extends State { width: 300, decoration: subSectionContainerDecoration, child: Column( - mainAxisSize: MainAxisSize.min, // Ensures the Column only takes necessary height + mainAxisSize: + MainAxisSize.min, // Ensures the Column only takes necessary height crossAxisAlignment: CrossAxisAlignment.start, children: [ // Communities title with the add button @@ -153,9 +155,9 @@ class _SidebarWidgetState extends State { // Community list Expanded( child: ListView( - children: filteredCommunities.map((community) { - return _buildCommunityTile(context, community); - }).toList(), + children: filteredCommunities + .map((community) => _buildCommunityTile(context, community)) + .toList(), ), ), ], @@ -192,9 +194,7 @@ class _SidebarWidgetState extends State { SelectCommunityEvent(selectedCommunity: community), ); }, - onExpansionChanged: (String title, bool expanded) { - _handleExpansionChange(community.uuid, expanded); - }, + onExpansionChanged: (title, expanded) {}, children: hasChildren ? community.spaces .where((space) => (space.status != SpaceStatus.deleted || @@ -205,7 +205,8 @@ class _SidebarWidgetState extends State { ); } - Widget _buildSpaceTile(SpaceModel space, CommunityModel community, {int depth = 1}) { + Widget _buildSpaceTile(SpaceModel space, CommunityModel community, + {int depth = 1}) { bool isExpandedSpace = _isSpaceOrChildSelected(space); return Padding( padding: EdgeInsets.only(left: depth * 16.0), @@ -214,9 +215,7 @@ class _SidebarWidgetState extends State { key: ValueKey(space.uuid), isSelected: _selectedId == space.uuid, initiallyExpanded: isExpandedSpace, - onExpansionChanged: (bool expanded) { - _handleExpansionChange(space.uuid ?? '', expanded); - }, + onExpansionChanged: (expanded) {}, onItemSelected: () { setState(() { _selectedId = space.uuid; @@ -224,14 +223,15 @@ class _SidebarWidgetState extends State { }); context.read().add( - SelectSpaceEvent(selectedCommunity: community, selectedSpace: space), + SelectSpaceEvent( + selectedCommunity: community, selectedSpace: space), ); }, children: space.children.isNotEmpty - ? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList() + ? space.children + .map((childSpace) => _buildSpaceTile(childSpace, community)) + .toList() : [], // Recursively render child spaces if available )); } - - void _handleExpansionChange(String uuid, bool expanded) {} }