Support override script
Support proxies search Support svg display Optimize config persistence Add some scenes auto close connections Update core Optimize more details
This commit is contained in:
@@ -8,7 +8,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:hotkey_manager/hotkey_manager.dart';
|
||||
|
||||
class HotKeyManager extends StatelessWidget {
|
||||
class HotKeyManager extends ConsumerStatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
const HotKeyManager({
|
||||
@@ -16,6 +16,25 @@ class HotKeyManager extends StatelessWidget {
|
||||
required this.child,
|
||||
});
|
||||
|
||||
@override
|
||||
ConsumerState<HotKeyManager> createState() => _HotKeyManagerState();
|
||||
}
|
||||
|
||||
class _HotKeyManagerState extends ConsumerState<HotKeyManager> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
ref.listenManual(
|
||||
hotKeyActionsProvider,
|
||||
(prev, next) {
|
||||
if (!hotKeyActionListEquality.equals(prev, next)) {
|
||||
_updateHotKeys(hotKeyActions: next);
|
||||
}
|
||||
},
|
||||
fireImmediately: true,
|
||||
);
|
||||
}
|
||||
|
||||
_handleHotKeyAction(HotAction action) async {
|
||||
switch (action) {
|
||||
case HotAction.mode:
|
||||
@@ -59,22 +78,30 @@ class HotKeyManager extends StatelessWidget {
|
||||
await Future.wait(hotkeyActionHandles);
|
||||
}
|
||||
|
||||
_buildShortcuts(Widget child) {
|
||||
return Shortcuts(
|
||||
shortcuts: {
|
||||
utils.controlSingleActivator(LogicalKeyboardKey.keyW):
|
||||
CloseWindowIntent(),
|
||||
},
|
||||
child: Actions(
|
||||
actions: {
|
||||
CloseWindowIntent: CallbackAction<CloseWindowIntent>(
|
||||
onInvoke: (_) => globalState.appController.handleBackOrExit(),
|
||||
),
|
||||
DoNothingIntent: CallbackAction<DoNothingIntent>(
|
||||
onInvoke: (_) => null,
|
||||
),
|
||||
},
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer(
|
||||
builder: (_, ref, child) {
|
||||
ref.listenManual(
|
||||
hotKeyActionsProvider,
|
||||
(prev, next) {
|
||||
if (!hotKeyActionListEquality.equals(prev, next)) {
|
||||
_updateHotKeys(hotKeyActions: next);
|
||||
}
|
||||
},
|
||||
fireImmediately: true,
|
||||
);
|
||||
return child!;
|
||||
},
|
||||
child: child,
|
||||
return _buildShortcuts(
|
||||
widget.child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user