mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
updated LoadedSpaceView
This commit is contained in:
@ -36,32 +36,22 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) =>
|
create: (context) => SpaceManagementBloc(_api, _productApi)
|
||||||
SpaceManagementBloc(_api, _productApi)..add(LoadCommunityAndSpacesEvent()),
|
..add(LoadCommunityAndSpacesEvent()),
|
||||||
child: WebScaffold(
|
child: WebScaffold(
|
||||||
appBarTitle: Text('Space Management', style: Theme.of(context).textTheme.headlineLarge),
|
appBarTitle: Text('Space Management',
|
||||||
|
style: Theme.of(context).textTheme.headlineLarge),
|
||||||
enableMenuSidebar: false,
|
enableMenuSidebar: false,
|
||||||
rightBody: const NavigateHomeGridView(),
|
rightBody: const NavigateHomeGridView(),
|
||||||
scaffoldBody:
|
scaffoldBody: BlocBuilder<SpaceManagementBloc, SpaceManagementState>(
|
||||||
BlocBuilder<SpaceManagementBloc, SpaceManagementState>(builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is SpaceManagementLoading) {
|
if (state is SpaceManagementLoading) {
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
} else if (state is SpaceManagementLoaded) {
|
} else if (state is SpaceManagementLoaded) {
|
||||||
int selectedIndex = state.communities.indexWhere(
|
|
||||||
(community) => community.uuid == selectedCommunity?.uuid,
|
|
||||||
);
|
|
||||||
if (selectedIndex != -1) {
|
|
||||||
selectedCommunity = state.communities[selectedIndex];
|
|
||||||
} else if (state.selectedCommunity != null) {
|
|
||||||
selectedCommunity = state.selectedCommunity;
|
|
||||||
} else {
|
|
||||||
selectedCommunity = null;
|
|
||||||
selectedSpace = null;
|
|
||||||
}
|
|
||||||
return LoadedSpaceView(
|
return LoadedSpaceView(
|
||||||
communities: state.communities,
|
communities: state.communities,
|
||||||
selectedCommunity: selectedCommunity,
|
selectedCommunity: state.selectedCommunity,
|
||||||
selectedSpace: selectedSpace,
|
selectedSpace: state.selectedSpace,
|
||||||
products: state.products,
|
products: state.products,
|
||||||
onCommunitySelected: (community) {
|
onCommunitySelected: (community) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
Reference in New Issue
Block a user