You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.5 KiB
117 lines
3.5 KiB
import 'package:fluent_ui/fluent_ui.dart' as f; |
|
import 'package:flutter/cupertino.dart' as c; |
|
import 'package:flutter/material.dart' as m; |
|
import 'package:flutter/services.dart'; |
|
import 'package:flutter/widgets.dart'; |
|
import 'package:hooks_riverpod/hooks_riverpod.dart'; |
|
import 'package:info_tren/models.dart'; |
|
import 'package:info_tren/pages/about/about_page.dart'; |
|
import 'package:info_tren/pages/main/main_page.dart'; |
|
import 'package:info_tren/pages/station_arrdep_page/select_station/select_station.dart'; |
|
import 'package:info_tren/pages/station_arrdep_page/view_station/view_station.dart'; |
|
import 'package:info_tren/pages/train_info_page/view_train/train_info.dart'; |
|
import 'package:info_tren/pages/train_info_page/select_train/select_train.dart'; |
|
import 'package:info_tren/providers.dart'; |
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
void main() async { |
|
final sharedPreferences = await SharedPreferences.getInstance(); |
|
runApp( |
|
ProviderScope( |
|
overrides: [ |
|
sharedPreferencesProvider.overrideWithValue(sharedPreferences), |
|
], |
|
child: const StartPoint(), |
|
), |
|
); |
|
} |
|
|
|
Map<String, WidgetBuilder> get routes => { |
|
Navigator.defaultRouteName: (context) { |
|
return const MainPage(); |
|
}, |
|
AboutPage.routeName: (context) { |
|
return const AboutPage(); |
|
}, |
|
SelectTrainPage.routeName: (context) { |
|
return const SelectTrainPage(); |
|
}, |
|
TrainInfo.routeName: (context) { |
|
final args = ModalRoute.of(context)!.settings.arguments as TrainInfoArguments; |
|
return ProviderScope( |
|
overrides: [ |
|
trainInfoArgumentsProvider.overrideWithValue(args), |
|
], |
|
child: const TrainInfo(), |
|
); |
|
}, |
|
SelectStationPage.routeName: (context) { |
|
return const SelectStationPage(); |
|
}, |
|
ViewStationPage.routeName: (context) { |
|
final args = ModalRoute.of(context)!.settings.arguments as ViewStationArguments; |
|
return ProviderScope( |
|
overrides: [ |
|
viewStationArgumentsProvider.overrideWithValue(args), |
|
], |
|
child: const ViewStationPage(), |
|
); |
|
}, |
|
}; |
|
|
|
class StartPoint extends ConsumerWidget { |
|
final String appTitle = 'Info Tren'; |
|
|
|
const StartPoint({super.key}); |
|
|
|
@override |
|
Widget build(BuildContext context, WidgetRef ref) { |
|
final uiDesign = ref.watch(uiDesignProvider); |
|
if (uiDesign == UiDesign.CUPERTINO) { |
|
return AnnotatedRegion( |
|
value: const SystemUiOverlayStyle( |
|
statusBarBrightness: c.Brightness.dark, |
|
), |
|
child: c.CupertinoApp( |
|
title: appTitle, |
|
theme: c.CupertinoThemeData( |
|
primaryColor: m.Colors.blue.shade600, |
|
brightness: c.Brightness.dark, |
|
// textTheme: CupertinoTextThemeData( |
|
// textStyle: TextStyle( |
|
// fontFamily: 'Atkinson Hyperlegible', |
|
// ), |
|
// ), |
|
), |
|
routes: routes, |
|
), |
|
); |
|
} |
|
else if (uiDesign == UiDesign.FLUENT) { |
|
return f.FluentApp( |
|
title: appTitle, |
|
theme: f.ThemeData( |
|
brightness: f.Brightness.dark, |
|
accentColor: f.Colors.blue, |
|
), |
|
routes: routes, |
|
); |
|
} |
|
else { |
|
return m.MaterialApp( |
|
title: appTitle, |
|
theme: m.ThemeData( |
|
primarySwatch: m.Colors.blue, |
|
colorScheme: m.ColorScheme.fromSwatch( |
|
brightness: m.Brightness.dark, |
|
primarySwatch: m.Colors.blue, |
|
accentColor: m.Colors.blue.shade700, |
|
), |
|
useMaterial3: true, |
|
// fontFamily: 'Atkinson Hyperlegible', |
|
), |
|
routes: routes, |
|
); |
|
} |
|
} |
|
}
|
|
|