💄 Optimize snackbars

This commit is contained in:
2025-08-15 00:09:05 +08:00
parent 94481ec7bd
commit 3745157c42
3 changed files with 16 additions and 6 deletions

View File

@@ -411,7 +411,7 @@ final routerProvider = Provider<GoRouter>((ref) {
pageBuilder:
(context, state, child) => CustomTransitionPage(
key: const ValueKey('chat'),
child: child,
child: ChatShellScreen(child: child),
transitionsBuilder: _tabPagesTransitionBuilder,
),
routes: [
@@ -492,7 +492,7 @@ final routerProvider = Provider<GoRouter>((ref) {
pageBuilder:
(context, state, child) => CustomTransitionPage(
key: const ValueKey('account'),
child: child,
child: AccountShellScreen(child: child),
transitionsBuilder: _tabPagesTransitionBuilder,
),
routes: [

View File

@@ -26,7 +26,12 @@ StreamSubscription<WebSocketPacket> setupNotificationListener(
final notification = SnNotification.fromJson(pkt.data!);
showTopSnackBar(
globalOverlay.currentState!,
NotificationCard(notification: notification),
Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 480),
child: NotificationCard(notification: notification),
),
),
onTap: () {
if (notification.meta['action_uri'] != null) {
var uri = notification.meta['action_uri'] as String;
@@ -53,9 +58,9 @@ StreamSubscription<WebSocketPacket> setupNotificationListener(
(Platform.isMacOS ||
Platform.isWindows ||
Platform.isLinux))
? 24
? 28
// ignore: use_build_context_synchronously
: MediaQuery.of(context).padding.top + 8,
: MediaQuery.of(context).padding.top + 16,
bottom: 16,
),
);

View File

@@ -11,7 +11,12 @@ export 'content/alert.native.dart'
void showSnackBar(String message, {SnackBarAction? action}) {
showTopSnackBar(
globalOverlay.currentState!,
Card(child: Text(message).padding(horizontal: 20, vertical: 16)),
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 480),
child: Center(
child: Card(child: Text(message).padding(horizontal: 20, vertical: 16)),
),
),
snackBarPosition: SnackBarPosition.bottom,
);
}