This commit is contained in:
mr
2025-02-21 11:14:46 +01:00
parent 28510d0ba1
commit 863a35b878
34 changed files with 153 additions and 128 deletions

View File

@@ -9,7 +9,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:flutter_flow_chart/src/flow_chart_menu.dart';
import 'package:flutter_flow_chart/src/flow_chart_selected_menu.dart';
import 'package:flutter_flow_chart/src/ui/draw_arrow.dart';
import 'package:flutter_flow_chart/src/ui/segment_handler.dart';
/// Listener definition for a new connection
@@ -842,7 +841,6 @@ class Dashboard extends ChangeNotifier {
}
if (found == 0) {
debugPrint('Element with $destId id not found!');
return;
}
if (notify) {

View File

@@ -296,9 +296,9 @@ class HoverMenuState extends State<HoverMenu> {
}
}
bool isCtrl = false;
class FlowChartState<T extends FlowData> extends State<FlowChart> {
var node = FocusNode();
bool isCtrl = false;
@override
void initState() {
node.requestFocus();
@@ -313,7 +313,6 @@ class FlowChartState<T extends FlowData> extends State<FlowChart> {
@override
Widget build(BuildContext context) {
if (!widget.dashboard.isOpened && widget.onDashboardAlertOpened != null ) {
if (widget.dashboard.id != null) {
widget.dashboard.isOpened = true;
@@ -365,15 +364,20 @@ class FlowChartState<T extends FlowData> extends State<FlowChart> {
autofocus: true,
onKeyEvent: (event) {
bool change = false;
if (event.logicalKey == LogicalKeyboardKey.controlLeft) {
isCtrl = event is KeyDownEvent || event is KeyRepeatEvent;
if (event.logicalKey == LogicalKeyboardKey.controlLeft && event is KeyDownEvent) {
print("CTRL true");
isCtrl = true;
}
/*if ((event is KeyDownEvent || event.logicalKey == LogicalKeyboardKey.keyZ) && isCtrl) {
if (event.logicalKey == LogicalKeyboardKey.controlLeft && event is KeyUpEvent) {
print("CTRL false");
isCtrl = false;
}
if ((event is KeyDownEvent || event.logicalKey == LogicalKeyboardKey.keyZ) && isCtrl) {
widget.dashboard.back();
}
if ((event is KeyDownEvent || event.logicalKey == LogicalKeyboardKey.keyY) && isCtrl) {
widget.dashboard.forward();
}*/
}
if (event is KeyDownEvent && event.logicalKey == LogicalKeyboardKey.add) {
change = true;
for (var el in widget.dashboard.elementSelected) {
@@ -418,7 +422,7 @@ class FlowChartState<T extends FlowData> extends State<FlowChart> {
children: [
Stack(children: [
// Draw the grid
Container( child: DragTarget<T>(
DragTarget<T>(
builder: (
BuildContext context,
List<dynamic> accepted,
@@ -475,7 +479,7 @@ class FlowChartState<T extends FlowData> extends State<FlowChart> {
);
widget.dashboard.addElement(el, context);
},
))]
)]
),
widget.dashboard.isMenu ? Positioned(top: 50, child: FlowChartSelectedMenu(
key: widget.dashboard.selectedMenuKey,
@@ -729,9 +733,10 @@ class ChartWidgetState<T extends FlowData> extends State<ChartWidget> {
final gridKey = GlobalKey();
var tapDownPos = Offset.zero;
var secondaryTapDownPos = Offset.zero;
for (int i = 0; i < widget.dashboard.elements.length; i++)
for (int i = 0; i < widget.dashboard.elements.length; i++) {
widget.dashboard.elements[i].next.removeWhere((element) =>
widget.dashboard.findElementIndexById(element.destElementId) < 0);
}
return Stack( children: [
Positioned.fill(
child: GestureDetector(

View File

@@ -240,12 +240,12 @@ class FlowChartMenuState extends State<FlowChartMenu> {
])),
Expanded(
child: Padding( child: Text("current workflow : ${widget.dashboard.name}", overflow: TextOverflow.ellipsis,
style: TextStyle(color: Colors.white, fontSize: 14), textAlign: TextAlign.start),
padding: EdgeInsets.symmetric(horizontal: 20))),
child: Padding( padding: const EdgeInsets.symmetric(horizontal: 20),
child: Text("current workflow : ${widget.dashboard.name}", overflow: TextOverflow.ellipsis,
style: const TextStyle(color: Colors.white, fontSize: 14), textAlign: TextAlign.start))),
])),
widget.menuExtension != null && widget.chart.widget.flowChart.widget.width > 600 ? Container(
decoration: BoxDecoration(
decoration: const BoxDecoration(
border: Border(left: BorderSide(color: Colors.white, width: 1))
),
child: widget.menuExtension

View File

@@ -3,8 +3,6 @@ import 'dart:convert';
import 'dart:ui' as ui;
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_flow_chart/flutter_flow_chart.dart';
import 'package:flutter_flow_chart/src/ui/segment_handler.dart';
@@ -257,6 +255,7 @@ class DrawingArrow extends ChangeNotifier {
/// Draw arrow from [srcElement] to [destElement]
/// using [arrowParams] parameters
// ignore: must_be_immutable
class DrawArrow extends StatefulWidget {
ChartWidgetState flow;
///
@@ -377,14 +376,15 @@ class DrawArrowState extends State<DrawArrow> {
}
}
// ignore: must_be_immutable
class GraphParamsWidget extends StatefulWidget {
ChartWidgetState comp;
bool isShowed = false;
Offset? position;
FlowElement element;
int index;
GraphParamsWidget({ Key? key, required this.element, required this.comp,
required this.index }): super(key: key);
GraphParamsWidget({ super.key, required this.element, required this.comp,
required this.index });
@override GraphParamsWidgetState createState() => GraphParamsWidgetState();
}
class GraphParamsWidgetState extends State<GraphParamsWidget> {
@@ -393,32 +393,32 @@ class GraphParamsWidgetState extends State<GraphParamsWidget> {
top: (widget.position?.dy ?? 0) - 5, left: (widget.position?.dx ?? 0) - 5,
child: MouseRegion( cursor: SystemMouseCursors.click,
onHover: (event) => setState(() { widget.isShowed = true; }),
child: Container(
child: Row(children: [
IconButton(onPressed: () {
widget.comp.setState(() {
widget.comp.widget.dashboard.removeArrows((el) => el.fromID == "${widget.element.id}${widget.index}", context);
widget.element.next.removeAt(widget.index);
});
}, icon: Icon(Icons.delete))
],))));
}, icon: const Icon(Icons.delete))
],)));
}
}
// ignore: must_be_immutable
class ArrowInfoWidget extends StatefulWidget {
Dashboard dashboard;
ArrowInfoWidget ({ Key? key, required this.dashboard }): super(key: key);
ArrowInfoWidget ({ super.key, required this.dashboard });
@override ArrowInfoWidgetState createState() => ArrowInfoWidgetState();
}
class ArrowInfoWidgetState extends State<ArrowInfoWidget> {
@override Widget build(BuildContext context) {
return SingleChildScrollView( child: Column(children: [
Container(height: 50,
decoration: BoxDecoration(color: widget.dashboard.midDashColor, border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),
child: Center( child: Text("<Arrow> Style", style: TextStyle(fontSize: 20)))),
decoration: BoxDecoration(color: widget.dashboard.midDashColor, border: const Border(bottom: BorderSide(color: Colors.grey, width: 1))),
child: const Center( child: Text("<Arrow> Style", style: TextStyle(fontSize: 20)))),
Container(height: 50,
decoration: BoxDecoration(color: widget.dashboard.midDashColor, border: Border(bottom: BorderSide(color: Colors.grey, width: 1))),
child: Row(children: [],)
decoration: BoxDecoration(color: widget.dashboard.midDashColor, border: const Border(bottom: BorderSide(color: Colors.grey, width: 1))),
child: const Row(children: [],)
),
],) );
}

View File

@@ -136,32 +136,27 @@ class ElementWidgetState<T extends FlowData> extends State<ElementWidget> {
if (widget.element.widget == null) { element = RectangleWidget(element: widget.element);
} else { element = AnyWidget(element: widget.element); }
}
var tapLocation = Offset.zero;
var secondaryTapDownPos = Offset.zero;
Widget w = GestureDetector(
Widget w = InkWell(
onTapDown: (details) => tapLocation = details.globalPosition,
onSecondaryTapDown: (details) =>
secondaryTapDownPos = details.globalPosition,
onTap: () {
setState(() {
if (!(widget.dashboard.flutterChartKey.currentState?.isCtrl ?? true)) {
if (!isCtrl) {
for (var element in widget.dashboard.elements) {
element.isSelected = false;
element.dashboard.chartKey.currentState?. setState(() { });
widget.dashboard.selectedMenuKey.currentState?. setState(() { });
}
}
Future.delayed(Duration(milliseconds: 100), () {
DrawingArrow.instance.notifyListeners();
widget.element.isSelected = !widget.element.isSelected;
for (var sel in widget.dashboard.arrows) { sel.isSelected = false; }
widget.dashboard.selectedMenuKey.currentState?. setState(() { });
});
DrawingArrow.instance.notifyListeners();
widget.isHovered = false;
widget.element.isSelected = !widget.element.isSelected;
for (var sel in widget.dashboard.arrows) { sel.isSelected = false; }
widget.dashboard.selectedMenuKey.currentState?. setState(() { });
});
widget.onElementPressed?.call(context, tapLocation);
},
onSecondaryTap: () {
widget.onElementSecondaryTapped?.call(context, secondaryTapDownPos);
@@ -169,9 +164,9 @@ class ElementWidgetState<T extends FlowData> extends State<ElementWidget> {
onLongPress: () {
widget.onElementLongPressed?.call(context, tapLocation);
},
onSecondaryLongPress: () {
/*onSecondaryLongPress: () {
widget.onElementSecondaryLongTapped?.call(context, secondaryTapDownPos);
},
},*/
child: Listener(
onPointerDown: (event) {
delta = event.localPosition;
@@ -198,7 +193,7 @@ class ElementWidgetState<T extends FlowData> extends State<ElementWidget> {
onHandlerLongPressed: widget.onHandlerLongPressed,
onHandlerSecondaryLongTapped: widget.onHandlerSecondaryLongTapped,
child: Container(
margin: EdgeInsets.all(10), // why some change
margin: const EdgeInsets.all(10), // why some change
decoration: BoxDecoration(
border: Border.all(color: widget.element.isSelected ? Colors.red : widget.dashboard.midDashColor,
width: widget.element.isSelected ? 2 : 1),

View File

@@ -195,7 +195,6 @@ class _GridBackgroundPainter extends CustomPainter {
@override
bool shouldRepaint(_GridBackgroundPainter oldDelegate) {
debugPrint('shouldRepaint ${oldDelegate.dx} $dx ${oldDelegate.dy} $dy');
return oldDelegate.dx != dx || oldDelegate.dy != dy;
}
}