2025-07-07 17:00:37 +08:00
|
|
|
|
import 'package:flutter/material.dart';
|
2025-07-09 14:27:53 +08:00
|
|
|
|
import 'package:qhdkfq_regulatory_flutter/mine/change_pass_page.dart';
|
|
|
|
|
import 'package:qhdkfq_regulatory_flutter/mine/message_page.dart';
|
|
|
|
|
import 'package:qhdkfq_regulatory_flutter/tools/tools.dart';
|
|
|
|
|
|
2025-07-07 17:00:37 +08:00
|
|
|
|
|
|
|
|
|
class MinePage extends StatefulWidget {
|
|
|
|
|
const MinePage({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<MinePage> createState() => _MinePageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _MinePageState extends State<MinePage> {
|
|
|
|
|
// 设置项状态
|
|
|
|
|
bool notificationsEnabled = false;
|
|
|
|
|
bool passwordChanged = false;
|
|
|
|
|
bool updateAvailable = false;
|
|
|
|
|
bool logoutSelected = false;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
// child: Padding(
|
|
|
|
|
// padding: const EdgeInsets.all(24.0),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
// 顶部标题区域
|
|
|
|
|
_buildHeaderSection(),
|
|
|
|
|
const SizedBox(height: 15),
|
|
|
|
|
|
|
|
|
|
// 标语区域
|
|
|
|
|
// _buildSloganSection(),
|
|
|
|
|
// const SizedBox(height: 40),
|
|
|
|
|
// 图片区
|
|
|
|
|
_buildCenterImage(),
|
|
|
|
|
const SizedBox(height: 15),
|
|
|
|
|
|
|
|
|
|
// 设置项列表
|
|
|
|
|
_buildSettingsList(),
|
|
|
|
|
const SizedBox(height: 40),
|
|
|
|
|
|
|
|
|
|
// 底部按钮
|
|
|
|
|
// _buildActionButton(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
// ),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildHeaderSection() {
|
|
|
|
|
return Stack(
|
|
|
|
|
alignment: const FractionalOffset(0.5, 1),
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
|
|
Padding(
|
|
|
|
|
padding: EdgeInsets.fromLTRB(0,0,0,30),
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
"assets/images/bannerbg.png",
|
|
|
|
|
width: MediaQuery.of(context).size.width, // 获取屏幕宽度
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// 标语区域
|
|
|
|
|
_buildSloganSection(),
|
|
|
|
|
const SizedBox(height: 40),
|
|
|
|
|
],
|
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
// children: [
|
|
|
|
|
// const Text(
|
|
|
|
|
// "齐津诚",
|
|
|
|
|
// style: TextStyle(
|
|
|
|
|
// fontSize: 28,
|
|
|
|
|
// fontWeight: FontWeight.bold,
|
|
|
|
|
// color: Color(0xFF1A237E),
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// const SizedBox(height: 8),
|
|
|
|
|
// Text(
|
|
|
|
|
// "齐津诚",
|
|
|
|
|
// style: TextStyle(
|
|
|
|
|
// fontSize: 18,
|
|
|
|
|
// color: Colors.grey[700],
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
// ],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildSloganSection() {
|
|
|
|
|
return Container(
|
|
|
|
|
// padding: const EdgeInsets.all(24.0),
|
|
|
|
|
margin: EdgeInsets.fromLTRB(24,0,24,0),
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 20),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: Colors.grey.withOpacity(0.1),
|
|
|
|
|
spreadRadius: 2,
|
|
|
|
|
blurRadius: 8,
|
|
|
|
|
offset: const Offset(0, 4),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
CircleAvatar(
|
|
|
|
|
backgroundImage: AssetImage("assets/images/tx.png"),
|
|
|
|
|
radius: 30,
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(width: 16),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
"用户名称",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
color: Color(0xFF000000),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Text(
|
|
|
|
|
"用户简介",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: Colors.grey[600],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildSettingsList() {
|
|
|
|
|
return Container(
|
|
|
|
|
margin: const EdgeInsets.fromLTRB(24,0,24,0),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
|
boxShadow: [
|
|
|
|
|
BoxShadow(
|
|
|
|
|
color: Colors.grey.withOpacity(0.1),
|
|
|
|
|
spreadRadius: 2,
|
|
|
|
|
blurRadius: 8,
|
|
|
|
|
offset: const Offset(0, 4),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
// 通知提醒
|
|
|
|
|
_buildSettingItem(
|
|
|
|
|
title: "通知提醒",
|
|
|
|
|
icon: "assets/images/i2.png",
|
|
|
|
|
value: notificationsEnabled,
|
2025-07-09 14:27:53 +08:00
|
|
|
|
num:1,
|
2025-07-07 17:00:37 +08:00
|
|
|
|
onChanged: (value) => setState(() => notificationsEnabled = value!),
|
|
|
|
|
),
|
|
|
|
|
// const Divider(height: 1, indent: 60),
|
|
|
|
|
|
|
|
|
|
// 修改密码
|
|
|
|
|
_buildSettingItem(
|
|
|
|
|
title: "修改密码",
|
|
|
|
|
icon: "assets/images/i3.png",
|
|
|
|
|
value: passwordChanged,
|
2025-07-09 14:27:53 +08:00
|
|
|
|
num:2,
|
2025-07-07 17:00:37 +08:00
|
|
|
|
onChanged: (value) => setState(() => passwordChanged = value!),
|
|
|
|
|
),
|
|
|
|
|
// const Divider(height: 1, indent: 60),
|
|
|
|
|
|
|
|
|
|
// 版本更新
|
|
|
|
|
_buildSettingItem(
|
|
|
|
|
title: "版本更新",
|
|
|
|
|
icon: "assets/images/i5.png",
|
|
|
|
|
value: updateAvailable,
|
2025-07-09 14:27:53 +08:00
|
|
|
|
num:3,
|
2025-07-07 17:00:37 +08:00
|
|
|
|
onChanged: (value) => setState(() => updateAvailable = value!),
|
|
|
|
|
),
|
|
|
|
|
// const Divider(height: 1, indent: 60),
|
|
|
|
|
|
|
|
|
|
// 退出登录
|
|
|
|
|
_buildSettingItem(
|
|
|
|
|
title: "退出登录",
|
|
|
|
|
icon: "assets/images/i4.png",
|
|
|
|
|
value: logoutSelected,
|
2025-07-09 14:27:53 +08:00
|
|
|
|
num:4,
|
2025-07-07 17:00:37 +08:00
|
|
|
|
onChanged: (value) {
|
|
|
|
|
setState(() => logoutSelected = value!);
|
2025-07-09 14:27:53 +08:00
|
|
|
|
// if (value == true) {
|
|
|
|
|
// _showLogoutConfirmation();
|
|
|
|
|
// }
|
2025-07-07 17:00:37 +08:00
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildSettingItem({
|
|
|
|
|
required String title,
|
|
|
|
|
required String icon,
|
|
|
|
|
required bool value,
|
2025-07-09 14:27:53 +08:00
|
|
|
|
required int num,
|
2025-07-07 17:00:37 +08:00
|
|
|
|
required ValueChanged<bool?> onChanged,
|
|
|
|
|
}) {
|
2025-07-09 14:27:53 +08:00
|
|
|
|
return
|
|
|
|
|
GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
switch(num){
|
|
|
|
|
case 1:
|
|
|
|
|
pushPage(MessagePage(), context);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
pushPage(ChangePassPage(), context);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2025-07-07 17:00:37 +08:00
|
|
|
|
|
2025-07-09 14:27:53 +08:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
_showLogoutConfirmation();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: ListTile(
|
|
|
|
|
leading: Container(
|
|
|
|
|
width: 20,
|
|
|
|
|
height: 20,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
),
|
|
|
|
|
child: Image.asset(icon ,fit: BoxFit.cover, ),
|
|
|
|
|
),
|
|
|
|
|
title: Text(
|
|
|
|
|
title,
|
|
|
|
|
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
trailing: Transform.scale(
|
|
|
|
|
scale: 1.2,
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
"assets/images/right.png",
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
width: 15,
|
|
|
|
|
height: 15,
|
|
|
|
|
),
|
|
|
|
|
),
|
2025-07-07 17:00:37 +08:00
|
|
|
|
),
|
2025-07-09 14:27:53 +08:00
|
|
|
|
);
|
|
|
|
|
|
2025-07-07 17:00:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildActionButton() {
|
|
|
|
|
return SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: ElevatedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// 保存设置逻辑
|
|
|
|
|
_saveSettings();
|
|
|
|
|
},
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: const Color(0xFF1A237E),
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
),
|
|
|
|
|
elevation: 3, // 注意:elevation应该放在styleFrom内部
|
|
|
|
|
),
|
|
|
|
|
child: const Text(
|
|
|
|
|
"保存设置",
|
|
|
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _saveSettings() {
|
|
|
|
|
// 这里可以添加保存设置到服务器的逻辑
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
SnackBar(
|
|
|
|
|
content: const Text("设置已保存成功"),
|
|
|
|
|
backgroundColor: Colors.green[700],
|
|
|
|
|
duration: const Duration(seconds: 2),
|
|
|
|
|
behavior: SnackBarBehavior.floating,
|
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _showLogoutConfirmation() {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
builder: (context) => AlertDialog(
|
|
|
|
|
title: const Text("退出登录"),
|
2025-07-09 14:27:53 +08:00
|
|
|
|
content: const Text("确定要退出登录吗?"),
|
2025-07-07 17:00:37 +08:00
|
|
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
|
|
|
|
actions: [
|
2025-07-09 14:27:53 +08:00
|
|
|
|
ElevatedButton(
|
2025-07-07 17:00:37 +08:00
|
|
|
|
onPressed: () {
|
|
|
|
|
setState(() => logoutSelected = false);
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
},
|
2025-07-09 14:27:53 +08:00
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: Colors.grey[400],
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
child: const Text(" 取消 "),
|
2025-07-07 17:00:37 +08:00
|
|
|
|
),
|
|
|
|
|
ElevatedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// 执行退出登录操作
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
SnackBar(
|
|
|
|
|
content: const Text("您已成功退出登录"),
|
|
|
|
|
backgroundColor: Colors.blue[700],
|
|
|
|
|
duration: const Duration(seconds: 2),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: Colors.blue[700],
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
),
|
|
|
|
|
child: const Text("确定退出"),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildCenterImage (){
|
|
|
|
|
return Stack(
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
margin: const EdgeInsets.fromLTRB(24,0,24,0),
|
|
|
|
|
height: 100,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(10.0),
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
image: AssetImage('assets/images/bg1.png'),
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Positioned(
|
|
|
|
|
top: 25,
|
|
|
|
|
left: 45,
|
|
|
|
|
child: Text(
|
|
|
|
|
"防范事故 保障安全",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
color: Color(0xFF000000),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Positioned(
|
|
|
|
|
top: 55,
|
|
|
|
|
left: 45,
|
|
|
|
|
child: Text(
|
|
|
|
|
"治理隐患,健康你我他",
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
color: Colors.grey[600],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|