expansion only on clicking icon

This commit is contained in:
hannathkadher
2024-10-11 13:21:30 +04:00
parent cd957ed1c7
commit 56c4c858be
4 changed files with 83 additions and 66 deletions

View File

@ -175,20 +175,34 @@ class _SidebarWidgetState extends State<SidebarWidget> {
Widget _buildCommunityTile(CommunityModel community) {
bool hasChildren = community.spaces.isNotEmpty;
bool isSelectedCommunity = _selectedCommunityUuid == community.uuid;
bool isSelectedCommunity = _selectedCommunityUuid ==
community.uuid; // Check if this community is selected
debugPrint(
'Building CommunityTile for ${community.name}, hasChildren: $hasChildren');
debugPrint('Building CommunityTile for ${community.name} with UUID: ${community.uuid}');
debugPrint('Currently selected community UUID: $_selectedCommunityUuid');
debugPrint('Is selected: $isSelectedCommunity');
return CommunityTile(
title: community.name,
initiallyExpanded: isSelectedCommunity,
isSelected: isSelectedCommunity,
isExpanded: false,
onItemSelected: () {
setState(() {
_selectedSpaceUuid = community.uuid; // Update the selected community
debugPrint(
'Selected community: ${community.name}, UUID: ${community.uuid}');
debugPrint(
'Updated selected community UUID: $_selectedCommunityUuid');
});
if (widget.onCommunitySelected != null) {
widget.onCommunitySelected!(community); // Pass the entire community
}
},
onExpansionChanged: (String title, bool expanded) {
debugPrint(
'CommunityTile onExpansionChanged called for $title, expanded: $expanded');
_handleExpansionChange(community.uuid, expanded);
if (widget.onCommunitySelected != null) {
widget.onCommunitySelected!(community); // Pass the entire community
}
},
children: hasChildren
? community.spaces.map((space) => _buildSpaceTile(space)).toList()