145 lines
3.8 KiB
Dart
145 lines
3.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
import '../../../../core/constants/app_constants.dart';
|
|
import '../../../../routes/route_paths.dart';
|
|
import '../providers/auth_provider.dart';
|
|
|
|
/// 开屏页面 - 应用启动时显示的第一个页面
|
|
/// 显示 Logo 和应用名称,同时检查用户认证状态
|
|
class SplashPage extends ConsumerStatefulWidget {
|
|
const SplashPage({super.key});
|
|
|
|
@override
|
|
ConsumerState<SplashPage> createState() => _SplashPageState();
|
|
}
|
|
|
|
class _SplashPageState extends ConsumerState<SplashPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_initializeApp();
|
|
}
|
|
|
|
/// 初始化应用并检查认证状态
|
|
Future<void> _initializeApp() async {
|
|
// 等待开屏动画展示
|
|
await Future.delayed(AppConstants.splashDuration);
|
|
|
|
// 检查认证状态
|
|
await ref.read(authProvider.notifier).checkAuthStatus();
|
|
|
|
if (!mounted) return;
|
|
|
|
final authState = ref.read(authProvider);
|
|
|
|
if (authState.isWalletCreated) {
|
|
// 已创建钱包,进入主页面(龙虎榜)
|
|
context.go(RoutePaths.ranking);
|
|
} else {
|
|
// 未创建钱包,进入引导页面
|
|
context.go(RoutePaths.onboarding);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Container(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
// 渐变背景 - 从浅米色到金黄色
|
|
decoration: const BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color(0xFFFFF5E6), // 浅米色
|
|
Color(0xFFFFE4B5), // 金黄色
|
|
],
|
|
),
|
|
),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
// Logo 图片容器
|
|
_buildLogo(),
|
|
const SizedBox(height: 24),
|
|
// 应用名称
|
|
_buildAppTitle(),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 构建 Logo 组件
|
|
/// 深色背景上的皇冠图标
|
|
Widget _buildLogo() {
|
|
return Container(
|
|
width: 128,
|
|
height: 152,
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFF2D2A26), // 深棕色背景
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
// 皇冠图标
|
|
Container(
|
|
width: 64,
|
|
height: 48,
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFD4A84B), // 金色
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: const Icon(
|
|
Icons.workspace_premium,
|
|
size: 32,
|
|
color: Color(0xFF2D2A26),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
// DURIAN 文字
|
|
const Text(
|
|
'DURIAN',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.w600,
|
|
letterSpacing: 2,
|
|
color: Color(0xFFD4A84B),
|
|
),
|
|
),
|
|
const SizedBox(height: 2),
|
|
// QUEEN 文字
|
|
const Text(
|
|
'QUEEN',
|
|
style: TextStyle(
|
|
fontSize: 10,
|
|
fontWeight: FontWeight.w400,
|
|
letterSpacing: 1.5,
|
|
color: Color(0xFFD4A84B),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 构建应用标题
|
|
Widget _buildAppTitle() {
|
|
return const Text(
|
|
'榴莲女皇',
|
|
style: TextStyle(
|
|
fontSize: 32,
|
|
fontFamily: 'Noto Sans SC',
|
|
fontWeight: FontWeight.w700,
|
|
height: 1.25,
|
|
letterSpacing: 1.6,
|
|
color: Color(0xFF4A3F35), // 深棕色文字
|
|
),
|
|
);
|
|
}
|
|
}
|