- 新增 PlatformCapabilities 平台能力判断类,统一检测移动端原生插件可用性 - 地图、定位、扫码、相册、拨号、通话录制等入口在桌面端降级为提示 - 系统 UI 配置与 moveTaskToBack 在桌面端跳过,避免插件异常 - 设备信息工具新增 Windows 平台支持,返回 computerName - 百度地图 SDK 初始化增加平台判断,桌面端不再调用 - 新增个人资料编辑页面及路由,从「我的」页头部入口跳转 - 国际化添加 featureUnsupported 提示文案
283 lines
11 KiB
Dart
283 lines
11 KiB
Dart
import 'package:cupertino_ui/cupertino_ui.dart';
|
||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||
import 'package:go_router/go_router.dart';
|
||
import 'package:ttstd_family_care/app/theme/dark_mode.dart';
|
||
import 'package:ttstd_family_care/core/widgets/app_page_scaffold.dart';
|
||
|
||
import '../../../core/widgets/feature_ui.dart';
|
||
import '../../../features/device/data/device_providers.dart';
|
||
import '../../../features/device/domain/device_models.dart';
|
||
import '../../../l10n/app_localizations.dart';
|
||
import '../../auth/presentation/auth_controller.dart';
|
||
|
||
/// 我的 Tab 内容(特性模块:profile / presentation)。
|
||
///
|
||
/// 对应移动端设计稿的「我的」页:个人资料头部、绑定设备、
|
||
/// 个人资料、设置列表与退出登录。登出委托给 authController。
|
||
class ProfileTab extends ConsumerWidget {
|
||
const ProfileTab({super.key});
|
||
|
||
@override
|
||
Widget build(BuildContext context, WidgetRef ref) {
|
||
final l10n = AppLocalizations.of(context);
|
||
|
||
return AppPageScaffold(
|
||
child: SafeArea(
|
||
child: ListView(
|
||
padding: const EdgeInsets.only(bottom: 96),
|
||
children: [
|
||
// 个人资料头部卡片
|
||
CardBox(
|
||
padding: const EdgeInsets.all(18),
|
||
child: Row(
|
||
children: [
|
||
Container(
|
||
width: 58,
|
||
height: 58,
|
||
decoration: const BoxDecoration(
|
||
shape: BoxShape.circle,
|
||
gradient: LinearGradient(
|
||
colors: [AppColors.green, AppColors.blue],
|
||
begin: Alignment.topLeft,
|
||
end: Alignment.bottomRight,
|
||
),
|
||
),
|
||
child: const Center(
|
||
child: Text('U',
|
||
style: TextStyle(
|
||
fontSize: 24,
|
||
fontWeight: FontWeight.w700,
|
||
color: CupertinoColors.white)),
|
||
),
|
||
),
|
||
const SizedBox(width: 14),
|
||
Expanded(
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text('用户名',
|
||
style: TextStyle(
|
||
fontSize: 17,
|
||
fontWeight: FontWeight.w700,
|
||
color: DarkMode.color(context, AppColors.ink))),
|
||
const SizedBox(height: 4),
|
||
Text('ID: u_8821 · 平板管家 Pro',
|
||
style: TextStyle(
|
||
fontSize: 12.5,
|
||
color: DarkMode.color(context, AppColors.sub))),
|
||
],
|
||
),
|
||
),
|
||
GestureDetector(
|
||
onTap: () => context.push('/profile/edit'),
|
||
child: Container(
|
||
padding:
|
||
const EdgeInsets.symmetric(horizontal: 14, vertical: 7),
|
||
decoration: BoxDecoration(
|
||
color: AppColors.green.withValues(alpha: 0.12),
|
||
borderRadius: BorderRadius.circular(20),
|
||
),
|
||
child: Text(l10n.profileEdit,
|
||
style: const TextStyle(
|
||
fontSize: 12.5,
|
||
fontWeight: FontWeight.w600,
|
||
color: AppColors.green)),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
|
||
SectionTitle(
|
||
l10n.deviceBound,
|
||
action: l10n.deviceManage,
|
||
onAction: () => context.push('/device/manage'),
|
||
),
|
||
_boundDeviceCard(context, ref, l10n),
|
||
|
||
SectionTitle(l10n.settingsTitle),
|
||
CardBox(
|
||
padding: EdgeInsets.zero,
|
||
child: Column(
|
||
children: [
|
||
_settingRow(context, '🔔', AppColors.teal, l10n.setNotify, '消息、设备状态提醒'),
|
||
const AppDivider(),
|
||
_settingRow(context, '🔒', const Color(0xFF22C55E), l10n.setPrivacy, '定位、相册、权限管理'),
|
||
const AppDivider(),
|
||
_settingRow(context, '🛡️', AppColors.red, l10n.setSecurity, '登录设备、密码',
|
||
onTap: () => context.push('/security')),
|
||
const AppDivider(),
|
||
_settingRow(context, '❓', AppColors.gray, l10n.setHelp, null),
|
||
const AppDivider(),
|
||
_settingRow(context, 'ℹ️', const Color(0xFF64748B), l10n.setAbout, '平板管家 v3.2.1'),
|
||
],
|
||
),
|
||
),
|
||
|
||
GestureDetector(
|
||
onTap: () {
|
||
ref.read(authControllerProvider.notifier).logout();
|
||
context.go('/login');
|
||
},
|
||
child: Container(
|
||
margin: const EdgeInsets.fromLTRB(16, 18, 16, 0),
|
||
height: 48,
|
||
decoration: BoxDecoration(
|
||
color: DarkMode.color(context, AppColors.card),
|
||
borderRadius: BorderRadius.circular(14),
|
||
boxShadow: const [
|
||
BoxShadow(color: Color(0x14141E3C), blurRadius: 16, offset: Offset(0, 4)),
|
||
],
|
||
),
|
||
child: Center(
|
||
child: Text(
|
||
l10n.logout,
|
||
style: TextStyle(
|
||
fontSize: 15,
|
||
fontWeight: FontWeight.w700,
|
||
color: DarkMode.tone(
|
||
context,
|
||
AppColors.red,
|
||
const Color(0xFFFF8A94),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _boundDeviceCard(
|
||
BuildContext context, WidgetRef ref, AppLocalizations l10n) {
|
||
final devicesAsync = ref.watch(myDevicesProvider);
|
||
final device = ref.watch(currentDeviceProvider);
|
||
return CardBox(
|
||
padding: EdgeInsets.zero,
|
||
gradient: const LinearGradient(
|
||
colors: [Color(0xFFEEF6FF), Color(0xFFF3FBF6)],
|
||
begin: Alignment.topLeft,
|
||
end: Alignment.bottomRight,
|
||
),
|
||
child: devicesAsync.when(
|
||
loading: () => const Padding(
|
||
padding: EdgeInsets.symmetric(vertical: 24),
|
||
child: Center(child: CupertinoActivityIndicator()),
|
||
),
|
||
error: (e, _) => Padding(
|
||
padding: const EdgeInsets.all(16),
|
||
child: Text('${l10n.deviceLoadFailed}:$e',
|
||
style: TextStyle(fontSize: 12, color: DarkMode.color(context, AppColors.sub))),
|
||
),
|
||
data: (_) {
|
||
if (device == null) {
|
||
// 无绑定设备时也可点击进入设备管理页添加设备。
|
||
return GestureDetector(
|
||
behavior: HitTestBehavior.opaque,
|
||
onTap: () => context.push('/device/manage'),
|
||
child: Padding(
|
||
padding: const EdgeInsets.all(16),
|
||
child: Row(
|
||
children: [
|
||
Expanded(
|
||
child: Text(l10n.deviceNone,
|
||
style: TextStyle(fontSize: 13, color: DarkMode.color(context, AppColors.sub))),
|
||
),
|
||
Text('${l10n.deviceManageAdd} ›',
|
||
style: const TextStyle(fontSize: 13, color: AppColors.green)),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
return GestureDetector(
|
||
behavior: HitTestBehavior.opaque,
|
||
onTap: () => context.push('/device/manage'),
|
||
child: _deviceCard(context, device, l10n),
|
||
);
|
||
},
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _deviceCard(BuildContext context, DeviceBrief device, AppLocalizations l10n) {
|
||
final status = device.isOnline ? l10n.deviceOnline : l10n.deviceOffline;
|
||
final sub = device.snModel?.isNotEmpty == true
|
||
? '$status · ${device.snModel}'
|
||
: status;
|
||
return _deviceRow(context, '📱',
|
||
device.isOnline ? AppColors.green : DarkMode.color(context, AppColors.track),
|
||
device.snName?.isNotEmpty == true ? device.snName! : device.serialno, sub,
|
||
l10n.deviceManage);
|
||
}
|
||
|
||
Widget _deviceRow(BuildContext context, String emoji, Color color, String title, String sub, String? action) => Padding(
|
||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||
child: Row(
|
||
children: [
|
||
Container(
|
||
width: 36,
|
||
height: 36,
|
||
decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(11)),
|
||
child: Center(child: Text(emoji, style: const TextStyle(fontSize: 17))),
|
||
),
|
||
const SizedBox(width: 12),
|
||
Expanded(
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text(title, style: TextStyle(fontSize: 14.5, fontWeight: FontWeight.w600, color: DarkMode.color(context, AppColors.ink))),
|
||
const SizedBox(height: 2),
|
||
Text(sub, style: TextStyle(fontSize: 12, color: DarkMode.color(context, AppColors.sub))),
|
||
],
|
||
),
|
||
),
|
||
if (action != null)
|
||
Text('$action ›', style: TextStyle(fontSize: 13, color: DarkMode.color(context, AppColors.sub)))
|
||
else
|
||
const Text('›', style: TextStyle(fontSize: 16, color: Color(0xFFCBD2DC))),
|
||
],
|
||
),
|
||
);
|
||
|
||
Widget _settingRow(BuildContext context, String emoji, Color color, String label, String? sub,
|
||
{VoidCallback? onTap}) {
|
||
final row = Padding(
|
||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 13),
|
||
child: Row(
|
||
children: [
|
||
Container(
|
||
width: 36,
|
||
height: 36,
|
||
decoration: BoxDecoration(color: color, borderRadius: BorderRadius.circular(11)),
|
||
child: Center(child: Text(emoji, style: const TextStyle(fontSize: 17))),
|
||
),
|
||
const SizedBox(width: 12),
|
||
Expanded(
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text(label, style: TextStyle(fontSize: 14.5, fontWeight: FontWeight.w600, color: DarkMode.color(context, AppColors.ink))),
|
||
if (sub != null) ...[
|
||
const SizedBox(height: 2),
|
||
Text(sub, style: TextStyle(fontSize: 12, color: DarkMode.color(context, AppColors.sub))),
|
||
],
|
||
],
|
||
),
|
||
),
|
||
const Text('›', style: TextStyle(fontSize: 16, color: Color(0xFFCBD2DC))),
|
||
],
|
||
),
|
||
);
|
||
if (onTap == null) return row;
|
||
return GestureDetector(
|
||
behavior: HitTestBehavior.opaque,
|
||
onTap: onTap,
|
||
child: row,
|
||
);
|
||
}
|
||
}
|