From 099ae9893d0c4a292b114580df6fdb7b4735edb3 Mon Sep 17 00:00:00 2001 From: Shawn Date: Sun, 1 Jan 2023 12:20:42 -0700 Subject: [PATCH] Formatting --- lib/common_libs.dart | 3 ++- lib/logic/app_logic.dart | 9 +++------ lib/main.dart | 13 ++++++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/common_libs.dart b/lib/common_libs.dart index 219104d1..76943ece 100644 --- a/lib/common_libs.dart +++ b/lib/common_libs.dart @@ -1,4 +1,4 @@ -/// Consolidate shared imports that are common across the app. +/// Consolidate imports that are common across the app. export 'dart:math'; @@ -23,6 +23,7 @@ export 'package:wonders/logic/settings_logic.dart'; export 'package:wonders/main.dart'; export 'package:wonders/router.dart'; export 'package:wonders/styles/styles.dart'; +export 'package:wonders/ui/app_scaffold.dart'; export 'package:wonders/ui/common/controls/app_image.dart'; export 'package:wonders/ui/common/controls/buttons.dart'; export 'package:wonders/ui/common/controls/circle_buttons.dart'; diff --git a/lib/logic/app_logic.dart b/lib/logic/app_logic.dart index 0e0d90ce..5e44fc94 100644 --- a/lib/logic/app_logic.dart +++ b/lib/logic/app_logic.dart @@ -11,8 +11,7 @@ class AppLogic { /// The router will use this to prevent redirects while bootstrapping. bool isBootstrapComplete = false; - bool get isLandscapeEnabled => - PlatformInfo.isDesktopOrWeb || deviceSize.shortestSide > 500; + bool get isLandscapeEnabled => PlatformInfo.isDesktopOrWeb || deviceSize.shortestSide > 500; /// Support portrait and landscape on desktop, web and tablets. Stick to portrait for phones. /// A return value of null indicated both orientations are supported. @@ -26,8 +25,7 @@ class AppLogic { /// Initialize the app and all main actors. /// Loads settings, sets up services etc. Future bootstrap() async { - debugPrint( - 'bootstrap app, deviceSize: $deviceSize, isTablet: $isLandscapeEnabled'); + debugPrint('bootstrap app, deviceSize: $deviceSize, isTablet: $isLandscapeEnabled'); // Set min-sizes for desktop apps if (PlatformInfo.isDesktop) { @@ -89,8 +87,7 @@ class AppLogic { SystemChrome.setPreferredOrientations(orientations); } - Future showFullscreenDialogRoute(BuildContext context, Widget child, - {bool transparent = false}) async { + Future showFullscreenDialogRoute(BuildContext context, Widget child, {bool transparent = false}) async { return await Navigator.of(context).push( PageRoutes.dialog(child, duration: $styles.times.pageTransition), ); diff --git a/lib/main.dart b/lib/main.dart index 1fd6199f..d7b87633 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,18 +25,18 @@ void main() async { FlutterNativeSplash.remove(); } -/// Creates an app using the [MaterialApp.router] constructor and the `appRouter`, an instance of [GoRouter]. +/// Creates an app using the [MaterialApp.router] constructor and the global `appRouter`, an instance of [GoRouter]. class WondersApp extends StatelessWidget with GetItMixin { WondersApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { final locale = watchX((SettingsLogic s) => s.currentLocale); return MaterialApp.router( + routeInformationProvider: appRouter.routeInformationProvider, + routeInformationParser: appRouter.routeInformationParser, locale: locale == null ? null : Locale(locale), debugShowCheckedModeBanner: false, routerDelegate: appRouter.routerDelegate, - routeInformationProvider: appRouter.routeInformationProvider, - routeInformationParser: appRouter.routeInformationParser, theme: ThemeData(fontFamily: $styles.text.body.fontFamily), localizationsDelegates: const [ AppLocalizations.delegate, @@ -49,7 +49,7 @@ class WondersApp extends StatelessWidget with GetItMixin { } } -/// Create singletons (controllers and services) that can be shared across the app. +/// Create singletons (logic and services) that can be shared across the app. void registerSingletons() { // Top level app controller GetIt.I.registerLazySingleton(() => AppLogic()); @@ -70,7 +70,7 @@ void registerSingletons() { GetIt.I.registerLazySingleton(() => LocaleLogic()); } -/// Add syntax sugar for quickly accessing the main logical controllers in the app +/// Add syntax sugar for quickly accessing the main "logic" controllers in the app /// We deliberately do not create shortcuts for services, to discourage their use directly in the view/widget layer. AppLogic get appLogic => GetIt.I.get(); WondersLogic get wondersLogic => GetIt.I.get(); @@ -81,4 +81,7 @@ MetAPILogic get metAPILogic => GetIt.I.get(); CollectiblesLogic get collectiblesLogic => GetIt.I.get(); WallPaperLogic get wallpaperLogic => GetIt.I.get(); LocaleLogic get localeLogic => GetIt.I.get(); + +/// Global helpers for readability AppLocalizations get $strings => localeLogic.strings; +AppStyle get $styles => WondersAppScaffold.style;