Add temporary navSpike to sanity check routing solutions

This commit is contained in:
Shawn 2024-01-11 10:16:05 -07:00
parent 2853af8f61
commit 539b79a20e
2 changed files with 62 additions and 2 deletions

View File

@ -9,17 +9,23 @@ import 'package:wonders/logic/locale_logic.dart';
import 'package:wonders/logic/timeline_logic.dart';
import 'package:wonders/logic/unsplash_logic.dart';
import 'package:wonders/logic/wonders_logic.dart';
import 'package:wonders/nav_spike.dart';
import 'package:wonders/ui/common/app_shortcuts.dart';
void main() async {
WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
// Keep native splash screen up until app is finished bootstrapping
FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
GoRouter.optionURLReflectsImperativeAPIs = true;
// Start app
registerSingletons();
runApp(WondersApp());
await appLogic.bootstrap();
// Spike:
runApp(NavSpikeApp());
//runApp(WondersApp());
//await appLogic.bootstrap();
// Remove splash screen when bootstrap is complete
FlutterNativeSplash.remove();

54
lib/nav_spike.dart Normal file
View File

@ -0,0 +1,54 @@
import 'package:advanced_navigator/advanced_navigator.dart';
import 'package:wonders/common_libs.dart';
final GoRouter _router = GoRouter(
initialLocation: '/a',
routes: <RouteBase>[
GoRoute(
path: '/a',
builder: (BuildContext context, GoRouterState state) => Screen(name: 'A'),
),
GoRoute(
path: '/b',
builder: (BuildContext context, GoRouterState state) => Screen(name: 'B'),
),
GoRoute(
path: '/c',
builder: (BuildContext context, GoRouterState state) => Screen(name: 'C'),
),
],
);
/// The main app.
class NavSpikeApp extends StatelessWidget {
const NavSpikeApp({super.key});
@override
Widget build(BuildContext context) => MaterialApp.router(routerConfig: _router);
}
/// The home screen
class Screen extends StatelessWidget {
const Screen({super.key, required this.name});
final String name;
@override
Widget build(BuildContext context) {
void navigate(String name) => context.push(name);
return Scaffold(
appBar: AppBar(title: Text(name)),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(name, style: TextStyle(fontSize: 48)),
ElevatedButton(onPressed: () => navigate('/a'), child: const Text('A')),
ElevatedButton(onPressed: () => navigate('/b'), child: const Text('B')),
ElevatedButton(onPressed: () => navigate('/c'), child: const Text('C')),
],
),
),
);
}
}