Skip to content

Commit

Permalink
Merge pull request #5 from schaetz/improved_dragging
Browse files Browse the repository at this point in the history
Improved node movement and resizing
  • Loading branch information
rodydavis authored Aug 19, 2024
2 parents b24414d + f8b8a78 commit 879796e
Show file tree
Hide file tree
Showing 16 changed files with 585 additions and 210 deletions.
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
143 changes: 126 additions & 17 deletions example/ios/Runner.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
3 changes: 3 additions & 0 deletions example/ios/Runner.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 9 additions & 12 deletions example/lib/generated_nodes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class _GeneratedNodesState extends State<GeneratedNodes> {
return InfiniteCanvasNode(
key: UniqueKey(),
label: 'Node $index',
allowResize: true,
resizeMode: ResizeMode.cornersAndEdges,
offset: Offset(
Random().nextDouble() * 5000,
Random().nextDouble() * 5000,
Expand Down Expand Up @@ -62,14 +62,11 @@ class _GeneratedNodesState extends State<GeneratedNodes> {
));
}
}
controller = InfiniteCanvasController(nodes: nodes, edges: edges);
controller.formatter = (node) {
// snap to grid
node.offset = Offset(
(node.offset.dx / gridSize.width).roundToDouble() * gridSize.width,
(node.offset.dy / gridSize.height).roundToDouble() * gridSize.height,
);
};
controller = InfiniteCanvasController(
nodes: nodes,
edges: edges,
snapMovementToGrid: true,
snapResizeToGrid: true);
}

@override
Expand All @@ -95,7 +92,7 @@ class _GeneratedNodesState extends State<GeneratedNodes> {
final node = InfiniteCanvasNode(
key: UniqueKey(),
label: 'Node ${controller.nodes.length}',
allowResize: true,
resizeMode: ResizeMode.cornersAndEdges,
offset: controller.mousePosition,
size: Size(
Random().nextDouble() * 200 + 100,
Expand Down Expand Up @@ -127,7 +124,7 @@ class _GeneratedNodesState extends State<GeneratedNodes> {
final node = InfiniteCanvasNode(
key: UniqueKey(),
label: 'Node ${controller.nodes.length}',
allowResize: true,
resizeMode: ResizeMode.cornersAndEdges,
offset: controller.mousePosition,
size: Size(
Random().nextDouble() * 200 + 100,
Expand Down Expand Up @@ -162,7 +159,7 @@ class _GeneratedNodesState extends State<GeneratedNodes> {
final node = InfiniteCanvasNode(
key: UniqueKey(),
label: 'Node ${controller.nodes.length}',
allowResize: true,
resizeMode: ResizeMode.cornersAndEdges,
offset: controller.mousePosition,
size: Size(
Random().nextDouble() * 200 + 100,
Expand Down
80 changes: 56 additions & 24 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ packages:
dependency: transitive
description:
name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.10.0"
version: "2.11.0"
audio_session:
dependency: transitive
description:
Expand Down Expand Up @@ -61,10 +61,10 @@ packages:
dependency: transitive
description:
name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.3.0"
charcode:
dependency: transitive
description:
Expand Down Expand Up @@ -93,10 +93,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.0"
version: "1.18.0"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -350,7 +350,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.8"
version: "0.0.9"
js:
dependency: transitive
description:
Expand Down Expand Up @@ -391,6 +391,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.1.2"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
url: "https://pub.dev"
source: hosted
version: "2.0.1"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
url: "https://pub.dev"
source: hosted
version: "2.0.1"
lints:
dependency: transitive
description:
Expand All @@ -411,26 +435,26 @@ packages:
dependency: transitive
description:
name: matcher
sha256: c94db23593b89766cda57aab9ac311e3616cf87c6fa4e9749df032f66f30dcb8
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.14"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.8.0"
version: "1.11.0"
nested:
dependency: transitive
description:
Expand All @@ -451,10 +475,10 @@ packages:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
path_drawing:
dependency: transitive
description:
Expand Down Expand Up @@ -648,10 +672,10 @@ packages:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
sqflite:
dependency: transitive
description:
Expand All @@ -672,18 +696,18 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
string_scanner:
dependency: transitive
description:
Expand Down Expand Up @@ -712,10 +736,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "6182294da5abf431177fccc1ee02401f6df30f766bc6130a0852c6b6d7ee6b2d"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.4.18"
version: "0.6.1"
typed_data:
dependency: transitive
description:
Expand Down Expand Up @@ -844,6 +868,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.13"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "13.0.0"
wakelock:
dependency: transitive
description:
Expand Down Expand Up @@ -949,5 +981,5 @@ packages:
source: hosted
version: "6.2.2"
sdks:
dart: ">=2.19.0-345.0.dev <4.0.0"
dart: ">=3.2.0-0 <4.0.0"
flutter: ">=3.3.0"
6 changes: 6 additions & 0 deletions lib/src/domain/model/menu_entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ class MenuEntry {
const MenuEntry({
required this.label,
this.shortcut,
this.isActivated,
this.onPressed,
this.menuChildren,
}) : assert(menuChildren == null || onPressed == null,
'onPressed is ignored if menuChildren are provided');
final String label;

final MenuSerializableShortcut? shortcut;
final bool Function()? isActivated;
final VoidCallback? onPressed;
final List<MenuEntry>? menuChildren;

Expand Down Expand Up @@ -55,6 +57,10 @@ class MenuEntry {
} else {
return MenuItemButton(
shortcut: selection.shortcut,
trailingIcon:
selection.isActivated != null && selection.isActivated!()
? const Icon(Icons.check)
: SizedBox.fromSize(size: const Size(22, 0)),
onPressed: selection.onPressed,
child: Text(selection.label),
);
Expand Down
Loading

0 comments on commit 879796e

Please sign in to comment.