mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-11-26 17:54:55 +00:00
pass selected space
This commit is contained in:
@ -20,6 +20,7 @@ class SpaceManagementPage extends StatefulWidget {
|
|||||||
|
|
||||||
class SpaceManagementPageState extends State<SpaceManagementPage> {
|
class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||||
CommunityModel? selectedCommunity;
|
CommunityModel? selectedCommunity;
|
||||||
|
SpaceModel? selectedSpace;
|
||||||
final CommunitySpaceManagementApi _api = CommunitySpaceManagementApi();
|
final CommunitySpaceManagementApi _api = CommunitySpaceManagementApi();
|
||||||
Map<String, List<SpaceModel>> communitySpaces = {};
|
Map<String, List<SpaceModel>> communitySpaces = {};
|
||||||
double canvasWidth = 1000;
|
double canvasWidth = 1000;
|
||||||
@ -55,11 +56,17 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
|||||||
return LoadedSpaceView(
|
return LoadedSpaceView(
|
||||||
communities: state.communities,
|
communities: state.communities,
|
||||||
selectedCommunity: selectedCommunity,
|
selectedCommunity: selectedCommunity,
|
||||||
|
selectedSpace: selectedSpace,
|
||||||
onCommunitySelected: (community) {
|
onCommunitySelected: (community) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedCommunity = community;
|
selectedCommunity = community;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
onSpaceSelected: (space) {
|
||||||
|
setState(() {
|
||||||
|
selectedSpace = space;
|
||||||
|
});
|
||||||
|
},
|
||||||
);
|
);
|
||||||
} else if (state is SpaceManagementError) {
|
} else if (state is SpaceManagementError) {
|
||||||
return Center(child: Text('Error: ${state.errorMessage}'));
|
return Center(child: Text('Error: ${state.errorMessage}'));
|
||||||
|
|||||||
@ -14,11 +14,14 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
|
|
||||||
class CommunityStructureArea extends StatefulWidget {
|
class CommunityStructureArea extends StatefulWidget {
|
||||||
final CommunityModel? selectedCommunity;
|
final CommunityModel? selectedCommunity;
|
||||||
|
final SpaceModel? selectedSpace;
|
||||||
|
|
||||||
final List<SpaceModel> spaces;
|
final List<SpaceModel> spaces;
|
||||||
final List<Connection> connections;
|
final List<Connection> connections;
|
||||||
|
|
||||||
CommunityStructureArea({
|
CommunityStructureArea({
|
||||||
this.selectedCommunity,
|
this.selectedCommunity,
|
||||||
|
this.selectedSpace,
|
||||||
required this.spaces,
|
required this.spaces,
|
||||||
required this.connections,
|
required this.connections,
|
||||||
});
|
});
|
||||||
@ -161,7 +164,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
),
|
),
|
||||||
if (widget.selectedCommunity != null)
|
if (widget.selectedCommunity != null)
|
||||||
Text(
|
Text(
|
||||||
widget.selectedCommunity!.name,
|
widget.selectedCommunity?.name ?? '',
|
||||||
style: const TextStyle(fontSize: 16, color: ColorsManager.blackColor),
|
style: const TextStyle(fontSize: 16, color: ColorsManager.blackColor),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -350,5 +353,4 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
|||||||
communityUuid: communityUuid,
|
communityUuid: communityUuid,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/model/community_model.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/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/gradient_canvas_border_widget.dart';
|
||||||
import 'package:syncrow_web/pages/spaces_management/widgets/sidebar_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 {
|
class LoadedSpaceView extends StatefulWidget {
|
||||||
final List<CommunityModel> communities;
|
final List<CommunityModel> communities;
|
||||||
final CommunityModel? selectedCommunity;
|
final CommunityModel? selectedCommunity;
|
||||||
|
final SpaceModel? selectedSpace;
|
||||||
final ValueChanged<CommunityModel> onCommunitySelected;
|
final ValueChanged<CommunityModel> onCommunitySelected;
|
||||||
|
final ValueChanged<SpaceModel> onSpaceSelected;
|
||||||
|
|
||||||
const LoadedSpaceView({
|
const LoadedSpaceView({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.communities,
|
required this.communities,
|
||||||
this.selectedCommunity,
|
this.selectedCommunity,
|
||||||
|
this.selectedSpace,
|
||||||
required this.onCommunitySelected,
|
required this.onCommunitySelected,
|
||||||
|
required this.onSpaceSelected,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -31,9 +36,11 @@ class _LoadedStateViewState extends State<LoadedSpaceView> {
|
|||||||
SidebarWidget(
|
SidebarWidget(
|
||||||
communities: widget.communities,
|
communities: widget.communities,
|
||||||
onCommunitySelected: widget.onCommunitySelected,
|
onCommunitySelected: widget.onCommunitySelected,
|
||||||
|
onSpaceSelected: widget.onSpaceSelected,
|
||||||
),
|
),
|
||||||
CommunityStructureArea(
|
CommunityStructureArea(
|
||||||
selectedCommunity: widget.selectedCommunity,
|
selectedCommunity: widget.selectedCommunity,
|
||||||
|
selectedSpace: widget.selectedSpace,
|
||||||
spaces: widget.selectedCommunity?.spaces ?? [],
|
spaces: widget.selectedCommunity?.spaces ?? [],
|
||||||
connections: [],
|
connections: [],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -15,9 +15,11 @@ import 'package:syncrow_web/utils/style.dart';
|
|||||||
|
|
||||||
class SidebarWidget extends StatefulWidget {
|
class SidebarWidget extends StatefulWidget {
|
||||||
final Function(CommunityModel)? onCommunitySelected;
|
final Function(CommunityModel)? onCommunitySelected;
|
||||||
|
final Function(SpaceModel)? onSpaceSelected;
|
||||||
final List<CommunityModel> communities;
|
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
|
@override
|
||||||
_SidebarWidgetState createState() => _SidebarWidgetState();
|
_SidebarWidgetState createState() => _SidebarWidgetState();
|
||||||
@ -204,10 +206,13 @@ class _SidebarWidgetState extends State<SidebarWidget> {
|
|||||||
onExpansionChanged: (bool expanded) {
|
onExpansionChanged: (bool expanded) {
|
||||||
_handleExpansionChange(space.uuid ?? '', expanded);
|
_handleExpansionChange(space.uuid ?? '', expanded);
|
||||||
},
|
},
|
||||||
onItemSelected: () => {
|
onItemSelected: () {
|
||||||
if (widget.onCommunitySelected != null)
|
if (widget.onCommunitySelected != null || widget.onSpaceSelected != null) {
|
||||||
{
|
widget.onCommunitySelected!(community); // Pass the entire community
|
||||||
widget.onCommunitySelected!(community) // Pass the entire community
|
}
|
||||||
|
|
||||||
|
if (widget.onSpaceSelected != null) {
|
||||||
|
widget.onSpaceSelected!(space); // Pass the entire community
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
children: space.children.isNotEmpty
|
children: space.children.isNotEmpty
|
||||||
|
|||||||
Reference in New Issue
Block a user