112 lines
3.4 KiB
Dart
112 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:qhd_prevention/customWidget/custom_button.dart';
|
|
import 'package:qhd_prevention/pages/my_appbar.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:qhd_prevention/tools/h_colors.dart';
|
|
|
|
class MineSetPwdPage extends StatefulWidget {
|
|
const MineSetPwdPage({super.key});
|
|
|
|
@override
|
|
State<MineSetPwdPage> createState() => _MineSetPwdPageState();
|
|
}
|
|
|
|
class _MineSetPwdPageState extends State<MineSetPwdPage> {
|
|
final _oldPwdController = TextEditingController();
|
|
final _newPwdController = TextEditingController();
|
|
final _confirmPwdController = TextEditingController();
|
|
|
|
@override
|
|
void dispose() {
|
|
_oldPwdController.dispose();
|
|
_newPwdController.dispose();
|
|
_confirmPwdController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
void _handleSubmit() {
|
|
final oldPwd = _oldPwdController.text.trim();
|
|
final newPwd = _newPwdController.text.trim();
|
|
final confirmPwd = _confirmPwdController.text.trim();
|
|
|
|
if (oldPwd.isEmpty || newPwd.isEmpty || confirmPwd.isEmpty) {
|
|
_showMessage('请填写完整所有字段');
|
|
return;
|
|
}
|
|
|
|
if (newPwd != confirmPwd) {
|
|
_showMessage('新密码与确认密码不一致');
|
|
return;
|
|
}
|
|
|
|
// 示例验证:密码复杂度(实际可用正则加强)
|
|
if (newPwd.length < 8 || newPwd.length > 20) {
|
|
_showMessage('密码长度需在8-20位之间');
|
|
return;
|
|
}
|
|
|
|
_showMessage('密码修改成功'); // 这里换成实际调用接口逻辑
|
|
}
|
|
|
|
void _showMessage(String msg) {
|
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(msg)));
|
|
}
|
|
|
|
Widget _buildPwdField(String hintText, TextEditingController controller) {
|
|
return Column(
|
|
children: [
|
|
TextField(
|
|
controller: controller,
|
|
obscureText: true,
|
|
decoration: InputDecoration(
|
|
hintText: hintText,
|
|
border: InputBorder.none,
|
|
contentPadding: const EdgeInsets.symmetric(vertical: 10),
|
|
),
|
|
),
|
|
const Divider(height: 1, color: Colors.grey),
|
|
],
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Colors.white,
|
|
appBar: MyAppbar(title: '修改密码'),
|
|
body: SafeArea(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const Text(
|
|
'修改密码',
|
|
style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
|
),
|
|
const SizedBox(height: 30),
|
|
_buildPwdField('旧密码', _oldPwdController),
|
|
const SizedBox(height: 20),
|
|
_buildPwdField('新密码', _newPwdController),
|
|
const SizedBox(height: 20),
|
|
_buildPwdField('确认新密码', _confirmPwdController),
|
|
const SizedBox(height: 15),
|
|
const Text(
|
|
'需8-20位字母大小写、数字、字符混合',
|
|
style: TextStyle(color: Colors.grey, fontSize: 13),
|
|
),
|
|
const SizedBox(height: 30,),
|
|
SizedBox(
|
|
width: double.infinity,
|
|
height: 48,
|
|
child: CustomButton(text: "提交", backgroundColor: Colors.blue),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|