mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
adjust the canvas if spaces are far positioned
This commit is contained in:
@ -38,6 +38,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
super.initState();
|
||||
spaces = widget.spaces.isNotEmpty ? flattenSpaces(widget.spaces) : [];
|
||||
connections = widget.spaces.isNotEmpty ? createConnections(widget.spaces) : [];
|
||||
_adjustCanvasSizeForSpaces();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -48,10 +49,8 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
setState(() {
|
||||
spaces = widget.spaces.isNotEmpty ? flattenSpaces(widget.spaces) : [];
|
||||
connections = widget.spaces.isNotEmpty ? createConnections(widget.spaces) : [];
|
||||
_adjustCanvasSizeForSpaces();
|
||||
});
|
||||
for (var space in spaces) {
|
||||
print('InitState - Space Position ${space.name}: ${space.incomingConnection?.direction}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,6 +212,18 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
});
|
||||
}
|
||||
|
||||
void _adjustCanvasSizeForSpaces() {
|
||||
for (var space in spaces) {
|
||||
if (space.position.dx >= canvasWidth - 200) {
|
||||
canvasWidth = space.position.dx + 200;
|
||||
}
|
||||
|
||||
if (space.position.dy >= canvasHeight - 200) {
|
||||
canvasHeight = space.position.dy + 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _showCreateSpaceDialog(Size screenSize,
|
||||
{Offset? position, int? parentIndex, String? direction}) {
|
||||
showDialog(
|
||||
@ -323,14 +334,6 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
List<SpaceModel> spaceList = spaces;
|
||||
String communityUuid = widget.selectedCommunity!.uuid;
|
||||
|
||||
for (var space in spaceList) {
|
||||
print("Processing space: ${space.name}, UUID: ${space.uuid}");
|
||||
// Example: Log connections
|
||||
print("Parent UUID: ${space.parent?.uuid}");
|
||||
print("Incoming connection: ${space.incomingConnection?.direction}");
|
||||
print("Outgoing connections: ${space.outgoingConnections.map((c) => c.direction).toList()}");
|
||||
}
|
||||
|
||||
// Dispatch the save event
|
||||
context.read<SpaceManagementBloc>().add(SaveSpacesEvent(
|
||||
spaces: spaceList,
|
||||
|
Reference in New Issue
Block a user