diff --git a/LabelStoreMax/lib/main.dart b/LabelStoreMax/lib/main.dart index 2bbcece..974e44c 100644 --- a/LabelStoreMax/lib/main.dart +++ b/LabelStoreMax/lib/main.dart @@ -31,101 +31,94 @@ import 'package:label_storemax/helpers/app_themes.dart'; import 'package:label_storemax/helpers/app_localizations.dart'; void main() async { - Widget _defaultHome = new HomePage(); + WidgetsFlutterBinding.ensureInitialized(); + + await SystemChrome.setPreferredOrientations([ + DeviceOrientation.portraitUp, + ]); - SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]).then( - (_) { - _defaultHome = HomePage(); + runApp( + new MaterialApp( + title: app_name, + color: Colors.white, + debugShowCheckedModeBanner: false, + initialRoute: "/home", + routes: { + '/home': (BuildContext context) => new HomePage(), + '/cart': (BuildContext context) => new CartPage(), + '/browse-category': (BuildContext context) => new BrowseCategoryPage(), + '/product-search': (BuildContext context) => new BrowseSearchPage(), + '/product-detail': (BuildContext context) => new ProductDetailPage(), + '/checkout': (BuildContext context) => new CheckoutConfirmationPage(), + '/checkout-status': (BuildContext context) => new CheckoutStatusPage(), + }, + onGenerateRoute: (settings) { + switch (settings.name) { + case '/home-menu': + return PageTransition( + child: HomeMenuPage(), type: PageTransitionType.leftToRight); + case '/checkout-details': + return PageTransition( + child: CheckoutDetailsPage(), + type: PageTransitionType.downToUp); + case '/about': + return PageTransition( + child: AboutPage(), type: PageTransitionType.leftToRight); - runApp( - new MaterialApp( - title: app_name, + case '/checkout-payment-type': + return PageTransition( + child: CheckoutPaymentTypePage(), + type: PageTransitionType.downToUp); + + case '/checkout-shipping-type': + return PageTransition( + child: CheckoutShippingTypePage(), + type: PageTransitionType.downToUp); + + case '/home-search': + return PageTransition( + child: HomeSearchPage(), type: PageTransitionType.downToUp); + default: + return null; + } + }, + supportedLocales: [Locale('en')], + localizationsDelegates: [ + AppLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalMaterialLocalizations.delegate + ], + localeResolutionCallback: + (Locale locale, Iterable supportedLocales) { + return locale; + }, + theme: ThemeData( + primaryColor: HexColor("#2f4ffe"), + backgroundColor: Colors.white, + buttonTheme: ButtonThemeData( + hoverColor: Colors.transparent, + buttonColor: HexColor("#529cda"), + colorScheme: colorSchemeButton(), + minWidth: double.infinity, + height: 70, + shape: RoundedRectangleBorder( + borderRadius: new BorderRadius.circular(5.0), + ), + ), + appBarTheme: AppBarTheme( color: Colors.white, - debugShowCheckedModeBanner: false, - routes: { - '/home': (BuildContext context) => new HomePage(), - '/cart': (BuildContext context) => new CartPage(), - '/browse-category': (BuildContext context) => - new BrowseCategoryPage(), - '/product-search': (BuildContext context) => - new BrowseSearchPage(), - '/product-detail': (BuildContext context) => - new ProductDetailPage(), - '/checkout': (BuildContext context) => - new CheckoutConfirmationPage(), - '/checkout-status': (BuildContext context) => - new CheckoutStatusPage(), - }, - onGenerateRoute: (settings) { - switch (settings.name) { - case '/home-menu': - return PageTransition( - child: HomeMenuPage(), - type: PageTransitionType.leftToRight); - case '/checkout-details': - return PageTransition( - child: CheckoutDetailsPage(), - type: PageTransitionType.downToUp); - case '/about': - return PageTransition( - child: AboutPage(), type: PageTransitionType.leftToRight); - - case '/checkout-payment-type': - return PageTransition( - child: CheckoutPaymentTypePage(), - type: PageTransitionType.downToUp); - - case '/checkout-shipping-type': - return PageTransition( - child: CheckoutShippingTypePage(), - type: PageTransitionType.downToUp); - - case '/home-search': - return PageTransition( - child: HomeSearchPage(), - type: PageTransitionType.downToUp); - default: - return null; - } - }, - supportedLocales: [Locale('en')], - localizationsDelegates: [ - AppLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalMaterialLocalizations.delegate - ], - localeResolutionCallback: - (Locale locale, Iterable supportedLocales) { - return locale; - }, - theme: ThemeData( - primaryColor: HexColor("#2f4ffe"), - backgroundColor: Colors.white, - buttonTheme: ButtonThemeData( - hoverColor: Colors.transparent, - buttonColor: HexColor("#529cda"), - colorScheme: colorSchemeButton(), - minWidth: double.infinity, - height: 70, - shape: RoundedRectangleBorder( - borderRadius: new BorderRadius.circular(5.0), - ), - ), - appBarTheme: AppBarTheme( - color: Colors.white, - textTheme: textThemeAppBar(), - elevation: 0.0, - brightness: Brightness.light, - iconTheme: IconThemeData(color: Colors.black), - actionsIconTheme: IconThemeData( - color: Colors.black, - )), - accentColor: Colors.black, - accentTextTheme: textThemeAccent(), - textTheme: textThemeMain(), - primaryTextTheme: textThemePrimary()), - home: _defaultHome), - ); - }, + textTheme: textThemeAppBar(), + elevation: 0.0, + brightness: Brightness.light, + iconTheme: IconThemeData(color: Colors.black), + actionsIconTheme: IconThemeData( + color: Colors.black, + )), + accentColor: Colors.black, + accentTextTheme: textThemeAccent(), + textTheme: textThemeMain(), + primaryTextTheme: textThemePrimary(), + ), + ), ); }