2020-01-14 18:13:07 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:git_touch/home.dart';
|
2020-02-01 14:44:15 +08:00
|
|
|
import 'package:git_touch/models/auth.dart';
|
2020-01-14 18:13:07 +08:00
|
|
|
import 'package:git_touch/models/theme.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2021-02-03 09:34:41 +05:30
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
2020-01-14 18:13:07 +08:00
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
2020-02-01 14:44:15 +08:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final auth = Provider.of<AuthModel>(context);
|
2021-02-14 13:01:09 +08:00
|
|
|
final theme = Provider.of<ThemeModel>(context);
|
|
|
|
|
|
|
|
final LocaleListResolutionCallback localeListResolutionCallback =
|
|
|
|
(locales, supportedLocales) {
|
2021-02-19 20:54:31 +08:00
|
|
|
return theme.userSetLocale ?? supportedLocales.first;
|
2021-02-14 13:01:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
key: auth.rootKey,
|
|
|
|
child: theme.theme == AppThemeType.cupertino
|
|
|
|
? CupertinoApp(
|
|
|
|
theme: CupertinoThemeData(brightness: theme.brightness),
|
|
|
|
home: Home(),
|
|
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
|
|
localeListResolutionCallback: localeListResolutionCallback,
|
|
|
|
)
|
|
|
|
: MaterialApp(
|
|
|
|
theme: ThemeData(
|
|
|
|
brightness: theme.brightness,
|
|
|
|
primaryColor:
|
|
|
|
theme.brightness == Brightness.dark ? null : Colors.white,
|
|
|
|
accentColor: theme.palette.primary,
|
|
|
|
scaffoldBackgroundColor: theme.palette.background,
|
|
|
|
pageTransitionsTheme: PageTransitionsTheme(
|
|
|
|
builders: {
|
|
|
|
TargetPlatform.android: ZoomPageTransitionsBuilder(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
home: Home(),
|
|
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
|
|
localeListResolutionCallback: localeListResolutionCallback,
|
|
|
|
),
|
|
|
|
);
|
2020-02-01 14:44:15 +08:00
|
|
|
}
|
2020-01-14 18:13:07 +08:00
|
|
|
}
|