fix(mining-app): 账户锁定弹窗 5 秒后自动关闭

AlertDialog 不会自动消失,加 Timer 5 秒后 maybePop 自动关闭。
SnackBar 已有 duration:5s 会自动消失。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-10 21:03:21 -07:00
parent fbf8b6c2e9
commit acc5c2be80
1 changed files with 25 additions and 19 deletions

View File

@ -1,3 +1,4 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
@ -57,27 +58,32 @@ class _LoginPageState extends ConsumerState<LoginPage> {
ScaffoldMessenger.of(context).clearSnackBars();
if (message.contains('锁定')) {
// +
// + 5
showDialog<void>(
context: context,
builder: (ctx) => AlertDialog(
title: const Text('账户已锁定'),
content: Text(message),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: Text('知道了', style: TextStyle(color: AppColors.textSecondaryOf(context))),
),
ElevatedButton(
onPressed: () {
Navigator.pop(ctx);
context.push(Routes.forgotPassword, extra: _phoneController.text.trim());
},
style: ElevatedButton.styleFrom(backgroundColor: _orange),
child: const Text('找回密码', style: TextStyle(color: Colors.white)),
),
],
),
builder: (ctx) {
Timer(const Duration(seconds: 5), () {
if (ctx.mounted) Navigator.of(ctx, rootNavigator: true).maybePop();
});
return AlertDialog(
title: const Text('账户已锁定'),
content: Text(message),
actions: [
TextButton(
onPressed: () => Navigator.pop(ctx),
child: Text('知道了', style: TextStyle(color: AppColors.textSecondaryOf(context))),
),
ElevatedButton(
onPressed: () {
Navigator.pop(ctx);
context.push(Routes.forgotPassword, extra: _phoneController.text.trim());
},
style: ElevatedButton.styleFrom(backgroundColor: _orange),
child: const Text('找回密码', style: TextStyle(color: Colors.white)),
),
],
);
},
);
} else if (message.contains('还剩')) {
// SnackBar +