1afec6aad1
CI / flutter-gates (push) Successful in 1m3s
- events 上传地址接错:AnalyticsService 误用 auth(8081),实际端点在 user 服务(8082),新增 patbondUserApiBaseUrl 并接线 - 冲刷时机:新增 flushNow(),SessionTracker 首次离开前台触发, 修复低活跃用户凑不满 20 条事件永不上传 - 毒丸批次:4xx 永久性拒绝不再重回队列无限重试,丢弃并打日志 - Web/桌面 Platform API 降级(kIsWeb + _platformName) - 注册手机号 UI 固定 +86 前缀、提交拼 E.164;AppTextField 支持 prefixText 51 测试全绿、analyze 0 问题;Linux 桌面实测注册成功, curl 实测后端 /api/v1/events 校验行为符合契约。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
95 lines
2.9 KiB
Dart
95 lines
2.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:patbond_flutter/core/theme/app_theme.dart';
|
|
|
|
/// 表单输入框封装(设计规范 §2.2 / §4.1)。
|
|
///
|
|
/// 密码模式([obscurable] 为 true)内置可见性切换按钮,点击目标 ≥44×44。
|
|
/// 提交中禁用时整体 60% 不透明度。
|
|
class AppTextField extends StatefulWidget {
|
|
const AppTextField({
|
|
required this.label,
|
|
super.key,
|
|
this.controller,
|
|
this.prefixIcon,
|
|
this.prefixText,
|
|
this.errorText,
|
|
this.helperText,
|
|
this.enabled = true,
|
|
this.obscurable = false,
|
|
this.keyboardType,
|
|
this.textInputAction,
|
|
this.autofillHints,
|
|
this.onChanged,
|
|
this.onSubmitted,
|
|
});
|
|
|
|
final String label;
|
|
final TextEditingController? controller;
|
|
final IconData? prefixIcon;
|
|
|
|
/// 固定前缀文本(如手机号的 '+86 '),仅展示与拼接语义,不进输入值。
|
|
final String? prefixText;
|
|
|
|
final String? errorText;
|
|
final String? helperText;
|
|
final bool enabled;
|
|
|
|
/// 是否为密码模式:默认遮蔽输入,并显示可见性切换按钮。
|
|
final bool obscurable;
|
|
|
|
final TextInputType? keyboardType;
|
|
final TextInputAction? textInputAction;
|
|
final Iterable<String>? autofillHints;
|
|
final ValueChanged<String>? onChanged;
|
|
final ValueChanged<String>? onSubmitted;
|
|
|
|
@override
|
|
State<AppTextField> createState() => _AppTextFieldState();
|
|
}
|
|
|
|
class _AppTextFieldState extends State<AppTextField> {
|
|
bool obscured = true;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Opacity(
|
|
opacity: widget.enabled ? 1 : 0.6,
|
|
child: TextFormField(
|
|
controller: widget.controller,
|
|
enabled: widget.enabled,
|
|
obscureText: widget.obscurable && obscured,
|
|
keyboardType: widget.keyboardType,
|
|
textInputAction: widget.textInputAction,
|
|
autofillHints: widget.autofillHints,
|
|
onChanged: widget.onChanged,
|
|
onFieldSubmitted: widget.onSubmitted,
|
|
decoration: InputDecoration(
|
|
labelText: widget.label,
|
|
errorText: widget.errorText,
|
|
helperText: widget.helperText,
|
|
prefixText: widget.prefixText,
|
|
prefixIcon: widget.prefixIcon == null
|
|
? null
|
|
: Icon(widget.prefixIcon, color: AppColors.muted),
|
|
suffixIcon: widget.obscurable
|
|
? IconButton(
|
|
tooltip: obscured ? '显示密码' : '隐藏密码',
|
|
constraints: const BoxConstraints(
|
|
minWidth: 44,
|
|
minHeight: 44,
|
|
),
|
|
onPressed: widget.enabled
|
|
? () => setState(() => obscured = !obscured)
|
|
: null,
|
|
icon: Icon(
|
|
obscured ? Icons.visibility_off : Icons.visibility,
|
|
color: AppColors.muted,
|
|
),
|
|
)
|
|
: null,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|