mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
93 lines
3.4 KiB
Dart
93 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:syncrow_web/pages/spaces_management/bloc/space_management_bloc.dart';
|
|
import 'package:syncrow_web/pages/spaces_management/bloc/space_management_event.dart';
|
|
import 'package:syncrow_web/pages/spaces_management/bloc/space_management_state.dart';
|
|
import 'package:syncrow_web/pages/spaces_management/model/community_model.dart';
|
|
import 'package:syncrow_web/pages/spaces_management/model/connection_model.dart';
|
|
import 'package:syncrow_web/pages/spaces_management/model/space_data_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/loaded_space_widget.dart';
|
|
import 'package:syncrow_web/pages/spaces_management/widgets/sidebar_widget.dart';
|
|
import 'package:syncrow_web/services/space_mana_api.dart';
|
|
import 'package:syncrow_web/web_layout/web_scaffold.dart';
|
|
|
|
class SpaceManagementPage extends StatefulWidget {
|
|
const SpaceManagementPage({super.key});
|
|
|
|
@override
|
|
SpaceManagementPageState createState() => SpaceManagementPageState();
|
|
}
|
|
|
|
class SpaceManagementPageState extends State<SpaceManagementPage> {
|
|
CommunityModel? selectedCommunity;
|
|
final CommunitySpaceManagementApi _api = CommunitySpaceManagementApi();
|
|
Map<String, List<SpaceModel>> communitySpaces = {};
|
|
double canvasWidth = 1000;
|
|
double canvasHeight = 1000;
|
|
List<SpaceData> spaces = [];
|
|
List<Connection> connections = [];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider(
|
|
create: (context) => SpaceManagementBloc(CommunitySpaceManagementApi())
|
|
..add(LoadCommunityAndSpacesEvent()),
|
|
child: WebScaffold(
|
|
appBarTitle: Text('Space Management',
|
|
style: Theme.of(context).textTheme.headlineLarge),
|
|
enableMenuSidebar: false,
|
|
scaffoldBody: BlocBuilder<SpaceManagementBloc, SpaceManagementState>(
|
|
builder: (context, state) {
|
|
if (state is SpaceManagementLoading) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
} else if (state is SpaceManagementLoaded) {
|
|
return LoadedSpaceView(
|
|
communities: state.communities,
|
|
selectedCommunity: selectedCommunity,
|
|
onCommunitySelected: (community) {
|
|
setState(() {
|
|
selectedCommunity = community;
|
|
});
|
|
},
|
|
);
|
|
} else if (state is SpaceManagementError) {
|
|
return Center(child: Text('Error: ${state.errorMessage}'));
|
|
}
|
|
return Container();
|
|
}),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildLoadedState(
|
|
BuildContext context, List<CommunityModel> communities) {
|
|
return Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
SidebarWidget(
|
|
communities: communities,
|
|
onCommunitySelected: (community) {
|
|
setState(() {
|
|
selectedCommunity = community;
|
|
});
|
|
},
|
|
),
|
|
CommunityStructureArea(selectedCommunity: selectedCommunity),
|
|
],
|
|
),
|
|
const GradientCanvasBorderWidget()
|
|
],
|
|
);
|
|
}
|
|
}
|