diff --git a/demo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux b/demo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux index e433ea04f..78ce7e341 120000 --- a/demo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux +++ b/demo/linux/flutter/ephemeral/.plugin_symlinks/url_launcher_linux @@ -1 +1 @@ -C:/Users/manek/AppData/Local/Pub/Cache/hosted/pub.dev/url_launcher_linux-3.0.2/ \ No newline at end of file +/Users/macos/.pub-cache/hosted/pub.dev/url_launcher_linux-3.1.1/ \ No newline at end of file diff --git a/lib/src/helper/pluto_key_manager_event.dart b/lib/src/helper/pluto_key_manager_event.dart index 91267675c..64ed12f15 100644 --- a/lib/src/helper/pluto_key_manager_event.dart +++ b/lib/src/helper/pluto_key_manager_event.dart @@ -3,7 +3,7 @@ import 'package:flutter/services.dart'; class PlutoKeyManagerEvent { FocusNode focusNode; - RawKeyEvent event; + KeyEvent event; PlutoKeyManagerEvent({ required this.focusNode, @@ -12,9 +12,9 @@ class PlutoKeyManagerEvent { bool get needsThrottle => isMoving || isTab || isPageUp || isPageDown; - bool get isKeyDownEvent => event.runtimeType == RawKeyDownEvent; + bool get isKeyDownEvent => event.runtimeType == KeyDownEvent; - bool get isKeyUpEvent => event.runtimeType == RawKeyUpEvent; + bool get isKeyUpEvent => event.runtimeType == KeyUpEvent; bool get isMoving => isHorizontal || isVertical; @@ -94,15 +94,18 @@ class PlutoKeyManagerEvent { } bool get isShiftPressed { - return event.isShiftPressed; + // return event.isShiftPressed; + return event.logicalKey.keyId == LogicalKeyboardKey.shift.keyId; } bool get isCtrlPressed { - return event.isMetaPressed || event.isControlPressed; + // return event.isMetaPressed || event.isControlPressed; + return event.logicalKey.keyId == LogicalKeyboardKey.control.keyId; } bool get isAltPressed { - return event.isAltPressed; + // return event.isAltPressed; + return event.logicalKey.keyId == LogicalKeyboardKey.alt.keyId; } bool get isModifierPressed { diff --git a/lib/src/manager/pluto_grid_key_manager.dart b/lib/src/manager/pluto_grid_key_manager.dart index ba952c790..52a6a2e79 100644 --- a/lib/src/manager/pluto_grid_key_manager.dart +++ b/lib/src/manager/pluto_grid_key_manager.dart @@ -79,7 +79,7 @@ class PlutoGridKeyManager { if (stateManager.configuration.shortcut.handle( keyEvent: keyEvent, stateManager: stateManager, - state: RawKeyboard.instance, + state: HardwareKeyboard.instance, )) { return; } diff --git a/lib/src/manager/shortcut/pluto_grid_shortcut.dart b/lib/src/manager/shortcut/pluto_grid_shortcut.dart index 57907ab4d..a4511413f 100644 --- a/lib/src/manager/shortcut/pluto_grid_shortcut.dart +++ b/lib/src/manager/shortcut/pluto_grid_shortcut.dart @@ -27,7 +27,7 @@ class PlutoGridShortcut { bool handle({ required PlutoKeyManagerEvent keyEvent, required PlutoGridStateManager stateManager, - required RawKeyboard state, + required HardwareKeyboard state, }) { for (final action in actions.entries) { if (action.key.accepts(keyEvent.event, state)) { diff --git a/lib/src/manager/shortcut/pluto_grid_shortcut_action.dart b/lib/src/manager/shortcut/pluto_grid_shortcut_action.dart index 26110d358..2cfb6ba6a 100644 --- a/lib/src/manager/shortcut/pluto_grid_shortcut_action.dart +++ b/lib/src/manager/shortcut/pluto_grid_shortcut_action.dart @@ -250,10 +250,14 @@ class PlutoGridActionDefaultTab extends PlutoGridShortcutAction { final saveIsEditing = stateManager.isEditing; - keyEvent.event.isShiftPressed + // keyEvent.event.isShiftPressed + // ? _moveCellPrevious(stateManager) + // : _moveCellNext(stateManager); + keyEvent.event.logicalKey.keyId == LogicalKeyboardKey.shiftLeft.keyId || + keyEvent.event.logicalKey.keyId == + LogicalKeyboardKey.shiftRight.keyId ? _moveCellPrevious(stateManager) : _moveCellNext(stateManager); - stateManager.setEditing(stateManager.autoEditing || saveIsEditing); } @@ -408,7 +412,10 @@ class PlutoGridActionDefaultEnterKey extends PlutoGridShortcutAction { } if (enterKeyAction.isEditingAndMoveDown) { - if (keyEvent.event.isShiftPressed) { + if (keyEvent.event.logicalKey.keyId == + LogicalKeyboardKey.shiftRight.keyId || + keyEvent.event.logicalKey.keyId == + LogicalKeyboardKey.shiftLeft.keyId) { stateManager.moveCurrentCell( PlutoMoveDirection.up, notify: false, @@ -420,7 +427,10 @@ class PlutoGridActionDefaultEnterKey extends PlutoGridShortcutAction { ); } } else if (enterKeyAction.isEditingAndMoveRight) { - if (keyEvent.event.isShiftPressed) { + if (keyEvent.event.logicalKey.keyId == + LogicalKeyboardKey.shiftRight.keyId || + keyEvent.event.logicalKey.keyId == + LogicalKeyboardKey.shiftLeft.keyId) { stateManager.moveCurrentCell( PlutoMoveDirection.left, force: true, diff --git a/lib/src/pluto_grid.dart b/lib/src/pluto_grid.dart index 54d8e96ee..af5bbf916 100644 --- a/lib/src/pluto_grid.dart +++ b/lib/src/pluto_grid.dart @@ -593,7 +593,7 @@ class PlutoGridState extends PlutoStateWithChange { } } - KeyEventResult _handleGridFocusOnKey(FocusNode focusNode, RawKeyEvent event) { + KeyEventResult _handleGridFocusOnKey(FocusNode focusNode, KeyEvent event) { if (_keyManager.eventResult.isSkip == false) { _keyManager.subject.add(PlutoKeyManagerEvent( focusNode: focusNode, @@ -608,7 +608,7 @@ class PlutoGridState extends PlutoStateWithChange { Widget build(BuildContext context) { return FocusScope( onFocusChange: _stateManager.setKeepFocus, - onKey: _handleGridFocusOnKey, + onKeyEvent: _handleGridFocusOnKey, child: _GridContainer( stateManager: _stateManager, child: LayoutBuilder( diff --git a/lib/src/ui/cells/popup_cell.dart b/lib/src/ui/cells/popup_cell.dart index e2e6149da..add9e380b 100644 --- a/lib/src/ui/cells/popup_cell.dart +++ b/lib/src/ui/cells/popup_cell.dart @@ -62,7 +62,7 @@ mixin PopupCellState on State ..text = widget.column.formattedValueForDisplayInEditing(widget.cell.value); - textFocus = FocusNode(onKey: _handleKeyboardFocusOnKey); + textFocus = FocusNode(onKeyEvent: _handleKeyboardFocusOnKey); } @override @@ -175,7 +175,7 @@ mixin PopupCellState on State } } - KeyEventResult _handleKeyboardFocusOnKey(FocusNode node, RawKeyEvent event) { + KeyEventResult _handleKeyboardFocusOnKey(FocusNode node, KeyEvent event) { var keyManager = PlutoKeyManagerEvent( focusNode: node, event: event, diff --git a/lib/src/ui/cells/text_cell.dart b/lib/src/ui/cells/text_cell.dart index b007e4f35..87834461d 100644 --- a/lib/src/ui/cells/text_cell.dart +++ b/lib/src/ui/cells/text_cell.dart @@ -52,7 +52,7 @@ mixin TextCellState on State implements TextFieldProps { void initState() { super.initState(); - cellFocus = FocusNode(onKey: _handleOnKey); + cellFocus = FocusNode(onKeyEvent: _handleOnKey); widget.stateManager.setTextEditingController(_textController); @@ -172,7 +172,7 @@ mixin TextCellState on State implements TextFieldProps { }); } - KeyEventResult _handleOnKey(FocusNode node, RawKeyEvent event) { + KeyEventResult _handleOnKey(FocusNode node, KeyEvent event) { var keyManager = PlutoKeyManagerEvent( focusNode: node, event: event, diff --git a/lib/src/ui/columns/pluto_column_filter.dart b/lib/src/ui/columns/pluto_column_filter.dart index da1749122..486785ece 100644 --- a/lib/src/ui/columns/pluto_column_filter.dart +++ b/lib/src/ui/columns/pluto_column_filter.dart @@ -83,7 +83,7 @@ class PlutoColumnFilterState extends PlutoStateWithChange { initState() { super.initState(); - _focusNode = FocusNode(onKey: _handleOnKey); + _focusNode = FocusNode(onKeyEvent: _handleOnKey); widget.column.setFilterFocusNode(_focusNode); @@ -145,7 +145,7 @@ class PlutoColumnFilterState extends PlutoStateWithChange { stateManager.notifyListeners(); } - KeyEventResult _handleOnKey(FocusNode node, RawKeyEvent event) { + KeyEventResult _handleOnKey(FocusNode node, KeyEvent event) { var keyManager = PlutoKeyManagerEvent( focusNode: node, event: event, diff --git a/packages/pluto_grid_export/example/ios/Flutter/Debug.xcconfig b/packages/pluto_grid_export/example/ios/Flutter/Debug.xcconfig index 592ceee85..ec97fc6f3 100644 --- a/packages/pluto_grid_export/example/ios/Flutter/Debug.xcconfig +++ b/packages/pluto_grid_export/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/packages/pluto_grid_export/example/ios/Flutter/Release.xcconfig b/packages/pluto_grid_export/example/ios/Flutter/Release.xcconfig index 592ceee85..c4855bfe2 100644 --- a/packages/pluto_grid_export/example/ios/Flutter/Release.xcconfig +++ b/packages/pluto_grid_export/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/packages/pluto_grid_export/example/ios/Podfile b/packages/pluto_grid_export/example/ios/Podfile new file mode 100644 index 000000000..d97f17e22 --- /dev/null +++ b/packages/pluto_grid_export/example/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/packages/pluto_grid_export/example/macos/Flutter/Flutter-Debug.xcconfig b/packages/pluto_grid_export/example/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b60..4b81f9b2d 100644 --- a/packages/pluto_grid_export/example/macos/Flutter/Flutter-Debug.xcconfig +++ b/packages/pluto_grid_export/example/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/pluto_grid_export/example/macos/Flutter/Flutter-Release.xcconfig b/packages/pluto_grid_export/example/macos/Flutter/Flutter-Release.xcconfig index c2efd0b60..5caa9d157 100644 --- a/packages/pluto_grid_export/example/macos/Flutter/Flutter-Release.xcconfig +++ b/packages/pluto_grid_export/example/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/pluto_grid_export/example/macos/Flutter/GeneratedPluginRegistrant.swift b/packages/pluto_grid_export/example/macos/Flutter/GeneratedPluginRegistrant.swift index 416ef8457..9c4efdd9c 100644 --- a/packages/pluto_grid_export/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/packages/pluto_grid_export/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -6,7 +6,7 @@ import FlutterMacOS import Foundation import file_saver -import path_provider_macos +import path_provider_foundation import printing func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { diff --git a/packages/pluto_grid_export/example/macos/Podfile b/packages/pluto_grid_export/example/macos/Podfile new file mode 100644 index 000000000..c795730db --- /dev/null +++ b/packages/pluto_grid_export/example/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/test/src/helper/pluto_key_manager_event_test.dart b/test/src/helper/pluto_key_manager_event_test.dart index f0907a12d..b83925c95 100644 --- a/test/src/helper/pluto_key_manager_event_test.dart +++ b/test/src/helper/pluto_key_manager_event_test.dart @@ -8,7 +8,7 @@ void main() { late PlutoKeyManagerEvent? keyManagerEvent; - KeyEventResult callback(FocusNode node, RawKeyEvent event) { + KeyEventResult callback(FocusNode node, KeyEvent event) { keyManagerEvent = PlutoKeyManagerEvent( focusNode: node, event: event, @@ -28,12 +28,12 @@ void main() { Future buildWidget({ required WidgetTester tester, - required KeyEventResult Function(FocusNode, RawKeyEvent) callback, + required KeyEventResult Function(FocusNode, KeyEvent) callback, }) async { await tester.pumpWidget(MaterialApp( home: FocusScope( autofocus: true, - onKey: callback, + onKeyEvent: callback, child: Focus( focusNode: focusNode, child: const SizedBox(width: 100, height: 100), @@ -62,7 +62,7 @@ void main() { (tester) async { late PlutoKeyManagerEvent keyManagerEvent; - KeyEventResult callback(FocusNode node, RawKeyEvent event) { + KeyEventResult callback(FocusNode node, KeyEvent event) { keyManagerEvent = PlutoKeyManagerEvent( focusNode: node, event: event, diff --git a/test/src/manager/pluto_grid_key_manager_test.dart b/test/src/manager/pluto_grid_key_manager_test.dart index 57634f5e1..7e88553cd 100644 --- a/test/src/manager/pluto_grid_key_manager_test.dart +++ b/test/src/manager/pluto_grid_key_manager_test.dart @@ -46,8 +46,8 @@ void main() { await tester.pumpWidget( MaterialApp( home: Material( - child: RawKeyboardListener( - onKey: (event) { + child: KeyboardListener( + onKeyEvent: (event) { keyManager.subject.add(PlutoKeyManagerEvent( focusNode: FocusNode(), event: event, @@ -98,8 +98,8 @@ void main() { await tester.pumpWidget( MaterialApp( home: Material( - child: RawKeyboardListener( - onKey: (event) { + child: KeyboardListener( + onKeyEvent: (event) { keyManager.subject.add(PlutoKeyManagerEvent( focusNode: FocusNode(), event: event, @@ -150,8 +150,8 @@ void main() { await tester.pumpWidget( MaterialApp( home: Material( - child: RawKeyboardListener( - onKey: (event) { + child: KeyboardListener( + onKeyEvent: (event) { keyManager.subject.add(PlutoKeyManagerEvent( focusNode: FocusNode(), event: event, @@ -204,8 +204,8 @@ void main() { await tester.pumpWidget( MaterialApp( home: Material( - child: RawKeyboardListener( - onKey: (event) { + child: KeyboardListener( + onKeyEvent: (event) { keyManager.subject.add(PlutoKeyManagerEvent( focusNode: FocusNode(), event: event, @@ -258,8 +258,8 @@ void main() { await tester.pumpWidget( MaterialApp( home: Material( - child: RawKeyboardListener( - onKey: (event) { + child: KeyboardListener( + onKeyEvent: (event) { keyManager.subject.add(PlutoKeyManagerEvent( focusNode: FocusNode(), event: event, @@ -311,8 +311,8 @@ void main() { await tester.pumpWidget( MaterialApp( home: Material( - child: RawKeyboardListener( - onKey: (event) { + child: KeyboardListener( + onKeyEvent: (event) { keyManager.subject.add(PlutoKeyManagerEvent( focusNode: FocusNode(), event: event, @@ -440,8 +440,8 @@ void main() { await tester.pumpWidget( MaterialApp( home: Material( - child: RawKeyboardListener( - onKey: (event) { + child: KeyboardListener( + onKeyEvent: (event) { keyManager.subject.add(PlutoKeyManagerEvent( focusNode: FocusNode(), event: event,