mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
changed to curve line
This commit is contained in:
@ -28,7 +28,7 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
// Draw lines using a CustomPaint widget
|
||||
CustomPaint(
|
||||
size: Size.infinite,
|
||||
painter: LinePainter(connections),
|
||||
painter: CurvedLinePainter(connections),
|
||||
),
|
||||
Center(
|
||||
child: spaces.isEmpty
|
||||
@ -114,7 +114,7 @@ class SpaceManagementPageState extends State<SpaceManagementPage> {
|
||||
if (spaces[index].isHovered) ...[
|
||||
_buildPlusButton(index, 'left', const Offset(-21, 20), screenSize),
|
||||
_buildPlusButton(index, 'right', const Offset(140, 20), screenSize),
|
||||
_buildPlusButton(index, 'down', const Offset(63, 55), screenSize),
|
||||
_buildPlusButton(index, 'down', const Offset(63, 50), screenSize),
|
||||
],
|
||||
],
|
||||
),
|
||||
@ -239,10 +239,11 @@ class Connection {
|
||||
}
|
||||
|
||||
// Custom painter to draw lines between connected spaces
|
||||
class LinePainter extends CustomPainter {
|
||||
|
||||
class CurvedLinePainter extends CustomPainter {
|
||||
final List<Connection> connections;
|
||||
|
||||
LinePainter(this.connections);
|
||||
CurvedLinePainter(this.connections);
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
@ -255,8 +256,20 @@ class LinePainter extends CustomPainter {
|
||||
final start = connection.startSpace.position + Offset(75, 60); // Bottom center of the starting space
|
||||
final end = connection.endSpace.position + Offset(75, 0); // Top center of the ending space
|
||||
|
||||
// Draw a straight line connecting the two spaces
|
||||
canvas.drawLine(start, end, paint);
|
||||
// Calculate control point for Bézier curve (to create a curve)
|
||||
final controlPoint = Offset((start.dx + end.dx) / 2, start.dy + 50);
|
||||
|
||||
// Draw the Bézier curve
|
||||
final path = Path()
|
||||
..moveTo(start.dx, start.dy)
|
||||
..quadraticBezierTo(controlPoint.dx, controlPoint.dy, end.dx, end.dy);
|
||||
|
||||
canvas.drawPath(path, paint);
|
||||
|
||||
// Draw small connection dots at the start and end points
|
||||
final dotPaint = Paint()..color = ColorsManager.blackColor;
|
||||
canvas.drawCircle(start, 5, dotPaint); // Start dot
|
||||
canvas.drawCircle(end, 5, dotPaint); // End dot
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,6 +277,4 @@ class LinePainter extends CustomPainter {
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user