♻️ Gloablize pop intent

This commit is contained in:
2025-10-12 18:26:28 +08:00
parent 41c56a2319
commit 5327f04ec0

View File

@@ -92,7 +92,13 @@ class WindowScaffold extends HookConsumerWidget {
if (!kIsWeb && if (!kIsWeb &&
(Platform.isWindows || Platform.isLinux || Platform.isMacOS)) { (Platform.isWindows || Platform.isLinux || Platform.isMacOS)) {
return Material( return Shortcuts(
shortcuts: <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.escape): const PopIntent(),
},
child: Actions(
actions: <Type, Action<Intent>>{PopIntent: PopAction(context)},
child: Material(
color: Theme.of(context).colorScheme.surfaceContainer, color: Theme.of(context).colorScheme.surfaceContainer,
child: Stack( child: Stack(
fit: StackFit.expand, fit: StackFit.expand,
@@ -117,7 +123,9 @@ class WindowScaffold extends HookConsumerWidget {
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: color:
Theme.of(context).colorScheme.onSurface, Theme.of(
context,
).colorScheme.onSurface,
), ),
), ),
], ],
@@ -188,12 +196,22 @@ class WindowScaffold extends HookConsumerWidget {
_WebSocketIndicator(), _WebSocketIndicator(),
], ],
), ),
),
),
); );
} }
return Stack( return Shortcuts(
shortcuts: <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.escape): const PopIntent(),
},
child: Actions(
actions: <Type, Action<Intent>>{PopIntent: PopAction(context)},
child: Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [Positioned.fill(child: child), _WebSocketIndicator()], children: [Positioned.fill(child: child), _WebSocketIndicator()],
),
),
); );
} }
} }
@@ -300,13 +318,7 @@ class AppScaffold extends HookConsumerWidget {
], ],
); );
return Shortcuts( return Focus(
shortcuts: <LogicalKeySet, Intent>{
LogicalKeySet(LogicalKeyboardKey.escape): const PopIntent(),
},
child: Actions(
actions: <Type, Action<Intent>>{PopIntent: PopAction(context)},
child: Focus(
focusNode: focusNode, focusNode: focusNode,
child: Scaffold( child: Scaffold(
extendBody: extendBody ?? true, extendBody: extendBody ?? true,
@@ -330,8 +342,6 @@ class AppScaffold extends HookConsumerWidget {
onDrawerChanged: onDrawerChanged, onDrawerChanged: onDrawerChanged,
onEndDrawerChanged: onEndDrawerChanged, onEndDrawerChanged: onEndDrawerChanged,
), ),
),
),
); );
} }
} }