From e742338d920e9de2ec7122313ab79ff05b9c7d21 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 3 May 2024 14:04:34 +0800 Subject: [PATCH] :bug: Bug fixes of scaffold --- lib/main.dart | 6 +++++- lib/router.dart | 2 ++ lib/screens/chat/chat.dart | 1 - lib/screens/chat/chat_list.dart | 15 +++++++++++---- lib/utils/theme.dart | 3 --- lib/widgets/layouts/two_column.dart | 20 ++++++++------------ 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index d02b36a..ece1790 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -47,7 +47,11 @@ class SolianApp extends StatelessWidget { child: Overlay( initialEntries: [ OverlayEntry(builder: (context) { - return NotificationNotifier(child: child ?? Container()); + return ScaffoldMessenger( + child: Scaffold( + body: NotificationNotifier(child: child ?? Container()), + ), + ); }), OverlayEntry(builder: (context) => const CallOverlay()), ], diff --git a/lib/router.dart b/lib/router.dart index ee1d2ed..c176cde 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -159,6 +159,8 @@ abstract class SolianRouter { ], ); + static GoRoute get currentRoute => SolianRouter.router.routerDelegate.currentConfiguration.last.route; + static Page defaultPageBuilder( BuildContext context, GoRouterState state, diff --git a/lib/screens/chat/chat.dart b/lib/screens/chat/chat.dart index ef70e79..dd4fcef 100644 --- a/lib/screens/chat/chat.dart +++ b/lib/screens/chat/chat.dart @@ -32,7 +32,6 @@ class ChatScreen extends StatelessWidget { title: chat.focusChannel?.name ?? 'Loading...', hideDrawer: true, fixedAppBarColor: SolianTheme.isLargeScreen(context), - appBarLeading: IconButton(icon: const Icon(Icons.tag), onPressed: () {}), appBarActions: chat.focusChannel != null ? [ ChannelCallAction( diff --git a/lib/screens/chat/chat_list.dart b/lib/screens/chat/chat_list.dart index 6ce7b01..3277597 100644 --- a/lib/screens/chat/chat_list.dart +++ b/lib/screens/chat/chat_list.dart @@ -25,10 +25,17 @@ class ChatListScreen extends StatelessWidget { fixedAppBarColor: SolianTheme.isLargeScreen(context), child: ChatListWidget( onSelect: (item) { - SolianRouter.router.pushReplacementNamed( - 'chat.channel', - pathParameters: {'channel': item.alias}, - ); + if (SolianRouter.currentRoute.name == 'chat.channel') { + SolianRouter.router.pushReplacementNamed( + 'chat.channel', + pathParameters: {'channel': item.alias}, + ); + } else { + SolianRouter.router.pushNamed( + 'chat.channel', + pathParameters: {'channel': item.alias}, + ); + } }, ), ); diff --git a/lib/utils/theme.dart b/lib/utils/theme.dart index a9c618a..c9b8c06 100644 --- a/lib/utils/theme.dart +++ b/lib/utils/theme.dart @@ -9,9 +9,6 @@ abstract class SolianTheme { brightness: brightness, useMaterial3: true, colorScheme: ColorScheme.fromSeed(brightness: brightness, seedColor: Colors.indigo), - snackBarTheme: const SnackBarThemeData( - behavior: SnackBarBehavior.floating, - ), ); } } \ No newline at end of file diff --git a/lib/widgets/layouts/two_column.dart b/lib/widgets/layouts/two_column.dart index d83e642..4e9833f 100644 --- a/lib/widgets/layouts/two_column.dart +++ b/lib/widgets/layouts/two_column.dart @@ -13,19 +13,15 @@ class TwoColumnLayout extends StatelessWidget { @override Widget build(BuildContext context) { - return ScaffoldMessenger( - child: Scaffold( - body: Row( - children: [ - SizedBox( - width: 400, - child: sideChild, - ), - const VerticalDivider(width: 0.3, thickness: 0.3), - Expanded(child: mainChild ?? const PageEmptyWidget()), - ], + return Row( + children: [ + SizedBox( + width: 400, + child: sideChild, ), - ), + const VerticalDivider(width: 0.3, thickness: 0.3), + Expanded(child: mainChild ?? const PageEmptyWidget()), + ], ); } }