fix: 修复 register_page.dart 语法错误
This commit is contained in:
@@ -17,8 +17,11 @@ class RegisterPage extends StatefulWidget {
|
|||||||
const RegisterPage({super.key});
|
const RegisterPage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RegisterPage> createState() => _RegisterPageState>();
|
State<RegisterPage> createState() => _RegisterPageState();
|
||||||
int _currentStep = 0; // 0: 賬號信息, 2: 身份證上傳
|
}
|
||||||
|
|
||||||
|
class _RegisterPageState extends State<RegisterPage> {
|
||||||
|
int _currentStep = 0; // 0: 賬號信息, 1: 身份證上傳
|
||||||
|
|
||||||
// 第一步
|
// 第一步
|
||||||
final _usernameController = TextEditingController();
|
final _usernameController = TextEditingController();
|
||||||
@@ -96,7 +99,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
children: [
|
children: [
|
||||||
// 步驟指示器
|
// 步驟指示器
|
||||||
_buildStepIndicator(colorScheme),
|
_buildStepIndicator(colorScheme),
|
||||||
SizedBox(height: AppSpacing.xl),
|
const SizedBox(height: AppSpacing.xl),
|
||||||
|
|
||||||
// 內容區
|
// 內容區
|
||||||
_currentStep == 0 ? _buildStep1(colorScheme) : _buildStep2(colorScheme),
|
_currentStep == 0 ? _buildStep1(colorScheme) : _buildStep2(colorScheme),
|
||||||
@@ -178,7 +181,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.xs),
|
const SizedBox(height: AppSpacing.xs),
|
||||||
Text(
|
Text(
|
||||||
label,
|
label,
|
||||||
style: AppTextStyles.bodySmall(context).copyWith(
|
style: AppTextStyles.bodySmall(context).copyWith(
|
||||||
@@ -206,7 +209,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.xxl),
|
const SizedBox(height: AppSpacing.xxl),
|
||||||
|
|
||||||
// 用戶名
|
// 用戶名
|
||||||
MaterialInput(
|
MaterialInput(
|
||||||
@@ -221,7 +224,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.md),
|
const SizedBox(height: AppSpacing.md),
|
||||||
|
|
||||||
// 密碼
|
// 密碼
|
||||||
MaterialPasswordInput(
|
MaterialPasswordInput(
|
||||||
@@ -235,7 +238,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.md),
|
const SizedBox(height: AppSpacing.md),
|
||||||
|
|
||||||
// 確認密碼
|
// 確認密碼
|
||||||
MaterialPasswordInput(
|
MaterialPasswordInput(
|
||||||
@@ -249,7 +252,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.md),
|
const SizedBox(height: AppSpacing.md),
|
||||||
|
|
||||||
// 推廣碼(可選)
|
// 推廣碼(可選)
|
||||||
MaterialInput(
|
MaterialInput(
|
||||||
@@ -258,7 +261,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
hintText: '推廣碼(選填)',
|
hintText: '推廣碼(選填)',
|
||||||
prefixIcon: Icons.card_giftcard,
|
prefixIcon: Icons.card_giftcard,
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.xl),
|
const SizedBox(height: AppSpacing.xl),
|
||||||
|
|
||||||
// 下一步按鈕
|
// 下一步按鈕
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -275,7 +278,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
showGlow: true,
|
showGlow: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.md),
|
const SizedBox(height: AppSpacing.md),
|
||||||
|
|
||||||
// 登錄鏈接
|
// 登錄鏈接
|
||||||
Center(
|
Center(
|
||||||
@@ -283,9 +286,10 @@ class RegisterPage extends StatefulWidget {
|
|||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () => Navigator.pop(context),
|
||||||
child: Text(
|
child: Text(
|
||||||
'已有賬號?立即登錄',
|
'已有賬號?立即登錄',
|
||||||
style: AppTextStyles.headlineMedium(context)),
|
style: AppTextStyles.headlineMedium(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -298,17 +302,17 @@ class RegisterPage extends StatefulWidget {
|
|||||||
children: [
|
children: [
|
||||||
// 標題區
|
// 標題區
|
||||||
GlassPanel(
|
GlassPanel(
|
||||||
padding: EdgeInsets.all(AppSpacing.lg),
|
padding: const EdgeInsets.all(AppSpacing.lg),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.all(AppSpacing.sm),
|
padding: const EdgeInsets.all(AppSpacing.sm),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: colorScheme.primary.withValues(alpha: 0.1),
|
color: colorScheme.primary.withValues(alpha: 0.1),
|
||||||
borderRadius: AppRadius.radiusLg,
|
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||||
),
|
),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.shield,
|
Icons.shield,
|
||||||
@@ -316,7 +320,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
size: 22,
|
size: 22,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: AppSpacing.md),
|
const SizedBox(width: AppSpacing.md),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
@@ -327,7 +331,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
color: colorScheme.onSurface,
|
color: colorScheme.onSurface,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.xs),
|
const SizedBox(height: AppSpacing.xs),
|
||||||
Text(
|
Text(
|
||||||
'上傳身份證正反面完成註冊',
|
'上傳身份證正反面完成註冊',
|
||||||
style: AppTextStyles.bodyMedium(context).copyWith(
|
style: AppTextStyles.bodyMedium(context).copyWith(
|
||||||
@@ -336,73 +340,102 @@ class RegisterPage extends StatefulWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.xl),
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: AppSpacing.xl),
|
||||||
|
|
||||||
// 身份證正面
|
// 身份證正面
|
||||||
Text(
|
Text(
|
||||||
'身份證正面(人像面)',
|
'身份證正面(人像面)',
|
||||||
style: AppTextStyles.bodyLarge(context).copyWith(
|
style: AppTextStyles.bodyLarge(context).copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: colorScheme.onSurface,
|
color: colorScheme.onSurface,
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height: AppSpacing.sm),
|
|
||||||
_buildUploadZone(
|
|
||||||
imageFile: _frontFile,
|
|
||||||
imageBytes: _frontBytes,
|
|
||||||
label: '人像面',
|
|
||||||
onTap: () => _pickImage(true),
|
|
||||||
colorScheme: colorScheme,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.lg),
|
),
|
||||||
|
const SizedBox(height: AppSpacing.sm),
|
||||||
|
_buildUploadZone(
|
||||||
|
imageFile: _frontFile,
|
||||||
|
imageBytes: _frontBytes,
|
||||||
|
label: '人像面',
|
||||||
|
onTap: () => _pickImage(true),
|
||||||
|
colorScheme: colorScheme,
|
||||||
|
),
|
||||||
|
const SizedBox(height: AppSpacing.lg),
|
||||||
|
|
||||||
// 身份證反面
|
// 身份證反面
|
||||||
Text(
|
Text(
|
||||||
'身份證反面(國徽面)',
|
'身份證反面(國徽面)',
|
||||||
style: AppTextStyles.bodyLarge(context).copyWith(
|
style: AppTextStyles.bodyLarge(context).copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: colorScheme.onSurface
|
color: colorScheme.onSurface,
|
||||||
)
|
|
||||||
),
|
|
||||||
SizedBox(height: AppSpacing.sm),
|
|
||||||
_buildUploadZone(
|
|
||||||
imageFile: _backFile,
|
|
||||||
imageBytes: _backBytes,
|
|
||||||
label: '國徽面',
|
|
||||||
onTap: () => _pickImage(false),
|
|
||||||
colorScheme: colorScheme
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
SizedBox(height: AppSpacing.lg),
|
),
|
||||||
|
const SizedBox(height: AppSpacing.sm),
|
||||||
|
_buildUploadZone(
|
||||||
|
imageFile: _backFile,
|
||||||
|
imageBytes: _backBytes,
|
||||||
|
label: '國徽面',
|
||||||
|
onTap: () => _pickImage(false),
|
||||||
|
colorScheme: colorScheme,
|
||||||
|
),
|
||||||
|
const SizedBox(height: AppSpacing.xl),
|
||||||
|
|
||||||
// 註冊按鈕
|
// 註冊按鈕
|
||||||
Consumer<AuthProvider>(
|
Consumer<AuthProvider>(
|
||||||
builder: (context, auth, _) {
|
builder: (context, auth, _) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: NeonButton(
|
child: NeonButton(
|
||||||
text: _isLoading ? '註冊中...' : '完成註冊',
|
text: _isLoading ? '註冊中...' : '完成註冊',
|
||||||
type: NeonButtonType.primary,
|
type: NeonButtonType.primary,
|
||||||
onPressed: _canSubmit && !auth.isLoading ? _handleRegister : null,
|
onPressed: _canSubmit && !auth.isLoading
|
||||||
height: 48,
|
? _handleRegister
|
||||||
showGlow: _canSubmit,
|
: null,
|
||||||
)
|
height: 48,
|
||||||
|
showGlow: _canSubmit,
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: AppSpacing.lg),
|
||||||
|
|
||||||
|
// 安全提示
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(AppSpacing.md),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: AppColorScheme.up.withValues(alpha: 0.06),
|
||||||
|
borderRadius: AppRadius.radiusLg,
|
||||||
|
border: Border.all(
|
||||||
|
color: AppColorScheme.up.withValues(alpha: 0.12),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.lock, size: 16, color: AppColorScheme.up),
|
||||||
|
const SizedBox(width: AppSpacing.sm),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
'您的身份信息將被加密存儲,僅用於身份驗證',
|
||||||
|
style: AppTextStyles.bodySmall(context).copyWith(
|
||||||
|
color: AppColorScheme.up.withValues(alpha: 0.8),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildUploadZone({
|
Widget _buildUploadZone({
|
||||||
required XFile? imageFile;
|
required XFile? imageFile,
|
||||||
required Uint8List? imageBytes,
|
required Uint8List? imageBytes,
|
||||||
required String label;
|
required String label,
|
||||||
|
required VoidCallback onTap,
|
||||||
required ColorScheme colorScheme,
|
required ColorScheme colorScheme,
|
||||||
}) {
|
}) {
|
||||||
final hasImage = imageFile != null && imageBytes != null;
|
final hasImage = imageFile != null && imageBytes != null;
|
||||||
@@ -419,7 +452,9 @@ class RegisterPage extends StatefulWidget {
|
|||||||
: colorScheme.surfaceContainerHigh.withValues(alpha: 0.3),
|
: colorScheme.surfaceContainerHigh.withValues(alpha: 0.3),
|
||||||
borderRadius: AppRadius.radiusXl,
|
borderRadius: AppRadius.radiusXl,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: hasImage ? AppColorScheme.up.withValues(alpha: 0.3) : AppColorScheme.darkBackground.withValues(alpha: 0),
|
color: hasImage
|
||||||
|
? AppColorScheme.up.withValues(alpha: 0.3)
|
||||||
|
: Colors.transparent,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: hasImage
|
child: hasImage
|
||||||
@@ -434,7 +469,7 @@ class RegisterPage extends StatefulWidget {
|
|||||||
right: 0,
|
right: 0,
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: AppSpacing.sm,
|
vertical: AppSpacing.sm,
|
||||||
horizontal: AppSpacing.md,
|
horizontal: AppSpacing.md,
|
||||||
),
|
),
|
||||||
@@ -444,9 +479,11 @@ class RegisterPage extends StatefulWidget {
|
|||||||
end: Alignment.bottomCenter,
|
end: Alignment.bottomCenter,
|
||||||
colors: [
|
colors: [
|
||||||
AppColorScheme.darkBackground.withValues(alpha: 0),
|
AppColorScheme.darkBackground.withValues(alpha: 0),
|
||||||
AppColorScheme.darkSurfaceLowest.withValues(alpha: 0.6),
|
AppColorScheme.darkSurfaceLowest
|
||||||
|
.withValues(alpha: 0.6),
|
||||||
],
|
],
|
||||||
borderRadius: BorderRadius.only(
|
),
|
||||||
|
borderRadius: const BorderRadius.only(
|
||||||
bottomLeft: Radius.circular(AppRadius.xl),
|
bottomLeft: Radius.circular(AppRadius.xl),
|
||||||
bottomRight: Radius.circular(AppRadius.xl),
|
bottomRight: Radius.circular(AppRadius.xl),
|
||||||
),
|
),
|
||||||
@@ -474,82 +511,56 @@ class RegisterPage extends StatefulWidget {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(AppSpacing.xs),
|
padding: const EdgeInsets.all(AppSpacing.xs),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColorScheme.darkOnPrimary.withValues(alpha: 0.15),
|
color: AppColorScheme.darkOnPrimary
|
||||||
|
.withValues(alpha: 0.15),
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Icon(Icons.close, size: 14, color: AppColorScheme.darkOnPrimary),
|
child: Icon(
|
||||||
),
|
Icons.close,
|
||||||
),
|
size: 14,
|
||||||
],
|
color: AppColorScheme.darkOnPrimary,
|
||||||
),
|
),
|
||||||
: CustomPaint(
|
|
||||||
painter: _DashedBorderPainter(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.2),
|
|
||||||
borderRadius: AppRadius.xl,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.camera_alt,
|
|
||||||
size: 28,
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
|
|
||||||
),
|
|
||||||
SizedBox(height: AppSpacing.sm),
|
|
||||||
Text(
|
|
||||||
'點擊上傳$label',
|
|
||||||
style: AppTextStyles.bodyLarge(context).copyWith(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.6),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SizedBox(height: AppSpacing.xs),
|
|
||||||
Text(
|
|
||||||
'支持 JPG、PNG 格式',
|
|
||||||
style: AppTextStyles.bodySmall(context).copyWith(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
],
|
],
|
||||||
);
|
),
|
||||||
)
|
)
|
||||||
: CustomPaint(
|
: CustomPaint(
|
||||||
painter: _DashedBorderPainter(
|
painter: _DashedBorderPainter(
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.2),
|
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.2),
|
||||||
borderRadius: AppRadius.xl,
|
borderRadius: AppRadius.xl,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
Icons.camera_alt,
|
Icons.camera_alt,
|
||||||
size: 28,
|
size: 28,
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
|
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.5),
|
||||||
),
|
|
||||||
SizedBox(height: AppSpacing.sm),
|
|
||||||
Text(
|
|
||||||
'点击上传$label',
|
|
||||||
style: AppTextStyles.bodyLarge(context).copyWith(
|
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.6),
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: AppSpacing.sm),
|
||||||
SizedBox(height: AppSpacing.xs),
|
Text(
|
||||||
Text(
|
'點擊上傳$label',
|
||||||
'支持 JPG、PNG 格式',
|
style: AppTextStyles.bodyLarge(context).copyWith(
|
||||||
style: AppTextStyles.bodySmall(context).copyWith(
|
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.6),
|
||||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: AppSpacing.xs),
|
||||||
],
|
Text(
|
||||||
|
'支持 JPG、PNG 格式',
|
||||||
|
style: AppTextStyles.bodySmall(context).copyWith(
|
||||||
|
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -563,15 +574,12 @@ class RegisterPage extends StatefulWidget {
|
|||||||
final response = await auth.register(
|
final response = await auth.register(
|
||||||
_usernameController.text.trim(),
|
_usernameController.text.trim(),
|
||||||
_passwordController.text,
|
_passwordController.text,
|
||||||
referralCode: _referralCodeController.text.trim().isEmpty ? null
|
referralCode: _referralCodeController.text.trim().isEmpty
|
||||||
|
? null
|
||||||
: _referralCodeController.text.trim(),
|
: _referralCodeController.text.trim(),
|
||||||
: referralCode,
|
|
||||||
},
|
|
||||||
frontBytes: _frontBytes!,
|
frontBytes: _frontBytes!,
|
||||||
backBytes: _backBytes!,
|
backBytes: _backBytes!,
|
||||||
referralCode: _referralCodeController.text,
|
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
|
||||||
@@ -634,8 +642,8 @@ class _DashedBorderPainter extends CustomPainter {
|
|||||||
..strokeWidth = 1.5
|
..strokeWidth = 1.5
|
||||||
..style = PaintingStyle.stroke;
|
..style = PaintingStyle.stroke;
|
||||||
|
|
||||||
final dashWidth = 6.0;
|
const dashWidth = 6.0;
|
||||||
final dashSpace = 4.0;
|
const dashSpace = 4.0;
|
||||||
|
|
||||||
final path = Path()
|
final path = Path()
|
||||||
..addRRect(RRect.fromRectAndRadius(
|
..addRRect(RRect.fromRectAndRadius(
|
||||||
|
|||||||
Reference in New Issue
Block a user