removed unused method and its use.

This commit is contained in:
Faris Armoush
2025-04-13 12:25:03 +03:00
parent c23176706f
commit bc32fe7941

View File

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