mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
updated api
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/common/buttons/add_space_button.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/widgets/curved_line_painter.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/widgets/space_card_widget.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/model/space_data_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/model/connection_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/widgets/space_container_widget.dart';
|
||||
import 'package:syncrow_web/utils/color_manager.dart';
|
||||
@ -21,7 +21,7 @@ class CommunityStructureArea extends StatefulWidget {
|
||||
class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
double canvasWidth = 1000;
|
||||
double canvasHeight = 1000;
|
||||
List<SpaceData> spaces = [];
|
||||
List<SpaceModel> spaces = [];
|
||||
List<Connection> connections = [];
|
||||
|
||||
@override
|
||||
@ -81,7 +81,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
buildSpaceContainer: (int index) {
|
||||
return SpaceContainerWidget(
|
||||
index: index,
|
||||
icon: spaces[index].icon,
|
||||
icon: spaces[index].icon ?? '',
|
||||
name: spaces[index].name,
|
||||
);
|
||||
},
|
||||
@ -122,25 +122,51 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'Community Structure',
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Community Structure',
|
||||
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
||||
),
|
||||
if (widget.selectedCommunity != null)
|
||||
Text(
|
||||
widget.selectedCommunity!.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, color: ColorsManager.blackColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (widget.selectedCommunity != null)
|
||||
Text(
|
||||
widget.selectedCommunity!.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, color: ColorsManager.blackColor),
|
||||
// Show "Save" button only if there are spaces
|
||||
if (spaces.isNotEmpty && widget.selectedCommunity != null )
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
_saveSpaces();
|
||||
},
|
||||
icon: const Icon(Icons.save, size: 18),
|
||||
label: const Text("Save"),
|
||||
style: ElevatedButton.styleFrom(
|
||||
|
||||
backgroundColor: ColorsManager.whiteColors,
|
||||
foregroundColor: Colors.black,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8.0),
|
||||
),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 12.0, vertical: 8.0),
|
||||
side: BorderSide(color: Colors.grey.shade300),
|
||||
elevation: 0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _updateNodePosition(SpaceData node, Offset newPosition) {
|
||||
void _updateNodePosition(SpaceModel node, Offset newPosition) {
|
||||
setState(() {
|
||||
node.position = newPosition;
|
||||
|
||||
@ -188,15 +214,15 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
50, // Slightly above the center vertically
|
||||
);
|
||||
|
||||
SpaceData newSpace =
|
||||
SpaceData(name: name, icon: icon, position: centerPosition);
|
||||
SpaceModel newSpace =
|
||||
SpaceModel(name: name, icon: icon, position: centerPosition, isPrivate: false, children: []);
|
||||
spaces.add(newSpace);
|
||||
|
||||
_updateNodePosition(newSpace, newSpace.position);
|
||||
|
||||
// Add connection for down-button
|
||||
if (parentIndex != null && direction != null) {
|
||||
SpaceData parentSpace = spaces[parentIndex];
|
||||
SpaceModel parentSpace = spaces[parentIndex];
|
||||
connections.add(Connection(
|
||||
startSpace: parentSpace,
|
||||
endSpace: newSpace,
|
||||
@ -215,4 +241,10 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
spaces[index].isHovered = isHovered;
|
||||
});
|
||||
}
|
||||
|
||||
void _saveSpaces() {
|
||||
// Implement your save functionality here
|
||||
|
||||
print("Spaces saved: ${spaces.length}");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user