重整多余的UI组件和未定功能的逻辑链路的修正
This commit is contained in:
@@ -6,7 +6,9 @@ import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
|
||||
/// 帮助与反馈页面
|
||||
class HelpFeedbackPage extends StatefulWidget {
|
||||
const HelpFeedbackPage({super.key});
|
||||
const HelpFeedbackPage({super.key, this.faqOnly = false});
|
||||
|
||||
final bool faqOnly;
|
||||
|
||||
@override
|
||||
State<HelpFeedbackPage> createState() => _HelpFeedbackPageState();
|
||||
@@ -81,6 +83,7 @@ class _HelpFeedbackPageState extends State<HelpFeedbackPage>
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
@@ -95,7 +98,9 @@ class _HelpFeedbackPageState extends State<HelpFeedbackPage>
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.help_feedback'),
|
||||
l10n.translate(
|
||||
widget.faqOnly ? 'help_feedback.tab_faq' : 'my_v2.help_feedback',
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -103,25 +108,26 @@ class _HelpFeedbackPageState extends State<HelpFeedbackPage>
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
bottom: TabBar(
|
||||
controller: _tabController,
|
||||
labelColor: const Color(0xFF165DFF),
|
||||
unselectedLabelColor: context.appColors.textTertiary,
|
||||
indicatorColor: const Color(0xFF165DFF),
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
tabs: [
|
||||
Tab(text: AppLocalizations.of(context).translate('help_feedback.tab_faq')),
|
||||
Tab(text: AppLocalizations.of(context).translate('help_feedback.tab_feedback')),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
_buildFAQTab(),
|
||||
_buildFeedbackTab(),
|
||||
],
|
||||
bottom: widget.faqOnly
|
||||
? null
|
||||
: TabBar(
|
||||
controller: _tabController,
|
||||
labelColor: const Color(0xFF165DFF),
|
||||
unselectedLabelColor: context.appColors.textTertiary,
|
||||
indicatorColor: const Color(0xFF165DFF),
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
tabs: [
|
||||
Tab(text: l10n.translate('help_feedback.tab_faq')),
|
||||
Tab(text: l10n.translate('help_feedback.tab_feedback')),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: widget.faqOnly
|
||||
? _buildFAQTab()
|
||||
: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [_buildFAQTab(), _buildFeedbackTab()],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -129,12 +135,17 @@ class _HelpFeedbackPageState extends State<HelpFeedbackPage>
|
||||
// ==================== 常见问题 ====================
|
||||
|
||||
Widget _buildFAQTab() {
|
||||
const guideCategories = {'cat_bind', 'cat_path', 'cat_remote'};
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
..._faqList.map((category) => _buildFAQCategory(category)),
|
||||
const SizedBox(height: 20),
|
||||
_buildContactSection(),
|
||||
for (final category in _faqList)
|
||||
if (!widget.faqOnly || guideCategories.contains(category['category']))
|
||||
_buildFAQCategory(category),
|
||||
if (!widget.faqOnly) ...[
|
||||
const SizedBox(height: 20),
|
||||
_buildContactSection(),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,26 +2,18 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
// import 'package:maibu_satabot_v2/components/app_logo.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
import 'package:maibu_satabot_v2/core/storage/user_storage.dart';
|
||||
import 'package:maibu_satabot_v2/core/utils/image_url_util.dart';
|
||||
import 'package:maibu_satabot_v2/components/capsule_toast.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/widgets/device_confirm_dialog.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/help_feedback_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/profile_detail_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/system_settings_page.dart';
|
||||
|
||||
/// 我的页面 V2 —— 按 M01「我的首页」设计稿实现。
|
||||
///
|
||||
/// 说明:
|
||||
/// - 视觉:背景渐变复用登录页 V2(纵向浅蓝 + 左上/右上径向光晕);
|
||||
/// 顶部 me_left_logo.png + 铃铛/设置按钮;用户卡片底图用 logo_me_bg.png 切图。
|
||||
/// - 保留旧版 my_page.dart(本文件为新版,路由/Tab 已切到本页)。
|
||||
/// - 「编辑个人资料」→ 现有 ProfileDetailPage;「通用设置」→ 现有 SystemSettingsPage。
|
||||
/// - 数字(工单/保养/未读)暂无接口,按约定显示「未知」;未实现入口统一 Toast。
|
||||
/// - 退出登录按需求放在页脚下方。
|
||||
/// 我的首页提供个人信息、设置和常见问题入口。
|
||||
class MyPageV2 extends StatelessWidget {
|
||||
const MyPageV2({super.key});
|
||||
|
||||
@@ -33,30 +25,29 @@ class MyPageV2 extends StatelessWidget {
|
||||
static const _grayText = Color(0xFF86909C);
|
||||
static const _subText = Color(0xFF4E5969);
|
||||
static const _primaryBlue = Color(0xFF1C96F6);
|
||||
static const _orange = Color(0xFFF5A623);
|
||||
static const _iconBgBlue = Color(0xFFE9F3FE);
|
||||
static const _iconBgOrange = Color(0xFFFEF3E3);
|
||||
static const _divider = Color(0xFFF0F4FA);
|
||||
static const _noteBg = Color(0xFFEAF3FD);
|
||||
// 设计稿卡片描边:白卡周围那圈淡蓝边(实测约 RGB 241,247,254)
|
||||
static const _cardBorder = Color(0xFFE9F1FA);
|
||||
|
||||
/// 未实现入口的统一提示
|
||||
static void _todoTap(BuildContext context) {
|
||||
CapsuleToast.show(
|
||||
AppLocalizations.of(context).translate('my_v2.todo_developing'),
|
||||
showCheck: false,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final user = context.watch<AppUserCubit>().state.user;
|
||||
final userName =
|
||||
user?.nickname ??
|
||||
user?.username ??
|
||||
AppLocalizations.of(context).translate('my_v2.default_user_name');
|
||||
final userContact = user?.email ?? user?.phone;
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final userName = [user?.nickname, user?.username]
|
||||
.whereType<String>()
|
||||
.map((name) => name.trim())
|
||||
.firstWhere(
|
||||
(name) => name.isNotEmpty,
|
||||
orElse: () => l10n.translate('my_v2.default_user_name'),
|
||||
);
|
||||
final userContact = [user?.email, user?.phone]
|
||||
.whereType<String>()
|
||||
.map((contact) => contact.trim())
|
||||
.firstWhere(
|
||||
(contact) => contact.isNotEmpty,
|
||||
orElse: () => l10n.translate('my_v2.contact_not_set'),
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: _bgTop,
|
||||
@@ -101,35 +92,12 @@ class MyPageV2 extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 12),
|
||||
_buildTopBar(context),
|
||||
const SizedBox(height: 16),
|
||||
// const AppLogo(size: 44), // 暂时隐藏「我的」页左上角 Logo。
|
||||
// const SizedBox(height: 16),
|
||||
_buildUserCard(context, userName, userContact, user?.avatar),
|
||||
const SizedBox(height: 14),
|
||||
_buildStatsRow(context),
|
||||
const SizedBox(height: 22),
|
||||
_buildSectionTitle(
|
||||
AppLocalizations.of(context).translate('my_v2.service_support'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildServiceGroup(context),
|
||||
const SizedBox(height: 22),
|
||||
_buildSectionTitle(
|
||||
AppLocalizations.of(context).translate('my_v2.account_settings'),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildAccountGroup(context),
|
||||
const SizedBox(height: 16),
|
||||
_buildNoteCard(context),
|
||||
const SizedBox(height: 14),
|
||||
// 页脚灰字(设计稿)
|
||||
Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.footer_note'),
|
||||
style: const TextStyle(fontSize: 11, color: _grayText),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// 退出登录:按需求放在设计稿内容下方
|
||||
_buildLinks(context, isAdmin: user?.isAdmin == true),
|
||||
const SizedBox(height: 16),
|
||||
_buildLogoutButton(context),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
@@ -141,61 +109,11 @@ class MyPageV2 extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 顶部栏:logo + 铃铛/设置按钮 =====
|
||||
Widget _buildTopBar(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/me_left_logo.png',
|
||||
height: 44,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
_buildTopIconButton(
|
||||
Icons.notifications_none,
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
_buildTopIconButton(
|
||||
Icons.settings_outlined,
|
||||
onTap: () => _push(context, const SystemSettingsPage()),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTopIconButton(IconData icon, {required VoidCallback onTap}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _cardBorder),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: _primaryBlue.withValues(alpha: 0.05),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(icon, size: 22, color: _navy),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 用户卡片:底图用 logo_me_bg.png 切图 =====
|
||||
Widget _buildUserCard(
|
||||
BuildContext context,
|
||||
String userName,
|
||||
String? userContact,
|
||||
String userContact,
|
||||
String? avatarUrl,
|
||||
) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
@@ -204,77 +122,64 @@ class MyPageV2 extends StatelessWidget {
|
||||
// 切图自身已烘进圆角、细描边与透明留白:不能再套 ClipRRect+cover,
|
||||
// 否则裁切会把描边线残留在卡片内部形成痕迹;fill 原样呈现即可。
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
'assets/images/logo_me_bg.png',
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
'assets/images/logo_me_bg.png',
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildAvatar(avatarUrl),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
userName,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 19,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 18,
|
||||
color: _navy,
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildAvatar(avatarUrl),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
userName,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
fontSize: 19,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
'${l10n.translate('my_v2.personal_account')} · ${userContact ?? l10n.translate('my_v2.contact_not_set')}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
color: _subText,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
l10n.translate('my_v2.edit_profile'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _primaryBlue,
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
userContact,
|
||||
style: const TextStyle(fontSize: 12.5, color: _subText),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
l10n.translate('my_v2.personal_info'),
|
||||
style: const TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _primaryBlue,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.chevron_right,
|
||||
size: 16,
|
||||
color: _primaryBlue,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -285,7 +190,10 @@ class MyPageV2 extends StatelessWidget {
|
||||
width: 60,
|
||||
height: 60,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: const BoxDecoration(color: Colors.white, shape: BoxShape.circle),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: url != null && url.isNotEmpty
|
||||
? Image.network(
|
||||
url,
|
||||
@@ -301,102 +209,8 @@ class MyPageV2 extends StatelessWidget {
|
||||
return const Icon(Icons.person, size: 36, color: _primaryBlue);
|
||||
}
|
||||
|
||||
// ===== 三个数据卡 =====
|
||||
Widget _buildStatsRow(BuildContext context) {
|
||||
Widget _buildLinks(BuildContext context, {required bool isAdmin}) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
icon: Icons.assignment_outlined,
|
||||
iconColor: _primaryBlue,
|
||||
value: l10n.translate('my_v2.unknown'),
|
||||
label: l10n.translate('my_v2.stat_processing_order'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
icon: Icons.build_outlined,
|
||||
iconColor: _orange,
|
||||
value: l10n.translate('my_v2.unknown'),
|
||||
label: l10n.translate('my_v2.stat_maintenance_reminder'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
icon: Icons.article_outlined,
|
||||
iconColor: _primaryBlue,
|
||||
value: l10n.translate('my_v2.stat_tutorial'),
|
||||
label: l10n.translate('my_v2.stat_usage_help'),
|
||||
onTap: () => _push(context, const HelpFeedbackPage()),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatCard({
|
||||
required IconData icon,
|
||||
required Color iconColor,
|
||||
required String value,
|
||||
required String label,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
border: Border.all(color: _cardBorder),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: _primaryBlue.withValues(alpha: 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Icon(icon, size: 20, color: iconColor),
|
||||
const SizedBox(height: 4),
|
||||
// 字号与登录页统一:数值 16 ≈ 登录按钮字号
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
// 标签 11.5 ≈ 登录页辅助文字,略小于输入提示 14
|
||||
Text(label, style: const TextStyle(fontSize: 11.5, color: _grayText)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 分组卡片 =====
|
||||
Widget _buildSectionTitle(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _navy,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildGroupCard(List<Widget> rows) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
@@ -410,93 +224,41 @@ class MyPageV2 extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(children: rows),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildMenuRow(
|
||||
icon: Icons.settings_outlined,
|
||||
title: l10n.translate('my_v2.general_settings'),
|
||||
subtitle: l10n.translate(
|
||||
isAdmin
|
||||
? 'my_v2.general_settings_desc'
|
||||
: 'my_v2.general_settings_basic_desc',
|
||||
),
|
||||
onTap: () => _push(context, const SystemSettingsPage()),
|
||||
),
|
||||
const Divider(height: 1, thickness: 1, color: _divider, indent: 66),
|
||||
_buildMenuRow(
|
||||
icon: Icons.menu_book_outlined,
|
||||
title: l10n.translate('help_feedback.tab_faq'),
|
||||
subtitle: l10n.translate('my_v2.help_guide_desc'),
|
||||
onTap: () => _push(context, const HelpFeedbackPage(faqOnly: true)),
|
||||
),
|
||||
const Divider(height: 1, thickness: 1, color: _divider, indent: 66),
|
||||
_buildMenuRow(
|
||||
icon: Icons.policy_outlined,
|
||||
title: l10n.translate('my_v2.privacy_and_terms'),
|
||||
onTap: () => _showLegalDocuments(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildServiceGroup(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return _buildGroupCard([
|
||||
_buildMenuRow(
|
||||
icon: Icons.headset_mic_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.after_sales_center'),
|
||||
subtitle: l10n.translate('my_v2.after_sales_center_desc'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.build_outlined,
|
||||
iconBg: _iconBgOrange,
|
||||
iconColor: _orange,
|
||||
title: l10n.translate('my_v2.maintenance'),
|
||||
subtitle: l10n.translate('my_v2.maintenance_desc'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.menu_book_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.help_guide'),
|
||||
subtitle: l10n.translate('my_v2.help_guide_desc'),
|
||||
onTap: () => _push(context, const HelpFeedbackPage()),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _buildAccountGroup(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return _buildGroupCard([
|
||||
_buildMenuRow(
|
||||
icon: Icons.verified_user_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.account_security'),
|
||||
subtitle: l10n.translate('my_v2.account_security_desc'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.notifications_none,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.message_notice'),
|
||||
subtitle: l10n.translate('my_v2.message_notice_desc'),
|
||||
// 未读接口暂无,按约定显示「未知」
|
||||
trailingText: l10n.translate('my_v2.unread_unknown'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.settings_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.general_settings'),
|
||||
subtitle: l10n.translate('my_v2.general_settings_desc'),
|
||||
onTap: () => _push(context, const SystemSettingsPage()),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.info_outline,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: l10n.translate('my_v2.about_legal'),
|
||||
subtitle: l10n.translate('my_v2.about_legal_desc'),
|
||||
onTap: () => _todoTap(context),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _buildMenuRow({
|
||||
required IconData icon,
|
||||
required Color iconBg,
|
||||
required Color iconColor,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
String? subtitle,
|
||||
required VoidCallback onTap,
|
||||
String? trailingText,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
@@ -509,10 +271,10 @@ class MyPageV2 extends StatelessWidget {
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: iconBg,
|
||||
color: _iconBgBlue,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(icon, size: 21, color: iconColor),
|
||||
child: Icon(icon, size: 21, color: _primaryBlue),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
@@ -527,19 +289,16 @@ class MyPageV2 extends StatelessWidget {
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
subtitle,
|
||||
style: const TextStyle(fontSize: 12, color: _grayText),
|
||||
),
|
||||
if (subtitle != null) ...[
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
subtitle,
|
||||
style: const TextStyle(fontSize: 12, color: _grayText),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
if (trailingText != null)
|
||||
Text(
|
||||
trailingText,
|
||||
style: const TextStyle(fontSize: 12.5, color: _grayText),
|
||||
),
|
||||
const SizedBox(width: 2),
|
||||
const Icon(Icons.chevron_right, size: 18, color: Color(0xFFC9CDD4)),
|
||||
],
|
||||
@@ -548,27 +307,29 @@ class MyPageV2 extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRowDivider() {
|
||||
return const Divider(height: 1, thickness: 1, color: _divider, indent: 66);
|
||||
}
|
||||
|
||||
// ===== 底部说明卡(设计稿原文) =====
|
||||
Widget _buildNoteCard(BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: _noteBg,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.note_card'),
|
||||
style: const TextStyle(fontSize: 12.5, color: _subText, height: 1.6),
|
||||
void _showLegalDocuments(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
showDragHandle: true,
|
||||
builder: (context) => SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final titleKey in ['my.privacy_policy', 'my.user_agreement'])
|
||||
ListTile(
|
||||
title: Text(l10n.translate(titleKey)),
|
||||
subtitle: Text(l10n.translate('my_v2.legal_unavailable')),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 退出登录(放在页脚下方) =====
|
||||
// ===== 退出登录 =====
|
||||
Widget _buildLogoutButton(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => _showLogoutDialog(context),
|
||||
@@ -590,41 +351,27 @@ class MyPageV2 extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
void _showLogoutDialog(BuildContext context) {
|
||||
Future<void> _showLogoutDialog(BuildContext context) async {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(l10n.translate('my_v2.logout')),
|
||||
content: Text(l10n.translate('my_v2.logout_confirm')),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(l10n.translate('my_v2.cancel')),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.pop(dialogContext);
|
||||
await GetIt.I<UserStorage>().deleteUser();
|
||||
GetIt.I<AuthCubit>().logout();
|
||||
if (dialogContext.mounted) {
|
||||
GoRouter.of(dialogContext).go(RoutePaths.login);
|
||||
}
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: const Color(0xFFF53F3F),
|
||||
),
|
||||
child: Text(l10n.translate('my_v2.confirm')),
|
||||
),
|
||||
],
|
||||
),
|
||||
final logoutLabel = l10n.translate('my_v2.logout');
|
||||
final confirmed = await showDeviceConfirmDialog(
|
||||
context,
|
||||
icon: Icons.logout_rounded,
|
||||
title: logoutLabel,
|
||||
message: l10n.translate('my_v2.logout_confirm'),
|
||||
confirmText: logoutLabel,
|
||||
cancelText: l10n.translate('my_v2.cancel'),
|
||||
danger: true,
|
||||
);
|
||||
if (!confirmed || !context.mounted) return;
|
||||
|
||||
await GetIt.I<AuthCubit>().logout();
|
||||
if (context.mounted) {
|
||||
context.go(RoutePaths.login);
|
||||
}
|
||||
}
|
||||
|
||||
void _push(BuildContext context, Widget page) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => page),
|
||||
);
|
||||
Navigator.push(context, MaterialPageRoute(builder: (context) => page));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,10 +51,6 @@ class ProfileDetailPage extends StatelessWidget {
|
||||
|
||||
// 信息列表
|
||||
_buildInfoCard(context, user),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 操作按钮
|
||||
_buildActionButtons(context),
|
||||
],
|
||||
);
|
||||
},
|
||||
@@ -254,41 +250,4 @@ class ProfileDetailPage extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 操作按钮
|
||||
Widget _buildActionButtons(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Column(
|
||||
children: [
|
||||
// 编辑资料按钮(预留)
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
// TODO: 跳转到编辑资料页面
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(l10n.translate('my_v2.edit_in_progress')),
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.edit, size: 20),
|
||||
label: Text(
|
||||
l10n.translate('my_v2.edit_profile_action'),
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF165DFF),
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import 'package:maibu_satabot_v2/core/storage/user_storage.dart';
|
||||
import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/domain/tab_config.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/float_bar/cubit/float_bar_setting_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/update/update_cubit.dart';
|
||||
@@ -38,6 +37,7 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
Future<void> _loadVersion() async {
|
||||
try {
|
||||
final String versionString = await rootBundle.loadString('pubspec.yaml');
|
||||
if (!mounted) return;
|
||||
final versionMatch = RegExp(r'version:\s*(\d+\.\d+\.\d+)\+(\d+)').firstMatch(versionString);
|
||||
setState(() {
|
||||
_currentVersion = versionMatch?.group(1) ?? '1.0.0';
|
||||
@@ -47,6 +47,8 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
}
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final user = context.watch<AppUserCubit>().state.user;
|
||||
final isAdmin = user?.isAdmin == true;
|
||||
return Scaffold(
|
||||
backgroundColor: context.appColors.pageBackground,
|
||||
appBar: AppBar(
|
||||
@@ -69,16 +71,17 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// Tab 设置
|
||||
_buildTabSettingsSection(),
|
||||
_buildTabSettingsSection(user?.roleKey, isAdmin: isAdmin),
|
||||
const SizedBox(height: 12),
|
||||
// 悬浮条设置
|
||||
_buildFloatBarSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 语言设置
|
||||
if (isAdmin) ...[
|
||||
_buildFloatBarSection(),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
_buildLanguageSection(),
|
||||
const SizedBox(height: 12),
|
||||
// 版本更新
|
||||
_buildUpdateSection(),
|
||||
if (isAdmin) ...[
|
||||
const SizedBox(height: 12),
|
||||
_buildUpdateSection(),
|
||||
],
|
||||
const SizedBox(height: 12),
|
||||
// 退出登录(已挪至“我的”页面最下边,此处注释掉)
|
||||
// _buildLogoutButton(context),
|
||||
@@ -148,10 +151,7 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
}
|
||||
|
||||
/// Tab 设置
|
||||
Widget _buildTabSettingsSection() {
|
||||
// 🔥 个人角色(roleKey == 'personal'):Tab 设置只列出「设备 + 我的」,且开关常开锁定
|
||||
final roleKey = context.watch<AppUserCubit>().state.user?.roleKey;
|
||||
final isPersonal = roleKey == TabConfig.personalRoleKey;
|
||||
Widget _buildTabSettingsSection(String? roleKey, {required bool isAdmin}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -177,9 +177,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
BlocBuilder<TabConfigCubit, dynamic>(
|
||||
BlocBuilder<TabConfigCubit, TabConfigState>(
|
||||
builder: (context, state) {
|
||||
if (state.runtimeType.toString() != 'TabConfigLoaded') {
|
||||
if (state is! TabConfigLoaded) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
@@ -208,13 +208,10 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
// 个人角色:设备/我的 强制常开且不可关闭
|
||||
value: isPersonal ? true : tab.isEnabled,
|
||||
onChanged: isPersonal
|
||||
? null
|
||||
: (value) {
|
||||
context.read<TabConfigCubit>().toggleTab(tab.id);
|
||||
},
|
||||
value: tab.isEnabled,
|
||||
onChanged: isAdmin
|
||||
? (_) => context.read<TabConfigCubit>().toggleTab(tab.id)
|
||||
: null,
|
||||
activeColor: const Color(0xFF165DFF),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user