From e09dc966e0d1281d389895f85afa9b780e3050d3 Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Wed, 9 Oct 2024 12:52:34 +0400 Subject: [PATCH] fixed space clipping --- .../view/spaces_management_page.dart | 115 +++++++++--------- 1 file changed, 56 insertions(+), 59 deletions(-) diff --git a/lib/pages/spaces_management/view/spaces_management_page.dart b/lib/pages/spaces_management/view/spaces_management_page.dart index 8ec604d9..cb0318b0 100644 --- a/lib/pages/spaces_management/view/spaces_management_page.dart +++ b/lib/pages/spaces_management/view/spaces_management_page.dart @@ -162,69 +162,66 @@ class SpaceManagementPageState extends State { panEnabled: true, // Enable panning scaleEnabled: true, // Enable zooming child: Container( - width: 2000, // Large canvas - height: 2000, // Large canvas - color: - ColorsManager.transparentColor, // Transparent background - child: Stack( - clipBehavior: Clip.none, - children: [ - // Draw lines using a CustomPaint widget - CustomPaint( - size: Size(2000, 2000), // Explicit canvas size - painter: CurvedLinePainter(connections), - ), - - spaces.isEmpty - ? Center(child: AddSpaceButton( + color: ColorsManager + .transparentColor, // Transparent background + child: spaces.isEmpty + ? Center( + child: AddSpaceButton( onTap: () { _showCreateSpaceDialog(screenSize); }, - )) - : Stack( - children: spaces - .asMap() - .entries - .map((entry) => SpaceCardWidget( - index: entry.key, - screenSize: screenSize, - position: spaces[entry.key].position, - isHovered: spaces[entry.key].isHovered, - onPanUpdate: (int index, Offset delta) { - setState(() { - spaces[index].position += delta; - }); - }, - onHoverChanged: - (int index, bool isHovered) { - setState(() { - spaces[index].isHovered = isHovered; - }); - }, - onButtonTap: (int index, - Offset newPosition, - String direction) { - _showCreateSpaceDialog( - screenSize, - position: spaces[index].position + - newPosition, - parentIndex: index, - direction: direction, - ); - }, - buildSpaceContainer: (int index) { - return SpaceContainerWidget( - index: index, - icon: spaces[index].icon, - name: spaces[index].name, - ); - }, - )) - .toList(), ), - ], - ), - ), + ) + : Stack( + clipBehavior: Clip.none, + children: [ + CustomPaint( + size: Size(4000, 4000), + painter: CurvedLinePainter(connections), + ), + ...spaces.asMap().entries.map((entry) { + final space = entry.value; + return Positioned( + left: space.position.dx, + top: space.position.dy, + child: SpaceCardWidget( + index: entry.key, + screenSize: screenSize, + position: space.position, + isHovered: space.isHovered, + onPanUpdate: (int index, Offset delta) { + setState(() { + spaces[index].position += delta; + }); + }, + onHoverChanged: + (int index, bool isHovered) { + setState(() { + spaces[index].isHovered = isHovered; + }); + }, + onButtonTap: (int index, Offset newPosition, + String direction) { + _showCreateSpaceDialog( + screenSize, + position: spaces[index].position + + newPosition, + parentIndex: index, + direction: direction, + ); + }, + buildSpaceContainer: (int index) { + return SpaceContainerWidget( + index: index, + icon: spaces[index].icon, + name: spaces[index].name, + ); + }, + ), + ); + }), + ], + )), ), ), ],