feat(auth): 实现注册模块与登录页优化
1. 新增用户注册接口与页面,对齐Vue端业务逻辑 2. 新增居中Toast组件,替换原有SnackBar轻提示 3. 完善登录历史本地存储与下拉选择交互 4. 新增审核模式接口适配,动态控制注册入口显示 5. 优化登录页UI布局与交互细节
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
/// ============================================================
|
||||
/// 【CenterToast】居中轻量提示 —— 对标 uni.showToast(icon: 'none')
|
||||
///
|
||||
/// 一、适用场景:
|
||||
/// 表单校验失败("请填写账号"/"请填写密码")、轻量成功提示等
|
||||
/// 不需要用户确认、1.2s 自动消失、不阻塞交互(IgnorePointer)。
|
||||
///
|
||||
/// 二、与 SnackBar / ConfirmBox 的分工:
|
||||
/// CenterToast → 短暂轻量提示,自动消失,中间弹出
|
||||
/// SnackBar → 底部提示(信息可能较长),可手动关闭
|
||||
/// ConfirmBox → 需要用户决策的确认框,双按钮
|
||||
///
|
||||
/// 三、用法:
|
||||
/// CenterToast.show(context, '请填写账号');
|
||||
/// ============================================================
|
||||
class CenterToast {
|
||||
CenterToast._();
|
||||
|
||||
static OverlayEntry? _current;
|
||||
|
||||
static void show(
|
||||
BuildContext context,
|
||||
String msg, {
|
||||
Duration duration = const Duration(milliseconds: 1200),
|
||||
}) {
|
||||
// 连续调用时先移除上一个,避免叠加
|
||||
_current?.remove();
|
||||
|
||||
late final OverlayEntry entry;
|
||||
entry = OverlayEntry(
|
||||
builder: (_) => Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 14.h),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.75),
|
||||
borderRadius: BorderRadius.circular(12.r),
|
||||
),
|
||||
child: Text(
|
||||
msg,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
color: Colors.white,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
_current = entry;
|
||||
Overlay.of(context).insert(entry);
|
||||
Future<void>.delayed(duration, () {
|
||||
if (entry.mounted && _current == entry) {
|
||||
entry.remove();
|
||||
_current = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user