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