app.dart 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. final color = const Color(0xffFFC400);
  24. final backgroundColor = const Color(0xffF1F1F1);
  25. return MultiProvider(
  26. providers: [
  27. ChangeNotifierProvider<UserModel>(
  28. create: (_) => UserModel(),
  29. lazy: false,
  30. ),
  31. ],
  32. child: MaterialApp(
  33. debugShowCheckedModeBanner: false,
  34. // supportedLocales: [const Locale('zh', 'CH'), const Locale('en', 'US')],
  35. localizationsDelegates: [
  36. CupertinoLocalizationsDelegate(),
  37. GlobalMaterialLocalizations.delegate,
  38. GlobalWidgetsLocalizations.delegate,
  39. ],
  40. localeResolutionCallback: (deviceLocale, supportedLocales) {
  41. locale = deviceLocale;
  42. return deviceLocale;
  43. },
  44. onGenerateRoute: Application.router?.generator,
  45. navigatorObservers: [routeObserver],
  46. theme: ThemeData(
  47. platform: TargetPlatform.iOS,
  48. brightness: Brightness.light,
  49. primaryColor: Colors.white,
  50. accentColor: color,
  51. // splashColor: Colors.transparent,
  52. backgroundColor: backgroundColor,
  53. scaffoldBackgroundColor: backgroundColor,
  54. textTheme: TextTheme(
  55. headline1: TextStyle(fontSize: 18.0, color: const Color(0xff333333), fontWeight: FontWeight.w600, height: 1.2),
  56. headline2: TextStyle(fontSize: 25.0, color: const Color(0xff333333), fontWeight: FontWeight.w600, height: 1.2),
  57. headline3: TextStyle(fontSize: 16.0, color: const Color(0xff333333), fontWeight: FontWeight.w600, height: 1.2),
  58. headline4: TextStyle(fontSize: 16.0, color: const Color(0xffffffff), fontWeight: FontWeight.w600, height: 1.2),
  59. headline6: TextStyle(fontSize: 14.0, color: const Color(0xffffffff), fontWeight: FontWeight.normal, height: 1.2),
  60. subtitle1: TextStyle(fontSize: 14.0, color: const Color(0xff333333), fontWeight: FontWeight.normal, height: 1.2),
  61. subtitle2: TextStyle(fontSize: 12.0, color: const Color(0xff333333), fontWeight: FontWeight.normal, height: 1.2),
  62. bodyText1: TextStyle(fontSize: 12.0, color: const Color(0xff999999), fontWeight: FontWeight.normal, height: 1.2),
  63. bodyText2: TextStyle(fontSize: 14.0, color: const Color(0xff999999), fontWeight: FontWeight.normal, height: 1.2),
  64. ),
  65. colorScheme: ColorScheme.light(primary: Colors.white, secondary: color, ),
  66. textSelectionTheme: TextSelectionThemeData(cursorColor: color),
  67. progressIndicatorTheme: ProgressIndicatorThemeData(color: color),
  68. sliderTheme: SliderThemeData(thumbColor: color, activeTrackColor: color),
  69. dividerTheme: DividerThemeData(color: const Color(0xffDCDCDC)),
  70. tabBarTheme: TabBarTheme(indicatorSize: TabBarIndicatorSize.label, labelColor: color, unselectedLabelColor: Color(0xff333333), labelStyle: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600), unselectedLabelStyle: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600)),
  71. appBarTheme: AppBarTheme(
  72. elevation: 0,
  73. ),
  74. popupMenuTheme: PopupMenuThemeData(textStyle: TextStyle(fontSize: 14.0, color: Color(0xff666666), fontWeight: FontWeight.normal), shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))))),
  75. home: SplashPage(),
  76. ),
  77. );
  78. }
  79. }