app.dart 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import 'package:fluro/fluro.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:flutter_localizations/flutter_localizations.dart';
  5. import 'package:get_it/get_it.dart';
  6. import 'package:provider/provider.dart';
  7. import 'package:sport/config_inject.dart';
  8. import 'package:sport/pages/splash_page.dart';
  9. import 'package:sport/provider/bluetooth.dart';
  10. import 'package:sport/provider/game_model.dart';
  11. import 'package:sport/provider/message_model.dart';
  12. import 'package:sport/router/routes.dart';
  13. import 'package:umeng_common_sdk/umeng_common_sdk.dart';
  14. import 'application.dart';
  15. import 'provider/user_model.dart';
  16. import 'utils/CupertinoLocalizationsDelegate.dart';
  17. class MyApp extends StatelessWidget with ConfigInject {
  18. @override
  19. Widget build(BuildContext context) {
  20. final router = FluroRouter();
  21. Routes.configureRoutes(router);
  22. Application.router = router;
  23. UmengCommonSdk.initCommon("60f23987a6f90557b7bc7505", "60f23a652a1a2a58e7db1b21", "ouj");
  24. return MultiProvider(
  25. providers: [
  26. ChangeNotifierProvider<UserModel>(
  27. create: (_) => UserModel(),
  28. lazy: false,
  29. ),
  30. ChangeNotifierProvider<Bluetooth>(
  31. create: (_) => Bluetooth(),
  32. ),
  33. ChangeNotifierProvider<MessageModel>(
  34. create: (_) => MessageModel(),
  35. ),
  36. ChangeNotifierProvider<GameModel>(
  37. create: (_) => GetIt.I<GameModel>(),
  38. ),
  39. ],
  40. child: MaterialApp(
  41. debugShowCheckedModeBanner: false,
  42. // supportedLocales: [const Locale('zh', 'CH'), const Locale('en', 'US')],
  43. localizationsDelegates: [
  44. CupertinoLocalizationsDelegate(),
  45. GlobalMaterialLocalizations.delegate,
  46. GlobalWidgetsLocalizations.delegate,
  47. ],
  48. localeResolutionCallback: (deviceLocale, supportedLocales) {
  49. locale = deviceLocale;
  50. return deviceLocale;
  51. },
  52. onGenerateRoute: Application.router?.generator,
  53. navigatorObservers: [routeObserver],
  54. theme: ThemeData(
  55. platform: TargetPlatform.iOS,
  56. brightness: Brightness.light,
  57. primaryColor: Colors.white,
  58. accentColor: const Color(0xffFFC400),
  59. // splashColor: Colors.transparent,
  60. backgroundColor: const Color(0xffF1F1F1),
  61. scaffoldBackgroundColor: const Color(0xffF1F1F1),
  62. textTheme: TextTheme(
  63. headline1: TextStyle(fontSize: 18.0, color: const Color(0xff333333), fontWeight: FontWeight.w600, height: 1.2),
  64. headline2: TextStyle(fontSize: 25.0, color: const Color(0xff333333), fontWeight: FontWeight.w600, height: 1.2),
  65. headline3: TextStyle(fontSize: 16.0, color: const Color(0xff333333), fontWeight: FontWeight.w600, height: 1.2),
  66. headline4: TextStyle(fontSize: 16.0, color: const Color(0xffffffff), fontWeight: FontWeight.w600, height: 1.2),
  67. headline6: TextStyle(fontSize: 14.0, color: const Color(0xffffffff), fontWeight: FontWeight.normal, height: 1.2),
  68. subtitle1: TextStyle(fontSize: 14.0, color: const Color(0xff333333), fontWeight: FontWeight.normal, height: 1.2),
  69. subtitle2: TextStyle(fontSize: 12.0, color: const Color(0xff333333), fontWeight: FontWeight.normal, height: 1.2),
  70. bodyText1: TextStyle(fontSize: 12.0, color: const Color(0xff999999), fontWeight: FontWeight.normal, height: 1.2),
  71. bodyText2: TextStyle(fontSize: 14.0, color: const Color(0xff999999), fontWeight: FontWeight.normal, height: 1.2),
  72. ),
  73. colorScheme: ColorScheme.light(primary: Colors.white, secondary: const Color(0xffFFC400)),
  74. textSelectionTheme: TextSelectionThemeData(cursorColor: const Color(0xffFFC400)),
  75. progressIndicatorTheme: ProgressIndicatorThemeData(color: const Color(0xffFFC400)),
  76. sliderTheme: SliderThemeData(thumbColor: const Color(0xffFFC400), activeTrackColor: const Color(0xffFFC400)),
  77. dividerTheme: DividerThemeData(color: const Color(0xffDCDCDC)),
  78. tabBarTheme: TabBarTheme(indicatorSize: TabBarIndicatorSize.label, labelColor: Color(0xffFFC400), unselectedLabelColor: Color(0xff333333), labelStyle: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600), unselectedLabelStyle: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600)),
  79. appBarTheme: AppBarTheme(
  80. elevation: 0,
  81. ),
  82. popupMenuTheme: PopupMenuThemeData(textStyle: TextStyle(fontSize: 14.0, color: Color(0xff666666), fontWeight: FontWeight.normal), shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))))),
  83. home: SplashPage(),
  84. ),
  85. );
  86. }
  87. }