| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- import '../providers/auth_provider.dart';
- import '../../core/constants/route_constants.dart';
-
- class SplashScreen extends StatefulWidget {
- const SplashScreen({super.key});
-
- @override
- SplashScreenState createState() => SplashScreenState();
- }
-
- class SplashScreenState extends State<SplashScreen> {
- @override
- void initState() {
- super.initState();
- _initializeApp();
- }
-
- Future<void> _initializeApp() async {
- final authProvider = Provider.of<AuthProvider>(context, listen: false);
- await authProvider.checkAuthStatus();
-
- // 模拟初始化延迟
- await Future.delayed(const Duration(milliseconds: 1500));
-
- // 导航到首页
- if (mounted) {
- Navigator.of(context).pushReplacementNamed(RouteConstants.home);
- }
- }
-
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.blue,
- body: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- const Icon(
- Icons.apps,
- size: 100,
- color: Colors.white,
- ),
- const SizedBox(height: 20),
- const Text(
- '采油会',
- style: TextStyle(
- fontSize: 32,
- fontWeight: FontWeight.bold,
- color: Colors.white,
- ),
- ),
- const SizedBox(height: 20),
- SizedBox(
- width: 60,
- height: 60,
- child: CircularProgressIndicator(
- valueColor: AlwaysStoppedAnimation<Color>(
- Color.lerp(Colors.white, Colors.transparent, 0.3)!, // 0.3表示30%透明
- ),
- strokeWidth: 4,
- ),
- ),
- ],
- ),
- ),
- );
- }
- }
|