引导、通知栏计时
This commit is contained in:
@@ -4,6 +4,7 @@ import 'services/storage_service.dart';
|
||||
import 'services/encouragement_service.dart';
|
||||
import 'services/notification_service.dart';
|
||||
import 'screens/home_screen.dart';
|
||||
import 'screens/onboarding_screen.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -23,7 +24,7 @@ void main() async {
|
||||
runApp(MyApp(encouragementService: encouragementService));
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
class MyApp extends StatefulWidget {
|
||||
final EncouragementService encouragementService;
|
||||
|
||||
const MyApp({
|
||||
@@ -31,13 +32,45 @@ class MyApp extends StatelessWidget {
|
||||
required this.encouragementService,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MyApp> createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
bool _hasCompletedOnboarding = false;
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_checkOnboardingStatus();
|
||||
}
|
||||
|
||||
Future<void> _checkOnboardingStatus() async {
|
||||
final completed = await OnboardingScreen.hasCompletedOnboarding();
|
||||
setState(() {
|
||||
_hasCompletedOnboarding = completed;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
title: 'FocusBuddy',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppTheme.lightTheme,
|
||||
home: HomeScreen(encouragementService: encouragementService),
|
||||
home: _isLoading
|
||||
? const Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
)
|
||||
: _hasCompletedOnboarding
|
||||
? HomeScreen(encouragementService: widget.encouragementService)
|
||||
: OnboardingScreen(
|
||||
encouragementService: widget.encouragementService,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user