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