mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-27 20:14:55 +00:00
selected space/community become dark
This commit is contained in:
@ -29,6 +29,7 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
String _searchQuery = ''; // Track search query
|
||||
String? _selectedCommunityUuid;
|
||||
String? _selectedSpaceUuid;
|
||||
String? _selectedId;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -173,15 +174,19 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
|
||||
Widget _buildCommunityTile(CommunityModel community) {
|
||||
bool hasChildren = community.spaces.isNotEmpty;
|
||||
bool isSelectedCommunity =
|
||||
_selectedCommunityUuid == community.uuid; // Check if this community is selected
|
||||
bool isSelectedCommunity = _selectedCommunityUuid == community.uuid;
|
||||
|
||||
// Check if this community is selected
|
||||
return CommunityTile(
|
||||
title: community.name,
|
||||
isSelected: isSelectedCommunity,
|
||||
key: ValueKey(community.uuid),
|
||||
isSelected: _selectedId == community.uuid,
|
||||
isExpanded: false,
|
||||
onItemSelected: () {
|
||||
setState(() {
|
||||
_selectedSpaceUuid = community.uuid; // Update the selected community
|
||||
_selectedId = community.uuid;
|
||||
_selectedCommunityUuid = community.uuid;
|
||||
_selectedSpaceUuid = null; // Update the selected community
|
||||
});
|
||||
|
||||
if (widget.onCommunitySelected != null) {
|
||||
@ -198,21 +203,26 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
}
|
||||
|
||||
Widget _buildSpaceTile(SpaceModel space, CommunityModel community) {
|
||||
bool isSelectedSpace = _isSpaceOrChildSelected(space); // Check if space should be expanded
|
||||
bool isExpandedSpace = _isSpaceOrChildSelected(space);
|
||||
bool isSelectedSpace = _selectedSpaceUuid == space.uuid;
|
||||
// Check if space should be expanded
|
||||
return SpaceTile(
|
||||
title: space.name,
|
||||
isSelected: isSelectedSpace,
|
||||
initiallyExpanded: isSelectedSpace,
|
||||
key: ValueKey(space.uuid),
|
||||
isSelected: _selectedId == space.uuid,
|
||||
initiallyExpanded: isExpandedSpace,
|
||||
onExpansionChanged: (bool expanded) {
|
||||
_handleExpansionChange(space.uuid ?? '', expanded);
|
||||
},
|
||||
onItemSelected: () {
|
||||
if (widget.onCommunitySelected != null || widget.onSpaceSelected != null) {
|
||||
widget.onCommunitySelected!(community); // Pass the entire community
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_selectedId = space.uuid;
|
||||
_selectedSpaceUuid = space.uuid;
|
||||
_selectedCommunityUuid = community.uuid; // Update selected community
|
||||
});
|
||||
print(_selectedSpaceUuid);
|
||||
if (widget.onSpaceSelected != null) {
|
||||
widget.onSpaceSelected!(space); // Pass the entire community
|
||||
widget.onSpaceSelected!(space);
|
||||
}
|
||||
},
|
||||
children: space.children.isNotEmpty
|
||||
|
||||
Reference in New Issue
Block a user