fix:靠原型不齐页面

This commit is contained in:
jingyun
2026-06-18 16:53:08 +08:00
parent 35eed6b5b8
commit f42ad566e0
14 changed files with 4013 additions and 569 deletions
File diff suppressed because it is too large Load Diff
@@ -2,12 +2,15 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:url_launcher/url_launcher_string.dart';
import '../../../common/config/app_h5_urls.dart';
import '../../../common/router/app_router.dart';
import '../../../common/widgets/adaptive.dart';
import '../../../common/widgets/prototype_ui.dart';
import '../../auth/application/auth_controller.dart';
import '../../auth/data/auth_models.dart';
import '../../profile/application/profile_settings_controller.dart';
import '../application/profile_settings_controller.dart';
import '../data/profile_models.dart';
class ProfilePage extends ConsumerWidget {
const ProfilePage({super.key});
@@ -25,161 +28,416 @@ class ProfilePage extends ConsumerWidget {
return SafeArea(
top: false,
child: ListView(
padding: const EdgeInsets.fromLTRB(18, 18, 18, 24),
padding: const EdgeInsets.fromLTRB(0, 8, 0, 86),
children: [
Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: Adaptive.contentMaxWidth,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_Card(
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
currentUser?.nickname ?? '未登录',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w700,
color: cs.foreground,
),
),
const SizedBox(height: 6),
Text(
currentUser?.phone ?? '登录后可使用本地同步、云备份占位和账户管理。',
style: TextStyle(color: cs.mutedForeground),
),
],
),
PrototypeFrame(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
'我的',
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
const SizedBox(height: 14),
PrototypeCard(
child: Row(
children: [
Container(
width: 46,
height: 46,
decoration: BoxDecoration(
color: const Color(0xFFF1EFE9),
borderRadius: BorderRadius.circular(999),
),
FilledButton(
onPressed: () => context.push(AppRoutes.settings),
child: const Text('设置'),
child: const Icon(
Icons.person_outline,
color: Color(0xFF9A968D),
),
],
),
),
const SizedBox(height: 12),
_Card(
child: Column(
children: [
_SettingRow(
label: '隐藏金额',
value: settings.amountHidden ? '已隐藏' : '显示中',
trailing: Switch(
value: settings.amountHidden,
onChanged: (_) => ref
.read(
profileSettingsControllerProvider.notifier,
)
.toggleAmountHidden(),
),
),
_SettingRow(
label: '回收折扣',
value:
'${(settings.recycleDiscounts.values.first * 100).toStringAsFixed(0)}%',
),
_SettingRow(
label: '涨跌颜色',
value: settings.priceColorMode.label,
),
_SettingRow(
label: '纯度系数',
value: '${settings.purityPresets.length}',
),
],
),
),
const SizedBox(height: 12),
_Card(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
FilledButton.tonal(
onPressed: loggedIn
? () => context.push(AppRoutes.login)
: () => context.push(AppRoutes.login),
child: Text(loggedIn ? '切换账号' : '去登录'),
),
const SizedBox(height: 10),
OutlinedButton(
onPressed: () => context.push(AppRoutes.settings),
child: const Text('打开设置'),
),
],
),
),
const SizedBox(height: 12),
_Card(
child: Text(
'风险提示 · 数据来源 · 免责\n价格、资讯与估值均为本地 mock 数据,仅用于产品原型验证,不构成投资建议。',
style: TextStyle(
color: cs.mutedForeground,
height: 1.6,
fontSize: 13,
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
currentUser?.nickname ?? '未登录',
style: const TextStyle(
fontSize: 15,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
Text(
currentUser?.phone ?? '登录后可云备份、多端同步',
style: TextStyle(
fontSize: 12,
color: cs.mutedForeground,
),
),
],
),
),
if (!loggedIn)
FilledButton(
onPressed: () => context.push(AppRoutes.login),
style: FilledButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 10,
),
minimumSize: Size.zero,
),
child: Text('登录'),
),
],
),
),
const SizedBox(height: 12),
PrototypeCard(
padding: EdgeInsets.zero,
child: Column(
children: [
_MenuRow(
title: '邀请好友,各得奖励',
subtitle: '需登录',
icon: Icons.card_giftcard_outlined,
backgroundColor: const Color(0xFFF6ECD6),
iconColor: const Color(0xFFB5862A),
onTap: () => _showInviteSheet(context),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_MenuRow(
title: '分享我的贵金属估值卡',
subtitle: '免登录 · 自动打码金额',
icon: Icons.share_outlined,
backgroundColor: const Color(0xFFEAF1FF),
iconColor: const Color(0xFF4F7DD1),
onTap: () =>
_showShareCardSheet(context, currentUser?.nickname),
),
],
),
),
const SizedBox(height: 12),
PrototypeCard(
padding: EdgeInsets.zero,
child: Column(
children: [
_SettingRow(
icon: Icons.download_outlined,
title: '本地导出备份',
trailing: '导出',
onTap: () => _showLocalBackupSheet(context),
backgroundColor: const Color(0xFFF3EFE7),
iconColor: const Color(0xFF8A8780),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_SettingRow(
icon: Icons.cloud_outlined,
title: '云备份 · 多端同步',
trailing: loggedIn ? '已登录' : '登录解锁',
onTap: () => _showCloudBackupSheet(context, loggedIn),
backgroundColor: const Color(0xFFEAF2ED),
iconColor: const Color(0xFF5E8E75),
),
],
),
),
const SizedBox(height: 12),
PrototypeCard(
padding: EdgeInsets.zero,
child: Column(
children: [
_SettingRow(
icon: Icons.grid_view_outlined,
title: '添加桌面小组件',
trailing: '占位',
onTap: () => _showWidgetSheet(context),
backgroundColor: const Color(0xFFF6ECD6),
iconColor: const Color(0xFFB5862A),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_SettingRow(
icon: Icons.tune_outlined,
title: '纯度系数管理',
trailing: '${settings.purityPresets.length}',
onTap: () => _showPuritySheet(context, settings),
backgroundColor: const Color(0xFFF4EAF8),
iconColor: const Color(0xFF8A5CBF),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_SettingRow(
icon: Icons.percent_outlined,
title: '回收折扣设置',
trailing:
'${(settings.recycleDiscounts.values.first * 100).toStringAsFixed(0)}%',
onTap: () => _showRecycleSheet(context, settings),
backgroundColor: const Color(0xFFF8EFE0),
iconColor: const Color(0xFFB07A32),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_SettingRow(
icon: Icons.palette_outlined,
title: '涨跌颜色',
trailing: settings.priceColorMode.label,
onTap: () => _showPriceColorSheet(context, ref),
backgroundColor: const Color(0xFFE9F3F1),
iconColor: const Color(0xFF4E8B7B),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_SettingRow(
icon: Icons.currency_yen_outlined,
title: '显示币种',
trailing: '¥ CNY',
onTap: () => _showCurrencySheet(context),
backgroundColor: const Color(0xFFF1EFE9),
iconColor: const Color(0xFF7F7A73),
),
],
),
),
const SizedBox(height: 12),
PrototypeCard(
padding: EdgeInsets.zero,
child: Column(
children: [
_SettingRow(
icon: Icons.settings,
title: '设置',
trailing: null,
onTap: () => context.push(AppRoutes.settings),
backgroundColor: const Color(0xFFF1EFE9),
iconColor: const Color(0xFF7F7A73),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_SettingRow(
icon: Icons.privacy_tip_outlined,
title: '隐私政策 · 用户协议',
trailing: null,
onTap: () => launchUrlString(
AppH5UrlsHelper.withCacheBuster(
AppH5Urls.userProtocolUrl,
),
mode: LaunchMode.inAppBrowserView,
),
backgroundColor: const Color(0xFFF1EFE9),
iconColor: const Color(0xFF7F7A73),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_SettingRow(
icon: Icons.info_outline,
title: '免责声明 · 数据来源',
trailing: null,
onTap: () => _showDisclaimer(context),
backgroundColor: const Color(0xFFF7F0E2),
iconColor: const Color(0xFFB07A32),
),
const PrototypeDivider(margin: EdgeInsets.zero),
_SettingRow(
icon: Icons.feedback_outlined,
title: '意见反馈 · 关于金值',
trailing: null,
onTap: () => _showAbout(context),
backgroundColor: const Color(0xFFEAF1FF),
iconColor: const Color(0xFF4F7DD1),
),
],
),
),
const SizedBox(height: 14),
PrototypeCard(
child: Text(
'风险提示 · 数据来源 · 免责\n金值是贵金属资产记录与估值工具,所有信息不构成投资建议。\n· 行情 / 兑换价格均为参考,标注来源与更新时间,实际以交易系统 / 门店为准。\n· 材料价值 = 克重 × 纯度系数 × 上海金现货,非金店零售价(含工费 / 品牌溢价)、非回收实收价。\n· 资讯为信息整理,非投资建议;历史走势不代表未来。',
style: TextStyle(
color: cs.mutedForeground,
height: 1.7,
fontSize: 12,
),
),
),
],
),
),
],
),
);
}
void _showDisclaimer(BuildContext context) {
context.push(AppRoutes.profileDisclaimer);
}
Future<void> _showInviteSheet(BuildContext context) async {
context.push(AppRoutes.profileInvite);
}
Future<void> _showShareCardSheet(
BuildContext context,
String? nickname,
) async {
context.push(AppRoutes.profileShare);
}
Future<void> _showLocalBackupSheet(BuildContext context) async {
context.push(AppRoutes.profileLocalBackup);
}
Future<void> _showCloudBackupSheet(
BuildContext context,
bool loggedIn,
) async {
context.push(AppRoutes.profileCloudBackup);
}
Future<void> _showWidgetSheet(BuildContext context) async {
context.push(AppRoutes.profileWidget);
}
Future<void> _showPriceColorSheet(BuildContext context, WidgetRef ref) async {
context.push(AppRoutes.profilePriceColor);
}
Future<void> _showPuritySheet(
BuildContext context,
ProfileSettings settings,
) async {
context.push(AppRoutes.profilePurity);
}
Future<void> _showRecycleSheet(
BuildContext context,
ProfileSettings settings,
) async {
context.push(AppRoutes.profileRecycle);
}
Future<void> _showCurrencySheet(BuildContext context) async {
context.push(AppRoutes.profileCurrency);
}
void _showAbout(BuildContext context) {
context.push(AppRoutes.profileAbout);
}
}
class _MenuRow extends StatelessWidget {
const _MenuRow({
required this.title,
required this.subtitle,
required this.icon,
required this.backgroundColor,
required this.iconColor,
required this.onTap,
});
final String title;
final String subtitle;
final IconData icon;
final Color backgroundColor;
final Color iconColor;
final VoidCallback onTap;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Row(
children: [
Container(
width: 34,
height: 34,
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.circular(10),
),
child: Icon(icon, size: 18, color: iconColor),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 4),
Text(
subtitle,
style: TextStyle(fontSize: 12, color: cs.mutedForeground),
),
],
),
),
),
],
Icon(Icons.chevron_right, size: 16, color: cs.mutedForeground),
],
),
),
);
}
}
class _SettingRow extends StatelessWidget {
const _SettingRow({required this.label, required this.value, this.trailing});
const _SettingRow({
required this.icon,
required this.title,
required this.onTap,
required this.backgroundColor,
required this.iconColor,
this.trailing,
});
final String label;
final String value;
final Widget? trailing;
final IconData icon;
final String title;
final String? trailing;
final VoidCallback onTap;
final Color backgroundColor;
final Color iconColor;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Row(
children: [
Expanded(
child: Text(
label,
style: TextStyle(fontSize: 15, color: cs.foreground),
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Row(
children: [
Container(
width: 34,
height: 34,
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.circular(10),
),
child: Icon(icon, size: 18, color: iconColor),
),
),
Text(value, style: TextStyle(color: cs.mutedForeground)),
if (trailing != null) ...[const SizedBox(width: 8), trailing!],
],
const SizedBox(width: 12),
Expanded(
child: Text(
title,
style: const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
),
),
),
if (trailing != null)
Text(
trailing!,
style: TextStyle(fontSize: 12, color: cs.mutedForeground),
),
const SizedBox(width: 6),
Icon(Icons.chevron_right, size: 16, color: cs.mutedForeground),
],
),
),
);
}
}
class _Card extends StatelessWidget {
const _Card({required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
final cs = ShadTheme.of(context).colorScheme;
return DecoratedBox(
decoration: BoxDecoration(
color: cs.card,
border: Border.all(color: cs.border),
borderRadius: BorderRadius.circular(12),
),
child: Padding(padding: const EdgeInsets.all(16), child: child),
);
}
}