This commit is contained in:
sion
2026-04-07 01:05:05 +08:00
parent edad10ff06
commit 5ca1274607
83 changed files with 1561 additions and 1241 deletions

View File

@@ -11,7 +11,7 @@ import '../../components/glass_panel.dart';
import '../../components/neon_glow.dart';
import '../main/main_page.dart';
/// 注册页面(两步注册:账号信息 + 身份证上传
/// 註冊頁面(兩步註冊:賬號信息 + 身份證上傳
class RegisterPage extends StatefulWidget {
const RegisterPage({super.key});
@@ -20,7 +20,7 @@ class RegisterPage extends StatefulWidget {
}
class _RegisterPageState extends State<RegisterPage> {
int _currentStep = 0; // 0: 账号信息, 1: 身份证上传
int _currentStep = 0; // 0: 賬號信息, 1: 身份證上傳
// 第一步
final _usernameController = TextEditingController();
@@ -96,11 +96,11 @@ class _RegisterPageState extends State<RegisterPage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// 步指示器
// 步指示器
_buildStepIndicator(colorScheme),
SizedBox(height: AppSpacing.xl),
// 内容区
// 內容區
_currentStep == 0 ? _buildStep1(colorScheme) : _buildStep2(colorScheme),
],
),
@@ -114,7 +114,7 @@ class _RegisterPageState extends State<RegisterPage> {
children: [
_buildStepCircle(
number: '1',
label: '账号信息',
label: '賬號信息',
isActive: true,
isComplete: _currentStep > 0,
colorScheme: colorScheme,
@@ -129,7 +129,7 @@ class _RegisterPageState extends State<RegisterPage> {
),
_buildStepCircle(
number: '2',
label: '身份验证',
label: '身份驗證',
isActive: _currentStep >= 1,
isComplete: false,
colorScheme: colorScheme,
@@ -191,17 +191,17 @@ class _RegisterPageState extends State<RegisterPage> {
);
}
/// 第一步:账号信息
/// 第一步:賬號信息
Widget _buildStep1(ColorScheme colorScheme) {
return Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// 标题
// 標題
Center(
child: Text(
'创建账号',
'創建賬號',
style: AppTextStyles.displaySmall(context).copyWith(
fontWeight: FontWeight.bold,
color: colorScheme.onSurface,
@@ -210,30 +210,30 @@ class _RegisterPageState extends State<RegisterPage> {
),
SizedBox(height: AppSpacing.xxl),
// 用
// 用
TextFormField(
controller: _usernameController,
style: TextStyle(color: colorScheme.onSurface),
decoration: InputDecoration(
hintText: '请输入账号(4-20位字母字)',
hintText: '請輸入賬號(4-20位字母字)',
prefixIcon: Icon(Icons.person_outline, color: colorScheme.onSurfaceVariant),
),
validator: (value) {
if (value == null || value.isEmpty) return '请输入账号';
if (value.length < 4) return '账号至少4位';
if (value.length > 20) return '账号最多20位';
if (value == null || value.isEmpty) return '請輸入賬號';
if (value.length < 4) return '賬號至少4位';
if (value.length > 20) return '賬號最多20位';
return null;
},
),
SizedBox(height: AppSpacing.md),
// 密
// 密
TextFormField(
controller: _passwordController,
obscureText: _obscurePassword,
style: TextStyle(color: colorScheme.onSurface),
decoration: InputDecoration(
hintText: '请输入密(至少6位)',
hintText: '請輸入密(至少6位)',
prefixIcon: Icon(Icons.lock_outline, color: colorScheme.onSurfaceVariant),
suffixIcon: IconButton(
icon: Icon(
@@ -244,20 +244,20 @@ class _RegisterPageState extends State<RegisterPage> {
),
),
validator: (value) {
if (value == null || value.isEmpty) return '请输入密';
if (value.length < 6) return '至少6位';
if (value == null || value.isEmpty) return '請輸入密';
if (value.length < 6) return '至少6位';
return null;
},
),
SizedBox(height: AppSpacing.md),
// 确认密码
// 確認密碼
TextFormField(
controller: _confirmPasswordController,
obscureText: _obscureConfirmPassword,
style: TextStyle(color: colorScheme.onSurface),
decoration: InputDecoration(
hintText: '再次入密',
hintText: '再次入密',
prefixIcon: Icon(Icons.lock_outline, color: colorScheme.onSurfaceVariant),
suffixIcon: IconButton(
icon: Icon(
@@ -268,25 +268,25 @@ class _RegisterPageState extends State<RegisterPage> {
),
),
validator: (value) {
if (value == null || value.isEmpty) return '再次入密';
if (value != _passwordController.text) return '次密不一致';
if (value == null || value.isEmpty) return '再次入密';
if (value != _passwordController.text) return '次密不一致';
return null;
},
),
SizedBox(height: AppSpacing.md),
// 推广码(可
// 推廣碼(可
TextFormField(
controller: _referralCodeController,
style: TextStyle(color: colorScheme.onSurface),
decoration: InputDecoration(
hintText: '广码(选填)',
hintText: '廣碼(選填)',
prefixIcon: Icon(Icons.card_giftcard, color: colorScheme.onSurfaceVariant),
),
),
SizedBox(height: AppSpacing.xl),
// 下一步按
// 下一步按
SizedBox(
width: double.infinity,
child: NeonButton(
@@ -303,11 +303,11 @@ class _RegisterPageState extends State<RegisterPage> {
),
SizedBox(height: AppSpacing.md),
// 登录链
// 登錄鏈
Center(
child: TextButton(
onPressed: () => Navigator.pop(context),
child: Text('已有账号?立即登', style: AppTextStyles.headlineMedium(context)),
child: Text('已有賬號?立即登', style: AppTextStyles.headlineMedium(context)),
),
),
],
@@ -315,12 +315,12 @@ class _RegisterPageState extends State<RegisterPage> {
);
}
/// 第二步:身份证上传
/// 第二步:身份證上傳
Widget _buildStep2(ColorScheme colorScheme) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// 标题区
// 標題區
GlassPanel(
padding: EdgeInsets.all(AppSpacing.lg),
child: Column(
@@ -345,7 +345,7 @@ class _RegisterPageState extends State<RegisterPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'身份验证',
'身份驗證',
style: AppTextStyles.headlineLarge(context).copyWith(
fontWeight: FontWeight.bold,
color: colorScheme.onSurface,
@@ -353,7 +353,7 @@ class _RegisterPageState extends State<RegisterPage> {
),
SizedBox(height: AppSpacing.xs),
Text(
'身份正反面完成注册',
'身份正反面完成註冊',
style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
),
@@ -364,9 +364,9 @@ class _RegisterPageState extends State<RegisterPage> {
),
SizedBox(height: AppSpacing.xl),
// 身份正面
// 身份正面
Text(
'身份正面(人像面)',
'身份正面(人像面)',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
color: colorScheme.onSurface,
@@ -382,9 +382,9 @@ class _RegisterPageState extends State<RegisterPage> {
),
SizedBox(height: AppSpacing.lg),
// 身份反面
// 身份反面
Text(
'身份反面(徽面)',
'身份反面(徽面)',
style: AppTextStyles.bodyLarge(context).copyWith(
fontWeight: FontWeight.w600,
color: colorScheme.onSurface,
@@ -394,19 +394,19 @@ class _RegisterPageState extends State<RegisterPage> {
_buildUploadZone(
imageFile: _backFile,
imageBytes: _backBytes,
label: '徽面',
label: '徽面',
onTap: () => _pickImage(false),
colorScheme: colorScheme,
),
SizedBox(height: AppSpacing.xl),
// 注册按钮
// 註冊按鈕
Consumer<AuthProvider>(
builder: (context, auth, _) {
return SizedBox(
width: double.infinity,
child: NeonButton(
text: _isLoading ? '注册中...' : '完成注册',
text: _isLoading ? '註冊中...' : '完成註冊',
type: NeonButtonType.primary,
onPressed: _canSubmit && !auth.isLoading ? _handleRegister : null,
height: 48,
@@ -434,7 +434,7 @@ class _RegisterPageState extends State<RegisterPage> {
SizedBox(width: AppSpacing.sm),
Expanded(
child: Text(
'您的身份信息被加密存储,仅用于身份验证',
'您的身份信息被加密存儲,僅用於身份驗證',
style: AppTextStyles.bodySmall(context).copyWith(
color: AppColorScheme.up.withValues(alpha: 0.8),
),
@@ -502,7 +502,7 @@ class _RegisterPageState extends State<RegisterPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'$label已选择',
'$label已選擇',
style: AppTextStyles.bodyMedium(context).copyWith(
fontWeight: FontWeight.w600,
color: AppColorScheme.darkOnPrimary,
@@ -551,7 +551,7 @@ class _RegisterPageState extends State<RegisterPage> {
),
SizedBox(height: AppSpacing.sm),
Text(
'点击上传$label',
'點擊上傳$label',
style: AppTextStyles.bodyLarge(context).copyWith(
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.6),
),
@@ -597,11 +597,11 @@ class _RegisterPageState extends State<RegisterPage> {
showShadDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
title: const Text('注册失败'),
description: Text(response.message ?? '请稍后重试'),
title: const Text('註冊失敗'),
description: Text(response.message ?? '請稍後重試'),
actions: [
ShadButton(
child: const Text(''),
child: const Text(''),
onPressed: () => Navigator.of(ctx).pop(),
),
],
@@ -613,11 +613,11 @@ class _RegisterPageState extends State<RegisterPage> {
showShadDialog(
context: context,
builder: (ctx) => ShadDialog.alert(
title: const Text('注册失败'),
title: const Text('註冊失敗'),
description: Text(e.toString()),
actions: [
ShadButton(
child: const Text(''),
child: const Text(''),
onPressed: () => Navigator.of(ctx).pop(),
),
],
@@ -630,7 +630,7 @@ class _RegisterPageState extends State<RegisterPage> {
}
}
/// 虚线边框画笔
/// 虛線邊框畫筆
class _DashedBorderPainter extends CustomPainter {
final Color color;
final double borderRadius;