- 新增 PlatformCapabilities 平台能力判断类,统一检测移动端原生插件可用性 - 地图、定位、扫码、相册、拨号、通话录制等入口在桌面端降级为提示 - 系统 UI 配置与 moveTaskToBack 在桌面端跳过,避免插件异常 - 设备信息工具新增 Windows 平台支持,返回 computerName - 百度地图 SDK 初始化增加平台判断,桌面端不再调用 - 新增个人资料编辑页面及路由,从「我的」页头部入口跳转 - 国际化添加 featureUnsupported 提示文案
360 lines
11 KiB
Dart
360 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/platform/platform_capabilities.dart';
|
||
import '../../../core/widgets/feature_ui.dart';
|
||
import '../../../l10n/app_localizations.dart';
|
||
|
||
/// 管理 Tab 内容(特性模块:messages / presentation)。
|
||
///
|
||
/// 对应移动端设计稿的「管理」页:顶部横版菜单(相册/闹钟/联系人/应用 …)
|
||
/// 可点击进入对应子页面,下方为消息列表。底部 Tab 文案为「管理」。
|
||
class MessagesTab extends ConsumerWidget {
|
||
const MessagesTab({super.key});
|
||
|
||
@override
|
||
Widget build(BuildContext context, WidgetRef ref) {
|
||
final l10n = AppLocalizations.of(context);
|
||
|
||
final menus = [
|
||
_Menu(
|
||
emoji: '🖼️',
|
||
color: AppColors.blue,
|
||
label: l10n.menuAlbum,
|
||
route: '/album',
|
||
supported: PlatformCapabilities.photoLibrary,
|
||
),
|
||
_Menu(
|
||
emoji: '⏰',
|
||
color: AppColors.orange,
|
||
label: l10n.menuAlarm,
|
||
route: '/alarm',
|
||
),
|
||
_Menu(
|
||
emoji: '👥',
|
||
color: AppColors.green,
|
||
label: l10n.menuContacts,
|
||
route: '/contacts',
|
||
),
|
||
_Menu(
|
||
emoji: '🧩',
|
||
color: AppColors.purple,
|
||
label: l10n.menuApps,
|
||
route: '/apps',
|
||
),
|
||
_Menu(
|
||
emoji: '📁',
|
||
color: AppColors.teal,
|
||
label: l10n.menuFiles,
|
||
route: '/apps',
|
||
),
|
||
_Menu(
|
||
emoji: '➕',
|
||
color: AppColors.gray,
|
||
label: l10n.menuMore,
|
||
route: null,
|
||
),
|
||
];
|
||
|
||
final messages = [
|
||
_Message(
|
||
emoji: '📱',
|
||
color: AppColors.green,
|
||
title: l10n.msgOnline,
|
||
preview: '我的平板 Pro 已连接办公室 WiFi',
|
||
time: '09:30',
|
||
unread: true,
|
||
badge: 1,
|
||
),
|
||
_Message(
|
||
emoji: '🖼️',
|
||
color: AppColors.blue,
|
||
title: l10n.msgScreenshot,
|
||
preview: '收到 3 张新截图,已存入相册',
|
||
time: '昨天',
|
||
unread: false,
|
||
),
|
||
_Message(
|
||
emoji: '🛠️',
|
||
color: AppColors.purple,
|
||
title: l10n.msgRemote,
|
||
preview: '李工请求对平板进行远程协助',
|
||
time: '昨天',
|
||
unread: true,
|
||
),
|
||
_Message(
|
||
emoji: '🔋',
|
||
color: AppColors.red,
|
||
title: l10n.msgBattery,
|
||
preview: '平板电量低于 20%,请尽快充电',
|
||
time: '周一',
|
||
unread: false,
|
||
),
|
||
_Message(
|
||
emoji: '🔄',
|
||
color: AppColors.teal,
|
||
title: l10n.msgUpdate,
|
||
preview: '平板管家 v3.2.1 已更新完成',
|
||
time: '周一',
|
||
unread: false,
|
||
),
|
||
];
|
||
|
||
return AppPageScaffold(
|
||
navigationBar: CupertinoNavigationBar(
|
||
middle: Text(l10n.manageTitle),
|
||
trailing: Container(
|
||
width: 38,
|
||
height: 38,
|
||
decoration: BoxDecoration(
|
||
color: DarkMode.color(context, AppColors.card),
|
||
borderRadius: BorderRadius.circular(12),
|
||
boxShadow: [
|
||
BoxShadow(
|
||
color: CupertinoColors.black.withValues(alpha: 0.06),
|
||
blurRadius: 8,
|
||
offset: const Offset(0, 2),
|
||
),
|
||
],
|
||
),
|
||
child: Stack(
|
||
children: [
|
||
Center(
|
||
child: Icon(
|
||
CupertinoIcons.bell,
|
||
size: 18,
|
||
color: DarkMode.color(context, AppColors.ink),
|
||
),
|
||
),
|
||
Positioned(
|
||
top: 5,
|
||
right: 7,
|
||
child: Container(
|
||
width: 8,
|
||
height: 8,
|
||
decoration: const BoxDecoration(
|
||
color: AppColors.red,
|
||
shape: BoxShape.circle,
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
child: SafeArea(
|
||
child: ListView(
|
||
padding: const EdgeInsets.only(bottom: 100),
|
||
children: [
|
||
Padding(
|
||
padding: const EdgeInsets.fromLTRB(18, 10, 18, 4),
|
||
child: Text(
|
||
l10n.manageSubtitle,
|
||
style: TextStyle(fontSize: 12, color: DarkMode.color(context, AppColors.sub)),
|
||
),
|
||
),
|
||
// 横版菜单
|
||
SizedBox(
|
||
height: 108,
|
||
child: ListView.separated(
|
||
scrollDirection: Axis.horizontal,
|
||
clipBehavior: Clip.none,
|
||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||
separatorBuilder: (_, _) => const SizedBox(width: 12),
|
||
itemCount: menus.length,
|
||
itemBuilder: (_, i) {
|
||
final m = menus[i];
|
||
// 手势放在整张卡片上并设为 opaque,保证点击卡片任意位置
|
||
// (含图标/文字之外的空白区域)都能进入对应页面。
|
||
return GestureDetector(
|
||
behavior: HitTestBehavior.opaque,
|
||
onTap: m.route == null
|
||
? null
|
||
: () {
|
||
if (!m.supported) {
|
||
PlatformCapabilities.showUnsupported(context);
|
||
return;
|
||
}
|
||
context.push(m.route!);
|
||
},
|
||
child: Container(
|
||
width: 80,
|
||
margin: const EdgeInsets.symmetric(vertical: 8),
|
||
decoration: BoxDecoration(
|
||
color: DarkMode.color(context, AppColors.card),
|
||
borderRadius: BorderRadius.circular(16),
|
||
boxShadow: const [
|
||
BoxShadow(
|
||
color: Color(0x14141E3C),
|
||
blurRadius: 12,
|
||
offset: Offset(0, 4),
|
||
),
|
||
],
|
||
),
|
||
child: IconTile(
|
||
emoji: m.emoji,
|
||
color: m.color,
|
||
label: m.label,
|
||
size: 44,
|
||
iconSize: 22,
|
||
),
|
||
),
|
||
);
|
||
},
|
||
),
|
||
),
|
||
SectionTitle(l10n.tabMessages, action: l10n.msgAllRead),
|
||
CardBox(
|
||
padding: EdgeInsets.zero,
|
||
child: Column(
|
||
children: [
|
||
for (var i = 0; i < messages.length; i++) ...[
|
||
if (i > 0)
|
||
const Padding(
|
||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||
child: AppDivider(),
|
||
),
|
||
_messageRow(context, messages[i]),
|
||
],
|
||
],
|
||
),
|
||
),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _messageRow(BuildContext context, _Message m) => Padding(
|
||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||
child: Row(
|
||
children: [
|
||
Stack(
|
||
clipBehavior: Clip.none,
|
||
children: [
|
||
Container(
|
||
width: 44,
|
||
height: 44,
|
||
decoration: BoxDecoration(
|
||
color: m.color,
|
||
borderRadius: BorderRadius.circular(14),
|
||
),
|
||
child: Center(
|
||
child: Text(m.emoji, style: const TextStyle(fontSize: 19)),
|
||
),
|
||
),
|
||
if (m.badge != null)
|
||
Positioned(
|
||
top: -4,
|
||
right: -4,
|
||
child: Container(
|
||
constraints: const BoxConstraints(minWidth: 17),
|
||
height: 17,
|
||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||
decoration: BoxDecoration(
|
||
color: AppColors.red,
|
||
borderRadius: BorderRadius.circular(9),
|
||
),
|
||
child: Center(
|
||
child: Text(
|
||
'${m.badge}',
|
||
style: const TextStyle(
|
||
fontSize: 10,
|
||
color: CupertinoColors.white,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
const SizedBox(width: 12),
|
||
Expanded(
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Row(
|
||
children: [
|
||
Text(
|
||
m.title,
|
||
style: TextStyle(
|
||
fontSize: 14.5,
|
||
fontWeight: FontWeight.w600,
|
||
color: DarkMode.color(context, AppColors.ink),
|
||
),
|
||
),
|
||
const Spacer(),
|
||
Text(
|
||
m.time,
|
||
style: TextStyle(fontSize: 11, color: DarkMode.color(context, AppColors.sub)),
|
||
),
|
||
],
|
||
),
|
||
const SizedBox(height: 3),
|
||
Text(
|
||
m.preview,
|
||
style: TextStyle(fontSize: 12.5, color: DarkMode.color(context, AppColors.sub)),
|
||
maxLines: 1,
|
||
overflow: TextOverflow.ellipsis,
|
||
),
|
||
],
|
||
),
|
||
),
|
||
if (m.unread)
|
||
const Padding(
|
||
padding: EdgeInsets.only(left: 8),
|
||
child: SizedBox(
|
||
width: 9,
|
||
height: 9,
|
||
child: DecoratedBox(
|
||
decoration: BoxDecoration(
|
||
color: AppColors.red,
|
||
shape: BoxShape.circle,
|
||
),
|
||
),
|
||
),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
class _Menu {
|
||
const _Menu({
|
||
required this.emoji,
|
||
required this.color,
|
||
required this.label,
|
||
this.route,
|
||
this.supported = true,
|
||
});
|
||
final String emoji;
|
||
final Color color;
|
||
final String label;
|
||
final String? route;
|
||
|
||
/// 当前平台是否具备该入口依赖的原生能力。
|
||
final bool supported;
|
||
}
|
||
|
||
class _Message {
|
||
const _Message({
|
||
required this.emoji,
|
||
required this.color,
|
||
required this.title,
|
||
required this.preview,
|
||
required this.time,
|
||
required this.unread,
|
||
this.badge,
|
||
});
|
||
final String emoji;
|
||
final Color color;
|
||
final String title;
|
||
final String preview;
|
||
final String time;
|
||
final bool unread;
|
||
final int? badge;
|
||
}
|