Formatting
This commit is contained in:
parent
01b1a16ec4
commit
099ae9893d
@ -1,4 +1,4 @@
|
|||||||
/// Consolidate shared imports that are common across the app.
|
/// Consolidate imports that are common across the app.
|
||||||
|
|
||||||
export 'dart:math';
|
export 'dart:math';
|
||||||
|
|
||||||
@ -23,6 +23,7 @@ export 'package:wonders/logic/settings_logic.dart';
|
|||||||
export 'package:wonders/main.dart';
|
export 'package:wonders/main.dart';
|
||||||
export 'package:wonders/router.dart';
|
export 'package:wonders/router.dart';
|
||||||
export 'package:wonders/styles/styles.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/app_image.dart';
|
||||||
export 'package:wonders/ui/common/controls/buttons.dart';
|
export 'package:wonders/ui/common/controls/buttons.dart';
|
||||||
export 'package:wonders/ui/common/controls/circle_buttons.dart';
|
export 'package:wonders/ui/common/controls/circle_buttons.dart';
|
||||||
|
@ -11,8 +11,7 @@ class AppLogic {
|
|||||||
/// The router will use this to prevent redirects while bootstrapping.
|
/// The router will use this to prevent redirects while bootstrapping.
|
||||||
bool isBootstrapComplete = false;
|
bool isBootstrapComplete = false;
|
||||||
|
|
||||||
bool get isLandscapeEnabled =>
|
bool get isLandscapeEnabled => PlatformInfo.isDesktopOrWeb || deviceSize.shortestSide > 500;
|
||||||
PlatformInfo.isDesktopOrWeb || deviceSize.shortestSide > 500;
|
|
||||||
|
|
||||||
/// Support portrait and landscape on desktop, web and tablets. Stick to portrait for phones.
|
/// Support portrait and landscape on desktop, web and tablets. Stick to portrait for phones.
|
||||||
/// A return value of null indicated both orientations are supported.
|
/// A return value of null indicated both orientations are supported.
|
||||||
@ -26,8 +25,7 @@ class AppLogic {
|
|||||||
/// Initialize the app and all main actors.
|
/// Initialize the app and all main actors.
|
||||||
/// Loads settings, sets up services etc.
|
/// Loads settings, sets up services etc.
|
||||||
Future<void> bootstrap() async {
|
Future<void> bootstrap() async {
|
||||||
debugPrint(
|
debugPrint('bootstrap app, deviceSize: $deviceSize, isTablet: $isLandscapeEnabled');
|
||||||
'bootstrap app, deviceSize: $deviceSize, isTablet: $isLandscapeEnabled');
|
|
||||||
|
|
||||||
// Set min-sizes for desktop apps
|
// Set min-sizes for desktop apps
|
||||||
if (PlatformInfo.isDesktop) {
|
if (PlatformInfo.isDesktop) {
|
||||||
@ -89,8 +87,7 @@ class AppLogic {
|
|||||||
SystemChrome.setPreferredOrientations(orientations);
|
SystemChrome.setPreferredOrientations(orientations);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<T?> showFullscreenDialogRoute<T>(BuildContext context, Widget child,
|
Future<T?> showFullscreenDialogRoute<T>(BuildContext context, Widget child, {bool transparent = false}) async {
|
||||||
{bool transparent = false}) async {
|
|
||||||
return await Navigator.of(context).push<T>(
|
return await Navigator.of(context).push<T>(
|
||||||
PageRoutes.dialog<T>(child, duration: $styles.times.pageTransition),
|
PageRoutes.dialog<T>(child, duration: $styles.times.pageTransition),
|
||||||
);
|
);
|
||||||
|
@ -25,18 +25,18 @@ void main() async {
|
|||||||
FlutterNativeSplash.remove();
|
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 {
|
class WondersApp extends StatelessWidget with GetItMixin {
|
||||||
WondersApp({Key? key}) : super(key: key);
|
WondersApp({Key? key}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final locale = watchX((SettingsLogic s) => s.currentLocale);
|
final locale = watchX((SettingsLogic s) => s.currentLocale);
|
||||||
return MaterialApp.router(
|
return MaterialApp.router(
|
||||||
|
routeInformationProvider: appRouter.routeInformationProvider,
|
||||||
|
routeInformationParser: appRouter.routeInformationParser,
|
||||||
locale: locale == null ? null : Locale(locale),
|
locale: locale == null ? null : Locale(locale),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
routerDelegate: appRouter.routerDelegate,
|
routerDelegate: appRouter.routerDelegate,
|
||||||
routeInformationProvider: appRouter.routeInformationProvider,
|
|
||||||
routeInformationParser: appRouter.routeInformationParser,
|
|
||||||
theme: ThemeData(fontFamily: $styles.text.body.fontFamily),
|
theme: ThemeData(fontFamily: $styles.text.body.fontFamily),
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
AppLocalizations.delegate,
|
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() {
|
void registerSingletons() {
|
||||||
// Top level app controller
|
// Top level app controller
|
||||||
GetIt.I.registerLazySingleton<AppLogic>(() => AppLogic());
|
GetIt.I.registerLazySingleton<AppLogic>(() => AppLogic());
|
||||||
@ -70,7 +70,7 @@ void registerSingletons() {
|
|||||||
GetIt.I.registerLazySingleton<LocaleLogic>(() => LocaleLogic());
|
GetIt.I.registerLazySingleton<LocaleLogic>(() => 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.
|
/// We deliberately do not create shortcuts for services, to discourage their use directly in the view/widget layer.
|
||||||
AppLogic get appLogic => GetIt.I.get<AppLogic>();
|
AppLogic get appLogic => GetIt.I.get<AppLogic>();
|
||||||
WondersLogic get wondersLogic => GetIt.I.get<WondersLogic>();
|
WondersLogic get wondersLogic => GetIt.I.get<WondersLogic>();
|
||||||
@ -81,4 +81,7 @@ MetAPILogic get metAPILogic => GetIt.I.get<MetAPILogic>();
|
|||||||
CollectiblesLogic get collectiblesLogic => GetIt.I.get<CollectiblesLogic>();
|
CollectiblesLogic get collectiblesLogic => GetIt.I.get<CollectiblesLogic>();
|
||||||
WallPaperLogic get wallpaperLogic => GetIt.I.get<WallPaperLogic>();
|
WallPaperLogic get wallpaperLogic => GetIt.I.get<WallPaperLogic>();
|
||||||
LocaleLogic get localeLogic => GetIt.I.get<LocaleLogic>();
|
LocaleLogic get localeLogic => GetIt.I.get<LocaleLogic>();
|
||||||
|
|
||||||
|
/// Global helpers for readability
|
||||||
AppLocalizations get $strings => localeLogic.strings;
|
AppLocalizations get $strings => localeLogic.strings;
|
||||||
|
AppStyle get $styles => WondersAppScaffold.style;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user