main.dart 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:flutter_localizations/flutter_localizations.dart';
  4. import 'l10n/app_localizations.dart';
  5. import 'ui/main_menu.dart';
  6. import 'utils/colors.dart';
  7. import 'utils/settings_manager.dart';
  8. import 'utils/score_manager.dart';
  9. import 'utils/google_play_games_manager.dart';
  10. import 'utils/locale_manager.dart';
  11. import 'utils/app_lifecycle_manager.dart';
  12. void main() async {
  13. WidgetsFlutterBinding.ensureInitialized();
  14. await SettingsManager.init();
  15. await ScoreManager.initialize();
  16. await LocaleManager.init();
  17. // Initialize Google Play Games (silent init, don't require sign-in)
  18. await GooglePlayGamesManager.instance.initialize();
  19. // Initialize app lifecycle manager for game suspension
  20. AppLifecycleManager.instance.initialize();
  21. runApp(const ZenTapApp());
  22. }
  23. class ZenTapApp extends StatefulWidget {
  24. const ZenTapApp({super.key});
  25. @override
  26. State<ZenTapApp> createState() => _ZenTapAppState();
  27. }
  28. class _ZenTapAppState extends State<ZenTapApp> {
  29. static _ZenTapAppState? _instance;
  30. @override
  31. void initState() {
  32. super.initState();
  33. _instance = this;
  34. // Set up locale change callback
  35. LocaleManager.setLocaleChangeCallback(() {
  36. setState(() {});
  37. });
  38. }
  39. @override
  40. void dispose() {
  41. _instance = null;
  42. super.dispose();
  43. }
  44. @override
  45. Widget build(BuildContext context) {
  46. return MaterialApp(
  47. title: 'ZenTap',
  48. debugShowCheckedModeBanner: false,
  49. locale: LocaleManager.currentLocale,
  50. localizationsDelegates: const [
  51. AppLocalizations.delegate,
  52. GlobalMaterialLocalizations.delegate,
  53. GlobalWidgetsLocalizations.delegate,
  54. GlobalCupertinoLocalizations.delegate,
  55. ],
  56. supportedLocales: LocaleManager.supportedLocales,
  57. theme: ThemeData(
  58. // Use ZenTap color scheme
  59. colorScheme: ColorScheme.dark(
  60. primary: ZenColors.buttonBackground,
  61. secondary: ZenColors.defaultLink,
  62. surface: ZenColors.uiElements,
  63. onPrimary: ZenColors.buttonText,
  64. onSecondary: ZenColors.white,
  65. onSurface: ZenColors.primaryText,
  66. ),
  67. scaffoldBackgroundColor: ZenColors.appBackground,
  68. appBarTheme: const AppBarTheme(
  69. backgroundColor: ZenColors.appBackground,
  70. foregroundColor: ZenColors.primaryText,
  71. elevation: 0,
  72. systemOverlayStyle: SystemUiOverlayStyle.light,
  73. ),
  74. textTheme: const TextTheme(
  75. bodyLarge: TextStyle(color: ZenColors.primaryText),
  76. bodyMedium: TextStyle(color: ZenColors.primaryText),
  77. bodySmall: TextStyle(color: ZenColors.secondaryText),
  78. titleLarge: TextStyle(color: ZenColors.primaryText),
  79. titleMedium: TextStyle(color: ZenColors.primaryText),
  80. titleSmall: TextStyle(color: ZenColors.primaryText),
  81. ),
  82. elevatedButtonTheme: ElevatedButtonThemeData(
  83. style: ElevatedButton.styleFrom(
  84. backgroundColor: ZenColors.buttonBackground,
  85. foregroundColor: ZenColors.buttonText,
  86. elevation: 4,
  87. shape: RoundedRectangleBorder(
  88. borderRadius: BorderRadius.circular(12),
  89. ),
  90. ),
  91. ),
  92. dialogTheme: DialogThemeData(
  93. backgroundColor: ZenColors.uiElements,
  94. titleTextStyle: const TextStyle(
  95. color: ZenColors.primaryText,
  96. fontSize: 20,
  97. fontWeight: FontWeight.bold,
  98. ),
  99. contentTextStyle: TextStyle(
  100. color: ZenColors.secondaryText,
  101. fontSize: 16,
  102. ),
  103. ),
  104. useMaterial3: true,
  105. ),
  106. home: const MainMenu(),
  107. );
  108. }
  109. }