- 全局字体统一(Outfit/DM Sans), 头部/按钮/Toast规范化 - 故事详情页: Genie Suck吸入动画(标题+卡片一起缩小模糊消失) - 书架页: bookPop弹出+粒子效果(三段式动画完整链路) - 音乐页面: 心情卡片emoji换Material图标+彩色圆块横排布局 - 音乐页面: 进度条胶囊宽度对齐, 播放按钮位置修复, 间距均匀化 - 音乐播放: 接入just_audio, 支持播放暂停进度拖拽自动切歌 - 新增: iOS风格毛玻璃Toast, 渐变背景组件, 通知页面 - 阶段总结文档更新 Co-authored-by: Cursor <cursoragent@cursor.com>
145 lines
4.2 KiB
Dart
145 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import '../theme/app_colors.dart';
|
|
|
|
class GradientButton extends StatelessWidget {
|
|
final String text;
|
|
final VoidCallback? onPressed;
|
|
final double width;
|
|
final double height;
|
|
final bool isLoading;
|
|
final Gradient? gradient;
|
|
|
|
const GradientButton({
|
|
super.key,
|
|
required this.text,
|
|
this.onPressed,
|
|
this.width = double.infinity,
|
|
this.height = 48.0, // 统一规范高度
|
|
this.isLoading = false,
|
|
this.gradient,
|
|
});
|
|
|
|
// Check if using plush/capybara gradient
|
|
bool get _isPlushGradient {
|
|
if (gradient == null) return false;
|
|
if (gradient is LinearGradient) {
|
|
final lg = gradient as LinearGradient;
|
|
// Check if colors match plush gradient colors
|
|
if (lg.colors.length >= 2) {
|
|
return lg.colors.first.value == 0xFFECCFA8 ||
|
|
lg.colors.last.value == 0xFFC99672;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
List<BoxShadow> get _boxShadows {
|
|
if (_isPlushGradient) {
|
|
// Warm brown glow for Capybara plush gradient
|
|
return [
|
|
BoxShadow(
|
|
color: const Color(0xFFC99672).withOpacity(0.35),
|
|
offset: Offset.zero,
|
|
blurRadius: 15,
|
|
),
|
|
BoxShadow(
|
|
color: const Color(0xFFC99672).withOpacity(0.25),
|
|
offset: Offset.zero,
|
|
blurRadius: 30,
|
|
),
|
|
BoxShadow(
|
|
color: const Color(0xFFC99672).withOpacity(0.4),
|
|
offset: const Offset(0, 6),
|
|
blurRadius: 20,
|
|
),
|
|
];
|
|
} else {
|
|
// Purple/indigo glow for primary gradient
|
|
return [
|
|
BoxShadow(
|
|
color: const Color(0xFF6366F1).withOpacity(0.4),
|
|
offset: const Offset(0, 4),
|
|
blurRadius: 20,
|
|
),
|
|
BoxShadow(
|
|
color: const Color(0xFF8B5CF6).withOpacity(0.2),
|
|
offset: Offset.zero,
|
|
blurRadius: 40,
|
|
),
|
|
];
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final bool isDisabled = onPressed == null || isLoading;
|
|
|
|
return Opacity(
|
|
opacity: isDisabled ? 0.7 : 1.0,
|
|
child: Container(
|
|
width: width,
|
|
height: height,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(height / 2),
|
|
gradient: gradient ?? AppColors.btnPrimaryGradient,
|
|
boxShadow: _boxShadows,
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
// Shine overlay (top half gradient)
|
|
Positioned.fill(
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(height / 2),
|
|
child: DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Colors.white.withOpacity(0.15),
|
|
Colors.transparent,
|
|
],
|
|
stops: const [0.0, 0.5],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
// Button content
|
|
Material(
|
|
color: Colors.transparent,
|
|
elevation: 0,
|
|
child: InkWell(
|
|
onTap: isDisabled ? null : onPressed,
|
|
borderRadius: BorderRadius.circular(height / 2),
|
|
splashColor: Colors.white.withOpacity(0.2),
|
|
highlightColor: Colors.white.withOpacity(0.1),
|
|
child: Center(
|
|
child: isLoading
|
|
? const SizedBox(
|
|
width: 24,
|
|
height: 24,
|
|
child: CircularProgressIndicator(
|
|
color: Colors.white,
|
|
strokeWidth: 2.5,
|
|
),
|
|
)
|
|
: Text(
|
|
text,
|
|
style: GoogleFonts.dmSans(
|
|
fontSize: 17,
|
|
fontWeight: FontWeight.w600,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|