85 lines
2.6 KiB
Dart
85 lines
2.6 KiB
Dart
import 'package:catcher/catcher.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_device_locale/flutter_device_locale.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:flutter_redux/flutter_redux.dart';
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
import 'package:splashscreen/splashscreen.dart';
|
|
|
|
import 'constants.dart';
|
|
import 'generated/l10n.dart';
|
|
import 'pages/home.dart';
|
|
import 'routes.dart';
|
|
import 'store/actions.dart';
|
|
import 'store/store.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
Locale locale = await DeviceLocale.getCurrentLocale();
|
|
|
|
runApp(MyApp(locale));
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
final Locale localLocate;
|
|
|
|
MyApp(this.localLocate) {
|
|
Routes.configure();
|
|
store.dispatch(UpdateLocale(localLocate));
|
|
}
|
|
|
|
// This widget is the root of your application.
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget _buildBody() {
|
|
return SplashScreen(
|
|
seconds: 5,
|
|
routeName: '/',
|
|
navigateAfterSeconds: Home(localLocate, title: 'Welcome',),
|
|
styleTextUnderTheLoader: new TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 20.0,
|
|
),
|
|
// imageBackground: (Image.network(Constants.BASE_API_URL + 'gallery/get-wisetronic-slpash')).image,
|
|
imageBackground: (new Image.network(Constants.BASE_API_URL + 'gallery/get-minimanager-splash/')).image,
|
|
backgroundColor: Colors.white,
|
|
onClick: () {
|
|
|
|
},
|
|
loaderColor: Colors.blue,
|
|
);
|
|
}
|
|
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: Constants.DEBUG,
|
|
navigatorKey: kIsWeb ? null : Catcher.navigatorKey,
|
|
localizationsDelegates: [
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
GlobalCupertinoLocalizations.delegate,
|
|
RefreshLocalizations.delegate,
|
|
S.delegate,
|
|
],
|
|
supportedLocales: S.delegate.supportedLocales,
|
|
localeResolutionCallback: (Locale locale, Iterable<Locale> supportedLocales) {
|
|
print('Language code: ${localLocate.languageCode}');
|
|
for (final supportedLocale in supportedLocales) {
|
|
if (supportedLocale.languageCode == localLocate.languageCode) {
|
|
return supportedLocale;
|
|
}
|
|
}
|
|
return supportedLocales.first;
|
|
},
|
|
title: 'Wisetronic Inc.',
|
|
theme: ThemeData(
|
|
primarySwatch: Colors.blue,
|
|
),
|
|
home: StoreProvider(
|
|
store: store,
|
|
child: _buildBody(),
|
|
),
|
|
);
|
|
}
|
|
}
|