mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
community title will list from the api
This commit is contained in:
@ -4,12 +4,15 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_web/common/custom_expansion_tile.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/add_space_button.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/view/dialogs/create_space_dialog.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/view/sidebar_widget.dart';
|
||||
import 'package:syncrow_web/services/space_mana_api.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class SpaceManagementPage extends StatefulWidget{
|
||||
class SpaceManagementPage extends StatefulWidget {
|
||||
@override
|
||||
SpaceManagementPageState createState() => SpaceManagementPageState();
|
||||
}
|
||||
@ -19,6 +22,41 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
List<SpaceData> spaces = [];
|
||||
List<Connection> connections = [];
|
||||
|
||||
// API instance
|
||||
final CommunitySpaceManagementApi _api = CommunitySpaceManagementApi();
|
||||
|
||||
// Data structure to store community and associated spaces
|
||||
Map<String, List<SpaceModel>> communitySpaces = {};
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadCommunityAndSpacesData();
|
||||
}
|
||||
|
||||
// Function to load all communities and their respective spaces
|
||||
void _loadCommunityAndSpacesData() async {
|
||||
try {
|
||||
// Fetch all communities
|
||||
List<CommunityModel> communities = await _api.fetchCommunities();
|
||||
|
||||
for (CommunityModel community in communities) {
|
||||
// Fetch spaces hierarchy for each community
|
||||
List<SpaceModel> spaces = await _api.getSpaceHierarchy(community.uuid);
|
||||
|
||||
// Store the result in the communitySpaces map
|
||||
communitySpaces[community.name] = spaces;
|
||||
}
|
||||
|
||||
// Update the state to reflect loaded data
|
||||
setState(() {
|
||||
// Optionally, you can initialize something here based on the loaded data
|
||||
});
|
||||
} catch (e) {
|
||||
debugPrint('Error loading communities and spaces: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void _handleCommunitySelection(String community) {
|
||||
// Handle community selection here
|
||||
print("Selected Community: $community");
|
||||
@ -40,6 +78,7 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
children: [
|
||||
// Sidebar for navigation and community list
|
||||
SidebarWidget(
|
||||
communitySpaces: communitySpaces, // Pass communitySpaces here
|
||||
onCommunitySelected: _handleCommunitySelection,
|
||||
),
|
||||
// Right Side: Community Structure Area
|
||||
|
Reference in New Issue
Block a user