mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
pass selected space
This commit is contained in:
@ -20,6 +20,7 @@ class SpaceManagementPage extends StatefulWidget {
|
||||
|
||||
class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
CommunityModel? selectedCommunity;
|
||||
SpaceModel? selectedSpace;
|
||||
final CommunitySpaceManagementApi _api = CommunitySpaceManagementApi();
|
||||
Map<String, List<SpaceModel>> communitySpaces = {};
|
||||
double canvasWidth = 1000;
|
||||
@ -55,11 +56,17 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
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}'));
|
||||
|
@ -14,11 +14,14 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
|
||||
class CommunityStructureArea extends StatefulWidget {
|
||||
final CommunityModel? selectedCommunity;
|
||||
final SpaceModel? selectedSpace;
|
||||
|
||||
final List<SpaceModel> spaces;
|
||||
final List<Connection> connections;
|
||||
|
||||
CommunityStructureArea({
|
||||
this.selectedCommunity,
|
||||
this.selectedSpace,
|
||||
required this.spaces,
|
||||
required this.connections,
|
||||
});
|
||||
@ -161,7 +164,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
),
|
||||
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<CommunityStructureArea> {
|
||||
communityUuid: communityUuid,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<CommunityModel> communities;
|
||||
final CommunityModel? selectedCommunity;
|
||||
final SpaceModel? selectedSpace;
|
||||
final ValueChanged<CommunityModel> onCommunitySelected;
|
||||
final ValueChanged<SpaceModel> 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<LoadedSpaceView> {
|
||||
SidebarWidget(
|
||||
communities: widget.communities,
|
||||
onCommunitySelected: widget.onCommunitySelected,
|
||||
onSpaceSelected: widget.onSpaceSelected,
|
||||
),
|
||||
CommunityStructureArea(
|
||||
selectedCommunity: widget.selectedCommunity,
|
||||
selectedSpace: widget.selectedSpace,
|
||||
spaces: widget.selectedCommunity?.spaces ?? [],
|
||||
connections: [],
|
||||
),
|
||||
|
@ -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<CommunityModel> 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,10 +206,13 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
||||
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
|
||||
|
Reference in New Issue
Block a user