新版UI-登录页面-我的页面(简单适配)-设备的部分(无设备的+有设备)
This commit is contained in:
610
lib/features/v2/my/presentation/pages/my_page_v2.dart
Normal file
610
lib/features/v2/my/presentation/pages/my_page_v2.dart
Normal file
@@ -0,0 +1,610 @@
|
||||
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/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/features/auth/presentation/bloc/auth_cubit.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});
|
||||
|
||||
// ===== 设计稿配色(与登录页 V2 同一套固定视觉,不随主题切换) =====
|
||||
static const _bgTop = Color(0xFFFAFCFF);
|
||||
static const _bgMid = Color(0xFFF0F6FE);
|
||||
static const _bgBottom = Color(0xFFD6E9FB);
|
||||
static const _navy = Color(0xFF1A2B4A);
|
||||
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() {
|
||||
CapsuleToast.show('功能暂未开发', showCheck: false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final user = context.watch<AppUserCubit>().state.user;
|
||||
final userName = user?.nickname ?? user?.username ?? 'SATA用户';
|
||||
final userContact = user?.email ?? user?.phone;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: _bgTop,
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// 背景三层:纵向渐变 + 左上/右上蓝色光晕(与登录页 V2 一致)
|
||||
const DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [_bgTop, _bgMid, _bgBottom],
|
||||
stops: [0.0, 0.4, 1.0],
|
||||
),
|
||||
),
|
||||
),
|
||||
const DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: RadialGradient(
|
||||
center: Alignment(-1.1, -1.0),
|
||||
radius: 1.1,
|
||||
colors: [Color(0xFFD6E8FC), Color(0x00D6E8FC)],
|
||||
),
|
||||
),
|
||||
),
|
||||
const DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
gradient: RadialGradient(
|
||||
center: Alignment(1.1, -0.9),
|
||||
radius: 1.25,
|
||||
colors: [Color(0xFFC7DFF8), Color(0x00C7DFF8)],
|
||||
),
|
||||
),
|
||||
),
|
||||
SafeArea(
|
||||
bottom: false,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 12),
|
||||
_buildTopBar(context),
|
||||
const SizedBox(height: 16),
|
||||
_buildUserCard(context, userName, userContact, user?.avatar),
|
||||
const SizedBox(height: 14),
|
||||
_buildStatsRow(context),
|
||||
const SizedBox(height: 22),
|
||||
_buildSectionTitle('服务支持'),
|
||||
const SizedBox(height: 10),
|
||||
_buildServiceGroup(context),
|
||||
const SizedBox(height: 22),
|
||||
_buildSectionTitle('账户与设置'),
|
||||
const SizedBox(height: 10),
|
||||
_buildAccountGroup(context),
|
||||
const SizedBox(height: 16),
|
||||
_buildNoteCard(),
|
||||
const SizedBox(height: 14),
|
||||
// 页脚灰字(设计稿)
|
||||
const Center(
|
||||
child: Text(
|
||||
'设计原型 · 数据仅供演示 · 不连接真实设备或账号',
|
||||
style: TextStyle(fontSize: 11, color: _grayText),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
// 退出登录:按需求放在设计稿内容下方
|
||||
_buildLogoutButton(context),
|
||||
const SizedBox(height: 24),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 顶部栏: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),
|
||||
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? avatarUrl,
|
||||
) {
|
||||
return GestureDetector(
|
||||
onTap: () => _push(context, const ProfileDetailPage()),
|
||||
// 切图自身已烘进圆角、细描边与透明留白:不能再套 ClipRRect+cover,
|
||||
// 否则裁切会把描边线残留在卡片内部形成痕迹;fill 原样呈现即可。
|
||||
child: Stack(
|
||||
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,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 3),
|
||||
Text(
|
||||
'个人账号 · ${userContact ?? '未设置联系方式'}',
|
||||
style: const TextStyle(
|
||||
fontSize: 12.5,
|
||||
color: _subText,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Row(
|
||||
children: [
|
||||
Text(
|
||||
'编辑个人资料',
|
||||
style: TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _primaryBlue,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
size: 16,
|
||||
color: _primaryBlue,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 头像:后端可能返回相对路径,先经 ImageUrlUtil 补全(项目规范)
|
||||
Widget _buildAvatar(String? avatarUrl) {
|
||||
final url = ImageUrlUtil.resolve(avatarUrl);
|
||||
return Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: const BoxDecoration(color: Colors.white, shape: BoxShape.circle),
|
||||
child: url != null && url.isNotEmpty
|
||||
? Image.network(
|
||||
url,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) =>
|
||||
_buildDefaultAvatar(),
|
||||
)
|
||||
: _buildDefaultAvatar(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDefaultAvatar() {
|
||||
return const Icon(Icons.person, size: 36, color: _primaryBlue);
|
||||
}
|
||||
|
||||
// ===== 三个数据卡 =====
|
||||
Widget _buildStatsRow(BuildContext context) {
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
icon: Icons.assignment_outlined,
|
||||
iconColor: _primaryBlue,
|
||||
value: '未知',
|
||||
label: '处理中工单',
|
||||
onTap: _todoTap,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
icon: Icons.build_outlined,
|
||||
iconColor: _orange,
|
||||
value: '未知',
|
||||
label: '保养提醒',
|
||||
onTap: _todoTap,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: _buildStatCard(
|
||||
icon: Icons.article_outlined,
|
||||
iconColor: _primaryBlue,
|
||||
value: '教程',
|
||||
label: '使用与帮助',
|
||||
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,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: _cardBorder),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: _primaryBlue.withValues(alpha: 0.05),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(children: rows),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildServiceGroup(BuildContext context) {
|
||||
return _buildGroupCard([
|
||||
_buildMenuRow(
|
||||
icon: Icons.headset_mic_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: '售后服务中心',
|
||||
subtitle: '报修、工单、保修查询',
|
||||
onTap: _todoTap,
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.build_outlined,
|
||||
iconBg: _iconBgOrange,
|
||||
iconColor: _orange,
|
||||
title: '维修保养',
|
||||
subtitle: '保养计划、提醒与维护记录',
|
||||
onTap: _todoTap,
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.menu_book_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: '帮助与操作指南',
|
||||
subtitle: '产品说明书、教程及常见问题',
|
||||
onTap: () => _push(context, const HelpFeedbackPage()),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _buildAccountGroup(BuildContext context) {
|
||||
return _buildGroupCard([
|
||||
_buildMenuRow(
|
||||
icon: Icons.verified_user_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: '账号与安全',
|
||||
subtitle: '邮箱/手机、密码及登录设备',
|
||||
onTap: _todoTap,
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.notifications_none,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: '消息通知',
|
||||
subtitle: '设备、作业、服务及授权消息',
|
||||
// 未读接口暂无,按约定显示「未知」
|
||||
trailingText: '未读未知',
|
||||
onTap: _todoTap,
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.settings_outlined,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: '通用设置',
|
||||
subtitle: '语言、单位、地区及APP偏好',
|
||||
onTap: () => _push(context, const SystemSettingsPage()),
|
||||
),
|
||||
_buildRowDivider(),
|
||||
_buildMenuRow(
|
||||
icon: Icons.info_outline,
|
||||
iconBg: _iconBgBlue,
|
||||
iconColor: _primaryBlue,
|
||||
title: '关于与法律协议',
|
||||
subtitle: 'APP版本、协议和隐私政策',
|
||||
onTap: _todoTap,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _buildMenuRow({
|
||||
required IconData icon,
|
||||
required Color iconBg,
|
||||
required Color iconColor,
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required VoidCallback onTap,
|
||||
String? trailingText,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: iconBg,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(icon, size: 21, color: iconColor),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: _navy,
|
||||
),
|
||||
),
|
||||
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)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRowDivider() {
|
||||
return const Divider(height: 1, thickness: 1, color: _divider, indent: 66);
|
||||
}
|
||||
|
||||
// ===== 底部说明卡(设计稿原文) =====
|
||||
Widget _buildNoteCard() {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(14),
|
||||
decoration: BoxDecoration(
|
||||
color: _noteBg,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: const Text(
|
||||
'设备共享、成员授权、管理员移交与解绑转让沿用「设备」模块已有流程,本模块不重复开发。',
|
||||
style: TextStyle(fontSize: 12.5, color: _subText, height: 1.6),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ===== 退出登录(放在页脚下方) =====
|
||||
Widget _buildLogoutButton(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => _showLogoutDialog(context),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: const SizedBox(
|
||||
width: double.infinity,
|
||||
height: 44,
|
||||
child: Center(
|
||||
child: Text(
|
||||
'退出登录',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFFF53F3F),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _showLogoutDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: const Text('退出登录'),
|
||||
content: const Text('确定要退出登录吗?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: const Text('取消'),
|
||||
),
|
||||
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: const Text('确定'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _push(BuildContext context, Widget page) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => page),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user