rtc_prd/airhub_app/lib/pages/profile/settings_page.dart
2026-02-06 16:03:32 +08:00

324 lines
10 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:airhub_app/theme/design_tokens.dart';
import 'package:airhub_app/pages/profile/settings_sub_pages.dart';
import 'package:airhub_app/pages/product_selection_page.dart';
import 'package:airhub_app/widgets/glass_dialog.dart';
class SettingsPage extends StatefulWidget {
const SettingsPage({super.key});
@override
State<SettingsPage> createState() => _SettingsPageState();
}
class _SettingsPageState extends State<SettingsPage> {
bool _notificationEnabled = true;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.background,
body: Stack(
children: [
Container(decoration: const BoxDecoration(color: Color(0xFFFEFEFE))),
Column(
children: [
_buildHeader(context),
Expanded(
child: SingleChildScrollView(
padding: EdgeInsets.only(
top: 20,
left: AppSpacing.lg,
right: AppSpacing.lg,
bottom: 40 + MediaQuery.of(context).padding.bottom,
),
child: Column(
children: [
_buildSection('账号安全', [
_buildItem(
'📱',
'绑定手机',
value: '138****3069',
onTap: () => _showMessage('绑定手机', '138****3069'),
),
_buildItem(
'🔐',
'账号密码',
onTap: () => _showMessage('提示', '密码修改功能开发中...'),
),
_buildItem(
'📦',
'设备管理',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const ProductSelectionPage(),
),
),
),
_buildItem(
'🔔',
'推送通知权限',
value: _notificationEnabled ? '已开启' : '已关闭',
onTap: _toggleNotification,
),
]),
const SizedBox(height: 24),
_buildSection('关于', [
_buildItem(
'🔄',
'检查更新',
value: '当前最新 1.0.0',
onTap: () => _showMessage('检查更新', '当前已是最新版本 v1.0.0'),
),
_buildItem(
'💻',
'硬件信息',
onTap: () => _showMessage(
'硬件信息',
'设备型号: Airhub_5G\n固件版本: 2.1.3',
),
),
_buildItem(
'📄',
'用户协议',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const AgreementPage(),
),
),
),
_buildItem(
'🔒',
'隐私政策',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const PrivacyPage(),
),
),
),
_buildItem(
'📋',
'个人信息收集清单',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const CollectionListPage(),
),
),
),
_buildItem(
'🔗',
'第三方信息共享清单',
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const SharingListPage(),
),
),
),
]),
const SizedBox(height: 24),
_buildSection(null, [
_buildItem(
'🚪',
'退出登录',
isDanger: true,
onTap: _showLogoutDialog,
),
_buildItem(
'⚠️',
'账号注销',
isDanger: true,
isLast: true,
onTap: _showDeleteAccountDialog,
),
]),
const SizedBox(height: 32),
const Text(
'Airhub v1.0.0\n© 2025 Airhub Team',
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.textSecondary,
fontSize: 13,
),
),
],
),
),
),
],
),
],
),
);
}
Widget _buildHeader(BuildContext context) {
return Container(
padding: EdgeInsets.only(
top: MediaQuery.of(context).padding.top + 20,
left: AppSpacing.lg,
right: AppSpacing.lg,
bottom: AppSpacing.md,
),
child: Row(
children: [
GestureDetector(
onTap: () => Navigator.pop(context),
child: Container(
width: 44,
height: 44,
decoration: BoxDecoration(
color: AppColors.iconBtnBg,
borderRadius: BorderRadius.circular(AppRadius.button),
border: Border.all(color: AppColors.iconBtnBorder),
),
child: const Icon(
Icons.arrow_back,
color: AppColors.textPrimary,
size: 20,
),
),
),
Expanded(
child: Center(child: Text('设置', style: AppTextStyles.title)),
),
const SizedBox(width: 44), // Balance
],
),
);
}
Widget _buildSection(String? title, List<Widget> children) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (title != null)
Padding(
padding: const EdgeInsets.only(left: 4, bottom: 8),
child: Text(
title,
style: const TextStyle(
color: AppColors.sectionTitle,
fontSize: 13,
fontWeight: FontWeight.w500,
),
),
),
Container(
decoration: BoxDecoration(
color: AppColors.cardSurface,
borderRadius: BorderRadius.circular(16),
boxShadow: const [AppShadows.card],
),
child: Column(children: children),
),
],
);
}
Widget _buildItem(
String icon,
String text, {
String? value,
bool isDanger = false,
bool isLast = false,
VoidCallback? onTap,
}) {
return InkWell(
onTap: onTap,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
decoration: !isLast
? const BoxDecoration(
border: Border(bottom: BorderSide(color: AppColors.divider)),
)
: null,
child: Row(
children: [
SizedBox(
width: 24,
child: Text(icon, style: const TextStyle(fontSize: 18)),
),
const SizedBox(width: 12),
Expanded(
child: Text(
text,
style: TextStyle(
fontSize: 16,
color: isDanger ? AppColors.danger : AppColors.textPrimary,
),
),
),
if (value != null) ...[
Text(
value,
style: const TextStyle(
fontSize: 14,
color: AppColors.textSecondary,
),
),
const SizedBox(width: 8),
],
const Icon(
Icons.chevron_right,
color: AppColors.textHint,
size: 18,
),
],
),
),
);
}
void _toggleNotification() {
setState(() => _notificationEnabled = !_notificationEnabled);
}
void _showMessage(String title, String desc) {
showGlassDialog(
context: context,
title: title,
description: desc,
confirmText: '确定',
onConfirm: () => Navigator.pop(context),
);
}
void _showLogoutDialog() {
showGlassDialog(
context: context,
title: '确认退出登录?',
description: '退出后需要重新登录才能使用。',
cancelText: '取消',
confirmText: '退出',
isDanger: true,
onConfirm: () {
Navigator.pop(context); // Close dialog
// In real app: clear session and nav to login
Navigator.of(
context,
).pushNamedAndRemoveUntil('/login', (route) => false);
},
);
}
void _showDeleteAccountDialog() {
showGlassDialog(
context: context,
title: '确认注销账号?',
description: '账号注销后所有数据将被永久删除,且无法恢复。',
cancelText: '取消',
confirmText: '确认注销',
isDanger: true,
onConfirm: () {
Navigator.pop(context);
_showMessage('已提交', '账号注销申请已提交将在7个工作日内处理。');
},
);
}
}