git-touch-android-ios-app/lib/app.dart

72 lines
2.3 KiB
Dart
Raw Normal View History

2020-01-14 11:13:07 +01:00
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:git_touch/home.dart';
2020-02-01 07:44:15 +01:00
import 'package:git_touch/models/auth.dart';
2020-01-14 11:13:07 +01:00
import 'package:git_touch/models/theme.dart';
import 'package:provider/provider.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'generated/l10n.dart';
2020-01-14 11:13:07 +01:00
class MyApp extends StatelessWidget {
2020-02-01 07:44:15 +01:00
Widget _buildChild(BuildContext context) {
2020-01-14 11:13:07 +01:00
final theme = Provider.of<ThemeModel>(context);
switch (theme.theme) {
case AppThemeType.cupertino:
return CupertinoApp(
theme: CupertinoThemeData(brightness: theme.brightness),
home: Home(),
localeResolutionCallback:
(Locale locale, Iterable<Locale> supportedLocales) {
return locale;
},
localizationsDelegates: [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('en', ''),
const Locale('hi', ''),
],
2020-01-14 11:13:07 +01:00
);
default:
return MaterialApp(
2020-01-16 14:14:25 +01:00
theme: ThemeData(
brightness: theme.brightness,
primaryColor:
theme.brightness == Brightness.dark ? null : Colors.white,
2020-01-27 08:11:51 +01:00
accentColor: theme.palette.primary,
scaffoldBackgroundColor: theme.palette.background,
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.android: ZoomPageTransitionsBuilder(),
},
),
2020-01-16 14:14:25 +01:00
),
2020-01-14 11:13:07 +01:00
home: Home(),
localeResolutionCallback:
(Locale locale, Iterable<Locale> supportedLocales) {
return locale;
},
localizationsDelegates: [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('en', ''),
const Locale('hi', ''),
],
2020-01-14 11:13:07 +01:00
);
}
}
2020-02-01 07:44:15 +01:00
@override
Widget build(BuildContext context) {
final auth = Provider.of<AuthModel>(context);
return Container(key: auth.rootKey, child: _buildChild(context));
}
2020-01-14 11:13:07 +01:00
}