You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

256 lines
6.7 KiB

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../controllers/splash_controller.dart';
class SplashView extends GetView<SplashController> {
const SplashView({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F7),
body: Stack(
children: [
// 状态栏
_buildStatusBar(),
// 主内容
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Logo动画
_buildAnimatedLogo(),
// 应用名称
_buildAppTitle(),
// 标语
_buildSlogan(),
// 加载进度条
SizedBox(height: 40.h),
_buildLoadingBar(),
// 额外信息
SizedBox(height: 16.h),
_buildExtraInfo(),
],
),
),
// 版本号
_buildVersionInfo(),
],
),
);
}
// 状态栏
Widget _buildStatusBar() {
return Positioned(
top: 0,
left: 0,
right: 0,
child: SafeArea(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 8.h),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'9:41',
style: TextStyle(
fontSize: 12.sp,
color: Colors.grey[800],
),
),
Row(
children: [
Icon(Icons.signal_cellular_4_bar, size: 12.sp, color: Colors.grey[800]),
SizedBox(width: 4.w),
Icon(Icons.wifi, size: 12.sp, color: Colors.grey[800]),
SizedBox(width: 4.w),
Icon(Icons.battery_full, size: 12.sp, color: Colors.grey[800]),
],
),
],
),
),
),
);
}
// 动画Logo
Widget _buildAnimatedLogo() {
return TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 0.8, end: 1.1),
duration: const Duration(seconds: 2),
curve: Curves.easeInOut,
builder: (context, value, child) {
// 确保opacity值不超过1.0
final opacity = value <= 1.0 ? value : 1.0;
return Transform.scale(
scale: value,
child: AnimatedOpacity(
opacity: opacity,
duration: const Duration(milliseconds: 500),
child: child,
),
);
},
child: Container(
width: 96.w,
height: 96.w,
decoration: BoxDecoration(
gradient: const LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Colors.blue, Colors.purple],
),
borderRadius: BorderRadius.circular(24.r),
boxShadow: [
BoxShadow(
color: Colors.blue.withOpacity(0.3),
blurRadius: 15,
offset: const Offset(0, 8),
spreadRadius: 3,
),
],
),
child: Icon(
Icons.headset,
size: 48.sp,
color: Colors.white,
),
),
);
}
// 应用标题
Widget _buildAppTitle() {
return TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 1500),
curve: Curves.easeOut,
builder: (context, value, child) {
return Opacity(
opacity: value,
child: Padding(
padding: EdgeInsets.only(top: 24.h),
child: Text(
'DeepVoice',
style: TextStyle(
fontSize: 28.sp,
fontWeight: FontWeight.bold,
color: Colors.grey[800],
),
),
),
);
},
);
}
// 标语
Widget _buildSlogan() {
return TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 1500),
curve: Curves.easeOut,
builder: (context, value, child) {
return Opacity(
opacity: value,
child: Padding(
padding: EdgeInsets.only(top: 8.h),
child: Text(
'连接世界,岂止声音',
style: TextStyle(
fontSize: 14.sp,
color: Colors.grey[600],
),
),
),
);
},
);
}
// 加载进度条
Widget _buildLoadingBar() {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 80.w),
child: Stack(
children: [
Container(
height: 4.h,
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(2.r),
),
),
Obx(() {
final progress = controller.loadingProgress;
return LayoutBuilder(
builder: (context, constraints) {
return Container(
height: 4.h,
width: constraints.maxWidth * progress,
decoration: BoxDecoration(
gradient: const LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [Colors.blue, Colors.purple],
),
borderRadius: BorderRadius.circular(2.r),
),
);
},
);
}),
],
),
);
}
// 额外信息
Widget _buildExtraInfo() {
return TweenAnimationBuilder<double>(
tween: Tween<double>(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 1500),
curve: Curves.easeOut,
builder: (context, value, child) {
return Opacity(
opacity: value,
child: Text(
'AI语音专家 · 随时随地',
style: TextStyle(
fontSize: 12.sp,
color: Colors.grey[400],
),
),
);
},
);
}
// 版本信息
Widget _buildVersionInfo() {
return Positioned(
bottom: 32.h,
left: 0,
right: 0,
child: Center(
child: Text(
controller.version,
style: TextStyle(
fontSize: 12.sp,
color: Colors.grey[400],
),
),
),
);
}
}