fixed space select

This commit is contained in:
hannathkadher
2024-11-21 20:40:36 +04:00
parent 082f8b0b27
commit 278d39cca1
4 changed files with 68 additions and 21 deletions

View File

@ -37,16 +37,29 @@ class _LoadedStateViewState extends State<LoadedSpaceView> {
Row(
children: [
SidebarWidget(
communities: widget.communities,
onCommunitySelected: widget.onCommunitySelected,
onSpaceSelected: widget.onSpaceSelected,
),
communities: widget.communities,
onCommunitySelected: widget.onCommunitySelected,
onSpaceSelected: widget.onSpaceSelected,
selectedSpaceUuid: widget.selectedSpace?.uuid,
onSelectedSpaceChanged: (String? spaceUuid) {
setState(() {
final selectedSpace = findSpaceByUuid(spaceUuid, widget.communities);
if (selectedSpace != null) {
widget.onSpaceSelected!(selectedSpace);
}
});
}),
CommunityStructureArea(
selectedCommunity: widget.selectedCommunity,
selectedSpace: widget.selectedSpace,
spaces: widget.selectedCommunity?.spaces ?? [],
connections: [],
connections: const [],
products: widget.products,
onSpaceSelected: (SpaceModel? space) {
setState(() {
widget.onSpaceSelected!(space);
});
},
),
],
),
@ -54,4 +67,13 @@ class _LoadedStateViewState extends State<LoadedSpaceView> {
],
);
}
SpaceModel? findSpaceByUuid(String? uuid, List<CommunityModel> communities) {
for (var community in communities) {
for (var space in community.spaces) {
if (space.uuid == uuid) return space;
}
}
return null;
}
}