diff --git a/lib/pages/spaces_management/view/spaces_management_page.dart b/lib/pages/spaces_management/view/spaces_management_page.dart index 95d2e9d3..fc01f5ac 100644 --- a/lib/pages/spaces_management/view/spaces_management_page.dart +++ b/lib/pages/spaces_management/view/spaces_management_page.dart @@ -20,6 +20,7 @@ class SpaceManagementPage extends StatefulWidget { class SpaceManagementPageState extends State { CommunityModel? selectedCommunity; + SpaceModel? selectedSpace; final CommunitySpaceManagementApi _api = CommunitySpaceManagementApi(); Map> communitySpaces = {}; double canvasWidth = 1000; @@ -55,11 +56,17 @@ class SpaceManagementPageState extends State { return LoadedSpaceView( communities: state.communities, selectedCommunity: selectedCommunity, + selectedSpace: selectedSpace, onCommunitySelected: (community) { setState(() { selectedCommunity = community; }); }, + onSpaceSelected: (space) { + setState(() { + selectedSpace = space; + }); + }, ); } else if (state is SpaceManagementError) { return Center(child: Text('Error: ${state.errorMessage}')); diff --git a/lib/pages/spaces_management/widgets/community_structure_widget.dart b/lib/pages/spaces_management/widgets/community_structure_widget.dart index 9fb20606..26e268c7 100644 --- a/lib/pages/spaces_management/widgets/community_structure_widget.dart +++ b/lib/pages/spaces_management/widgets/community_structure_widget.dart @@ -14,11 +14,14 @@ import 'package:syncrow_web/utils/color_manager.dart'; class CommunityStructureArea extends StatefulWidget { final CommunityModel? selectedCommunity; + final SpaceModel? selectedSpace; + final List spaces; final List connections; CommunityStructureArea({ this.selectedCommunity, + this.selectedSpace, required this.spaces, required this.connections, }); @@ -161,7 +164,7 @@ class _CommunityStructureAreaState extends State { ), if (widget.selectedCommunity != null) Text( - widget.selectedCommunity!.name, + widget.selectedCommunity?.name ?? '', style: const TextStyle(fontSize: 16, color: ColorsManager.blackColor), ), ], @@ -350,5 +353,4 @@ class _CommunityStructureAreaState extends State { communityUuid: communityUuid, )); } - } diff --git a/lib/pages/spaces_management/widgets/loaded_space_widget.dart b/lib/pages/spaces_management/widgets/loaded_space_widget.dart index 3b3ebeab..f3318107 100644 --- a/lib/pages/spaces_management/widgets/loaded_space_widget.dart +++ b/lib/pages/spaces_management/widgets/loaded_space_widget.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:syncrow_web/pages/spaces_management/model/community_model.dart'; +import 'package:syncrow_web/pages/spaces_management/model/space_model.dart'; import 'package:syncrow_web/pages/spaces_management/widgets/community_structure_widget.dart'; import 'package:syncrow_web/pages/spaces_management/widgets/gradient_canvas_border_widget.dart'; import 'package:syncrow_web/pages/spaces_management/widgets/sidebar_widget.dart'; @@ -7,13 +8,17 @@ import 'package:syncrow_web/pages/spaces_management/widgets/sidebar_widget.dart' class LoadedSpaceView extends StatefulWidget { final List communities; final CommunityModel? selectedCommunity; + final SpaceModel? selectedSpace; final ValueChanged onCommunitySelected; + final ValueChanged onSpaceSelected; const LoadedSpaceView({ Key? key, required this.communities, this.selectedCommunity, + this.selectedSpace, required this.onCommunitySelected, + required this.onSpaceSelected, }) : super(key: key); @override @@ -31,9 +36,11 @@ class _LoadedStateViewState extends State { SidebarWidget( communities: widget.communities, onCommunitySelected: widget.onCommunitySelected, + onSpaceSelected: widget.onSpaceSelected, ), CommunityStructureArea( selectedCommunity: widget.selectedCommunity, + selectedSpace: widget.selectedSpace, spaces: widget.selectedCommunity?.spaces ?? [], connections: [], ), diff --git a/lib/pages/spaces_management/widgets/sidebar_widget.dart b/lib/pages/spaces_management/widgets/sidebar_widget.dart index 10f03d4a..f50663b3 100644 --- a/lib/pages/spaces_management/widgets/sidebar_widget.dart +++ b/lib/pages/spaces_management/widgets/sidebar_widget.dart @@ -15,9 +15,11 @@ import 'package:syncrow_web/utils/style.dart'; class SidebarWidget extends StatefulWidget { final Function(CommunityModel)? onCommunitySelected; + final Function(SpaceModel)? onSpaceSelected; final List communities; - const SidebarWidget({super.key, this.onCommunitySelected, required this.communities}); + const SidebarWidget( + {super.key, this.onCommunitySelected, this.onSpaceSelected, required this.communities}); @override _SidebarWidgetState createState() => _SidebarWidgetState(); @@ -204,11 +206,14 @@ class _SidebarWidgetState extends State { onExpansionChanged: (bool expanded) { _handleExpansionChange(space.uuid ?? '', expanded); }, - onItemSelected: () => { - if (widget.onCommunitySelected != null) - { - widget.onCommunitySelected!(community) // Pass the entire community - } + onItemSelected: () { + if (widget.onCommunitySelected != null || widget.onSpaceSelected != null) { + widget.onCommunitySelected!(community); // Pass the entire community + } + + if (widget.onSpaceSelected != null) { + widget.onSpaceSelected!(space); // Pass the entire community + } }, children: space.children.isNotEmpty ? space.children.map((childSpace) => _buildSpaceTile(childSpace, community)).toList()