修复一点问题
This commit is contained in:
@@ -105,7 +105,12 @@ class _LoginPageState extends State<LoginPage> {
|
||||
? null
|
||||
: () {
|
||||
if (!_isAgreed) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('请先阅读并同意用户协议')));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('请先阅读并同意用户协议'),
|
||||
duration: Duration(seconds: 1), // 这里设置显示时长:2秒
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
_handleLogin();
|
||||
|
||||
@@ -10,40 +10,25 @@ class StatusChip extends StatefulWidget {
|
||||
final bool breathing;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const StatusChip({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.color,
|
||||
this.icon,
|
||||
this.svgPath,
|
||||
this.svgColor,
|
||||
this.breathing = false,
|
||||
this.onTap,
|
||||
}) : assert(icon != null || svgPath != null, '必须提供 icon 或 svgPath 其中之一');
|
||||
const StatusChip({super.key, required this.text, required this.color, this.icon, this.svgPath, this.svgColor, this.breathing = false, this.onTap})
|
||||
: assert(icon != null || svgPath != null, '必须提供 icon 或 svgPath 其中之一');
|
||||
|
||||
@override
|
||||
State<StatusChip> createState() => _StatusChipState();
|
||||
}
|
||||
|
||||
class _StatusChipState extends State<StatusChip>
|
||||
with SingleTickerProviderStateMixin {
|
||||
class _StatusChipState extends State<StatusChip> with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
late Animation<double> _opacityAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 1000),
|
||||
);
|
||||
_controller = AnimationController(vsync: this, duration: const Duration(milliseconds: 1000));
|
||||
if (widget.breathing) _controller.repeat(reverse: true);
|
||||
|
||||
// 动画区间从 0.3 到 1.0
|
||||
_opacityAnimation = Tween<double>(
|
||||
begin: 0.3,
|
||||
end: 1.0,
|
||||
).animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut));
|
||||
_opacityAnimation = Tween<double>(begin: 0.3, end: 1.0).animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOut));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -69,9 +54,7 @@ class _StatusChipState extends State<StatusChip>
|
||||
animation: _opacityAnimation,
|
||||
builder: (context, child) {
|
||||
// 【关键】如果不呼吸,直接用 baseOpacity,不再强制给 1.0
|
||||
final currentAlpha = widget.breathing
|
||||
? _opacityAnimation.value * baseOpacity
|
||||
: baseOpacity;
|
||||
final currentAlpha = widget.breathing ? _opacityAnimation.value * baseOpacity : baseOpacity;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: widget.onTap,
|
||||
@@ -81,38 +64,15 @@ class _StatusChipState extends State<StatusChip>
|
||||
// 这里应用计算后的透明度
|
||||
color: widget.color.withOpacity(currentAlpha),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.15),
|
||||
width: 0.5,
|
||||
),
|
||||
border: Border.all(color: Colors.white.withOpacity(0.15), width: 0.5),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (widget.svgPath != null)
|
||||
SvgPicture.asset(
|
||||
widget.svgPath!,
|
||||
width: 14,
|
||||
height: 14,
|
||||
colorFilter: ColorFilter.mode(
|
||||
widget.svgColor ?? Colors.white,
|
||||
BlendMode.srcIn,
|
||||
),
|
||||
)
|
||||
else
|
||||
Icon(
|
||||
widget.icon,
|
||||
color: widget.svgColor ?? Colors.white,
|
||||
size: 14,
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Text(
|
||||
widget.text,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
style: const TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.w600),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user