Optimize nav transition performance

This commit is contained in:
LittleSheep 2024-11-15 22:46:12 +08:00
parent fa73a28324
commit 37c61a0406
3 changed files with 21 additions and 12 deletions

View File

@ -13,6 +13,7 @@ import 'package:surface/providers/theme.dart';
import 'package:surface/providers/userinfo.dart';
import 'package:surface/providers/websocket.dart';
import 'package:surface/router.dart';
import 'package:surface/widgets/navigation/app_scaffold.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
@ -83,6 +84,9 @@ class AppMainContent extends StatelessWidget {
...context.localizationDelegates,
],
routerConfig: appRouter,
builder: (context, child) {
return AppRootScaffold(body: child ?? const SizedBox.shrink());
},
);
}
}

View File

@ -27,27 +27,37 @@ final _appRoutes = [
GoRoute(
path: '/',
name: 'home',
builder: (context, state) => const HomeScreen(),
pageBuilder: (context, state) => NoTransitionPage(
child: const HomeScreen(),
),
),
GoRoute(
path: '/posts',
name: 'explore',
builder: (context, state) => const ExploreScreen(),
pageBuilder: (context, state) => NoTransitionPage(
child: const ExploreScreen(),
),
),
GoRoute(
path: '/account',
name: 'account',
builder: (context, state) => const AccountScreen(),
pageBuilder: (context, state) => NoTransitionPage(
child: const AccountScreen(),
),
),
GoRoute(
path: '/chat',
name: 'chat',
builder: (context, state) => const ChatScreen(),
pageBuilder: (context, state) => NoTransitionPage(
child: const ChatScreen(),
),
),
GoRoute(
path: '/album',
name: 'album',
builder: (context, state) => const AlbumScreen(),
pageBuilder: (context, state) => NoTransitionPage(
child: const AlbumScreen(),
),
),
],
),
@ -130,10 +140,5 @@ final _appRoutes = [
];
final appRouter = GoRouter(
routes: [
ShellRoute(
builder: (context, state, child) => AppRootScaffold(body: child),
routes: _appRoutes,
),
],
);

View File

@ -42,7 +42,7 @@ class ConnectionIndicator extends StatelessWidget {
)
.height(
(ws.isBusy || !ws.isConnected) && ua.isAuthorized
? MediaQuery.of(context).padding.top + 30
? MediaQuery.of(context).padding.top + 36
: 0,
animate: true)
.animate(