关怀模式
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
/// 时间: 2026-03-29
|
||||
/// 功能: 填写投票凭证弹窗组件
|
||||
/// 介绍: 提供投票功能的用户凭证填写功能
|
||||
/// 最新变化: 支持动态主题色设置
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../constants/app_constants.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../../../models/colors/app_colors.dart';
|
||||
import '../../../services/get/theme_controller.dart';
|
||||
import '../../../utils/http/vote_api.dart';
|
||||
|
||||
class LoginRegisterDialog extends StatefulWidget {
|
||||
@@ -16,6 +19,7 @@ class LoginRegisterDialog extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LoginRegisterDialogState extends State<LoginRegisterDialog> {
|
||||
final ThemeController _themeController = Get.find<ThemeController>();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _usernameController = TextEditingController();
|
||||
bool _isLoading = false;
|
||||
@@ -63,9 +67,9 @@ class _LoginRegisterDialogState extends State<LoginRegisterDialog> {
|
||||
Navigator.pop(context);
|
||||
widget.onLoginSuccess?.call();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('验证成功'),
|
||||
backgroundColor: AppConstants.successColor,
|
||||
SnackBar(
|
||||
content: const Text('验证成功'),
|
||||
backgroundColor: AppColors.success,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -80,9 +84,9 @@ class _LoginRegisterDialogState extends State<LoginRegisterDialog> {
|
||||
Navigator.pop(context);
|
||||
widget.onLoginSuccess?.call();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('注册并验证成功'),
|
||||
backgroundColor: AppConstants.successColor,
|
||||
SnackBar(
|
||||
content: const Text('注册并验证成功'),
|
||||
backgroundColor: AppColors.success,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -92,7 +96,7 @@ class _LoginRegisterDialogState extends State<LoginRegisterDialog> {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(e.toString().replaceAll('Exception: ', '')),
|
||||
backgroundColor: AppConstants.errorColor,
|
||||
backgroundColor: AppColors.error,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -107,80 +111,101 @@ class _LoginRegisterDialogState extends State<LoginRegisterDialog> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'填写 投票凭证',
|
||||
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
// const SizedBox(height: 8),
|
||||
// 副标题
|
||||
const Text(
|
||||
'微信号或手机号或邮箱作为投票凭证,\n任何人都可以填写,限时开放投票,\n投票凭证仅用于投票,不会泄露隐私.\n结束后删除会所有凭证,仅保留投票结果',
|
||||
style: TextStyle(fontSize: 14, color: Colors.grey),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
return Obx(() {
|
||||
final isDark = _themeController.isDarkMode;
|
||||
return Dialog(
|
||||
backgroundColor: AppColors.surface,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _usernameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: '点击填写',
|
||||
hintText: '手机号/邮箱/微信号',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.person),
|
||||
Text(
|
||||
'填写 投票凭证',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppColors.primaryText,
|
||||
),
|
||||
validator: _validateUsername,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _isLoading ? null : _submit,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppConstants.primaryColor,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: _isLoading
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
: const Text('验证', style: TextStyle(fontSize: 16)),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.close, color: AppColors.tertiaryText),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
Text(
|
||||
'微信号或手机号或邮箱作为投票凭证,\n任何人都可以填写,限时开放投票,\n投票凭证仅用于投票,不会泄露隐私.\n结束后删除会所有凭证,仅保留投票结果',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.secondaryText,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _usernameController,
|
||||
style: TextStyle(color: AppColors.primaryText),
|
||||
decoration: InputDecoration(
|
||||
labelText: '点击填写',
|
||||
hintText: '手机号/邮箱/微信号',
|
||||
labelStyle: TextStyle(color: AppColors.secondaryText),
|
||||
hintStyle: TextStyle(color: AppColors.tertiaryText),
|
||||
border: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: AppColors.divider),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: AppColors.divider),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(color: AppColors.primary),
|
||||
),
|
||||
prefixIcon: Icon(Icons.person, color: AppColors.primary),
|
||||
),
|
||||
validator: _validateUsername,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _isLoading ? null : _submit,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.primary,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: _isLoading
|
||||
? const SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
)
|
||||
: const Text('验证', style: TextStyle(fontSize: 16)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user