Remove page swipe transitions - instant navigation via NoTransitionPage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
98 lines
2.8 KiB
Dart
98 lines
2.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
import 'package:tatlock_ui/features/control_room/router.dart';
|
|
import 'package:tatlock_ui/features/front_hall/presentation/pages/front_hall_page.dart';
|
|
import 'package:tatlock_ui/features/security/router.dart';
|
|
import 'package:tatlock_ui/shared/layouts/app_scaffold.dart';
|
|
|
|
part 'app_router.g.dart';
|
|
|
|
/// No-animation page builder for instant transitions
|
|
Page<void> noTransitionPage(BuildContext context, GoRouterState state, Widget child) {
|
|
return NoTransitionPage<void>(
|
|
key: state.pageKey,
|
|
child: child,
|
|
);
|
|
}
|
|
|
|
/// Route paths as constants.
|
|
abstract class AppRoutes {
|
|
static const frontHall = '/';
|
|
static const parlor = '/parlor';
|
|
static const settings = '/settings';
|
|
}
|
|
|
|
/// Provides the GoRouter instance.
|
|
@riverpod
|
|
GoRouter appRouter(Ref ref) {
|
|
return GoRouter(
|
|
initialLocation: AppRoutes.frontHall,
|
|
debugLogDiagnostics: true,
|
|
routes: [
|
|
// Main app routes (inside shell with app scaffold)
|
|
ShellRoute(
|
|
builder: (context, state, child) => AppScaffold(child: child),
|
|
routes: [
|
|
GoRoute(
|
|
path: AppRoutes.frontHall,
|
|
name: 'frontHall',
|
|
pageBuilder: (context, state) =>
|
|
noTransitionPage(context, state, const FrontHallPage()),
|
|
),
|
|
...controlRoomRoutes(),
|
|
...securityRoutes(),
|
|
GoRoute(
|
|
path: AppRoutes.parlor,
|
|
name: 'parlor',
|
|
pageBuilder: (context, state) =>
|
|
noTransitionPage(context, state, const _PlaceholderPage(title: 'Parlor')),
|
|
),
|
|
GoRoute(
|
|
path: AppRoutes.settings,
|
|
name: 'settings',
|
|
pageBuilder: (context, state) =>
|
|
noTransitionPage(context, state, const _PlaceholderPage(title: 'Settings')),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// Placeholder page for routes not yet implemented.
|
|
class _PlaceholderPage extends StatelessWidget {
|
|
const _PlaceholderPage({required this.title});
|
|
|
|
final String title;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.construction,
|
|
size: 64,
|
|
color: Theme.of(context).colorScheme.outline,
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
title,
|
|
style: Theme.of(context).textTheme.headlineMedium,
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
'Coming soon',
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
|
color: Theme.of(context).colorScheme.outline,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|