Resolve all lints and deprecation warnings
This commit is contained in:
@@ -2,13 +2,17 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
|
||||
import 'models/scripture.dart';
|
||||
import 'theme/app_theme.dart';
|
||||
import 'screens/splash_screen.dart';
|
||||
|
||||
import 'screens/onboarding/onboarding_screen.dart';
|
||||
import 'screens/home/home_screen.dart';
|
||||
import 'screens/husband/husband_home_screen.dart';
|
||||
import 'models/user_profile.dart';
|
||||
import 'models/cycle_entry.dart';
|
||||
import 'models/teaching_plan.dart';
|
||||
import 'models/scripture.dart';
|
||||
import 'providers/user_provider.dart';
|
||||
import 'services/notification_service.dart';
|
||||
import 'app_startup.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -28,24 +32,14 @@ void main() async {
|
||||
Hive.registerAdapter(UserRoleAdapter());
|
||||
Hive.registerAdapter(BibleTranslationAdapter());
|
||||
Hive.registerAdapter(ScriptureAdapter());
|
||||
Hive.registerAdapter(AppThemeModeAdapter()); // Register new adapter
|
||||
Hive.registerAdapter(AppThemeModeAdapter());
|
||||
Hive.registerAdapter(SupplyItemAdapter());
|
||||
Hive.registerAdapter(PadTypeAdapter());
|
||||
Hive.registerAdapter(TeachingPlanAdapter());
|
||||
|
||||
// Open boxes and load scriptures in parallel
|
||||
await Future.wait([
|
||||
Hive.openBox<UserProfile>('user_profile'),
|
||||
Hive.openBox<CycleEntry>('cycle_entries'),
|
||||
ScriptureDatabase().loadScriptures(),
|
||||
]);
|
||||
|
||||
// Initialize notifications
|
||||
await NotificationService().initialize();
|
||||
|
||||
runApp(const ProviderScope(child: ChristianPeriodTrackerApp()));
|
||||
runApp(const ProviderScope(child: AppStartupWidget()));
|
||||
}
|
||||
|
||||
|
||||
// Helper to convert hex string to Color
|
||||
Color _colorFromHex(String hexColor) {
|
||||
try {
|
||||
@@ -61,6 +55,7 @@ class ChristianPeriodTrackerApp extends ConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
// Watch user profile to determine
|
||||
final userProfile = ref.watch(userProfileProvider);
|
||||
|
||||
final ThemeMode themeMode;
|
||||
@@ -74,9 +69,8 @@ class ChristianPeriodTrackerApp extends ConsumerWidget {
|
||||
break;
|
||||
case AppThemeMode.dark:
|
||||
themeMode = ThemeMode.dark;
|
||||
break;
|
||||
|
||||
case AppThemeMode.system:
|
||||
default:
|
||||
themeMode = ThemeMode.system;
|
||||
break;
|
||||
}
|
||||
@@ -86,13 +80,23 @@ class ChristianPeriodTrackerApp extends ConsumerWidget {
|
||||
accentColor = AppColors.sageGreen;
|
||||
}
|
||||
|
||||
// Determine the home screen based on profile state
|
||||
Widget homeScreen;
|
||||
if (userProfile == null) {
|
||||
homeScreen = const OnboardingScreen();
|
||||
} else if (userProfile.role == UserRole.husband) {
|
||||
homeScreen = const HusbandHomeScreen();
|
||||
} else {
|
||||
homeScreen = const HomeScreen();
|
||||
}
|
||||
|
||||
return MaterialApp(
|
||||
title: 'Christian Period Tracker',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.getLightTheme(accentColor),
|
||||
darkTheme: AppTheme.getDarkTheme(accentColor),
|
||||
themeMode: themeMode,
|
||||
home: const SplashScreen(),
|
||||
home: homeScreen,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user