diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 005abcd..836c4a3 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -26,6 +26,10 @@ + + + + diff --git a/android/app/src/main/java/com/ttstd/familycare/MainActivity.java b/android/app/src/main/java/com/ttstd/familycare/MainActivity.java index 80c18ed..89e5b6c 100644 --- a/android/app/src/main/java/com/ttstd/familycare/MainActivity.java +++ b/android/app/src/main/java/com/ttstd/familycare/MainActivity.java @@ -1,5 +1,8 @@ package com.ttstd.familycare; +import android.content.Intent; +import android.net.Uri; + import androidx.annotation.NonNull; import io.flutter.embedding.android.FlutterActivity; import io.flutter.embedding.engine.FlutterEngine; @@ -18,6 +21,23 @@ public class MainActivity extends FlutterActivity { // 将应用退到后台而不销毁 Engine,实现热启动优化 moveTaskToBack(false); result.success(true); + } else if (call.method.equals("dialPhone")) { + // 打开系统拨号盘拨打指定号码(ACTION_DIAL 无需拨号权限) + String phone = call.argument("phone"); + if (phone == null || phone.isEmpty()) { + result.error("INVALID_PHONE", "电话号码为空", null); + return; + } + try { + Intent intent = new Intent( + Intent.ACTION_DIAL, + Uri.parse("tel:" + Uri.encode(phone))); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + result.success(true); + } catch (Exception e) { + result.error("DIAL_FAILED", e.getMessage(), null); + } } else { result.notImplemented(); } diff --git a/android/build/reports/problems/problems-report.html b/android/build/reports/problems/problems-report.html new file mode 100644 index 0000000..1c1eecb --- /dev/null +++ b/android/build/reports/problems/problems-report.html @@ -0,0 +1,663 @@ + + + + + + + + + + + + + Gradle Configuration Cache + + + +
+ +
+ Loading... +
+ + + + + + diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index 774b49e..bead1a0 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -27,7 +27,7 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" id("com.android.application") version "8.11.1" apply false - id("org.jetbrains.kotlin.android") version "2.2.20" apply false + id("org.jetbrains.kotlin.android") version "2.3.20" apply false } include(":app") diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index c30b367..07abfef 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -12,5 +12,33 @@ import UIKit func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) { GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry) + // 拨号 MethodChannel:与 Android 侧保持一致(com.ttstd.familycare/app) + guard let registrar = engineBridge.pluginRegistry.registrar(forPlugin: "PhoneDialer") else { + return + } + let channel = FlutterMethodChannel( + name: "com.ttstd.familycare/app", + binaryMessenger: registrar.messenger() + ) + channel.setMethodCallHandler { call, result in + if call.method == "dialPhone" { + guard let args = call.arguments as? [String: Any], + let phone = args["phone"] as? String else { + result(FlutterError(code: "INVALID_PHONE", message: "电话号码为空", details: nil)) + return + } + // 仅保留数字与 +,避免空格/括号等字符导致 URL 解析失败 + let cleaned = phone.filter { $0.isNumber || $0 == "+" } + guard !cleaned.isEmpty, let url = URL(string: "tel:\(cleaned)") else { + result(FlutterError(code: "INVALID_PHONE", message: "电话号码为空", details: nil)) + return + } + UIApplication.shared.open(url) { success in + result(success) + } + } else { + result(FlutterMethodNotImplemented) + } + } } } diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 9cdc51a..e7ccb67 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -80,7 +80,7 @@ NSCameraUsageDescription 用于扫描设备二维码完成绑定 NSPhotoLibraryUsageDescription - 用于从相册选取二维码图片完成设备绑定 + 用于查看本机相册照片并按文件夹浏览,以及从相册选取二维码图片完成设备绑定 io.flutter.embedded_views_preview diff --git a/lib/app/app.dart b/lib/app/app.dart index 445d64d..07cbaba 100644 --- a/lib/app/app.dart +++ b/lib/app/app.dart @@ -2,6 +2,9 @@ import 'package:cupertino_ui/cupertino_ui.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; +// GlobalMaterialLocalizations 须用 material_ui 自带的(vendored 框架副本), +// 若整体导入 flutter_localizations 会与 material_ui 导出的同名类冲突。 +import 'package:material_ui/material_ui.dart' show GlobalMaterialLocalizations; import '../l10n/app_localizations.dart'; import 'theme/app_theme.dart'; @@ -28,6 +31,9 @@ class App extends StatelessWidget { // cupertino_ui 的 delegate,否则 CupertinoTabBar 等组件会在运行时 // 抛 "could not find a CupertinoLocalizations ancestor" 异常。 ...GlobalCupertinoLocalizations.delegates, + // easy_image_viewer 的关闭按钮使用 Material Tooltip,需要 + // MaterialLocalizations 兜底(用 material_ui 自带的多语言副本)。 + GlobalMaterialLocalizations.delegate, ], supportedLocales: AppLocalizations.supportedLocales, debugShowCheckedModeBanner: false, diff --git a/lib/app/router/app_router.dart b/lib/app/router/app_router.dart index 51a1ab0..6e08d23 100644 --- a/lib/app/router/app_router.dart +++ b/lib/app/router/app_router.dart @@ -11,12 +11,15 @@ import '../../features/home/presentation/home_page.dart'; import '../../features/home/presentation/home_tab.dart'; import '../../features/home/presentation/map_page.dart'; import '../../features/home/presentation/screenshot_page.dart'; +import '../../features/home/presentation/system_settings_page.dart'; +import '../../features/home/presentation/wallpaper_page.dart'; import '../../features/messages/presentation/messages_tab.dart'; import '../../features/profile/presentation/profile_tab.dart'; import '../../features/album/presentation/album_page.dart'; import '../../features/alarm/presentation/alarm_page.dart'; +import '../../features/alarm/presentation/alarm_edit_page.dart'; +import '../../features/alarm/domain/alarm_models.dart'; import '../../features/contacts/presentation/contacts_page.dart'; -import '../../features/contacts/presentation/contact_detail_page.dart'; import '../../features/contacts/presentation/contact_edit_page.dart'; import '../../features/contacts/domain/contact_models.dart'; import '../../features/apps/presentation/apps_page.dart'; @@ -74,16 +77,14 @@ GoRouter buildAppRouter() { builder: (context, state) => const AlarmPage(), ), GoRoute( - path: '/contacts', - builder: (context, state) => const ContactsPage(), + path: '/alarm/edit', + builder: (context, state) => AlarmEditPage( + alarm: state.extra is AlarmModel ? state.extra as AlarmModel : null, + ), ), GoRoute( - path: '/contacts/detail', - builder: (context, state) => ContactDetailPage( - contact: state.extra is Contact - ? state.extra as Contact - : const Contact(id: 0, name: '', phoneNumber: ''), - ), + path: '/contacts', + builder: (context, state) => const ContactsPage(), ), GoRoute( path: '/contacts/edit', @@ -145,6 +146,14 @@ GoRouter buildAppRouter() { path: '/connection', builder: (context, state) => _RemoteControlRoute(), ), + GoRoute( + path: '/settings', + builder: (context, state) => const SystemSettingsPage(), + ), + GoRoute( + path: '/wallpaper', + builder: (context, state) => const WallpaperPage(), + ), StatefulShellRoute.indexedStack( builder: (context, state, shell) => HomePage(child: shell), branches: [ diff --git a/lib/core/network/dio_client.dart b/lib/core/network/dio_client.dart index d84343d..54b6210 100644 --- a/lib/core/network/dio_client.dart +++ b/lib/core/network/dio_client.dart @@ -107,7 +107,7 @@ class DioClient { try { // 对接 open 模块刷新接口,路径需带 v1/open/ 前缀。 final response = await _refreshDio.post( - 'v1/open/refresh-token', + 'v1/open/auth/refresh-token', queryParameters: {'refreshToken': refreshToken}, ); debugPrint('[DioClient] _refreshToken: response status=${response.statusCode} body=${response.data}'); @@ -155,6 +155,25 @@ class DioClient { }) => _request(() => instance.put(path, data: data)); + /// 统一 POST 请求(multipart 文件上传),返回解析后的 data。 + static Future postMultipart( + String path, { + required FormData formData, + Map? queryParameters, + }) => + _request(() => instance.post( + path, + data: formData, + queryParameters: queryParameters, + )); + + /// 下载静态资源文件到本地路径(图片等二进制内容,不走 JSON 业务解析)。 + /// + /// [url] 支持相对路径(如 `/static/wallpaper/xxx.jpg`),会基于 baseUrl 拼接。 + static Future downloadToFile(String url, String savePath) async { + await instance.download(url, savePath); + } + /// 统一 DELETE 请求,返回解析后的 data。 static Future delete(String path) => _request(() => instance.delete(path)); @@ -252,7 +271,11 @@ class _AuthInterceptor extends Interceptor { class _ResponseInterceptor extends Interceptor { /// 解析响应体,提取 data 字段;code != "00000" 时抛出业务错误。 static dynamic parse(Response response) { - final body = response.data as Map?; + // 下载等场景响应体可能是二进制(ResponseBody 等),先做类型判定再强转, + // 避免对非 JSON 数据直接 `as Map` 抛 TypeError。 + final body = response.data is Map + ? response.data as Map + : null; if (body == null) { throw const ApiException(code: '-1', message: '响应为空'); } @@ -283,7 +306,9 @@ class _ErrorInterceptor extends Interceptor { void onError(DioException err, ErrorInterceptorHandler handler) { final response = err.response; final statusCode = response?.statusCode; - final body = response?.data as Map?; + // 响应体可能是二进制(ResponseBody 等),先类型判定再取业务码,避免强转抛错。 + final data = response?.data; + final body = data is Map ? data : null; final code = body?['code']?.toString(); // 访问权限异常(A0300):通常意味着当前令牌的端标识不符(如旧令牌未携带 diff --git a/lib/core/utils/phone_call_util.dart b/lib/core/utils/phone_call_util.dart new file mode 100644 index 0000000..399f2ed --- /dev/null +++ b/lib/core/utils/phone_call_util.dart @@ -0,0 +1,27 @@ +import 'package:flutter/services.dart'; + +/// 拨打电话工具。 +/// +/// 通过原生 MethodChannel(channel 名与系统 UI 工具共用 `com.ttstd.familycare/app`) +/// 调起系统拨号盘: +/// - Android:`Intent.ACTION_DIAL`(`tel:` 号码),无需拨号权限; +/// - iOS:`UIApplication.open` 打开 `tel:` URL,系统弹确认后拨号。 +class PhoneCallUtil { + const PhoneCallUtil._(); + + static const MethodChannel _channel = MethodChannel('com.ttstd.familycare/app'); + + /// 打开系统拨号盘拨打 [phone]。 + /// + /// 成功返回 null;失败返回错误信息(如号码为空、设备无拨号能力)。 + static Future dial(String phone) async { + if (phone.isEmpty) return '电话号码为空'; + try { + final ok = await _channel + .invokeMethod('dialPhone', {'phone': phone}); + return ok == true ? null : '无法打开拨号盘'; + } on PlatformException catch (e) { + return e.message ?? '拨号失败'; + } + } +} diff --git a/lib/core/widgets/settings_ui.dart b/lib/core/widgets/settings_ui.dart index 059ee85..624bc0a 100644 --- a/lib/core/widgets/settings_ui.dart +++ b/lib/core/widgets/settings_ui.dart @@ -107,6 +107,7 @@ class LabeledField extends StatelessWidget { this.maxLength, this.enabled = true, this.suffix, + this.labelTrailing, super.key, }); @@ -121,19 +122,36 @@ class LabeledField extends StatelessWidget { /// 输入框右侧控件(如「获取验证码」按钮)。 final Widget? suffix; + /// 标签右侧的小字提示(如「区分大小写」),可为空。 + final String? labelTrailing; + @override Widget build(BuildContext context) => Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - label, - style: const TextStyle( - fontSize: 12.5, - fontWeight: FontWeight.w600, - color: AppColors.sub, - ), + Row( + children: [ + Text( + label, + style: const TextStyle( + fontSize: 12.5, + fontWeight: FontWeight.w600, + color: AppColors.sub, + ), + ), + if (labelTrailing != null) ...[ + const SizedBox(width: 6), + Text( + labelTrailing!, + style: const TextStyle( + fontSize: 11, + color: AppColors.orange, + ), + ), + ], + ], ), const SizedBox(height: 6), Row( diff --git a/lib/features/alarm/data/alarm_api.dart b/lib/features/alarm/data/alarm_api.dart new file mode 100644 index 0000000..35dbef9 --- /dev/null +++ b/lib/features/alarm/data/alarm_api.dart @@ -0,0 +1,74 @@ +import 'package:cupertino_ui/cupertino_ui.dart'; +import 'package:ttstd_family_care/core/network/api_exception.dart'; +import 'package:ttstd_family_care/core/network/dio_client.dart'; +import 'package:ttstd_family_care/features/alarm/domain/alarm_models.dart'; + +/// 家属端闹钟接口访问层。 +/// +/// 对应后台 `/api/v1/client/sn/alarm`(GET 列表 / POST 新增 / PUT 修改 / DELETE 删除)。 +class AlarmApi { + const AlarmApi(); + + /// 查询设备闹钟列表(按时间升序)。 + Future> getAlarms(String sn) async { + try { + final data = await DioClient.get( + 'v1/client/sn/alarm', + queryParameters: {'sn': sn}, + ); + final list = data is List ? data : const []; + return list + .whereType() + .map((e) => AlarmModel.fromJson( + e.map((k, v) => MapEntry(k.toString(), v)))) + .toList(growable: false); + } on ApiException { + return const []; + } + } + + /// 新增闹钟;成功返回新闹钟 id,失败 [error] 为错误提示。 + Future<({int? id, String? error})> addAlarm(String sn, AlarmModel alarm) async { + try { + final data = await DioClient.post( + 'v1/client/sn/alarm', + queryParameters: {'sn': sn}, + data: alarm.toJson(), + ); + debugPrint('[AlarmApi] addAlarm sn=$sn success, id=$data'); + return (id: data is int ? data : null, error: null); + } on ApiException catch (e) { + debugPrint('[AlarmApi] addAlarm sn=$sn failed: ${e.message}'); + return (id: null, error: e.message); + } + } + + /// 修改闹钟;成功返回 null,失败返回错误提示。 + Future updateAlarm(String sn, AlarmModel alarm) async { + try { + await DioClient.put( + 'v1/client/sn/alarm?sn=${Uri.encodeQueryComponent(sn)}', + data: alarm.toJson(), + ); + debugPrint('[AlarmApi] updateAlarm sn=$sn success, id=${alarm.id}'); + return null; + } on ApiException catch (e) { + debugPrint('[AlarmApi] updateAlarm sn=$sn failed: ${e.message}'); + return e.message; + } + } + + /// 删除闹钟;成功返回 null,失败返回错误提示。 + Future deleteAlarm(String sn, int id) async { + try { + await DioClient.delete( + 'v1/client/sn/alarm?sn=${Uri.encodeQueryComponent(sn)}&id=$id', + ); + debugPrint('[AlarmApi] deleteAlarm sn=$sn id=$id success'); + return null; + } on ApiException catch (e) { + debugPrint('[AlarmApi] deleteAlarm sn=$sn id=$id failed: ${e.message}'); + return e.message; + } + } +} diff --git a/lib/features/alarm/data/alarm_providers.dart b/lib/features/alarm/data/alarm_providers.dart new file mode 100644 index 0000000..f445013 --- /dev/null +++ b/lib/features/alarm/data/alarm_providers.dart @@ -0,0 +1,6 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import 'alarm_api.dart'; + +/// 闹钟接口访问层单例。 +final alarmApiProvider = Provider((ref) => const AlarmApi()); diff --git a/lib/features/alarm/domain/alarm_models.dart b/lib/features/alarm/domain/alarm_models.dart new file mode 100644 index 0000000..9871fb5 --- /dev/null +++ b/lib/features/alarm/domain/alarm_models.dart @@ -0,0 +1,102 @@ +/// 闹钟实体(家属端对接 client 接口,与设备端 Room AlarmInfo 字段对齐)。 +/// +/// 重复类型与设备端一致:0-只响一次 1-每天 2-工作日 3-自定义。 +class AlarmModel { + const AlarmModel({ + this.id, + this.hour = 7, + this.minute = 0, + this.label = '', + this.repeatType = 1, + this.customDays = '', + this.isEnabled = true, + this.vibration = false, + this.volume = 80, + this.ringtoneUri, + this.snoozeInterval = 5, + }); + + /// 闹钟ID(新增时为 null)。 + final int? id; + final int hour; + final int minute; + final String label; + + /// 重复类型:0-只响一次 1-每天 2-工作日 3-自定义。 + final int repeatType; + + /// 自定义星期("2,3,6,7",与设备端 Calendar.MONDAY=2 对齐)。 + final String customDays; + final bool isEnabled; + final bool vibration; + final int volume; + final String? ringtoneUri; + final int snoozeInterval; + + /// 显示用时间字符串(HH:mm)。 + String get timeText => + '${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}'; + + factory AlarmModel.fromJson(Map json) => AlarmModel( + id: _toInt(json['id']), + hour: _toInt(json['hour']) ?? 0, + minute: _toInt(json['minute']) ?? 0, + label: (json['label'] as String?) ?? '', + repeatType: _toInt(json['repeatType']) ?? 1, + customDays: (json['customDays'] as String?) ?? '', + isEnabled: _toInt(json['isEnabled']) == 1, + vibration: _toInt(json['vibration']) == 1, + volume: _toInt(json['volume']) ?? 80, + ringtoneUri: json['ringtoneUri'] as String?, + snoozeInterval: _toInt(json['snoozeInterval']) ?? 5, + ); + + Map toJson() => { + 'id': id, + 'hour': hour, + 'minute': minute, + 'label': label, + 'repeatType': repeatType, + 'customDays': customDays, + 'isEnabled': isEnabled ? 1 : 0, + 'vibration': vibration ? 1 : 0, + 'volume': volume, + 'ringtoneUri': ringtoneUri, + 'snoozeInterval': snoozeInterval, + }; + + AlarmModel copyWith({ + int? id, + int? hour, + int? minute, + String? label, + int? repeatType, + String? customDays, + bool? isEnabled, + bool? vibration, + int? volume, + String? ringtoneUri, + int? snoozeInterval, + }) => + AlarmModel( + id: id ?? this.id, + hour: hour ?? this.hour, + minute: minute ?? this.minute, + label: label ?? this.label, + repeatType: repeatType ?? this.repeatType, + customDays: customDays ?? this.customDays, + isEnabled: isEnabled ?? this.isEnabled, + vibration: vibration ?? this.vibration, + volume: volume ?? this.volume, + ringtoneUri: ringtoneUri ?? this.ringtoneUri, + snoozeInterval: snoozeInterval ?? this.snoozeInterval, + ); +} + +int? _toInt(dynamic value) { + if (value == null) return null; + if (value is int) return value; + if (value is num) return value.toInt(); + if (value is String) return int.tryParse(value); + return null; +} diff --git a/lib/features/alarm/presentation/alarm_edit_page.dart b/lib/features/alarm/presentation/alarm_edit_page.dart new file mode 100644 index 0000000..f1b250d --- /dev/null +++ b/lib/features/alarm/presentation/alarm_edit_page.dart @@ -0,0 +1,259 @@ +import 'package:cupertino_ui/cupertino_ui.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../../core/widgets/feature_ui.dart'; +import '../../../features/alarm/data/alarm_providers.dart'; +import '../../../features/alarm/domain/alarm_models.dart'; +import '../../../features/device/data/device_providers.dart'; +import '../../../l10n/app_localizations.dart'; + +/// 闹钟新增 / 编辑页。 +/// +/// [alarm] 为空表示新增;否则为编辑(可删除)。 +class AlarmEditPage extends ConsumerStatefulWidget { + const AlarmEditPage({super.key, this.alarm}); + + final AlarmModel? alarm; + + @override + ConsumerState createState() => _AlarmEditPageState(); +} + +class _AlarmEditPageState extends ConsumerState { + late int _hour; + late int _minute; + late String _label; + late int _repeatType; + late bool _isEnabled; + bool _saving = false; + + AppLocalizations get _l10n => AppLocalizations.of(context); + + bool get _isEdit => widget.alarm != null; + + @override + void initState() { + super.initState(); + final a = widget.alarm; + _hour = a?.hour ?? 7; + _minute = a?.minute ?? 0; + _label = a?.label ?? ''; + _repeatType = a?.repeatType ?? 1; + _isEnabled = a?.isEnabled ?? true; + } + + Future _save() async { + if (_saving) return; + final l10n = _l10n; + final sn = ref.read(selectedDeviceSnProvider); + if (sn == null || sn.isEmpty) { + _alert(l10n.contactNoDevice); + return; + } + final base = widget.alarm ?? const AlarmModel(); + final alarm = base.copyWith( + hour: _hour, + minute: _minute, + label: _label, + repeatType: _repeatType, + isEnabled: _isEnabled, + ); + setState(() => _saving = true); + final err = _isEdit + ? await ref + .read(alarmApiProvider) + .updateAlarm(sn, alarm) + : (await ref.read(alarmApiProvider).addAlarm(sn, alarm)).error; + if (!mounted) return; + setState(() => _saving = false); + if (err != null) { + _alert(err); + return; + } + context.pop(true); + } + + Future _delete() async { + final l10n = _l10n; + final sn = ref.read(selectedDeviceSnProvider); + final id = widget.alarm?.id; + if (sn == null || sn.isEmpty || id == null) return; + final confirmed = await showCupertinoDialog( + context: context, + builder: (ctx) => CupertinoAlertDialog( + title: Text(l10n.alarmDeleteConfirm), + actions: [ + CupertinoDialogAction( + onPressed: () => Navigator.of(ctx).pop(false), + child: Text(l10n.commonCancel), + ), + CupertinoDialogAction( + isDestructiveAction: true, + onPressed: () => Navigator.of(ctx).pop(true), + child: Text(l10n.commonDelete), + ), + ], + ), + ); + if (confirmed != true || !mounted) return; + final err = await ref.read(alarmApiProvider).deleteAlarm(sn, id); + if (!mounted) return; + if (err != null) { + _alert(err); + return; + } + context.pop(true); + } + + void _alert(String message) { + showCupertinoDialog( + context: context, + builder: (ctx) => CupertinoAlertDialog( + content: Text(message), + actions: [ + CupertinoDialogAction( + onPressed: () => Navigator.of(ctx).pop(), + child: Text(_l10n.commonConfirm), + ), + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + final l10n = _l10n; + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text(_isEdit ? l10n.alarmEditTitle : l10n.addAlarm), + leading: CupertinoButton( + padding: EdgeInsets.zero, + child: const Icon(CupertinoIcons.back), + onPressed: () => context.pop(), + ), + trailing: CupertinoButton( + padding: EdgeInsets.zero, + child: _saving + ? const CupertinoActivityIndicator(radius: 10) + : Text(l10n.commonSave, + style: const TextStyle(fontWeight: FontWeight.w600)), + onPressed: _saving ? null : _save, + ), + ), + child: SafeArea( + top: false, + child: ListView( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 32), + children: [ + // 时间选择器 + CardBox( + padding: const EdgeInsets.all(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(l10n.alarmTime, + style: const TextStyle( + fontSize: 13, + color: AppColors.sub, + fontWeight: FontWeight.w600)), + const SizedBox(height: 8), + SizedBox( + height: 160, + child: CupertinoTimerPicker( + mode: CupertinoTimerPickerMode.hm, + initialTimerDuration: + Duration(hours: _hour, minutes: _minute), + onTimerDurationChanged: (d) { + setState(() { + _hour = d.inHours % 24; + _minute = d.inMinutes % 60; + }); + }, + ), + ), + ], + ), + ), + const SizedBox(height: 12), + // 标签 + CardBox( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: CupertinoTextField( + controller: TextEditingController(text: _label), + placeholder: l10n.alarmLabel, + padding: + const EdgeInsets.symmetric(horizontal: 4, vertical: 14), + onChanged: (v) => _label = v, + ), + ), + const SizedBox(height: 12), + // 重复 + CardBox( + padding: const EdgeInsets.all(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(l10n.alarmRepeat, + style: const TextStyle( + fontSize: 13, + color: AppColors.sub, + fontWeight: FontWeight.w600)), + const SizedBox(height: 10), + CupertinoSegmentedControl( + groupValue: _repeatType == 3 ? 1 : _repeatType, + onValueChanged: (v) => setState(() => _repeatType = v), + children: { + 0: Text(l10n.alarmRepeatOnce), + 1: Text(l10n.alarmRepeatEveryday), + 2: Text(l10n.alarmRepeatWeekdays), + }, + ), + ], + ), + ), + const SizedBox(height: 12), + // 开启 + CardBox( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), + child: Row( + children: [ + Expanded( + child: Text(l10n.alarmEnabled, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: AppColors.ink)), + ), + CupertinoSwitch( + value: _isEnabled, + activeTrackColor: AppColors.green, + onChanged: (v) => setState(() => _isEnabled = v), + ), + ], + ), + ), + if (_isEdit) ...[ + const SizedBox(height: 24), + CupertinoButton( + borderRadius: BorderRadius.circular(14), + color: const Color(0xFFFEE2E2), + pressedOpacity: 0.7, + onPressed: _delete, + child: SizedBox( + width: double.infinity, + child: Center( + child: Text(l10n.alarmDelete, + style: const TextStyle( + color: Color(0xFFDC2626), + fontWeight: FontWeight.w600)), + ), + ), + ), + ], + ], + ), + ), + ); + } +} diff --git a/lib/features/alarm/presentation/alarm_page.dart b/lib/features/alarm/presentation/alarm_page.dart index 82c77d4..e492749 100644 --- a/lib/features/alarm/presentation/alarm_page.dart +++ b/lib/features/alarm/presentation/alarm_page.dart @@ -1,33 +1,116 @@ import 'package:cupertino_ui/cupertino_ui.dart'; import 'package:go_router/go_router.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; import '../../../core/widgets/feature_ui.dart'; +import '../../../features/alarm/data/alarm_providers.dart'; +import '../../../features/alarm/domain/alarm_models.dart'; +import '../../../features/device/data/device_providers.dart'; import '../../../l10n/app_localizations.dart'; +import 'alarm_edit_page.dart'; /// 闹钟页(管理 → 闹钟)。 /// -/// 对应移动端设计稿:多条闹钟卡片,大号时间 + 标签/重复说明 + 开关切换。 -class AlarmPage extends StatefulWidget { +/// 展示设备闹钟列表(后端同步),支持新增 / 编辑 / 删除 / 开关切换; +/// 变更后由后端推送 contentType=25 到设备端覆盖同步。 +class AlarmPage extends ConsumerStatefulWidget { const AlarmPage({super.key}); @override - State createState() => _AlarmPageState(); + ConsumerState createState() => _AlarmPageState(); } -class _AlarmPageState extends State { - final List<_Alarm> _alarms = [ - _Alarm(time: '07:30', am: 'AM', label: '起床', repeat: '工作日 · 响铃 天籁之音', on: true), - _Alarm(time: '12:30', am: 'PM', label: '午休提醒', repeat: '每天 · 振动', on: false), - _Alarm(time: '14:00', am: 'PM', label: '会议纪要', repeat: '仅今天 · 响铃 轻快', on: true), - _Alarm(time: '21:00', am: 'PM', label: '早睡', repeat: '每天 · 渐强铃声', on: true), - _Alarm(time: '08:00', am: 'AM', label: '周末晨练', repeat: '周六、周日 · 响铃 自然', on: false), - ]; +class _AlarmPageState extends ConsumerState { + List _alarms = const []; + bool _loading = true; + + AppLocalizations get _l10n => AppLocalizations.of(context); + + @override + void initState() { + super.initState(); + _loadAlarms(); + } + + Future _loadAlarms() async { + final sn = ref.read(selectedDeviceSnProvider); + if (sn == null || sn.isEmpty) { + if (mounted) { + setState(() { + _alarms = const []; + _loading = false; + }); + } + return; + } + final alarms = await ref.read(alarmApiProvider).getAlarms(sn); + if (!mounted) return; + setState(() { + _alarms = alarms; + _loading = false; + }); + } + + /// 打开新增/编辑页,返回后刷新。 + Future _openEdit([AlarmModel? alarm]) async { + await context.push('/alarm/edit', extra: alarm); + if (mounted) _loadAlarms(); + } + + /// 开关切换 → 修改闹钟并推送。 + Future _toggle(AlarmModel alarm, bool value) async { + final sn = ref.read(selectedDeviceSnProvider); + if (sn == null || sn.isEmpty) return; + final updated = alarm.copyWith(isEnabled: value); + setState(() { + _alarms = [ + for (final a in _alarms) + a.id == alarm.id ? updated : a, + ]; + }); + final err = await ref.read(alarmApiProvider).updateAlarm(sn, updated); + if (!mounted) return; + if (err != null) { + _showAlert(err); + _loadAlarms(); + } + } + + void _showAlert(String message) { + showCupertinoDialog( + context: context, + builder: (ctx) => CupertinoAlertDialog( + content: Text(message), + actions: [ + CupertinoDialogAction( + onPressed: () => Navigator.of(ctx).pop(), + child: Text(_l10n.commonConfirm), + ), + ], + ), + ); + } + + String _repeatText(AlarmModel a) { + final l10n = _l10n; + switch (a.repeatType) { + case 0: + return l10n.alarmRepeatOnce; + case 2: + return l10n.alarmRepeatWeekdays; + case 3: + return a.customDays.isEmpty + ? l10n.alarmRepeatCustom + : '${l10n.alarmRepeatCustom} · ${a.customDays}'; + default: + return l10n.alarmRepeatEveryday; + } + } @override Widget build(BuildContext context) { - final l10n = AppLocalizations.of(context); + final l10n = _l10n; return PopScope( - // 拦截系统返回键:优先出栈;若无法出栈则跳回「管理」页,避免直接退到桌面。 canPop: false, onPopInvokedWithResult: (didPop, _) { if (didPop) return; @@ -48,79 +131,119 @@ class _AlarmPageState extends State { trailing: CupertinoButton( padding: EdgeInsets.zero, child: const Icon(CupertinoIcons.add, size: 26), - onPressed: () {}, + onPressed: () => _openEdit(), ), ), - child: ListView.separated( - padding: const EdgeInsets.only(bottom: 24), - itemCount: _alarms.length + 1, - separatorBuilder: (_, _) => const SizedBox(height: 12), - itemBuilder: (_, i) { - if (i == _alarms.length) { - return GestureDetector( - onTap: () {}, - child: Container( - margin: const EdgeInsets.symmetric(horizontal: 16), - height: 50, - decoration: BoxDecoration( - border: Border.all(color: const Color(0xFFCBD5E1), width: 2), - borderRadius: BorderRadius.circular(14), - ), - child: Center( - child: Text('+ ${l10n.addAlarm}', - style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: Color(0xFF6B7280))), - ), - ), - ); - } - final a = _alarms[i]; - return CardBox( - child: Row( - children: [ - RichText( - text: TextSpan( - children: [ - TextSpan( - text: a.time, - style: const TextStyle(fontSize: 30, fontWeight: FontWeight.w700, color: AppColors.ink), - ), - TextSpan( - text: ' ${a.am}', - style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: AppColors.sub), - ), - ], - ), - ), - const SizedBox(width: 14), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(a.label, style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: AppColors.ink)), - Text(a.repeat, style: const TextStyle(fontSize: 12, color: AppColors.sub)), - ], - ), - ), - CupertinoSwitch( - value: a.on, - activeTrackColor: AppColors.green, - onChanged: (v) => setState(() => a.on = v), - ), - ], - ), - ); - }, + child: SafeArea( + top: false, + child: _loading + ? const Center(child: CupertinoActivityIndicator(radius: 14)) + : _alarms.isEmpty + ? _buildEmpty(l10n) + : ListView.separated( + padding: const EdgeInsets.only(bottom: 24), + itemCount: _alarms.length + 1, + separatorBuilder: (_, _) => const SizedBox(height: 12), + itemBuilder: (_, i) { + if (i == _alarms.length) { + return _buildAddTile(l10n); + } + return _buildAlarmCard(_alarms[i], l10n); + }, + ), + ), ), + ); + } + + Widget _buildEmpty(AppLocalizations l10n) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(CupertinoIcons.alarm, size: 56, color: AppColors.sub), + const SizedBox(height: 12), + Text( + l10n.alarmEmpty, + style: const TextStyle(fontSize: 14, color: AppColors.sub), + ), + const SizedBox(height: 20), + CupertinoButton.filled( + onPressed: () => _openEdit(), + child: Text(l10n.addAlarm), + ), + ], + ); + } + + Widget _buildAddTile(AppLocalizations l10n) { + return GestureDetector( + onTap: () => _openEdit(), + child: Container( + margin: const EdgeInsets.symmetric(horizontal: 16), + height: 50, + decoration: BoxDecoration( + border: Border.all(color: const Color(0xFFCBD5E1), width: 2), + borderRadius: BorderRadius.circular(14), + ), + child: Center( + child: Text('+ ${l10n.addAlarm}', + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: Color(0xFF6B7280))), + ), + ), + ); + } + + Widget _buildAlarmCard(AlarmModel a, AppLocalizations l10n) { + return GestureDetector( + onTap: () => _openEdit(a), + child: CardBox( + child: Row( + children: [ + RichText( + text: TextSpan( + children: [ + TextSpan( + text: a.timeText, + style: const TextStyle( + fontSize: 30, + fontWeight: FontWeight.w700, + color: AppColors.ink), + ), + ], + ), + ), + const SizedBox(width: 14), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + a.label.isEmpty ? l10n.addAlarm : a.label, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: AppColors.ink), + ), + Text( + _repeatText(a), + style: const TextStyle(fontSize: 12, color: AppColors.sub), + ), + ], + ), + ), + CupertinoSwitch( + value: a.isEnabled, + activeTrackColor: AppColors.green, + onChanged: (v) => _toggle(a, v), + ), + ], + ), ), ); } } - -class _Alarm { - _Alarm({required this.time, required this.am, required this.label, required this.repeat, required this.on}); - final String time; - final String am; - final String label; - final String repeat; - bool on; -} diff --git a/lib/features/album/data/photo_providers.dart b/lib/features/album/data/photo_providers.dart new file mode 100644 index 0000000..6c90adc --- /dev/null +++ b/lib/features/album/data/photo_providers.dart @@ -0,0 +1,9 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:ttstd_family_care/features/album/data/photo_repository.dart'; + +/// 本机相册仓库 Provider。 +/// +/// 页面级单例:随相册页销毁自动 dispose,同步释放内存中的媒体缓存 +/// (见 [PhotoRepository.clearCache]),避免大量缩略图句柄常驻。 +final photoRepositoryProvider = + Provider((ref) => PhotoRepository()); diff --git a/lib/features/album/data/photo_repository.dart b/lib/features/album/data/photo_repository.dart new file mode 100644 index 0000000..10754b2 --- /dev/null +++ b/lib/features/album/data/photo_repository.dart @@ -0,0 +1,211 @@ +import 'dart:io'; +import 'dart:ui' as ui; + +import 'package:cupertino_ui/cupertino_ui.dart'; +import 'package:photo_manager/photo_manager.dart'; + +import '../domain/album_models.dart'; + +/// 相册权限状态(跨平台抽象)。 +enum AlbumPermissionStatus { + /// 已授权(Android 全量 / iOS 全量)。 + granted, + + /// 仅限(iOS 相册「允许部分照片」/ Android 14 部分授权)。可读但非全量。 + limited, + + /// 明确拒绝(可再次申请)。 + denied, + + /// 永久拒绝(不再弹系统授权框,需打开设置)。 + permanentlyDenied, + + /// 系统受限(如家长控制),无法申请。 + restricted, +} + +/// 本机相册仓库。 +/// +/// 基于 `photo_manager` 实现,负责: +/// - 跨 Android / iOS 统一处理相册权限申请(覆盖 Android 6.0~12 的 +/// `READ_EXTERNAL_STORAGE`、Android 13+ 的 `READ_MEDIA_IMAGES` / +/// `READ_MEDIA_VIDEO`、Android 14+ 的 `READ_MEDIA_VISUAL_USER_SELECTED`, +/// 以及 iOS 的 PhotoKit 全量/部分授权)。 +/// - 按文件夹(相簿)读取本机照片与视频,每个相簿内媒体按时间降序返回。 +/// - 生成媒体缩略图([ui.Image]),供相簿封面与照片墙展示。 +/// +/// 由于 `photo_manager` 的 [AssetEntity] 只有通过 `getAssetListPaged` / +/// `getAssetListRange` 批量获取,没有按 id 单独获取的静态方法,因此本仓库在 +/// 加载相簿/媒体时把返回的 [AssetEntity] 缓存进内存([PhotoRepository.clearCache]), +/// 之后按 id 生成缩略图即从缓存取用。仓库为页面级 Provider 单例,随相册页 +/// 销毁而释放。 +class PhotoRepository { + /// 已加载媒体的缓存(assetId -> [AssetEntity]),供缩略图按 id 取用。 + final Map _assetCache = {}; + + /// 已加载相簿的缓存(albumId -> [AssetPathEntity])。 + final Map _pathCache = {}; + + /// 是否已出现过一次「拒绝」:用于区分首次拒绝(可再弹窗)与永久拒绝。 + bool _hasDeniedBefore = false; + + /// 申请相册权限。 + /// + /// 首次申请时系统会弹授权框;若用户曾选择「不再询问」或 iOS 上已拒绝, + /// 则直接返回对应的拒绝状态,由 UI 引导打开系统设置。 + /// photo_manager 内部会根据系统版本自动申请对应权限: + /// - Android 6.0~12:`READ_EXTERNAL_STORAGE` + /// - Android 13+:`READ_MEDIA_IMAGES` / `READ_MEDIA_VIDEO` + /// - Android 14+:支持 `READ_MEDIA_VISUAL_USER_SELECTED` 部分授权 + /// - iOS:PhotoKit(支持「允许部分照片」的 limited 状态) + /// + /// 由于 [PermissionState] 在 3.x 中没有「永久拒绝」枚举,这里用连续两次 + /// 拒绝来近似:第一次返回 [AlbumPermissionStatus.denied](可再次申请), + /// 用户再次申请仍被拒则返回 [AlbumPermissionStatus.permanentlyDenied] + /// (引导打开系统设置)。iOS 一旦拒绝便不再弹窗,用户点「重新申请」一次 + /// 后即会进入「去设置」引导。 + Future requestPermission() async { + final status = await PhotoManager.requestPermissionExtend(); + final mapped = _mapStatus(status); + if (mapped == AlbumPermissionStatus.denied) { + if (_hasDeniedBefore) { + return AlbumPermissionStatus.permanentlyDenied; + } + _hasDeniedBefore = true; + return AlbumPermissionStatus.denied; + } + _hasDeniedBefore = false; + return mapped; + } + + /// 打开应用系统设置(用于永久拒绝后引导用户手动开启)。 + Future openAppSettings() => PhotoManager.openSetting(); + + /// 读取所有相簿(文件夹)。 + /// + /// [type] 指定只读照片、只读视频或全部;默认全部(照片 + 视频)。 + /// `hasAll: false` 排除系统「全部照片」根相簿,只展示真实文件夹。 + /// 需要先保证权限已 [requestPermission]。 + Future> loadAlbums({RequestType type = RequestType.common}) async { + final paths = await PhotoManager.getAssetPathList( + type: type, + onlyAll: false, + hasAll: false, + ); + + _pathCache.clear(); + for (final p in paths) { + _pathCache[p.id] = p; + } + + final result = []; + for (final path in paths) { + // 仅处理「相簿」类型(albumType==1);iOS 的文件夹(albumType==2) + // 不能直接 getAssetListPaged,跳过避免断言失败。 + if (path.albumType != 1) continue; + // 每个相簿内也取首张作为封面(getAssetListPaged 默认按时间排序)。 + final assets = await path.getAssetListPaged(page: 0, size: 1); + if (assets.isEmpty) continue; + final first = assets.first; + _assetCache[first.id] = first; + result.add( + AlbumFolder( + id: path.id, + name: path.name, + assetCount: await path.assetCountAsync, + coverAssetId: first.id, + coverThumb: PhotoThumb( + assetId: first.id, + originalWidth: first.width, + originalHeight: first.height, + ), + ), + ); + } + return result; + } + + /// 读取指定相簿内的媒体,按时间降序。 + /// + /// [albumId] 为 [loadAlbums] 返回的 [AlbumFolder.id]。 + /// 返回媒体的缩略图句柄列表(供照片墙按需加载)。 + Future> loadFolderAssets(String albumId) async { + final path = _pathCache[albumId]; + if (path == null) return const []; + + final assets = await path.getAssetListPaged(page: 0, size: 20000); + // 按创建时间降序(最新在前),保证照片墙时间顺序稳定。 + assets.sort((a, b) { + final t = b.createDateTime.compareTo(a.createDateTime); + return t != 0 ? t : b.id.compareTo(a.id); + }); + for (final a in assets) { + _assetCache[a.id] = a; + } + return assets + .map( + (a) => PhotoThumb( + assetId: a.id, + originalWidth: a.width, + originalHeight: a.height, + ), + ) + .toList(); + } + + /// 生成指定媒体的缩略图 [ui.Image]。 + /// + /// [size] 为目标最长边(px),按原图比例缩放,保证 [ThumbnailSize] 非空 + /// (photo_manager 断言宽高均 > 0);加载失败时返回 null,由 UI 兜底。 + Future loadThumb(PhotoThumb thumb, {int size = 200}) async { + final asset = _assetCache[thumb.assetId]; + if (asset == null) return null; + final w = thumb.originalWidth; + final h = thumb.originalHeight; + // 按原图比例缩放到最长边为 size;原图尺寸异常时退化为正方形。 + final scale = (w <= 0 || h <= 0) + ? 1.0 + : size / (w >= h ? w : h); + final tw = ((w * scale).round()).clamp(1, size); + final th = ((h * scale).round()).clamp(1, size); + final data = await asset.thumbnailDataWithSize(ThumbnailSize(tw, th)); + if (data == null) return null; + return decodeImageFromList(data); + } + + /// 获取媒体原图文件(用于上传等场景);缓存中不存在或取文件失败时返回 null。 + Future getAssetFile(String assetId) async { + final asset = _assetCache[assetId]; + if (asset == null) return null; + try { + return await asset.file; + } catch (_) { + return null; + } + } + + /// 清空内存缓存(相册页销毁时调用,释放资源)。 + void clearCache() { + _assetCache.clear(); + _pathCache.clear(); + } + + /// 把 photo_manager 的授权状态映射为领域状态。 + /// + /// [PermissionState] 是枚举:`authorized` / `limited` / `restricted` / + /// `denied` / `notDetermined`。其中「永久拒绝」在 3.x 无独立枚举, + /// 由 [requestPermission] 通过连续两次拒绝判定。 + AlbumPermissionStatus _mapStatus(PermissionState status) { + switch (status) { + case PermissionState.authorized: + return AlbumPermissionStatus.granted; + case PermissionState.limited: + return AlbumPermissionStatus.limited; + case PermissionState.restricted: + return AlbumPermissionStatus.restricted; + case PermissionState.denied: + case PermissionState.notDetermined: + return AlbumPermissionStatus.denied; + } + } +} diff --git a/lib/features/album/domain/album_models.dart b/lib/features/album/domain/album_models.dart new file mode 100644 index 0000000..c4b37b6 --- /dev/null +++ b/lib/features/album/domain/album_models.dart @@ -0,0 +1,58 @@ +import 'dart:ui'; + +/// 相册(文件夹)实体。 +/// +/// 对应本机相册的一个相簿(文件夹),如「相机」「微信」「截图」等。 +/// 每个相簿持有其内的媒体项列表(按时间降序),封面用首张缩略图展示。 +class AlbumFolder { + const AlbumFolder({ + required this.id, + required this.name, + required this.assetCount, + required this.coverAssetId, + this.coverThumb, + }); + + /// 相簿唯一标识(photo_manager 的 [AssetPathEntity.id])。 + final String id; + + /// 相簿名称(空目录等特殊相簿可能为空字符串)。 + final String name; + + /// 相簿内的媒体数量(照片 + 视频)。 + final int assetCount; + + /// 封面使用的首张媒体 ID。 + final String coverAssetId; + + /// 封面缩略图(用于封面展示),按需从 [PhotoThumb] 请求。 + final PhotoThumb? coverThumb; + + AlbumFolder copyWith({PhotoThumb? coverThumb}) => AlbumFolder( + id: id, + name: name, + assetCount: assetCount, + coverAssetId: coverAssetId, + coverThumb: coverThumb ?? this.coverThumb, + ); +} + +/// 单张媒体(照片/视频)的缩略图加载句柄。 +/// +/// 复用 photo_manager 的 [ui.Image] 能力,仅持有加载所需的最小信息, +/// 避免在领域层直接依赖 photo_manager 的实体类型。 +class PhotoThumb { + const PhotoThumb({required this.assetId, required this.originalWidth, required this.originalHeight}); + + /// 媒体唯一 ID。 + final String assetId; + + /// 原图宽(用于生成符合比例的缩略图)。 + final int originalWidth; + + /// 原图高。 + final int originalHeight; + + @override + String toString() => 'PhotoThumb(assetId: $assetId, ${originalWidth}x$originalHeight)'; +} diff --git a/lib/features/album/presentation/album_controller.dart b/lib/features/album/presentation/album_controller.dart new file mode 100644 index 0000000..ea22459 --- /dev/null +++ b/lib/features/album/presentation/album_controller.dart @@ -0,0 +1,196 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:ttstd_family_care/features/album/data/photo_providers.dart'; +import 'package:ttstd_family_care/features/album/data/photo_repository.dart'; +import 'package:ttstd_family_care/features/album/domain/album_models.dart'; + +/// 相簿加载错误类型。 +enum AlbumLoadError { loadFolders, loadFolderAssets } + +/// 哨兵值:用于区分 copyWith 中「不修改该字段」与「显式置为 null」。 +/// +/// 直接用 `field ?? this.field` 会导致 `copyWith(field: null)` 无法清空字段 +/// (null 会被 `??` 兜底成旧值)。可空字段([AlbumState.currentAlbum]、 +/// [AlbumState.error])必须用本哨兵作为参数默认值,才能支持显式清空。 +const Object _noValue = Object(); + +/// 相簿页状态。 +/// +/// 只维护「相簿」分段所需数据: +/// - [permission]:相册权限状态(决定是否展示引导/空态)。 +/// - [requesting]:是否正在请求权限或加载数据。 +/// - [folders]:本机相簿(文件夹)列表,按时间降序。 +/// - [currentAlbum]:当前打开查看的相簿;null 表示停留在相簿列表。 +/// - [assets]:当前相簿内的媒体(缩略图句柄,时间降序)。 +/// - [error]:一次性加载错误,UI 展示后调用 [AlbumController.consumeError] 消费。 +/// 错误文案由 UI 依据 [AlbumLoadError] 映射到本地化文案,控制器不持有多语言字符串。 +class AlbumState { + const AlbumState({ + this.permission = AlbumPermissionStatus.denied, + this.requesting = false, + this.folders = const [], + this.currentAlbum, + this.assets = const [], + this.error, + }); + + final AlbumPermissionStatus permission; + final bool requesting; + final List folders; + + /// 当前打开查看的相簿。 + final AlbumFolder? currentAlbum; + + /// 当前相簿内的媒体缩略图句柄。 + final List assets; + + /// 一次性加载错误。 + final AlbumLoadError? error; + + /// 复制并覆盖部分字段。 + /// + /// 可空字段 [currentAlbum] / [error] 使用 [Object] 类型参数 + [_noValue] + /// 哨兵实现:不传(保持默认)表示不修改,显式传 `null` 表示清空为 null, + /// 显式传具体值表示覆盖。其余字段沿用 `??` 语义。 + AlbumState copyWith({ + AlbumPermissionStatus? permission, + bool? requesting, + List? folders, + Object? currentAlbum = _noValue, + List? assets, + Object? error = _noValue, + }) => AlbumState( + permission: permission ?? this.permission, + requesting: requesting ?? this.requesting, + folders: folders ?? this.folders, + currentAlbum: identical(currentAlbum, _noValue) + ? this.currentAlbum + : currentAlbum as AlbumFolder?, + assets: assets ?? this.assets, + error: identical(error, _noValue) ? this.error : error as AlbumLoadError?, + ); +} + +/// 相簿页控制器。 +/// +/// 页面级控制器,**不使用** keepAlive,随页面销毁自动释放(见 AGENTS.md §4)。 +/// +/// 职责: +/// - 进入「相簿」分段时申请相册权限(覆盖 Android / iOS 各版本)。 +/// - 授权后加载本机相簿列表(按时间降序)。 +/// - 打开某个相簿后加载其内媒体(时间降序)。 +/// - 返回相簿列表(currentAlbum 置空)。 +class AlbumController extends Notifier { + /// 请求令牌:用于丢弃过期的异步结果。 + /// + /// 每次发起新的 [openAlbum] 或调用 [backToFolders] 时递增。`openAlbum` + /// 的 `await` 完成回来后,若令牌已变化(用户期间已返回或打开了其他相簿), + /// 则丢弃该次结果,避免「点了返回后相簿又被重新打开」的竞态。 + int _loadToken = 0; + + @override + AlbumState build() { + // 页面级控制器,无需 keepAlive,随页面销毁自动 dispose; + // 同步清理仓库内存缓存,释放缩略图句柄。 + ref.onDispose(() { + ref.read(photoRepositoryProvider).clearCache(); + }); + return const AlbumState(); + } + + /// 申请相册权限并在授权后加载相簿列表。 + /// + /// 首次调用会触发系统授权弹窗;已授权则直接刷新相簿。 + Future requestPermissionAndLoad() async { + if (state.requesting) return; + final repo = ref.read(photoRepositoryProvider); + + // 1. 申请权限。 + state = state.copyWith(requesting: true); + final status = await repo.requestPermission(); + + if (status == AlbumPermissionStatus.denied || + status == AlbumPermissionStatus.permanentlyDenied || + status == AlbumPermissionStatus.restricted) { + state = state.copyWith( + permission: status, + requesting: false, + folders: const [], + currentAlbum: null, + assets: const [], + ); + return; + } + + // 2. 授权(含 limited),加载相簿。 + state = state.copyWith(permission: status, requesting: true); + try { + final folders = await repo.loadAlbums(); + state = state.copyWith( + permission: status, + requesting: false, + folders: folders, + currentAlbum: null, + assets: const [], + ); + } catch (e) { + state = state.copyWith( + permission: status, + requesting: false, + error: AlbumLoadError.loadFolders, + ); + } + } + + /// 打开指定相簿,加载其内媒体(时间降序)。 + Future openAlbum(AlbumFolder folder) async { + final token = ++_loadToken; + final repo = ref.read(photoRepositoryProvider); + state = state.copyWith(requesting: true); + try { + final assets = await repo.loadFolderAssets(folder.id); + // 若期间用户已返回/打开了其他相簿(令牌变化),丢弃本次过期结果。 + if (token != _loadToken) return; + state = state.copyWith( + requesting: false, + currentAlbum: folder, + assets: assets, + ); + } catch (e) { + if (token != _loadToken) return; + state = state.copyWith( + requesting: false, + error: AlbumLoadError.loadFolderAssets, + ); + } + } + + /// 返回相簿列表。 + /// + /// 同时递增令牌,使在途的 [openAlbum] 结果失效,避免「返回后相簿又被重新 + /// 打开」的竞态。 + void backToFolders() { + _loadToken++; + state = state.copyWith( + currentAlbum: null, + assets: const [], + requesting: false, + ); + } + + /// 打开系统设置(用于永久拒绝后引导用户手动开启)。 + Future openSettings() async { + await ref.read(photoRepositoryProvider).openAppSettings(); + } + + /// 消费一次性加载错误,避免重复弹窗。 + void consumeError() { + if (state.error != null) { + state = state.copyWith(error: null); + } + } +} + +/// 相簿页控制器 Provider(页面级,不 keepAlive)。 +final albumControllerProvider = NotifierProvider( + AlbumController.new, +); diff --git a/lib/features/album/presentation/album_page.dart b/lib/features/album/presentation/album_page.dart index 25ec18a..28459a3 100644 --- a/lib/features/album/presentation/album_page.dart +++ b/lib/features/album/presentation/album_page.dart @@ -1,50 +1,148 @@ +import 'dart:io'; + import 'package:cupertino_ui/cupertino_ui.dart'; +import 'package:easy_image_viewer/easy_image_viewer.dart'; import 'package:go_router/go_router.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:image_picker/image_picker.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 '../data/photo_providers.dart'; +import '../data/photo_repository.dart'; +import '../domain/album_models.dart'; +import 'album_controller.dart'; +import 'album_thumbnail.dart'; /// 相册页(管理 → 相册)。 /// -/// 对应移动端设计稿:分段切换(全部/收藏/视频/相簿)、照片数量统计、 +/// 对应移动端设计稿:分段切换(全部/收藏/相簿)、照片数量统计、 /// 三列照片墙与右下上传按钮。 -class AlbumPage extends StatefulWidget { +/// +/// 「全部」分段展示已发送到设备的图片列表(独立于壁纸接口,按发送时间倒序); +/// 「相簿」分段读取本机相册:进入时申请相册权限(适配 Android 各版本与 +/// iOS),授权后按文件夹(相簿)展示本机照片,媒体按时间降序排列; +/// 点击某张照片可将图片发送到设备(设备收到推送后弹窗显示)。 +class AlbumPage extends ConsumerStatefulWidget { const AlbumPage({super.key}); @override - State createState() => _AlbumPageState(); + ConsumerState createState() => _AlbumPageState(); } -class _AlbumPageState extends State { +class _AlbumPageState extends ConsumerState { int _segment = 0; - final _segments = ['全部', '收藏', '视频', '相簿']; + final _segments = ['全部', '收藏', '相簿']; - static const _gradients = [ - [AppColors.purple, AppColors.blue], - [AppColors.red, Color(0xFFF5576C)], - [AppColors.teal, Color(0xFF00F2FE)], - [Color(0xFF43E97B), Color(0xFF38F9D7)], - [Color(0xFFFA709A), Color(0xFFFEE140)], - [Color(0xFF30CFD0), Color(0xFF330867)], - [Color(0xFFA8ED92), Color(0xFFFED6E3)], - [Color(0xFFFBC2EB), Color(0xFFFECFEF)], - [Color(0xFF5EE7DF), Color(0xFFB490CA)], - [Color(0xFFF6D365), Color(0xFFFDA085)], - [Color(0xFF84FAB0), Color(0xFF8FD3F4)], - [Color(0xFFD4FC79), Color(0xFF96E6A1)], - [Color(0xFFE0C3FC), Color(0xFF8EC5FC)], - [Color(0xFFFBC2EB), Color(0xFFA6C1EE)], - [Color(0xFF21D4FD), Color(0xFFB721FF)], - ]; + final ImagePicker _picker = ImagePicker(); + + /// 已发送到设备的图片列表(含收藏状态,按发送时间倒序)。 + List _pictures = const []; + bool _picturesLoading = true; + + AppLocalizations get _l10n => AppLocalizations.of(context); + + @override + void initState() { + super.initState(); + // 首次进入若恰好停在「相簿」分段(如从相册页内跳转返回),主动申请权限。 + if (_segment == 2) { + _requestAlbum(); + } + _loadPictures(); + } + + /// 切换分段;进入「相簿」时申请相册权限并加载。 + void _onSegmentTap(int index) { + setState(() => _segment = index); + if (index == 2) _requestAlbum(); + } + + /// 申请相册权限并加载相簿列表。 + void _requestAlbum() { + final controller = ref.read(albumControllerProvider.notifier); + final state = ref.read(albumControllerProvider); + // 已授权且已有数据则不重复加载;正在请求时跳过。 + if (state.requesting) return; + final permission = state.permission; + if (permission == AlbumPermissionStatus.granted || + permission == AlbumPermissionStatus.limited) { + // 已授权但相簿为空(可能是权限变化后),补一次刷新。 + if (state.folders.isEmpty && !state.requesting) { + controller.requestPermissionAndLoad(); + } + return; + } + controller.requestPermissionAndLoad(); + } + + /// 打开系统设置(权限被拒时引导)。 + void _openSettings() { + ref.read(albumControllerProvider.notifier).openSettings(); + } + + /// 拉取已发送到设备的图片列表。 + Future _loadPictures() async { + final sn = ref.read(selectedDeviceSnProvider); + if (sn == null || sn.isEmpty) { + // 可能在 ref.listen 回调中被调用(build 期间),setState 需延后到帧后。 + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted) return; + setState(() { + _pictures = const []; + _picturesLoading = false; + }); + }); + return; + } + final pictures = + await ref.read(deviceRepositoryProvider).getPictureList(sn); + if (!mounted) return; + setState(() { + _pictures = pictures; + _picturesLoading = false; + }); + } @override Widget build(BuildContext context) { final l10n = AppLocalizations.of(context); + // 切换绑定设备后刷新图片列表。 + ref.listen(selectedDeviceSnProvider, (prev, next) { + if (prev != next) _loadPictures(); + }); + // 消费一次性加载错误(相簿/相簿内容加载失败)。 + ref.listen(albumControllerProvider, (prev, next) { + if (next.error != null && next.error != prev?.error) { + final error = next.error!; + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!mounted) return; + ref.read(albumControllerProvider.notifier).consumeError(); + _showAlert( + error == AlbumLoadError.loadFolders + ? l10n.albumLoadFailed + : l10n.albumFolderLoadFailed, + ); + }); + } + }); + + final currentAlbum = ref.watch( + albumControllerProvider.select((s) => s.currentAlbum), + ); + final inFolder = _segment == 2 && currentAlbum != null; + return PopScope( - // 拦截系统返回键:优先出栈;若无法出栈(如 go_router 顶级路由)则跳回「管理」页,避免直接退到桌面。 + // 拦截系统返回键:相簿内先返回列表;否则优先出栈,无法出栈则跳回「管理」页。 canPop: false, onPopInvokedWithResult: (didPop, _) { if (didPop) return; + if (inFolder) { + ref.read(albumControllerProvider.notifier).backToFolders(); + return; + } if (context.canPop()) { context.pop(); } else { @@ -53,11 +151,21 @@ class _AlbumPageState extends State { }, child: CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( - middle: Text(l10n.albumTitle), + middle: Text(inFolder ? currentAlbum!.name : l10n.albumTitle), leading: CupertinoButton( padding: EdgeInsets.zero, child: const Icon(CupertinoIcons.back), - onPressed: () => context.pop(), + onPressed: () { + if (inFolder) { + ref.read(albumControllerProvider.notifier).backToFolders(); + return; + } + if (context.canPop()) { + context.pop(); + } else { + context.go('/messages'); + } + }, ), trailing: CupertinoButton( padding: EdgeInsets.zero, @@ -65,10 +173,20 @@ class _AlbumPageState extends State { onPressed: () {}, ), ), + child: _buildBody(l10n), + ), + ); + } + + Widget _buildBody(AppLocalizations l10n) { + // edge-to-edge 沉浸式布局下,SafeArea 兜底顶部状态栏与底部导航/Home 条安全区; + // 顶部由 CupertinoNavigationBar 处理,这里仅保留底部 inset。 + return SafeArea( + top: false, child: Stack( children: [ ListView( - padding: const EdgeInsets.only(bottom: 90), + padding: const EdgeInsets.only(bottom: 120), children: [ // 分段切换 Padding( @@ -84,22 +202,35 @@ class _AlbumPageState extends State { for (var i = 0; i < _segments.length; i++) Expanded( child: GestureDetector( - onTap: () => setState(() => _segment = i), + onTap: () => _onSegmentTap(i), child: Container( padding: const EdgeInsets.symmetric(vertical: 8), decoration: BoxDecoration( - color: _segment == i ? CupertinoColors.white : const Color(0x00000000), + color: _segment == i + ? CupertinoColors.white + : const Color(0x00000000), borderRadius: BorderRadius.circular(9), boxShadow: _segment == i - ? const [BoxShadow(color: Color(0x14141E3C), blurRadius: 6, offset: Offset(0, 2))] + ? const [ + BoxShadow( + color: Color(0x14141E3C), + blurRadius: 6, + offset: Offset(0, 2), + ), + ] : null, ), child: Center( - child: Text(_segments[i], - style: TextStyle( - fontSize: 13, - fontWeight: FontWeight.w600, - color: _segment == i ? AppColors.ink : AppColors.sub)), + child: Text( + _segments[i], + style: TextStyle( + fontSize: 13, + fontWeight: FontWeight.w600, + color: _segment == i + ? AppColors.ink + : AppColors.sub, + ), + ), ), ), ), @@ -108,55 +239,604 @@ class _AlbumPageState extends State { ), ), ), - Padding( - padding: const EdgeInsets.fromLTRB(18, 10, 18, 10), - child: Text('1280 张照片 · 42 个视频 · 已占用 6.4 GB', - style: const TextStyle(fontSize: 12, color: AppColors.sub)), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 3), - child: GridView.builder( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 3, - crossAxisSpacing: 3, - mainAxisSpacing: 3, - ), - itemCount: _gradients.length, - itemBuilder: (_, i) => Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - gradient: LinearGradient( - colors: _gradients[i], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - ), - ), - ), - ), - ), + if (_segment == 2) + _buildAlbumSegment(l10n) + else if (_segment == 0) + _buildUploadedSegment(l10n) + else + _buildFavoritesSegment(l10n), ], ), Positioned( right: 18, - bottom: 26, + bottom: 44, child: GestureDetector( - onTap: () {}, + onTap: _uploadFromGallery, child: Container( width: 54, height: 54, decoration: BoxDecoration( color: AppColors.green, shape: BoxShape.circle, - boxShadow: const [BoxShadow(color: Color(0x6607C160), blurRadius: 20, offset: Offset(0, 8))], + boxShadow: const [ + BoxShadow( + color: Color(0x6607C160), + blurRadius: 20, + offset: Offset(0, 8), + ), + ], + ), + child: const Center( + child: Text( + '+', + style: TextStyle( + fontSize: 28, + color: CupertinoColors.white, + ), + ), ), - child: const Center(child: Text('+', style: TextStyle(fontSize: 28, color: CupertinoColors.white))), ), ), ), ], + ), + ); + } + + /// 「相簿」分段内容。 + Widget _buildAlbumSegment(AppLocalizations l10n) { + final state = ref.watch(albumControllerProvider); + + // 正在请求权限或加载。 + if (state.requesting) { + return const Padding( + padding: EdgeInsets.symmetric(vertical: 80), + child: Center(child: CupertinoActivityIndicator(radius: 14)), + ); + } + + // 权限未授权 -> 引导。 + if (state.permission == AlbumPermissionStatus.denied || + state.permission == AlbumPermissionStatus.permanentlyDenied || + state.permission == AlbumPermissionStatus.restricted) { + return _PermissionDeniedView( + l10n: l10n, + permanentlyDenied: + state.permission == AlbumPermissionStatus.permanentlyDenied, + onRetry: _requestAlbum, + onOpenSettings: _openSettings, + ); + } + + // 已授权(含 limited): + if (state.currentAlbum != null) { + return _FolderDetailView( + l10n: l10n, + album: state.currentAlbum!, + assets: state.assets, + onView: _viewLocalPicture, + onSend: _onPhotoTap, + ); + } + + // 相簿列表。 + if (state.folders.isEmpty) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 80), + child: Column( + children: [ + const Icon(CupertinoIcons.photo, size: 56, color: AppColors.sub), + const SizedBox(height: 12), + Text( + l10n.albumEmpty, + style: const TextStyle(fontSize: 14, color: AppColors.sub), + ), + ], ), + ); + } + + return _FolderListView( + l10n: l10n, + folders: state.folders, + onTap: (folder) => + ref.read(albumControllerProvider.notifier).openAlbum(folder), + ); + } + + /// 「全部」分段:已发送到设备的图片列表(按发送时间倒序),点击可切换收藏。 + Widget _buildUploadedSegment(AppLocalizations l10n) { + if (_picturesLoading && _pictures.isEmpty) { + return const Padding( + padding: EdgeInsets.symmetric(vertical: 80), + child: Center(child: CupertinoActivityIndicator(radius: 14)), + ); + } + if (_pictures.isEmpty) { + return _buildEmptyView(l10n.albumUploadedEmpty); + } + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(18, 10, 18, 10), + child: Text( + l10n.albumUploadedStats( + _pictures.length, + _formatSize( + _pictures.fold(0, (sum, p) => sum + p.fileSize), + ), + ), + style: const TextStyle(fontSize: 12, color: AppColors.sub), + ), + ), + _buildPictureGrid(_pictures), + ], + ); + } + + /// 「收藏」分段:只展示已收藏的图片。 + Widget _buildFavoritesSegment(AppLocalizations l10n) { + final favorites = _pictures.where((p) => p.favorite).toList(); + if (_picturesLoading && _pictures.isEmpty) { + return const Padding( + padding: EdgeInsets.symmetric(vertical: 80), + child: Center(child: CupertinoActivityIndicator(radius: 14)), + ); + } + if (favorites.isEmpty) { + return _buildEmptyView(l10n.albumFavoriteEmpty); + } + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(18, 10, 18, 10), + child: Text( + l10n.albumFavoriteStats( + favorites.length, + _formatSize( + favorites.fold(0, (sum, p) => sum + p.fileSize), + ), + ), + style: const TextStyle(fontSize: 12, color: AppColors.sub), + ), + ), + _buildPictureGrid(favorites), + ], + ); + } + + /// 三列图片网格,每格点击切换收藏状态。 + Widget _buildPictureGrid(List pictures) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 3), + child: GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 3, + mainAxisSpacing: 3, + ), + itemCount: pictures.length, + itemBuilder: (_, i) => _buildPictureCell(pictures[i]), + ), + ); + } + + /// 单张已上传图片:点击全屏查看,右上角心形图标单独切换收藏。 + Widget _buildPictureCell(DevicePictureInfo picture) { + return GestureDetector( + onTap: () => _viewPicture(picture), + child: Stack( + fit: StackFit.expand, + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(8), + child: Image.network( + picture.url, + fit: BoxFit.cover, + errorBuilder: (_, __, ___) => Container( + color: AppColors.track, + child: const Icon(CupertinoIcons.photo, + size: 28, color: AppColors.sub), + ), + ), + ), + Positioned( + top: 4, + right: 4, + child: GestureDetector( + onTap: () => _toggleFavorite(picture), + child: Container( + padding: const EdgeInsets.all(4), + decoration: const BoxDecoration( + color: Color(0x55000000), + shape: BoxShape.circle, + ), + child: Icon( + picture.favorite + ? CupertinoIcons.heart_fill + : CupertinoIcons.heart, + size: 16, + color: picture.favorite + ? const Color(0xFFFF5A79) + : CupertinoColors.white, + ), + ), + ), + ), + ], + ), + ); + } + + /// 全屏查看已上传图片(easy_image_viewer,支持双击/双指缩放)。 + void _viewPicture(DevicePictureInfo picture) { + showImageViewer( + context, + NetworkImage(picture.url), + doubleTapZoomable: true, + swipeDismissible: true, + ); + } + + /// 全屏查看本地相册照片(easy_image_viewer,取原图文件展示)。 + Future _viewLocalPicture(PhotoThumb thumb) async { + final file = + await ref.read(photoRepositoryProvider).getAssetFile(thumb.assetId); + if (!mounted) return; + if (file == null) { + _showAlert(_l10n.albumSendGetFileFailed); + return; + } + showImageViewer( + context, + FileImage(file), + doubleTapZoomable: true, + swipeDismissible: true, + ); + } + + Widget _buildEmptyView(String message) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 80, horizontal: 24), + child: Column( + children: [ + const Icon(CupertinoIcons.photo, size: 56, color: AppColors.sub), + const SizedBox(height: 12), + Text( + message, + textAlign: TextAlign.center, + style: const TextStyle(fontSize: 14, color: AppColors.sub), + ), + ], + ), + ); + } + + /// 字节数格式化为可读大小(B/KB/MB/GB)。 + String _formatSize(int bytes) { + if (bytes <= 0) return '0 B'; + if (bytes < 1024) return '$bytes B'; + if (bytes < 1024 * 1024) return '${(bytes / 1024).toStringAsFixed(1)} KB'; + if (bytes < 1024 * 1024 * 1024) { + return '${(bytes / (1024 * 1024)).toStringAsFixed(1)} MB'; + } + return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB'; + } + + /// 切换图片收藏状态(乐观更新,失败回滚)。 + Future _toggleFavorite(DevicePictureInfo picture) async { + final sn = ref.read(selectedDeviceSnProvider); + if (sn == null || sn.isEmpty) return; + final newValue = !picture.favorite; + setState(() { + _pictures = [ + for (final p in _pictures) + p.url == picture.url ? p.copyWith(favorite: newValue) : p, + ]; + }); + final err = await ref + .read(deviceRepositoryProvider) + .setPictureFavorite(sn, picture.url, newValue); + if (!mounted) return; + if (err != null) { + _showAlert(err); + _loadPictures(); + } + } + + /// 右上角「+」:打开系统相册选图并上传到设备。 + Future _uploadFromGallery() async { + final l10n = _l10n; + final sn = ref.read(selectedDeviceSnProvider); + if (sn == null || sn.isEmpty) { + _showAlert(l10n.contactNoDevice); + return; + } + final picked = await _picker.pickImage(source: ImageSource.gallery); + if (picked == null || !mounted) return; + final err = await ref + .read(deviceRepositoryProvider) + .sendPicture(sn, File(picked.path)); + if (!mounted) return; + if (err == null) { + _loadPictures(); + _showAlert(l10n.albumSendSuccess); + } else { + _showAlert(err); + } + } + + void _showAlert(String message) { + final l10n = AppLocalizations.of(context); + showCupertinoDialog( + context: context, + builder: (ctx) => CupertinoAlertDialog( + content: Text(message), + actions: [ + CupertinoDialogAction( + onPressed: () => Navigator.of(ctx).pop(), + child: Text(l10n.albumGotIt), + ), + ], + ), + ); + } + + /// 点击照片:确认后发送到设备(设备收到推送弹窗显示)。 + Future _onPhotoTap(PhotoThumb thumb) async { + final l10n = _l10n; + final sn = ref.read(selectedDeviceSnProvider); + if (sn == null || sn.isEmpty) { + _showAlert(l10n.contactNoDevice); + return; + } + final confirmed = await showCupertinoModalPopup( + context: context, + builder: (ctx) => CupertinoActionSheet( + title: Text(l10n.albumSendToDevice), + actions: [ + CupertinoActionSheetAction( + onPressed: () => Navigator.of(ctx).pop(true), + child: Text(l10n.albumSendToDevice), + ), + ], + cancelButton: CupertinoActionSheetAction( + onPressed: () => Navigator.of(ctx).pop(false), + child: Text(l10n.commonCancel), + ), + ), + ); + if (confirmed != true || !mounted) return; + final file = + await ref.read(photoRepositoryProvider).getAssetFile(thumb.assetId); + if (file == null || !mounted) { + _showAlert(l10n.albumSendGetFileFailed); + return; + } + final err = + await ref.read(deviceRepositoryProvider).sendPicture(sn, file); + if (!mounted) return; + if (err == null) { + // 发送成功后刷新「全部」已上传图片列表。 + _loadPictures(); + _showAlert(l10n.albumSendSuccess); + } else { + _showAlert(err); + } + } +} + +/// 相簿列表(文件夹网格)。 +class _FolderListView extends StatelessWidget { + const _FolderListView({ + required this.l10n, + required this.folders, + required this.onTap, + }); + + final AppLocalizations l10n; + final List folders; + final ValueChanged onTap; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.fromLTRB(12, 12, 12, 0), + child: GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + crossAxisSpacing: 8, + mainAxisSpacing: 8, + childAspectRatio: 1.05, + ), + itemCount: folders.length, + itemBuilder: (context, i) { + final folder = folders[i]; + final thumb = folder.coverThumb; + return GestureDetector( + onTap: () => onTap(folder), + child: ClipRRect( + borderRadius: BorderRadius.circular(12), + child: Stack( + fit: StackFit.expand, + children: [ + if (thumb != null) + AlbumThumb(thumb: thumb, size: 300) + else + Container(color: AppColors.track), + // 底部渐变 + 名称与数量 + Positioned( + left: 0, + right: 0, + bottom: 0, + child: Container( + padding: const EdgeInsets.fromLTRB(10, 18, 10, 8), + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [Color(0x00000000), Color(0xB3000000)], + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + folder.name.isEmpty + ? l10n.albumUnknownFolder + : folder.name, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 13, + fontWeight: FontWeight.w600, + color: CupertinoColors.white, + ), + ), + const SizedBox(height: 2), + Text( + l10n.albumAssetCount(folder.assetCount), + style: const TextStyle( + fontSize: 11, + color: Color(0xCCFFFFFF), + ), + ), + ], + ), + ), + ), + ], + ), + ), + ); + }, + ), + ); + } +} + +/// 单个相簿内的媒体墙(时间降序),点击照片全屏查看,长按可发送到设备。 +class _FolderDetailView extends StatelessWidget { + const _FolderDetailView({ + required this.l10n, + required this.album, + required this.assets, + required this.onView, + required this.onSend, + }); + + final AppLocalizations l10n; + final AlbumFolder album; + final List assets; + + /// 点击:全屏查看。 + final ValueChanged onView; + + /// 长按:发送到设备。 + final ValueChanged onSend; + + @override + Widget build(BuildContext context) { + if (assets.isEmpty) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 80), + child: Column( + children: [ + const Icon(CupertinoIcons.photo, size: 56, color: AppColors.sub), + const SizedBox(height: 12), + Text( + l10n.albumFolderEmpty, + style: const TextStyle(fontSize: 14, color: AppColors.sub), + ), + ], + ), + ); + } + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 3, vertical: 8), + child: GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 3, + crossAxisSpacing: 3, + mainAxisSpacing: 3, + ), + itemCount: assets.length, + itemBuilder: (context, i) { + final thumb = assets[i]; + return GestureDetector( + onTap: () => onView(thumb), + onLongPress: () => onSend(thumb), + child: ClipRRect( + borderRadius: BorderRadius.circular(6), + child: AlbumThumb(thumb: thumb, size: 240), + ), + ); + }, + ), + ); + } +} + +/// 权限被拒引导视图。 +class _PermissionDeniedView extends StatelessWidget { + const _PermissionDeniedView({ + required this.l10n, + required this.permanentlyDenied, + required this.onRetry, + required this.onOpenSettings, + }); + + final AppLocalizations l10n; + final bool permanentlyDenied; + final VoidCallback onRetry; + final VoidCallback onOpenSettings; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 70), + child: Column( + children: [ + const Icon(CupertinoIcons.photo, size: 64, color: AppColors.sub), + const SizedBox(height: 16), + Text( + l10n.albumPermissionTitle, + textAlign: TextAlign.center, + style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600), + ), + const SizedBox(height: 8), + Text( + permanentlyDenied + ? l10n.albumPermissionPermanentSub + : l10n.albumPermissionSub, + textAlign: TextAlign.center, + style: const TextStyle(fontSize: 13, color: AppColors.sub), + ), + const SizedBox(height: 24), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (permanentlyDenied) + CupertinoButton.filled( + onPressed: onOpenSettings, + child: Text(l10n.albumOpenSettings), + ) + else + CupertinoButton.filled( + onPressed: onRetry, + child: Text(l10n.albumRetryRequest), + ), + ], + ), + ], ), ); } diff --git a/lib/features/album/presentation/album_thumbnail.dart b/lib/features/album/presentation/album_thumbnail.dart new file mode 100644 index 0000000..d7e35a6 --- /dev/null +++ b/lib/features/album/presentation/album_thumbnail.dart @@ -0,0 +1,71 @@ +import 'dart:ui' as ui; + +import 'package:cupertino_ui/cupertino_ui.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:ttstd_family_care/features/album/data/photo_providers.dart'; +import 'package:ttstd_family_care/features/album/domain/album_models.dart'; + +import '../../../core/widgets/feature_ui.dart'; + +/// 相册缩略图组件。 +/// +/// 接收 [PhotoThumb] 句柄,异步加载对应媒体缩略图并展示。 +/// 加载中显示浅灰占位块,加载失败(图已删/解码异常)显示灰色底。 +/// +/// 缩略图 future 在 [initState] 中创建并缓存,避免在 [build] 中调用异步方法 +/// 导致每次父组件重建都重新解码(相簿页控制器状态变化频繁,会造成闪烁与 +/// 无谓的 CPU/内存开销)。[thumb] 或 [size] 变化时才会重新加载。 +class AlbumThumb extends ConsumerStatefulWidget { + const AlbumThumb({required this.thumb, this.size = 200, super.key}); + + final PhotoThumb thumb; + + /// 缩略图目标边长(px),越大越清晰但更耗内存。 + final int size; + + @override + ConsumerState createState() => _AlbumThumbState(); +} + +class _AlbumThumbState extends ConsumerState { + late Future _future; + + @override + void initState() { + super.initState(); + _future = _load(); + } + + @override + void didUpdateWidget(covariant AlbumThumb oldWidget) { + super.didUpdateWidget(oldWidget); + // 复用同一组件但换了媒体/尺寸时,重新加载缩略图。 + if (oldWidget.thumb.assetId != widget.thumb.assetId || + oldWidget.size != widget.size) { + _future = _load(); + } + } + + Future _load() => ref + .read(photoRepositoryProvider) + .loadThumb(widget.thumb, size: widget.size); + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: _future, + builder: (context, snapshot) { + if (snapshot.connectionState != ConnectionState.done || + snapshot.data == null) { + return Container(color: AppColors.track); + } + return RawImage( + image: snapshot.data, + fit: BoxFit.cover, + filterQuality: FilterQuality.low, + ); + }, + ); + } +} diff --git a/lib/features/contacts/domain/contact_models.dart b/lib/features/contacts/domain/contact_models.dart index c912104..3d3c206 100644 --- a/lib/features/contacts/domain/contact_models.dart +++ b/lib/features/contacts/domain/contact_models.dart @@ -87,6 +87,16 @@ class Contact { }; } +/// 编辑页删除成功返回的哨兵 Contact。 +/// +/// 编辑页点击删除后以 [context.pop] 返回该常量,详情对话框据此识别「已删除」, +/// 从而关闭自身并刷新列表,避免把空对象当正常更新处理。 +const Contact deletedContactSentinel = Contact( + id: -1, + name: '__deleted__', + phoneNumber: '', +); + /// 容错整型解析:后台可能以字符串(如 "123")或数字返回整型字段, /// 直接用 `as int?` 在字符串场景下会抛出类型错误,故统一在此转换。 int? _toInt(dynamic value) { diff --git a/lib/features/contacts/presentation/contact_detail_page.dart b/lib/features/contacts/presentation/contact_detail_page.dart index f89871c..c1e13b8 100644 --- a/lib/features/contacts/presentation/contact_detail_page.dart +++ b/lib/features/contacts/presentation/contact_detail_page.dart @@ -3,29 +3,39 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:material_ui/material_ui.dart'; -import 'package:ttstd_family_care/core/widgets/feature_ui.dart'; import 'package:ttstd_family_care/core/widgets/settings_ui.dart'; import 'package:ttstd_family_care/features/contacts/domain/contact_models.dart'; import 'package:ttstd_family_care/features/contacts/data/contact_providers.dart'; -import 'package:ttstd_family_care/features/contacts/presentation/contact_edit_page.dart'; import 'package:ttstd_family_care/l10n/app_localizations.dart'; +import '../../../core/utils/phone_call_util.dart'; +import '../../../core/widgets/feature_ui.dart'; import '../../device/data/device_providers.dart'; -/// 联系人详情页。 +/// 底部弹出联系人详情面板。 /// -/// 顶部「编辑」进入 [ContactEditPage];底部「删除」按钮位于页面内(非弹窗), -/// 点击直接删除并回退到列表。 -class ContactDetailPage extends ConsumerStatefulWidget { - const ContactDetailPage({required this.contact, super.key}); +/// 以底部弹出、占满宽度的 Cupertino 面板形式展示联系人信息;标题栏右上角提供 +/// 「编辑」入口,编辑页的删除动作通过返回 [deletedContactSentinel] 通知本面板 +/// 关闭并刷新列表。 +Future showContactDetailDialog(BuildContext context, Contact contact) { + return showCupertinoSheet( + context: context, + showDragHandle: true, + builder: (_) => _ContactDetailDialog(contact: contact), + ); +} + +class _ContactDetailDialog extends ConsumerStatefulWidget { + const _ContactDetailDialog({required this.contact}); final Contact contact; @override - ConsumerState createState() => _ContactDetailPageState(); + ConsumerState<_ContactDetailDialog> createState() => + _ContactDetailDialogState(); } -class _ContactDetailPageState extends ConsumerState { +class _ContactDetailDialogState extends ConsumerState<_ContactDetailDialog> { late Contact _contact; @override @@ -35,11 +45,18 @@ class _ContactDetailPageState extends ConsumerState { } Future _openEdit() async { - final updated = await context.push( + final result = await context.push( '/contacts/edit', extra: _contact, ); - if (updated == null || !mounted) return; + if (!mounted || result == null) return; + + // 编辑页删除成功:关闭详情对话框并刷新列表。 + if (identical(result, deletedContactSentinel)) { + ref.invalidate(contactsProvider); + Navigator.of(context).pop(); + return; + } final l10n = AppLocalizations.of(context); final sn = ref.read(selectedDeviceSnProvider); @@ -47,7 +64,7 @@ class _ContactDetailPageState extends ConsumerState { final repo = ref.read(contactRepositoryProvider); final err = await repo.updateContact( sn, - updated.copyWithId(_contact.id), + result.copyWithId(_contact.id), ); if (!mounted) return; if (err != null) { @@ -58,108 +75,164 @@ class _ContactDetailPageState extends ConsumerState { ); return; } - setState(() => _contact = updated.copyWithId(_contact.id)); + setState(() => _contact = result.copyWithId(_contact.id)); ref.invalidate(contactsProvider); } - Future _delete() async { + /// 拨打电话:用本机系统拨号盘拨打该联系人电话。 + Future _onCall() async { final l10n = AppLocalizations.of(context); + final phone = _contact.phoneNumber; + if (phone.isEmpty) return; + final err = await PhoneCallUtil.dial(phone); + if (!mounted || err == null) return; + AppDialogs.alert( + context, + message: err, + confirmText: l10n.commonConfirm, + ); + } + + /// 反向拨号:向绑定设备下发拨号指令,由老人设备主动呼叫该联系人。 + Future _onReverseDial() async { + final l10n = AppLocalizations.of(context); + final phone = _contact.phoneNumber; + if (phone.isEmpty) return; final sn = ref.read(selectedDeviceSnProvider); - if (sn == null || sn.isEmpty) return; - final repo = ref.read(contactRepositoryProvider); - final err = await repo.deleteContact(sn, _contact.id); + if (sn == null || sn.isEmpty) { + AppDialogs.alert( + context, + message: l10n.contactNoDevice, + confirmText: l10n.commonConfirm, + ); + return; + } + final err = await ref + .read(deviceRepositoryProvider) + .reverseDial(sn, phone); if (!mounted) return; - if (err != null) { + if (err == null) { + AppDialogs.alert( + context, + message: l10n.contactReverseDialSent, + confirmText: l10n.commonConfirm, + ); + } else { AppDialogs.alert( context, message: err, confirmText: l10n.commonConfirm, ); - return; } - context.pop(); } @override Widget build(BuildContext context) { final l10n = AppLocalizations.of(context); final c = _contact; - final url = c.avatar; - final hasAvatar = url != null && url.isNotEmpty; - final avatar = hasAvatar - ? CircleAvatar( - radius: 40, - backgroundImage: NetworkImage(url), - onBackgroundImageError: (_, _) {}, - ) - : CircleAvatar( - radius: 40, - backgroundColor: AppColors.green.withValues(alpha: 0.15), - child: Text( - c.displayName.isNotEmpty ? c.displayName.characters.first : '?', - style: const TextStyle(color: AppColors.green, fontSize: 28), - ), - ); - - return CupertinoPageScaffold( - backgroundColor: AppColors.surface, - navigationBar: CupertinoNavigationBar( - middle: Text(l10n.contactDetailTitle), - trailing: CupertinoButton( - padding: EdgeInsets.zero, - onPressed: _openEdit, - child: Text(l10n.commonEdit), + return Container( + width: double.infinity, + color: AppColors.surface, + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + // 顶部标题栏:左侧标题,右上角「编辑」按钮。 + Padding( + padding: const EdgeInsets.fromLTRB(20, 14, 8, 4), + child: Row( + children: [ + Expanded( + child: Text( + l10n.contactDetailTitle, + style: const TextStyle( + fontSize: 17, + fontWeight: FontWeight.w600, + color: AppColors.ink, + ), + ), + ), + CupertinoButton( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + onPressed: _openEdit, + child: Text( + l10n.contactEdit, + style: const TextStyle(fontSize: 16, color: AppColors.green), + ), + ), + ], + ), ), + Padding( + padding: const EdgeInsets.fromLTRB(20, 4, 20, 16), + child: Center(child: _NameAvatar(name: c.name)), + ), + const Divider(height: 1, color: Color(0xFFE6EAF0)), + _DetailRow(label: l10n.contactName, value: c.name), + _DetailRow(label: l10n.contactNick, value: c.nickName ?? '-'), + _DetailRow(label: l10n.contactPhone, value: c.phoneNumber), + _DetailRow( + label: l10n.contactIsEmergency, + value: c.emergency + ? l10n.contactEmergencyYes + : l10n.contactEmergencyNo, + ), + Padding( + padding: const EdgeInsets.fromLTRB(20, 16, 20, 20), + child: Row( + children: [ + Expanded( + child: PrimaryButton( + text: l10n.contactCall, + onPressed: _onCall, + ), + ), + const SizedBox(width: 12), + Expanded( + child: SecondaryButton( + text: l10n.contactReverseDial, + onPressed: _onReverseDial, + ), + ), + ], + ), + ), + ], ), - child: SafeArea( - child: Column( - children: [ - Expanded( - child: ListView( - padding: const EdgeInsets.symmetric(vertical: 16), - children: [ - Center(child: avatar), - const SizedBox(height: 12), - Center( - child: Text( - c.displayName, - style: const TextStyle( - fontSize: 20, - fontWeight: FontWeight.w600, - color: AppColors.ink, - ), - ), - ), - const SizedBox(height: 24), - _DetailRow(label: l10n.contactName, value: c.name), - _DetailRow( - label: l10n.contactNick, - value: c.nickName ?? '-', - ), - _DetailRow( - label: l10n.contactPhone, - value: c.phoneNumber, - ), - _DetailRow( - label: l10n.contactIsEmergency, - value: c.emergency - ? l10n.contactEmergencyYes - : l10n.contactEmergencyNo, - ), - ], - ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(16, 8, 16, 16), - child: PrimaryButton( - text: l10n.commonDelete, - color: AppColors.red, - onPressed: _delete, - ), - ), - ], - ), + ); + } +} + +/// 由姓名首字生成的头像(纯色圆形 + 首字)。 +class _NameAvatar extends StatelessWidget { + const _NameAvatar({required this.name}); + + final String name; + + static const List _palette = [ + Color(0xFFF2994A), + Color(0xFFEB5757), + Color(0xFF27AE60), + Color(0xFF2D9CDB), + Color(0xFF9B51E0), + Color(0xFF56CCF2), + Color(0xFF6FCF97), + Color(0xFFF2C94C), + ]; + + @override + Widget build(BuildContext context) { + final text = name.trim(); + final first = text.isNotEmpty ? text.characters.first.toUpperCase() : '?'; + final index = text.isEmpty ? 0 : (text.codeUnitAt(0) % _palette.length); + final color = _palette[index]; + return CircleAvatar( + radius: 34, + backgroundColor: color.withValues(alpha: 0.15), + child: Text( + first, + style: TextStyle(color: color, fontSize: 26, fontWeight: FontWeight.w600), ), ); } @@ -174,10 +247,9 @@ class _DetailRow extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), - decoration: BoxDecoration( - color: AppColors.surface, - border: const Border( + padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14), + decoration: const BoxDecoration( + border: Border( bottom: BorderSide(color: Color(0xFFE6EAF0), width: 0.5), ), ), diff --git a/lib/features/contacts/presentation/contact_edit_page.dart b/lib/features/contacts/presentation/contact_edit_page.dart index 2cbe7f3..de13b0f 100644 --- a/lib/features/contacts/presentation/contact_edit_page.dart +++ b/lib/features/contacts/presentation/contact_edit_page.dart @@ -1,16 +1,20 @@ import 'package:cupertino_ui/cupertino_ui.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; +import 'package:material_ui/material_ui.dart'; -import 'package:ttstd_family_care/core/widgets/feature_ui.dart'; import 'package:ttstd_family_care/core/widgets/settings_ui.dart'; import 'package:ttstd_family_care/features/contacts/domain/contact_models.dart'; +import 'package:ttstd_family_care/features/contacts/data/contact_providers.dart'; import 'package:ttstd_family_care/l10n/app_localizations.dart'; +import '../../../core/widgets/feature_ui.dart'; +import '../../device/data/device_providers.dart'; + /// 新增/编辑联系人整页。 /// -/// 表单收集结果后以 [context.pop] 返回 [Contact],由调用方(列表页 / 详情页) -/// 决定新增还是更新。 +/// 表单收集结果后以 [context.pop] 返回 [Contact],由调用方(列表页 / 详情对话框) +/// 决定新增还是更新;删除成功后返回 [deletedContactSentinel]。 class ContactEditPage extends ConsumerStatefulWidget { const ContactEditPage({this.contact, super.key}); @@ -81,10 +85,41 @@ class _ContactEditPageState extends ConsumerState { context.pop(updated); } + Future _delete() async { + final c = widget.contact; + if (c == null) return; + final l10n = AppLocalizations.of(context); + final sn = ref.read(selectedDeviceSnProvider); + if (sn == null || sn.isEmpty) return; + + final ok = await AppDialogs.confirm( + context, + message: l10n.deleteConfirm(c.name), + confirmText: l10n.commonDelete, + cancelText: l10n.commonCancel, + ); + if (!ok || !mounted) return; + + final repo = ref.read(contactRepositoryProvider); + final err = await repo.deleteContact(sn, c.id); + if (!mounted) return; + if (err != null) { + AppDialogs.alert( + context, + message: err, + confirmText: l10n.commonConfirm, + ); + return; + } + ref.invalidate(contactsProvider); + context.pop(deletedContactSentinel); + } + @override Widget build(BuildContext context) { final l10n = AppLocalizations.of(context); - final isEdit = widget.contact != null; + final c = widget.contact; + final isEdit = c != null; return CupertinoPageScaffold( backgroundColor: AppColors.surface, navigationBar: CupertinoNavigationBar( @@ -104,6 +139,13 @@ class _ContactEditPageState extends ConsumerState { child: ListView( padding: const EdgeInsets.symmetric(vertical: 16), children: [ + if (c != null) + Padding( + padding: const EdgeInsets.only(bottom: 16), + child: Center( + child: _EditAvatar(name: c.name), + ), + ), LabeledField( label: l10n.contactName, controller: _nameController, @@ -151,9 +193,54 @@ class _ContactEditPageState extends ConsumerState { onPressed: _save, ), ), + if (isEdit) ...[ + const SizedBox(height: 12), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: PrimaryButton( + text: l10n.commonDelete, + color: AppColors.red, + onPressed: _delete, + ), + ), + ], ], ), ), ); } } + +/// 编辑页顶部由姓名首字生成的头像(与详情对话框一致的样式)。 +class _EditAvatar extends StatelessWidget { + const _EditAvatar({required this.name}); + + final String name; + + static const List _palette = [ + Color(0xFFF2994A), + Color(0xFFEB5757), + Color(0xFF27AE60), + Color(0xFF2D9CDB), + Color(0xFF9B51E0), + Color(0xFF56CCF2), + Color(0xFF6FCF97), + Color(0xFFF2C94C), + ]; + + @override + Widget build(BuildContext context) { + final text = name.trim(); + final first = text.isNotEmpty ? text.characters.first.toUpperCase() : '?'; + final index = text.isEmpty ? 0 : (text.codeUnitAt(0) % _palette.length); + final color = _palette[index]; + return CircleAvatar( + radius: 36, + backgroundColor: color.withValues(alpha: 0.15), + child: Text( + first, + style: TextStyle(color: color, fontSize: 28, fontWeight: FontWeight.w600), + ), + ); + } +} diff --git a/lib/features/contacts/presentation/contacts_page.dart b/lib/features/contacts/presentation/contacts_page.dart index 0856e27..0ef03e0 100644 --- a/lib/features/contacts/presentation/contacts_page.dart +++ b/lib/features/contacts/presentation/contacts_page.dart @@ -9,6 +9,7 @@ import 'package:ttstd_family_care/core/widgets/feature_ui.dart'; import 'package:ttstd_family_care/core/widgets/settings_ui.dart'; import 'package:ttstd_family_care/features/contacts/domain/contact_models.dart'; import 'package:ttstd_family_care/features/contacts/data/contact_providers.dart'; +import 'package:ttstd_family_care/features/contacts/presentation/contact_detail_page.dart'; import 'package:ttstd_family_care/l10n/app_localizations.dart'; import '../../device/data/device_providers.dart'; @@ -58,7 +59,7 @@ class _ContactsPageState extends ConsumerState { } void _onTap(Contact contact) { - context.push('/contacts/detail', extra: contact); + showContactDetailDialog(context, contact); } Future _onAdd() async { @@ -241,6 +242,7 @@ class _ContactTile extends StatelessWidget { return GestureDetector( onTap: onTap, + behavior: HitTestBehavior.opaque, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), child: Row( diff --git a/lib/features/device/data/device_api.dart b/lib/features/device/data/device_api.dart index 94aa710..13a89bf 100644 --- a/lib/features/device/data/device_api.dart +++ b/lib/features/device/data/device_api.dart @@ -1,4 +1,7 @@ +import 'dart:io'; + import 'package:cupertino_ui/cupertino_ui.dart'; +import 'package:dio/dio.dart'; import 'package:ttstd_family_care/app/constants/app_constants.dart'; import 'package:ttstd_family_care/core/network/api_exception.dart'; import 'package:ttstd_family_care/core/network/dio_client.dart'; @@ -26,15 +29,22 @@ class DeviceApi { } } - /// 绑定设备(手动输入 SN 或扫码得到 SN 后调用)。 + /// 请求绑定设备(手动输入 SN 或扫码得到 SN 后调用)。 + /// + /// 对应后台 `POST /api/v1/client/sn/bind-request`: + /// 后端校验设备存在后推送绑定请求到设备端,由设备端弹窗确认; + /// 设备同意后完成绑定。因此本接口成功仅表示「绑定请求已发送」。 /// /// 成功返回 null;失败返回后台错误提示。 Future bindDevice(String sn, {String? remark}) async { try { + final queryParameters = {'sn': sn}; + if (remark != null && remark.isNotEmpty) { + queryParameters['remark'] = remark; + } final data = await DioClient.post( - 'v1/client/sn/bind', - queryParameters: {'sn': sn}, - data: remark != null && remark.isNotEmpty ? {'remark': remark} : null, + 'v1/client/sn/bind-request', + queryParameters: queryParameters, ); debugPrint('[DeviceApi] bindDevice sn=$sn data=$data'); return null; @@ -100,6 +110,40 @@ class DeviceApi { } } + /// 获取已绑定设备策略信息(功能开关)。 + /// + /// 对应后台 `GET /api/v1/client/sn/policy?sn=xxx`;SN 合法且无记录时自动新建默认策略。 + /// 失败时返回 null。 + Future getPolicy(String sn) async { + try { + final data = await DioClient.get( + 'v1/client/sn/policy', + queryParameters: {'sn': sn}, + ); + return data is Map ? DevicePolicy.fromJson(data) : null; + } on ApiException { + return null; + } + } + + /// 单独设置某个策略开关。 + /// + /// 对应后台 `PUT /api/v1/client/sn/policy/toggle`,请求体 `{field, value}`。 + /// 成功返回 null;失败返回后台错误提示。 + Future togglePolicy(String sn, String field, int value) async { + try { + final data = await DioClient.put( + 'v1/client/sn/policy/toggle?sn=${Uri.encodeQueryComponent(sn)}', + data: {'field': field, 'value': value}, + ); + debugPrint('[DeviceApi] togglePolicy sn=$sn field=$field value=$value data=$data'); + return null; + } on ApiException catch (e) { + debugPrint('[DeviceApi] togglePolicy sn=$sn field=$field value=$value failed: ${e.message}'); + return e.message; + } + } + /// 向设备下发操作指令(重启/关机/截屏/刷新/定位/拍照等)。 /// /// [op] 为后端操作标识,如 `reboot` / `shutdown` / `screenshot` / `refresh` / `locate` / `take_photo`, @@ -122,6 +166,210 @@ class DeviceApi { } } + /// 反向拨号:向设备下发拨号指令,由设备主动呼叫指定手机号。 + /// + /// 对应后台 `POST /api/v1/client/sn/reverse-dial?sn=xxx&phone=xxx`。 + /// 成功返回 null;失败返回后台错误提示。 + Future reverseDial(String sn, String phone) async { + try { + await DioClient.post( + 'v1/client/sn/reverse-dial', + queryParameters: {'sn': sn, 'phone': phone}, + ); + debugPrint('[DeviceApi] reverseDial sn=$sn phone=$phone success'); + return null; + } on ApiException catch (e) { + debugPrint('[DeviceApi] reverseDial sn=$sn phone=$phone failed: ${e.message}'); + return e.message; + } + } + + /// 上传单个壁纸(家属端),保存为设备单个壁纸并推送设备。 + /// + /// 对应后台 `POST /api/v1/client/sn/wallpaper/single?sn=xxx`(multipart)。 + /// 返回记录:成功时 [url] 为保存后的图片 URL、[fileSize] 为文件大小(字节), + /// 失败时 [error] 为错误提示。 + Future<({String? url, int? fileSize, String? error})> uploadWallpaperSingle( + String sn, File file) async { + try { + final formData = FormData.fromMap({ + 'file': await MultipartFile.fromFile(file.path, + filename: file.uri.pathSegments.last), + }); + final data = await DioClient.postMultipart( + 'v1/client/sn/wallpaper/single', + formData: formData, + queryParameters: {'sn': sn}, + ); + debugPrint('[DeviceApi] uploadWallpaperSingle sn=$sn success'); + final map = data is Map ? data : null; + final rawSize = map?['fileSize']; + return ( + url: map?['url'] as String?, + fileSize: (rawSize is int) ? rawSize : null, + error: null, + ); + } on ApiException catch (e) { + debugPrint( + '[DeviceApi] uploadWallpaperSingle sn=$sn failed: ${e.message}'); + return (url: null, fileSize: null, error: e.message); + } + } + + /// 上传轮换壁纸(家属端),保存为设备轮换壁纸(最多 7 张)并推送设备。 + /// + /// 对应后台 `POST /api/v1/client/sn/wallpaper/rotation?sn=xxx`(multipart)。 + /// 返回记录:成功时 [urls] 为按顺序保存的图片 URL 列表,失败时 [error] 为错误提示。 + Future<({List? urls, String? error})> uploadWallpaperRotation( + String sn, List files) async { + try { + final formData = FormData(); + for (final file in files) { + formData.files.add(MapEntry( + 'files', + await MultipartFile.fromFile(file.path, + filename: file.uri.pathSegments.last), + )); + } + final data = await DioClient.postMultipart( + 'v1/client/sn/wallpaper/rotation', + formData: formData, + queryParameters: {'sn': sn}, + ); + final urls = data is List + ? data + .whereType() + .map((e) => e['url'] as String?) + .whereType() + .toList() + : null; + debugPrint( + '[DeviceApi] uploadWallpaperRotation sn=$sn count=${files.length} success'); + return (urls: urls, error: null); + } on ApiException catch (e) { + debugPrint( + '[DeviceApi] uploadWallpaperRotation sn=$sn failed: ${e.message}'); + return (urls: null, error: e.message); + } + } + + /// 调整壁纸展示顺序(家属端)。 + /// + /// 对应后台 `POST /api/v1/client/sn/wallpaper/reorder?sn=xxx`,body 携带按新顺序排列的图片URL。 + /// 成功返回 null;失败返回后台错误提示。 + Future reorderWallpaper(String sn, List urls) async { + try { + await DioClient.post( + 'v1/client/sn/wallpaper/reorder', + data: {'images': urls}, + queryParameters: {'sn': sn}, + ); + debugPrint('[DeviceApi] reorderWallpaper sn=$sn success, order=$urls'); + return null; + } on ApiException catch (e) { + debugPrint('[DeviceApi] reorderWallpaper sn=$sn failed: ${e.message}'); + return e.message; + } + } + + /// 获取设备壁纸配置(家属端)。 + /// + /// 对应后台 `GET /api/v1/client/sn/wallpaper?sn=xxx`。 + /// 未配置或无数据时返回 null。 + Future getWallpaperConfig(String sn) async { + try { + final data = await DioClient.get( + 'v1/client/sn/wallpaper', + queryParameters: {'sn': sn}, + ); + return data is Map + ? WallpaperConfig.fromJson(data) + : null; + } on ApiException { + return null; + } + } + + /// 发送图片到设备(家属端),设备收到推送后弹窗显示图片。 + /// + /// 独立于壁纸接口:对应后台 `POST /api/v1/client/sn/picture/send?sn=xxx`(multipart)。 + /// [favorite] 是否标记收藏,默认 false。 + /// 成功返回 null;失败返回后台错误提示。 + Future sendPicture(String sn, File file, + {bool favorite = false}) async { + try { + final formData = FormData.fromMap({ + 'file': await MultipartFile.fromFile(file.path, + filename: file.uri.pathSegments.last), + }); + await DioClient.postMultipart( + 'v1/client/sn/picture/send', + formData: formData, + queryParameters: {'sn': sn, 'favorite': favorite ? 1 : 0}, + ); + debugPrint('[DeviceApi] sendPicture sn=$sn favorite=$favorite success'); + return null; + } on ApiException catch (e) { + debugPrint('[DeviceApi] sendPicture sn=$sn failed: ${e.message}'); + return e.message; + } + } + + /// 查询已发送到设备的图片列表(家属端)。 + /// + /// 对应后台 `GET /api/v1/client/sn/picture/list?sn=xxx`(按发送时间倒序)。 + /// 返回补全源地址的图片信息列表(含收藏状态);无记录或失败时返回空列表。 + Future> getPictureList(String sn) async { + try { + final payload = await DioClient.get( + 'v1/client/sn/picture/list', + queryParameters: {'sn': sn}, + ); + final listData = payload is List + ? payload + : (payload is Map && payload['data'] is List + ? payload['data'] as List + : const []); + final origin = Uri.parse(AppConstants.kBaseUrl).origin; + return listData.whereType().map((e) { + final vo = DevicePictureInfo.fromJson( + e.map((k, v) => MapEntry(k.toString(), v))); + return DevicePictureInfo( + url: vo.url.startsWith('/') ? '$origin${vo.url}' : vo.url, + favorite: vo.favorite, + fileSize: vo.fileSize, + ); + }).toList(growable: false); + } on ApiException { + return const []; + } + } + + /// 设置图片收藏状态(家属端)。 + /// + /// 对应后台 `POST /api/v1/client/sn/picture/favorite?sn=xxx&url=xxx&favorite=0|1`。 + /// 成功返回 null;失败返回后台错误提示。 + Future setPictureFavorite( + String sn, String url, bool favorite) async { + try { + await DioClient.post( + 'v1/client/sn/picture/favorite', + queryParameters: { + 'sn': sn, + 'url': url, + 'favorite': favorite ? 1 : 0, + }, + ); + debugPrint( + '[DeviceApi] setPictureFavorite sn=$sn favorite=$favorite success'); + return null; + } on ApiException catch (e) { + debugPrint( + '[DeviceApi] setPictureFavorite sn=$sn failed: ${e.message}'); + return e.message; + } + } + /// 对指定应用执行操作(打开/停止/卸载/清除数据)。 /// /// [op] 为后端操作标识:`launch` / `stop` / `uninstall` / `clear_data`, diff --git a/lib/features/device/data/device_providers.dart b/lib/features/device/data/device_providers.dart index fe075ff..3da3f6c 100644 --- a/lib/features/device/data/device_providers.dart +++ b/lib/features/device/data/device_providers.dart @@ -20,12 +20,15 @@ final myDevicesProvider = FutureProvider>((ref) async { /// /// 使用普通 Provider(而非 StateProvider)以便随 [myDevicesProvider] 的加载完成 /// 自动推导出首个已绑定设备的 SN。若后续需要手动切换设备,可改为 StateProvider。 +/// +/// 解绑/绑定后 [myDevicesProvider] 被 invalidate 重新请求时,用 [AsyncValue.value] +/// 在刷新期间保留上一次的列表,避免默认 SN 短暂丢失;刷新完成后自动取新列表 +/// 首个设备作为新默认 SN(解绑的是默认设备时默认 SN 会随之更新)。 final selectedDeviceSnProvider = Provider((ref) { final devices = ref.watch(myDevicesProvider); - return devices.maybeWhen( - data: (list) => list.isEmpty ? null : list.first.serialno, - orElse: () => null, - ); + // loading/error 期间保留上一次成功数据,避免默认 SN 闪失。 + final list = devices.value ?? const []; + return list.isEmpty ? null : list.first.serialno; }); /// 按 SN 获取设备基本信息。 @@ -59,3 +62,11 @@ final recentScreenshotsProvider = final repo = ref.watch(deviceRepositoryProvider); return repo.getRecentScreenshots(sn); }); + +/// 按 SN 获取设备策略信息(功能开关)。 +final devicePolicyProvider = + FutureProvider.family((ref, sn) async { + if (sn.isEmpty) return null; + final repo = ref.watch(deviceRepositoryProvider); + return repo.getPolicy(sn); +}); diff --git a/lib/features/device/data/device_repository_impl.dart b/lib/features/device/data/device_repository_impl.dart index 3bd6a21..c075952 100644 --- a/lib/features/device/data/device_repository_impl.dart +++ b/lib/features/device/data/device_repository_impl.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:ttstd_family_care/features/device/data/device_api.dart'; import 'package:ttstd_family_care/features/device/domain/device_models.dart'; import 'package:ttstd_family_care/features/device/domain/device_repository.dart'; @@ -32,6 +34,13 @@ class DeviceRepositoryImpl implements DeviceRepository { Future> getRecentScreenshots(String sn) => _api.getRecentScreenshots(sn: sn); + @override + Future getPolicy(String sn) => _api.getPolicy(sn); + + @override + Future togglePolicy(String sn, String field, int value) => + _api.togglePolicy(sn, field, value); + @override Future sendDeviceOp(String sn, String op, {Map? extra}) => _api.sendDeviceOp(sn, op, extra: extra); @@ -40,6 +49,41 @@ class DeviceRepositoryImpl implements DeviceRepository { Future sendAppOp(String sn, String op, String packageName) => _api.sendAppOp(sn, op, packageName); + @override + Future reverseDial(String sn, String phone) => + _api.reverseDial(sn, phone); + + @override + Future<({String? url, int? fileSize, String? error})> uploadWallpaperSingle( + String sn, File file) => + _api.uploadWallpaperSingle(sn, file); + + @override + Future<({List? urls, String? error})> uploadWallpaperRotation( + String sn, List files) => + _api.uploadWallpaperRotation(sn, files); + + @override + Future reorderWallpaper(String sn, List urls) => + _api.reorderWallpaper(sn, urls); + + @override + Future getWallpaperConfig(String sn) => + _api.getWallpaperConfig(sn); + + @override + Future sendPicture(String sn, File file, + {bool favorite = false}) => + _api.sendPicture(sn, file, favorite: favorite); + + @override + Future> getPictureList(String sn) => + _api.getPictureList(sn); + + @override + Future setPictureFavorite(String sn, String url, bool favorite) => + _api.setPictureFavorite(sn, url, favorite); + @override Future deleteScreenshot(String sn, int id) => _api.deleteScreenshot(sn, id); diff --git a/lib/features/device/domain/device_models.dart b/lib/features/device/domain/device_models.dart index f6007a4..1d11571 100644 --- a/lib/features/device/domain/device_models.dart +++ b/lib/features/device/domain/device_models.dart @@ -201,6 +201,220 @@ class SnScreenshot { ); } +/// 设备策略信息(与后台 DevicePolicyVO 对齐,字段均对应「0关闭 1开启」策略开关)。 +class DevicePolicy { + const DevicePolicy({ + this.id, + this.serialno, + this.usbData, + this.timeSetting, + this.storageCard, + this.factoryReset, + this.wifiHotspot, + this.bluetooth, + this.wallpaper, + this.notificationBar, + this.statusBarPullDown, + this.systemNavBarShow, + this.systemNavBarSetting, + this.navBarOptions, + this.configBluetooth, + this.otaUpgrade, + this.installApps, + this.autoRotate, + this.autoBrightness, + this.eyeProtection, + this.darkMode, + this.safeBoot, + this.adbUsbDebug, + this.mountPhysicalStorage, + this.modifySystemTimeZone, + this.toggleAirplaneMode, + this.modifyMobileApn, + this.uninstallApps, + this.camera, + this.usbFileTransfer, + this.modifyLocationSwitch, + this.bluetoothSharing, + this.resetNetworkSettings, + this.adjustGlobalVolume, + this.modifyScreenTimeout, + this.manualAdjustTimeZone, + this.modifySystemLanguage, + this.manualAdjustBrightness, + }); + + final int? id; + final String? serialno; + + // 策略开关(0关闭 1开启),null 视为未返回。 + final int? usbData; + final int? timeSetting; + final int? storageCard; + final int? factoryReset; + final int? wifiHotspot; + final int? bluetooth; + final int? wallpaper; + final int? notificationBar; + final int? statusBarPullDown; + final int? systemNavBarShow; + final int? systemNavBarSetting; + final int? navBarOptions; + final int? configBluetooth; + final int? otaUpgrade; + final int? installApps; + final int? autoRotate; + final int? autoBrightness; + final int? eyeProtection; + final int? darkMode; + final int? safeBoot; + final int? adbUsbDebug; + final int? mountPhysicalStorage; + final int? modifySystemTimeZone; + final int? toggleAirplaneMode; + final int? modifyMobileApn; + final int? uninstallApps; + final int? camera; + final int? usbFileTransfer; + final int? modifyLocationSwitch; + final int? bluetoothSharing; + final int? resetNetworkSettings; + final int? adjustGlobalVolume; + final int? modifyScreenTimeout; + final int? manualAdjustTimeZone; + final int? modifySystemLanguage; + final int? manualAdjustBrightness; + + /// 读取某个策略字段开关值(0/1,缺失按 0 关闭处理)。 + bool enabled(String field) { + final value = _intField(field); + return value == 1; + } + + /// 返回某个策略字段当前值(null 表示未知)。 + int? valueOf(String field) => _intField(field); + + int? _intField(String field) { + switch (field) { + case 'usbData': + return usbData; + case 'timeSetting': + return timeSetting; + case 'storageCard': + return storageCard; + case 'factoryReset': + return factoryReset; + case 'wifiHotspot': + return wifiHotspot; + case 'bluetooth': + return bluetooth; + case 'wallpaper': + return wallpaper; + case 'notificationBar': + return notificationBar; + case 'statusBarPullDown': + return statusBarPullDown; + case 'systemNavBarShow': + return systemNavBarShow; + case 'systemNavBarSetting': + return systemNavBarSetting; + case 'navBarOptions': + return navBarOptions; + case 'configBluetooth': + return configBluetooth; + case 'otaUpgrade': + return otaUpgrade; + case 'installApps': + return installApps; + case 'autoRotate': + return autoRotate; + case 'autoBrightness': + return autoBrightness; + case 'eyeProtection': + return eyeProtection; + case 'darkMode': + return darkMode; + case 'safeBoot': + return safeBoot; + case 'adbUsbDebug': + return adbUsbDebug; + case 'mountPhysicalStorage': + return mountPhysicalStorage; + case 'modifySystemTimeZone': + return modifySystemTimeZone; + case 'toggleAirplaneMode': + return toggleAirplaneMode; + case 'modifyMobileApn': + return modifyMobileApn; + case 'uninstallApps': + return uninstallApps; + case 'camera': + return camera; + case 'usbFileTransfer': + return usbFileTransfer; + case 'modifyLocationSwitch': + return modifyLocationSwitch; + case 'bluetoothSharing': + return bluetoothSharing; + case 'resetNetworkSettings': + return resetNetworkSettings; + case 'adjustGlobalVolume': + return adjustGlobalVolume; + case 'modifyScreenTimeout': + return modifyScreenTimeout; + case 'manualAdjustTimeZone': + return manualAdjustTimeZone; + case 'modifySystemLanguage': + return modifySystemLanguage; + case 'manualAdjustBrightness': + return manualAdjustBrightness; + default: + return null; + } + } + + factory DevicePolicy.fromJson(Map json) => DevicePolicy( + id: _toInt(json['id']), + serialno: json['serialno'] as String?, + usbData: _toInt(json['usbData']), + timeSetting: _toInt(json['timeSetting']), + storageCard: _toInt(json['storageCard']), + factoryReset: _toInt(json['factoryReset']), + wifiHotspot: _toInt(json['wifiHotspot']), + bluetooth: _toInt(json['bluetooth']), + wallpaper: _toInt(json['wallpaper']), + notificationBar: _toInt(json['notificationBar']), + statusBarPullDown: _toInt(json['statusBarPullDown']), + systemNavBarShow: _toInt(json['systemNavBarShow']), + systemNavBarSetting: _toInt(json['systemNavBarSetting']), + navBarOptions: _toInt(json['navBarOptions']), + configBluetooth: _toInt(json['configBluetooth']), + otaUpgrade: _toInt(json['otaUpgrade']), + installApps: _toInt(json['installApps']), + autoRotate: _toInt(json['autoRotate']), + autoBrightness: _toInt(json['autoBrightness']), + eyeProtection: _toInt(json['eyeProtection']), + darkMode: _toInt(json['darkMode']), + safeBoot: _toInt(json['safeBoot']), + adbUsbDebug: _toInt(json['adbUsbDebug']), + mountPhysicalStorage: _toInt(json['mountPhysicalStorage']), + modifySystemTimeZone: _toInt(json['modifySystemTimeZone']), + toggleAirplaneMode: _toInt(json['toggleAirplaneMode']), + modifyMobileApn: _toInt(json['modifyMobileApn']), + uninstallApps: _toInt(json['uninstallApps']), + camera: _toInt(json['camera']), + usbFileTransfer: _toInt(json['usbFileTransfer']), + modifyLocationSwitch: _toInt(json['modifyLocationSwitch']), + bluetoothSharing: _toInt(json['bluetoothSharing']), + resetNetworkSettings: _toInt(json['resetNetworkSettings']), + adjustGlobalVolume: _toInt(json['adjustGlobalVolume']), + modifyScreenTimeout: _toInt(json['modifyScreenTimeout']), + manualAdjustTimeZone: _toInt(json['manualAdjustTimeZone']), + modifySystemLanguage: _toInt(json['modifySystemLanguage']), + manualAdjustBrightness: _toInt(json['manualAdjustBrightness']), + ); +} + /// 设备截图视图对象(与后台 ScreenshotVO 对齐)。 class ScreenshotVO { const ScreenshotVO({ @@ -229,6 +443,63 @@ class ScreenshotVO { ); } +//// 设备壁纸配置(与后台 DeviceWallpaperVO 对齐)。 +class WallpaperConfig { + const WallpaperConfig({ + this.serialno, + this.mode, + this.images = const [], + }); + + final String? serialno; + + /// 壁纸模式:0-单个壁纸,1-轮换壁纸。 + final int? mode; + + /// 壁纸图片URL列表(单个1张,轮换最多7张;可能为相对路径 /static/wallpaper/xxx)。 + final List images; + + factory WallpaperConfig.fromJson(Map json) => + WallpaperConfig( + serialno: json['serialno'] as String?, + mode: _toInt(json['mode']), + images: (json['images'] as List? ?? const []) + .whereType() + .toList(), + ); +} + +/// 已发送到设备的图片信息(与后台 DevicePictureVO 对齐)。 +class DevicePictureInfo { + const DevicePictureInfo({ + required this.url, + this.favorite = false, + this.fileSize = 0, + }); + + /// 图片完整URL。 + final String url; + + /// 是否收藏。 + final bool favorite; + + /// 文件大小(字节)。 + final int fileSize; + + factory DevicePictureInfo.fromJson(Map json) => + DevicePictureInfo( + url: (json['url'] as String?) ?? '', + favorite: _toInt(json['favorite']) == 1, + fileSize: _toInt(json['fileSize']) ?? 0, + ); + + DevicePictureInfo copyWith({bool? favorite}) => DevicePictureInfo( + url: url, + favorite: favorite ?? this.favorite, + fileSize: fileSize, + ); +} + /// 容错整型解析:后台可能以字符串(如 "123")或数字返回整型字段, /// 直接用 `as int?` 在字符串场景下会抛出 /// `type 'String' is not a subtype of type 'int'`,故统一在此转换。 diff --git a/lib/features/device/domain/device_repository.dart b/lib/features/device/domain/device_repository.dart index 9716790..fd49e89 100644 --- a/lib/features/device/domain/device_repository.dart +++ b/lib/features/device/domain/device_repository.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:ttstd_family_care/features/device/domain/device_models.dart'; /// 设备仓储,封装设备信息/定位/应用列表/绑定设备列表的获取。 @@ -27,6 +29,14 @@ abstract class DeviceRepository { /// 已绑定设备最近截图列表。 Future> getRecentScreenshots(String sn); + /// 已绑定设备策略信息(功能开关),无记录时为 null。 + Future getPolicy(String sn); + + /// 单独设置某个策略开关(field 为策略字段名,value 为 0/1)。 + /// + /// 成功返回 null;失败返回错误提示。 + Future togglePolicy(String sn, String field, int value); + /// 向设备下发操作指令(重启/关机/截屏/刷新/定位/拍照等)。 /// /// [op] 为后端操作标识,如 `reboot` / `shutdown` / `screenshot` / `refresh` / `locate` / `take_photo`。 @@ -40,6 +50,45 @@ abstract class DeviceRepository { /// 成功返回 null;失败返回错误提示。 Future sendAppOp(String sn, String op, String packageName); + /// 反向拨号:向设备下发拨号指令,由设备主动呼叫 [phone]。 + /// + /// 成功返回 null;失败返回错误提示。 + Future reverseDial(String sn, String phone); + + /// 上传单个壁纸:保存为设备单个壁纸并推送设备。 + /// + /// 返回记录:成功时 [url] 为保存后的图片 URL、[fileSize] 为文件大小(字节), + /// 失败时 [error] 为错误提示。 + Future<({String? url, int? fileSize, String? error})> uploadWallpaperSingle( + String sn, File file); + + /// 上传轮换壁纸(最多 7 张):保存为设备轮换壁纸并推送设备。 + /// + /// 返回记录:成功时 [urls] 为按顺序保存的图片 URL 列表,失败时 [error] 为错误提示。 + Future<({List? urls, String? error})> uploadWallpaperRotation( + String sn, List files); + + /// 调整壁纸展示顺序(按 [urls] 顺序更新 sort_no)。 + /// + /// 成功返回 null;失败返回错误提示。 + Future reorderWallpaper(String sn, List urls); + + /// 获取设备壁纸配置(家属端),未配置时返回 null。 + Future getWallpaperConfig(String sn); + + /// 发送图片到设备(设备收到推送后弹窗显示图片)。 + /// + /// [favorite] 是否标记收藏,默认 false。成功返回 null;失败返回错误提示。 + Future sendPicture(String sn, File file, {bool favorite = false}); + + /// 查询已发送到设备的图片列表(含收藏状态,按发送时间倒序)。 + Future> getPictureList(String sn); + + /// 设置图片收藏状态(按设备 + 图片URL)。 + /// + /// 成功返回 null;失败返回错误提示。 + Future setPictureFavorite(String sn, String url, bool favorite); + /// 删除单张设备截图(家属端 client 接口)。 /// /// [sn] 设备序列号,[id] 截图ID。成功返回 null;失败返回错误提示。 diff --git a/lib/features/device/presentation/device_bind_page.dart b/lib/features/device/presentation/device_bind_page.dart index 8b34864..2cb7efb 100644 --- a/lib/features/device/presentation/device_bind_page.dart +++ b/lib/features/device/presentation/device_bind_page.dart @@ -73,6 +73,7 @@ class _DeviceBindPageState extends ConsumerState { controller: _snController, placeholder: l10n.deviceBindSnHint, keyboardType: TextInputType.text, + labelTrailing: l10n.deviceBindSnCaseSensitive, ), LabeledField( label: l10n.deviceBindRemarkLabel, diff --git a/lib/features/device/presentation/device_manage_page.dart b/lib/features/device/presentation/device_manage_page.dart index cf1c015..f4423a5 100644 --- a/lib/features/device/presentation/device_manage_page.dart +++ b/lib/features/device/presentation/device_manage_page.dart @@ -13,11 +13,27 @@ import 'device_manage_controller.dart'; /// /// 列出当前账号已绑定的全部设备,每项尾部提供「解绑」按钮; /// 右上角提供「添加设备」入口跳转到绑定页。 -class DeviceManagePage extends ConsumerWidget { +/// 支持下拉刷新;每次进入页面都会重新请求设备列表。 +class DeviceManagePage extends ConsumerStatefulWidget { const DeviceManagePage({super.key}); @override - Widget build(BuildContext context, WidgetRef ref) { + ConsumerState createState() => _DeviceManagePageState(); +} + +class _DeviceManagePageState extends ConsumerState { + @override + void initState() { + super.initState(); + // 每次进入页面强制重新请求设备列表(GoRouter 每次 push 都会创建新页面实例, + // 但 myDevicesProvider 有缓存,需 invalidate 才会重新拉取)。 + WidgetsBinding.instance.addPostFrameCallback((_) { + if (mounted) ref.invalidate(myDevicesProvider); + }); + } + + @override + Widget build(BuildContext context) { final l10n = AppLocalizations.of(context); final devicesAsync = ref.watch(myDevicesProvider); final action = ref.watch(deviceManageControllerProvider); @@ -61,69 +77,82 @@ class DeviceManagePage extends ConsumerWidget { child: SafeArea( child: Stack( children: [ - ListView( - padding: const EdgeInsets.only(bottom: 24), - children: [ - SectionTitle(l10n.deviceBound), - devicesAsync.when( - loading: () => const CardBox( - child: Padding( - padding: EdgeInsets.symmetric(vertical: 20), - child: Center(child: CupertinoActivityIndicator()), - ), - ), - error: (e, _) => CardBox( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - l10n.deviceLoadFailed, - style: const TextStyle(fontSize: 13, color: AppColors.sub), - ), - const SizedBox(height: 10), - // 局部错误:内联展示 + retry(见 AGENTS.md §12)。 - GestureDetector( - onTap: () => ref.invalidate(myDevicesProvider), - child: Text( - l10n.commonRetry, - style: const TextStyle( - fontSize: 13, - fontWeight: FontWeight.w700, - color: AppColors.green, - ), + // 下拉刷新:重新请求设备列表。 + CustomScrollView( + physics: const AlwaysScrollableScrollPhysics( + parent: BouncingScrollPhysics(), + ), + slivers: [ + CupertinoSliverRefreshControl( + onRefresh: () => ref.refresh(myDevicesProvider.future), + ), + SliverPadding( + padding: const EdgeInsets.only(bottom: 24), + sliver: SliverList( + delegate: SliverChildListDelegate([ + SectionTitle(l10n.deviceBound), + devicesAsync.when( + loading: () => const CardBox( + child: Padding( + padding: EdgeInsets.symmetric(vertical: 20), + child: Center(child: CupertinoActivityIndicator()), ), ), - ], - ), - ), - data: (devices) => devices.isEmpty - ? CardBox( - child: Text( - l10n.deviceNone, - style: const TextStyle(fontSize: 13, color: AppColors.sub), - ), - ) - : CardBox( - padding: EdgeInsets.zero, + error: (e, _) => CardBox( child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - for (var i = 0; i < devices.length; i++) ...[ - if (i > 0) const AppDivider(), - _DeviceRow( - device: devices[i], - onUnbind: () => - _confirmUnbind(context, ref, devices[i], l10n), + Text( + l10n.deviceLoadFailed, + style: const TextStyle(fontSize: 13, color: AppColors.sub), + ), + const SizedBox(height: 10), + // 局部错误:内联展示 + retry(见 AGENTS.md §12)。 + GestureDetector( + onTap: () => ref.invalidate(myDevicesProvider), + child: Text( + l10n.commonRetry, + style: const TextStyle( + fontSize: 13, + fontWeight: FontWeight.w700, + color: AppColors.green, + ), ), - ], + ), ], ), ), - ), - const SizedBox(height: 8), - SecondaryButton( - text: l10n.deviceManageAdd, - icon: CupertinoIcons.add_circled, - onPressed: () => context.push('/device/bind'), + data: (devices) => devices.isEmpty + ? CardBox( + child: Text( + l10n.deviceNone, + style: const TextStyle(fontSize: 13, color: AppColors.sub), + ), + ) + : CardBox( + padding: EdgeInsets.zero, + child: Column( + children: [ + for (var i = 0; i < devices.length; i++) ...[ + if (i > 0) const AppDivider(), + _DeviceRow( + device: devices[i], + onUnbind: () => + _confirmUnbind(context, devices[i], l10n), + ), + ], + ], + ), + ), + ), + const SizedBox(height: 8), + SecondaryButton( + text: l10n.deviceManageAdd, + icon: CupertinoIcons.add_circled, + onPressed: () => context.push('/device/bind'), + ), + ]), + ), ), ], ), @@ -145,7 +174,6 @@ class DeviceManagePage extends ConsumerWidget { /// 解绑二次确认,确认后调用控制器并提示结果。 Future _confirmUnbind( BuildContext context, - WidgetRef ref, DeviceBrief device, AppLocalizations l10n, ) async { @@ -163,6 +191,10 @@ class DeviceManagePage extends ConsumerWidget { .read(deviceManageControllerProvider.notifier) .unbind(device.serialno); if (!ok || !context.mounted) return; + + // 解绑成功后重新请求设备列表,默认 SN(selectedDeviceSnProvider)随新列表自动更新。 + ref.invalidate(myDevicesProvider); + await AppDialogs.alert( context, message: l10n.deviceUnbindSuccess, diff --git a/lib/features/home/data/location_controller.dart b/lib/features/home/data/location_controller.dart index 78a830b..5fdd260 100644 --- a/lib/features/home/data/location_controller.dart +++ b/lib/features/home/data/location_controller.dart @@ -152,7 +152,7 @@ class LocationController extends Notifier { desiredAccuracy: BMFDesiredAccuracy.best, isNeedNewVersionRgc: true, ).getMap(); - final prepared = await plugin.prepareLoc(androidMap, iosMap, const {}); + final prepared = await plugin.prepareLoc(androidMap, iosMap); debugPrint('[Location] prepareLoc => $prepared'); if (!_started) return; diff --git a/lib/features/home/presentation/home_tab.dart b/lib/features/home/presentation/home_tab.dart index aef253d..bca1153 100644 --- a/lib/features/home/presentation/home_tab.dart +++ b/lib/features/home/presentation/home_tab.dart @@ -29,6 +29,9 @@ class HomeTab extends ConsumerWidget { final l10n = AppLocalizations.of(context); // 仅在此 watch 设备 SN;设备切换时才重建整页结构,其余异步数据由各卡片自行 watch。 final sn = ref.watch(selectedDeviceSnProvider); + // 设备列表加载完成且为空 → 展示「未绑定设备」引导界面。 + final devicesAsync = ref.watch(myDevicesProvider); + final noDevice = devicesAsync.hasValue && (devicesAsync.value?.isEmpty ?? true); return CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( @@ -66,7 +69,9 @@ class HomeTab extends ConsumerWidget { ), ), child: SafeArea( - child: CustomScrollView( + child: noDevice + ? _noDeviceView(context, l10n) + : CustomScrollView( physics: const AlwaysScrollableScrollPhysics( parent: BouncingScrollPhysics(), ), @@ -120,6 +125,67 @@ class HomeTab extends ConsumerWidget { ); } + /// 未绑定任何设备时的引导界面:提示文案 + 「去绑定」按钮。 + Widget _noDeviceView(BuildContext context, AppLocalizations l10n) { + return Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 40), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 72, + height: 72, + decoration: BoxDecoration( + color: AppColors.surface, + borderRadius: BorderRadius.circular(22), + ), + child: const Center( + child: Text('📱', style: TextStyle(fontSize: 34))), + ), + const SizedBox(height: 16), + Text( + l10n.homeNoDevice, + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: AppColors.ink, + ), + ), + const SizedBox(height: 8), + Text( + l10n.homeNoDeviceTip, + textAlign: TextAlign.center, + style: const TextStyle(fontSize: 12, color: AppColors.sub), + ), + const SizedBox(height: 20), + // 「去绑定」按钮:跳转设备管理页,用户可在其中进入绑定/扫码。 + GestureDetector( + onTap: () => context.push('/device/manage'), + child: Container( + padding: + const EdgeInsets.symmetric(horizontal: 32, vertical: 10), + decoration: BoxDecoration( + color: AppColors.green, + borderRadius: BorderRadius.circular(22), + ), + child: Text( + l10n.homeBindDevice, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w700, + color: CupertinoColors.white, + ), + ), + ), + ), + ], + ), + ), + ); + } + Widget _cardHeader( String emoji, Color color, @@ -673,6 +739,31 @@ class HomeTab extends ConsumerWidget { onTap: () => _runDeviceOp(context, ref, l10n, sn, 'developer'), ), ), + Expanded( + child: IconTile( + emoji: '⚙️', + color: AppColors.gray, + label: l10n.cfSystemSettings, + size: 50, + iconSize: 20, + onTap: () => context.push('/settings'), + ), + ), + Expanded( + child: IconTile( + emoji: '🖼️', + color: AppColors.teal, + label: l10n.cfWallpaper, + size: 50, + iconSize: 20, + onTap: () => context.push('/wallpaper'), + ), + ), + ], + ), + const SizedBox(height: 14), + Row( + children: [ Expanded( child: IconTile( emoji: '⋯', @@ -683,8 +774,6 @@ class HomeTab extends ConsumerWidget { onTap: () => _showMoreOpsSheet(context, ref, l10n, sn), ), ), - // 占位,保持每行 4 个 - const Expanded(child: SizedBox.shrink()), ], ), ], diff --git a/lib/features/home/presentation/location_map_view.dart b/lib/features/home/presentation/location_map_view.dart index b667640..cce9aeb 100644 --- a/lib/features/home/presentation/location_map_view.dart +++ b/lib/features/home/presentation/location_map_view.dart @@ -23,11 +23,16 @@ class LocationMapView extends ConsumerStatefulWidget { ConsumerState createState() => _LocationMapViewState(); } -class _LocationMapViewState extends ConsumerState { +class _LocationMapViewState extends ConsumerState + with WidgetsBindingObserver { BMFMapController? _mapController; bool _markerAdded = false; bool _mapReady = false; + /// 平台视图重建标记:app 从后台恢复后自增,用于强制重建 + /// [BMFMapWidget](AndroidView / UiKitView),修复原生地图残留在上层的问题。 + int _platformViewGeneration = 0; + /// 首次创建时计算并缓存的初始地图中心,之后固定复用。 /// /// ⚠️ 关键性能点:`BMFMapWidget` 的 `mapOptions` 一旦变化会触发原生地图重建。 @@ -41,16 +46,38 @@ class _LocationMapViewState extends ConsumerState { void initState() { super.initState(); _initialCenter = _computeCenter(widget.location); + // 监听 app 生命周期,app 从后台恢复时重建原生地图视图(见 didChangeAppLifecycleState)。 + WidgetsBinding.instance.addObserver(this); } @override void dispose() { + WidgetsBinding.instance.removeObserver(this); // 地图控制器由底层平台视图生命周期管理,销毁时主动清空本地引用, // 避免 teardown 阶段对已释放的原生视图发起调用(降低百度 SDK 原生崩溃风险)。 _mapController = null; super.dispose(); } + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + // 切换到桌面(paused)再返回时,百度地图原生 Surface 可能残留在其它 + // Flutter 页面之上不消失。恢复前台时通过递增 generation 重建平台视图, + // 让原生地图重新挂载到正确层级(每次重建成本可控,仅发生于前后台切换)。 + if (state == AppLifecycleState.resumed) { + _recreatePlatformView(); + } + } + + /// 通过替换 [BMFMapWidget] 的 key 强制重建平台视图,并复位内部状态。 + void _recreatePlatformView() { + // 复位控制器/标记/就绪状态,等待新视图的 onMapCreated 重新初始化。 + _mapController = null; + _mapReady = false; + _markerAdded = false; + setState(() => _platformViewGeneration++); + } + @override void didUpdateWidget(covariant LocationMapView oldWidget) { super.didUpdateWidget(oldWidget); @@ -195,6 +222,9 @@ class _LocationMapViewState extends ConsumerState { // 明确宽高的容器中(SizedBox.expand 强制铺满父级),否则地图会显示空白。 return SizedBox.expand( child: BMFMapWidget( + // key 依赖平台视图重建代数:app 从后台恢复时强制重建原生地图, + // 修复地图 Surface 残留在其它页面之上的问题。 + key: ValueKey('home_map_$_platformViewGeneration'), onBMFMapCreated: _onMapCreated, mapOptions: BMFMapOptions( center: _initialCenter, // 复用首次缓存中心,避免 rebuild 触发地图重建。 diff --git a/lib/features/home/presentation/map_page.dart b/lib/features/home/presentation/map_page.dart index 0399910..24efea6 100644 --- a/lib/features/home/presentation/map_page.dart +++ b/lib/features/home/presentation/map_page.dart @@ -24,20 +24,46 @@ class MapPage extends ConsumerStatefulWidget { ConsumerState createState() => _MapPageState(); } -class _MapPageState extends ConsumerState { +class _MapPageState extends ConsumerState with WidgetsBindingObserver { BMFMapController? _mapController; bool _markerAdded = false; // 是否正在「定位到我」:点击定位按钮后置 true,拿到本机定位后归 false。 bool _isLocatingSelf = false; + // 平台视图重建代数:app 从后台恢复时自增,强制重建原生地图(见 _recreatePlatformView)。 + int _platformViewGeneration = 0; + + @override + void initState() { + super.initState(); + // 监听 app 生命周期,app 从后台恢复时重建原生地图视图。 + WidgetsBinding.instance.addObserver(this); + } @override void dispose() { + WidgetsBinding.instance.removeObserver(this); // 地图控制器由底层平台视图生命周期管理,销毁时主动清空本地引用, // 避免 teardown 阶段对已释放的原生视图发起调用(降低百度 SDK 原生崩溃风险)。 _mapController = null; super.dispose(); } + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + // 切换到桌面(paused)再返回时,百度地图原生 Surface 可能残留在其它 + // Flutter 页面之上不消失。恢复前台时重建平台视图让其重新挂载到正确层级。 + if (state == AppLifecycleState.resumed) { + _recreatePlatformView(); + } + } + + /// 通过替换 [BMFMapWidget] 的 key 强制重建平台视图,并复位内部状态。 + void _recreatePlatformView() { + _mapController = null; + _markerAdded = false; + setState(() => _platformViewGeneration++); + } + @override Widget build(BuildContext context) { final l10n = AppLocalizations.of(context); @@ -86,6 +112,9 @@ class _MapPageState extends ConsumerState { child: Stack( children: [ BMFMapWidget( + // key 依赖平台视图重建代数:app 从后台恢复时强制重建原生地图, + // 修复地图 Surface 残留在其它页面之上的问题。 + key: ValueKey('full_map_$_platformViewGeneration'), onBMFMapCreated: _onMapCreated, mapOptions: BMFMapOptions( center: center, diff --git a/lib/features/home/presentation/system_settings_page.dart b/lib/features/home/presentation/system_settings_page.dart new file mode 100644 index 0000000..9b379dd --- /dev/null +++ b/lib/features/home/presentation/system_settings_page.dart @@ -0,0 +1,246 @@ +import 'package:cupertino_ui/cupertino_ui.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; +import 'package:material_ui/material_ui.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'; + +/// 系统设置页(首页 → 常用功能 → 系统设置)。 +/// +/// 对接后端 client 策略接口: +/// - `GET /api/v1/client/sn/policy` 获取当前设备的功能开关状态 +/// - `PUT /api/v1/client/sn/policy/toggle` 单独设置某个功能开关 +/// +/// 页面以分组列表展示后台 `DevicePolicyVO` 暴露的全部策略开关,逐项开关; +/// 每次切换即时调用 toggle 接口并刷新当前项状态。 +class SystemSettingsPage extends ConsumerWidget { + const SystemSettingsPage({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final l10n = AppLocalizations.of(context); + final sn = ref.watch(selectedDeviceSnProvider); + final policyAsync = sn == null + ? const AsyncValue.data(null) + : ref.watch(devicePolicyProvider(sn)); + final policy = policyAsync.valueOrNull; + + return PopScope( + canPop: false, + onPopInvokedWithResult: (didPop, _) { + if (didPop) return; + if (context.canPop()) { + context.pop(); + } else { + context.go('/home'); + } + }, + child: CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text(l10n.ssTitle), + leading: CupertinoButton( + padding: EdgeInsets.zero, + child: const Icon(CupertinoIcons.back), + onPressed: () => context.pop(), + ), + ), + child: SafeArea( + child: policyAsync.when( + loading: () => const Center(child: CupertinoActivityIndicator()), + error: (e, _) => Center( + child: Text(l10n.commonLoadFailed, + style: const TextStyle(color: AppColors.sub)), + ), + data: (data) { + if (data == null) { + return Center( + child: Text(l10n.ssLoadFailed, + style: const TextStyle(color: AppColors.sub)), + ); + } + return _buildGroups(context, ref, l10n, sn, data); + }, + ), + ), + ), + ); + } + + /// 按分组渲染策略开关列表。 + Widget _buildGroups( + BuildContext context, + WidgetRef ref, + AppLocalizations l10n, + String? sn, + DevicePolicy policy, + ) { + final groups = <_PolicyGroup>[ + _PolicyGroup( + title: l10n.ssGrpNetwork, + items: [ + _PolicyItem('wifiHotspot', l10n.ssWifiHotspot), + _PolicyItem('bluetooth', l10n.ssBluetooth), + _PolicyItem('bluetoothSharing', l10n.ssBluetoothSharing), + _PolicyItem('toggleAirplaneMode', l10n.ssAirplaneMode), + _PolicyItem('modifyMobileApn', l10n.ssModifyApn), + _PolicyItem('resetNetworkSettings', l10n.ssResetNetwork), + ], + ), + _PolicyGroup( + title: l10n.ssGrpDisplay, + items: [ + _PolicyItem('wallpaper', l10n.ssWallpaper), + _PolicyItem('notificationBar', l10n.ssNotificationBar), + _PolicyItem('statusBarPullDown', l10n.ssStatusBarPullDown), + _PolicyItem('autoRotate', l10n.ssAutoRotate), + _PolicyItem('autoBrightness', l10n.ssAutoBrightness), + _PolicyItem('manualAdjustBrightness', l10n.ssManualBrightness), + _PolicyItem('eyeProtection', l10n.ssEyeProtection), + _PolicyItem('darkMode', l10n.ssDarkMode), + _PolicyItem('modifyScreenTimeout', l10n.ssScreenTimeout), + ], + ), + _PolicyGroup( + title: l10n.ssGrpSystem, + items: [ + _PolicyItem('timeSetting', l10n.ssTimeSetting), + _PolicyItem('manualAdjustTimeZone', l10n.ssManualTimeZone), + _PolicyItem('modifySystemTimeZone', l10n.ssModifyTimeZone), + _PolicyItem('modifySystemLanguage', l10n.ssModifyLanguage), + _PolicyItem('systemNavBarShow', l10n.ssNavBarShow), + _PolicyItem('systemNavBarSetting', l10n.ssNavBarSetting), + _PolicyItem('navBarOptions', l10n.ssNavBarOptions), + _PolicyItem('safeBoot', l10n.ssSafeBoot), + _PolicyItem('otaUpgrade', l10n.ssOtaUpgrade), + ], + ), + _PolicyGroup( + title: l10n.ssGrpStorage, + items: [ + _PolicyItem('usbData', l10n.ssUsbData), + _PolicyItem('usbFileTransfer', l10n.ssUsbFileTransfer), + _PolicyItem('storageCard', l10n.ssStorageCard), + _PolicyItem('mountPhysicalStorage', l10n.ssMountPhysicalStorage), + _PolicyItem('factoryReset', l10n.ssFactoryReset), + _PolicyItem('adbUsbDebug', l10n.ssAdbUsbDebug), + ], + ), + _PolicyGroup( + title: l10n.ssGrpApp, + items: [ + _PolicyItem('installApps', l10n.ssInstallApps), + _PolicyItem('uninstallApps', l10n.ssUninstallApps), + _PolicyItem('camera', l10n.ssCamera), + _PolicyItem('modifyLocationSwitch', l10n.ssModifyLocation), + _PolicyItem('adjustGlobalVolume', l10n.ssGlobalVolume), + ], + ), + ]; + + return ListView( + padding: const EdgeInsets.only(bottom: 24), + children: [ + for (final group in groups) ...[ + SectionTitle(group.title), + CardBox( + padding: EdgeInsets.zero, + child: Column( + children: [ + for (var i = 0; i < group.items.length; i++) ...[ + if (i > 0) const AppDivider(), + _buildToggle(context, ref, l10n, sn, policy, group.items[i]), + ], + ], + ), + ), + ], + ], + ); + } + + /// 单个策略开关行。 + Widget _buildToggle( + BuildContext context, + WidgetRef ref, + AppLocalizations l10n, + String? sn, + DevicePolicy policy, + _PolicyItem item, + ) { + final enabled = policy.enabled(item.field); + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), + child: Row( + children: [ + Expanded( + child: Text( + item.label, + style: const TextStyle(fontSize: 14.5, color: AppColors.ink), + ), + ), + CupertinoSwitch( + value: enabled, + activeColor: AppColors.green, + onChanged: (value) => + _onToggle(context, ref, l10n, sn, item.field, value ? 1 : 0), + ), + ], + ), + ); + } + + /// 调用 toggle 接口并刷新策略状态。 + Future _onToggle( + BuildContext context, + WidgetRef ref, + AppLocalizations l10n, + String? sn, + String field, + int value, + ) async { + if (sn == null || sn.isEmpty) { + _showToast(context, l10n.opCmdFailed); + return; + } + final error = await ref + .read(deviceRepositoryProvider) + .togglePolicy(sn, field, value); + if (!context.mounted) return; + if (error == null) { + // 成功后仅刷新该策略数据,保证开关状态与后台一致。 + ref.invalidate(devicePolicyProvider(sn)); + } else { + _showToast(context, error); + } + } + + /// 轻提示:以 SnackBar 展示结果,避免连续切换时被弹窗打断。 + void _showToast(BuildContext context, String message) { + ScaffoldMessenger.of(context) + ..clearSnackBars() + ..showSnackBar(SnackBar( + content: Text(message), + duration: const Duration(seconds: 2), + behavior: SnackBarBehavior.floating, + )); + } +} + +/// 策略开关分组。 +class _PolicyGroup { + const _PolicyGroup({required this.title, required this.items}); + + final String title; + final List<_PolicyItem> items; +} + +/// 单个策略开关项(field 对应后台策略字段名)。 +class _PolicyItem { + const _PolicyItem(this.field, this.label); + + final String field; + final String label; +} diff --git a/lib/features/home/presentation/wallpaper_page.dart b/lib/features/home/presentation/wallpaper_page.dart new file mode 100644 index 0000000..4d3dec3 --- /dev/null +++ b/lib/features/home/presentation/wallpaper_page.dart @@ -0,0 +1,636 @@ +import 'dart:io'; + +import 'package:cupertino_ui/cupertino_ui.dart'; +// 仅取 GlobalWidgetsLocalizations;GlobalMaterialLocalizations 须用 material_ui 自带的 +//(vendored 框架副本,提供其 MaterialLocalizations 类型并支持 zh 等多语言), +// 若整体导入 flutter_localizations 会与 material_ui 导出的同名类冲突。 +import 'package:flutter_localizations/flutter_localizations.dart' + show GlobalWidgetsLocalizations; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; +import 'package:image_picker/image_picker.dart'; +import 'package:material_ui/material_ui.dart'; +import 'package:path_provider/path_provider.dart'; + +import '../../../app/constants/app_constants.dart'; +import '../../../core/network/dio_client.dart'; +import '../../../core/widgets/feature_ui.dart'; +import '../../../core/widgets/settings_ui.dart'; +import '../../../features/device/data/device_providers.dart'; +import '../../../l10n/app_localizations.dart'; + +/// 壁纸设置页(首页 → 常用功能 → 壁纸设置)。 +/// +/// 分段切换「单个 / 轮换」两种壁纸模式: +/// - 单个:展示一张壁纸图,底部「更换」按钮从系统相册选择图片, +/// 选择后立即上传到后端并推送设备(mode=0); +/// - 轮换:壁纸图列表(最多 7 张),「新增」每次从相册添加一张, +/// 增删后整组上传到后端并推送设备(mode=1),图片右上角可单独移除, +/// **长按拖动可调整展示顺序**(调用后端排序接口)。 +/// +/// 选中的图片会复制到应用文档目录用于本次会话内稳定展示, +/// 最终生效以服务端保存并推送至设备为准。 +class WallpaperPage extends ConsumerStatefulWidget { + const WallpaperPage({super.key}); + + @override + ConsumerState createState() => _WallpaperPageState(); +} + +class _WallpaperPageState extends ConsumerState { + /// 轮换壁纸数量上限。 + static const int _maxRotation = 7; + + final ImagePicker _picker = ImagePicker(); + + int _segment = 0; + String? _singleImage; + List<_RotationItem> _rotationItems = const []; + bool _uploading = false; + bool _loading = true; + + AppLocalizations get _l10n => AppLocalizations.of(context); + + @override + void initState() { + super.initState(); + _loadWallpaper(); + } + + /// 壁纸文件本地目录。 + Future _wallpaperDir() async { + final dir = await getApplicationDocumentsDirectory(); + return Directory('${dir.path}/wallpapers'); + } + + /// 将相册选中的图片复制到应用文档目录,返回持久路径 + /// (系统相册返回的是临时缓存路径,直接展示可能被系统清理)。 + Future _copyToApp(XFile file) async { + final folder = await _wallpaperDir(); + await folder.create(recursive: true); + final ext = + file.name.contains('.') ? file.name.split('.').last.toLowerCase() : 'jpg'; + final dest = + '${folder.path}/wp_${DateTime.now().millisecondsSinceEpoch}.$ext'; + await File(file.path).copy(dest); + return dest; + } + + /// 下载壁纸图片到本地目录,返回本地路径;失败返回 null。 + Future _downloadToLocal(String url) async { + try { + final folder = await _wallpaperDir(); + await folder.create(recursive: true); + final name = url.split('/').last; + final dest = '${folder.path}/$name'; + // 后端返回相对路径(如 /static/wallpaper/xxx),显式拼接服务端源地址, + // 避免依赖 dio 对相对路径的解析行为。 + final fullUrl = url.startsWith('http://') || url.startsWith('https://') + ? url + : '${Uri.parse(AppConstants.kBaseUrl).origin}$url'; + await DioClient.downloadToFile(fullUrl, dest); + return dest; + } catch (e) { + debugPrint('wallpaper download failed: $url $e'); + return null; + } + } + + /// 清空本地壁纸目录(重新拉取最新配置前调用)。 + Future _clearLocalWallpapers() async { + final folder = await _wallpaperDir(); + if (await folder.exists()) { + await folder.delete(recursive: true); + } + } + + /// 拉取后端最新的壁纸配置并下载图片到本地展示。 + /// + /// 页面进入与切换 Tab 时调用,保证展示的是最新数据。 + Future _loadWallpaper() async { + final sn = _sn; + if (sn == null || sn.isEmpty) { + if (mounted) setState(() => _loading = false); + return; + } + try { + final config = + await ref.read(deviceRepositoryProvider).getWallpaperConfig(sn); + if (!mounted) return; + setState(() => _loading = true); + await _clearLocalWallpapers(); + if (config == null || config.images.isEmpty) { + if (!mounted) return; + setState(() { + _singleImage = null; + _rotationItems = const []; + _loading = false; + }); + return; + } + final paths = await Future.wait(config.images.map(_downloadToLocal)); + final items = <_RotationItem>[]; + for (var i = 0; i < config.images.length; i++) { + final p = paths[i]; + if (p != null) { + items.add(_RotationItem(localPath: p, url: config.images[i])); + } + } + if (!mounted) return; + setState(() { + if (config.mode == 1) { + _singleImage = null; + _rotationItems = items; + } else { + _singleImage = items.isEmpty ? null : items.first.localPath; + _rotationItems = const []; + } + _loading = false; + }); + } catch (e) { + debugPrint('load wallpaper failed: $e'); + if (mounted) setState(() => _loading = false); + } + } + + /// 当前选中的绑定设备 SN;未绑定返回 null。 + String? get _sn => ref.read(selectedDeviceSnProvider); + + /// 未绑定设备提示。 + void _showNoDevice() { + AppDialogs.alert( + context, + message: _l10n.contactNoDevice, + confirmText: _l10n.commonConfirm, + ); + } + + /// 切换 Tab 并重新拉取最新壁纸数据。 + void _onSegmentTap(int index) { + if (index == _segment) return; + setState(() => _segment = index); + _loadWallpaper(); + } + + /// 单个模式:更换壁纸 → 立即上传到后端并推送设备。 + Future _changeSingle() async { + final sn = _sn; + if (sn == null || sn.isEmpty) { + _showNoDevice(); + return; + } + final picked = await _picker.pickImage(source: ImageSource.gallery); + if (picked == null || !mounted) return; + final path = await _copyToApp(picked); + setState(() { + _singleImage = path; + _uploading = true; + }); + final result = await ref + .read(deviceRepositoryProvider) + .uploadWallpaperSingle(sn, File(path)); + if (!mounted) return; + setState(() => _uploading = false); + if (result.error != null) { + AppDialogs.alert(context, message: result.error!, confirmText: _l10n.commonConfirm); + } + } + + /// 轮换模式:新增一张 → 整组上传到后端并推送设备。 + Future _addRotation() async { + final sn = _sn; + if (sn == null || sn.isEmpty) { + _showNoDevice(); + return; + } + if (_rotationItems.length >= _maxRotation) { + AppDialogs.alert( + context, + message: _l10n.wallpaperMaxLimit, + confirmText: _l10n.commonConfirm, + ); + return; + } + final picked = await _picker.pickImage(source: ImageSource.gallery); + if (picked == null || !mounted) return; + final path = await _copyToApp(picked); + setState(() => _rotationItems = [..._rotationItems, _RotationItem(localPath: path)]); + await _uploadRotation(sn); + } + + /// 移除某张轮换壁纸 → 整组重新上传。 + Future _removeRotation(int index) async { + final sn = _sn; + setState(() { + _rotationItems = [ + for (var i = 0; i < _rotationItems.length; i++) + if (i != index) _rotationItems[i], + ]; + }); + if (sn == null || sn.isEmpty) return; + if (_rotationItems.isEmpty) return; + await _uploadRotation(sn); + } + + /// 将当前轮换列表整组上传到后端并推送设备,成功后回填各图 URL。 + Future _uploadRotation(String sn) async { + if (_uploading) return; + setState(() => _uploading = true); + final files = [for (final item in _rotationItems) File(item.localPath)]; + final result = await ref + .read(deviceRepositoryProvider) + .uploadWallpaperRotation(sn, files); + if (!mounted) return; + setState(() => _uploading = false); + if (result.error != null) { + AppDialogs.alert(context, message: result.error!, confirmText: _l10n.commonConfirm); + return; + } + final urls = result.urls; + if (urls != null && urls.length == _rotationItems.length) { + setState(() { + _rotationItems = [ + for (var i = 0; i < _rotationItems.length; i++) + _RotationItem(localPath: _rotationItems[i].localPath, url: urls[i]), + ]; + }); + } + } + + /// 长按拖动排序回调:重排本地列表后持久化到后端。 + void _onReorder(int oldIndex, int newIndex) { + final count = _rotationItems.length; + if (newIndex > oldIndex) newIndex--; + if (newIndex >= count) newIndex = count - 1; + if (newIndex < 0) newIndex = 0; + if (newIndex == oldIndex) return; + setState(() { + final item = _rotationItems.removeAt(oldIndex); + _rotationItems.insert(newIndex, item); + }); + _persistOrder(); + } + + /// 将重排后的顺序同步到后端(sort_no)。 + Future _persistOrder() async { + final sn = _sn; + if (sn == null || sn.isEmpty) return; + final urls = [for (final item in _rotationItems) item.url]; + // 存在尚未回传 URL 的项(如刚新增尚未上传完成),退回整组重传以保序。 + if (urls.any((u) => u.isEmpty)) { + await _uploadRotation(sn); + return; + } + final err = await ref + .read(deviceRepositoryProvider) + .reorderWallpaper(sn, urls); + if (!mounted || err == null) return; + AppDialogs.alert(context, message: err, confirmText: _l10n.commonConfirm); + } + + @override + Widget build(BuildContext context) { + return PopScope( + canPop: false, + onPopInvokedWithResult: (didPop, _) { + if (didPop) return; + if (context.canPop()) { + context.pop(); + } else { + context.go('/home'); + } + }, + child: CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text(_l10n.wallpaperTitle), + leading: CupertinoButton( + padding: EdgeInsets.zero, + child: const Icon(CupertinoIcons.back), + onPressed: () => context.pop(), + ), + ), + child: SafeArea( + top: false, + child: _loading + ? const Center(child: CupertinoActivityIndicator()) + : Column( + children: [ + _buildSegment(), + Expanded( + child: _segment == 0 ? _buildSingle() : _buildRotation(), + ), + ], + ), + ), + ), + ); + } + + /// 分段切换:单个 / 轮换。 + Widget _buildSegment() { + final segments = [_l10n.wallpaperSingle, _l10n.wallpaperRotate]; + return Padding( + padding: const EdgeInsets.fromLTRB(16, 10, 16, 4), + child: Container( + padding: const EdgeInsets.all(3), + decoration: BoxDecoration( + color: AppColors.track, + borderRadius: BorderRadius.circular(12), + ), + child: Row( + children: [ + for (var i = 0; i < segments.length; i++) + Expanded( + child: GestureDetector( + onTap: () => _onSegmentTap(i), + child: Container( + padding: const EdgeInsets.symmetric(vertical: 8), + decoration: BoxDecoration( + color: _segment == i + ? CupertinoColors.white + : const Color(0x00000000), + borderRadius: BorderRadius.circular(9), + boxShadow: _segment == i + ? const [ + BoxShadow( + color: Color(0x14141E3C), + blurRadius: 6, + offset: Offset(0, 2), + ), + ] + : null, + ), + child: Center( + child: Text( + segments[i], + style: TextStyle( + fontSize: 13, + fontWeight: FontWeight.w600, + color: + _segment == i ? AppColors.ink : AppColors.sub, + ), + ), + ), + ), + ), + ), + ], + ), + ), + ); + } + + /// 单个模式:一张壁纸图 + 底部「更换」按钮。 + Widget _buildSingle() { + return ListView( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 24), + children: [ + CardBox( + padding: const EdgeInsets.all(12), + child: AspectRatio( + aspectRatio: 3 / 4, + child: ClipRRect( + borderRadius: BorderRadius.circular(12), + child: _WallpaperImage( + path: _singleImage, + emptyHint: _l10n.wallpaperEmptySingle, + ), + ), + ), + ), + const SizedBox(height: 16), + PrimaryButton( + text: _l10n.wallpaperChange, + loading: _uploading, + onPressed: _uploading ? null : _changeSingle, + ), + ], + ); + } + + /// 轮换模式:图片列表(最多 7 张),支持长按拖动排序,末尾为「新增」入口。 + Widget _buildRotation() { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(18, 10, 18, 6), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '${_l10n.wallpaperMaxLimit} · ${_l10n.wallpaperAdd}' + '(${_rotationItems.length}/$_maxRotation)', + style: const TextStyle(fontSize: 12, color: AppColors.sub), + ), + if (_rotationItems.isNotEmpty) ...[ + const SizedBox(height: 2), + Text( + _l10n.wallpaperDragTip, + style: const TextStyle(fontSize: 11, color: AppColors.sub), + ), + ], + ], + ), + ), + Expanded( + child: _rotationItems.isEmpty + ? _buildRotationEmpty() + // ReorderableListView 属于 Material 组件,运行期需要 MaterialLocalizations; + // 本应用根组件是 CupertinoApp(仅提供 CupertinoLocalizations),故此处 + // 局部包一层 Localizations 补齐。注意: + // - DefaultMaterialLocalizations 仅支持 en_US,zh 下不会加载,必须用 + // material_ui 自带、支持多语言的 GlobalMaterialLocalizations.delegate; + // - Localizations 断言要求至少一个 WidgetsLocalizations delegate, + // 使用 flutter_localizations 的 GlobalWidgetsLocalizations.delegate。 + : Localizations( + locale: Localizations.localeOf(context), + delegates: const [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + ], + child: ReorderableListView.builder( + padding: const EdgeInsets.fromLTRB(16, 4, 16, 24), + buildDefaultDragHandles: false, + // 默认 proxyDecorator 用不透明 Material 包裹拖拽项, + // 会把 item 底部内边距渲染成白色条(留白),且圆角处不透明白色。 + // 改用透明 Material,仅保留阴影,圆角处透出页面背景。 + proxyDecorator: (child, index, animation) => Material( + type: MaterialType.canvas, + color: Colors.transparent, + elevation: 4, + shadowColor: Colors.black26, + borderRadius: BorderRadius.circular(14), + child: child, + ), + itemCount: _rotationItems.length + + (_rotationItems.length < _maxRotation ? 1 : 0), + onReorder: _onReorder, + itemBuilder: (context, index) { + // 末尾「新增」占位项:不参与拖动。 + if (index >= _rotationItems.length) { + return Padding( + key: const ValueKey('wallpaper_add_tile'), + padding: const EdgeInsets.only(top: 12), + child: _buildAddTile(), + ); + } + return ReorderableDelayedDragStartListener( + key: ValueKey('wallpaper_item_$index'), + index: index, + child: Padding( + padding: const EdgeInsets.only(bottom: 12), + child: _buildImageTile(index), + ), + ); + }, + ), + ), + ), + ], + ); + } + + /// 轮换列表为空时的引导:居中提示 + 「新增」入口。 + Widget _buildRotationEmpty() { + return Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(CupertinoIcons.photo, size: 48, color: AppColors.sub), + const SizedBox(height: 12), + Text( + _l10n.wallpaperEmpty, + style: const TextStyle(fontSize: 13, color: AppColors.sub), + ), + const SizedBox(height: 20), + GestureDetector( + onTap: _addRotation, + child: Container( + padding: + const EdgeInsets.symmetric(horizontal: 28, vertical: 10), + decoration: BoxDecoration( + color: AppColors.green, + borderRadius: BorderRadius.circular(22), + ), + child: Text( + _l10n.wallpaperAdd, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w700, + color: CupertinoColors.white, + ), + ), + ), + ), + ], + ), + ); + } + + /// 「新增」占位项:点击从相册添加一张壁纸。 + Widget _buildAddTile() { + return GestureDetector( + onTap: _addRotation, + child: Container( + height: 64, + decoration: BoxDecoration( + color: AppColors.track, + borderRadius: BorderRadius.circular(14), + border: Border.all(color: const Color(0xFFDCE1EA), width: 1), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('+', + style: TextStyle( + fontSize: 22, height: 1, color: AppColors.green)), + const SizedBox(width: 8), + Text( + _l10n.wallpaperAdd, + style: const TextStyle(fontSize: 14, color: AppColors.sub), + ), + ], + ), + ), + ); + } + + /// 单张轮换壁纸(竖向整行):图片 + 右上角移除按钮。 + Widget _buildImageTile(int index) { + return Stack( + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(14), + child: AspectRatio( + aspectRatio: 16 / 9, + child: _WallpaperImage(path: _rotationItems[index].localPath), + ), + ), + Positioned( + top: 6, + right: 6, + child: GestureDetector( + onTap: () => _removeRotation(index), + child: Container( + width: 24, + height: 24, + decoration: const BoxDecoration( + color: Color(0x99000000), + shape: BoxShape.circle, + ), + child: const Center( + child: Icon(CupertinoIcons.xmark, + size: 14, color: CupertinoColors.white), + ), + ), + ), + ), + ], + ); + } +} + +/// 单张轮换壁纸项:本地展示路径 + 服务端图片 URL。 +class _RotationItem { + const _RotationItem({required this.localPath, this.url = ''}); + + final String localPath; + final String url; +} + +/// 本地壁纸图展示;路径为空或文件不存在时展示占位图。 +class _WallpaperImage extends StatelessWidget { + const _WallpaperImage({required this.path, this.emptyHint}); + + final String? path; + final String? emptyHint; + + @override + Widget build(BuildContext context) { + final p = path; + if (p == null || p.isEmpty || !File(p).existsSync()) { + return Container( + color: const Color(0xFFEEF2F7), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(CupertinoIcons.photo, size: 34, color: AppColors.sub), + if (emptyHint != null) ...[ + const SizedBox(height: 8), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Text( + emptyHint!, + textAlign: TextAlign.center, + style: const TextStyle(fontSize: 12, color: AppColors.sub), + ), + ), + ], + ], + ), + ); + } + return Image.file(File(p), fit: BoxFit.cover); + } +} diff --git a/lib/features/messages/presentation/messages_tab.dart b/lib/features/messages/presentation/messages_tab.dart index d47c2f7..d84ebd3 100644 --- a/lib/features/messages/presentation/messages_tab.dart +++ b/lib/features/messages/presentation/messages_tab.dart @@ -17,25 +17,86 @@ class MessagesTab extends ConsumerWidget { final l10n = AppLocalizations.of(context); final menus = [ - _Menu(emoji: '🖼️', color: AppColors.blue, label: l10n.menuAlbum, route: '/album'), - _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), + _Menu( + emoji: '🖼️', + color: AppColors.blue, + label: l10n.menuAlbum, + route: '/album', + ), + _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), + _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 CupertinoPageScaffold( @@ -58,8 +119,12 @@ class MessagesTab extends ConsumerWidget { child: Stack( children: [ const Center( - child: - Icon(CupertinoIcons.bell, size: 18, color: AppColors.ink)), + child: Icon( + CupertinoIcons.bell, + size: 18, + color: AppColors.ink, + ), + ), Positioned( top: 5, right: 7, @@ -67,7 +132,9 @@ class MessagesTab extends ConsumerWidget { width: 8, height: 8, decoration: const BoxDecoration( - color: AppColors.red, shape: BoxShape.circle), + color: AppColors.red, + shape: BoxShape.circle, + ), ), ), ], @@ -80,8 +147,10 @@ class MessagesTab extends ConsumerWidget { children: [ Padding( padding: const EdgeInsets.fromLTRB(18, 10, 18, 4), - child: Text(l10n.manageSubtitle, - style: const TextStyle(fontSize: 12, color: AppColors.sub)), + child: Text( + l10n.manageSubtitle, + style: const TextStyle(fontSize: 12, color: AppColors.sub), + ), ), // 横版菜单 SizedBox( @@ -94,23 +163,34 @@ class MessagesTab extends ConsumerWidget { itemCount: menus.length, itemBuilder: (_, i) { final m = menus[i]; - return Container( - width: 80, - margin: const EdgeInsets.symmetric(vertical: 8), - decoration: BoxDecoration( - color: CupertinoColors.white, - 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, - onTap: m.route == null ? null : () => context.push(m.route!), + // 手势放在整张卡片上并设为 opaque,保证点击卡片任意位置 + // (含图标/文字之外的空白区域)都能进入对应页面。 + return GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: m.route == null + ? null + : () => context.push(m.route!), + child: Container( + width: 80, + margin: const EdgeInsets.symmetric(vertical: 8), + decoration: BoxDecoration( + color: CupertinoColors.white, + 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, + ), ), ); }, @@ -139,80 +219,106 @@ class MessagesTab extends ConsumerWidget { } Widget _messageRow(_Message m) => Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), - child: Row( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), + child: Row( + children: [ + Stack( + clipBehavior: Clip.none, 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: const TextStyle(fontSize: 14.5, fontWeight: FontWeight.w600, color: AppColors.ink)), - const Spacer(), - Text(m.time, style: const TextStyle(fontSize: 11, color: AppColors.sub)), - ], - ), - const SizedBox(height: 3), - Text(m.preview, - style: const TextStyle(fontSize: 12.5, color: AppColors.sub), - maxLines: 1, - overflow: TextOverflow.ellipsis), - ], + 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.unread) - const Padding( - padding: EdgeInsets.only(left: 8), - child: SizedBox( - width: 9, - height: 9, - child: DecoratedBox( - decoration: BoxDecoration(color: AppColors.red, shape: BoxShape.circle), + 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: const TextStyle( + fontSize: 14.5, + fontWeight: FontWeight.w600, + color: AppColors.ink, + ), + ), + const Spacer(), + Text( + m.time, + style: const TextStyle(fontSize: 11, color: AppColors.sub), + ), + ], + ), + const SizedBox(height: 3), + Text( + m.preview, + style: const TextStyle(fontSize: 12.5, color: 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}); + const _Menu({ + required this.emoji, + required this.color, + required this.label, + this.route, + }); final String emoji; final Color color; final String label; diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index f41045e..01ed24a 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -392,12 +392,198 @@ abstract class AppLocalizations { /// **'添加闹钟'** String get addAlarm; + /// 编辑闹钟页标题 + /// + /// In zh, this message translates to: + /// **'编辑闹钟'** + String get alarmEditTitle; + + /// 闹钟列表为空提示 + /// + /// In zh, this message translates to: + /// **'暂无闹钟,点击「添加闹钟」创建'** + String get alarmEmpty; + + /// 闹钟时间选择标签 + /// + /// In zh, this message translates to: + /// **'时间'** + String get alarmTime; + + /// 闹钟标签输入占位 + /// + /// In zh, this message translates to: + /// **'标签(如:起床)'** + String get alarmLabel; + + /// 闹钟重复选择标签 + /// + /// In zh, this message translates to: + /// **'重复'** + String get alarmRepeat; + + /// 重复类型-只响一次 + /// + /// In zh, this message translates to: + /// **'只响一次'** + String get alarmRepeatOnce; + + /// 重复类型-每天 + /// + /// In zh, this message translates to: + /// **'每天'** + String get alarmRepeatEveryday; + + /// 重复类型-工作日 + /// + /// In zh, this message translates to: + /// **'工作日'** + String get alarmRepeatWeekdays; + + /// 重复类型-自定义 + /// + /// In zh, this message translates to: + /// **'自定义'** + String get alarmRepeatCustom; + + /// 闹钟开关标签 + /// + /// In zh, this message translates to: + /// **'开启闹钟'** + String get alarmEnabled; + + /// 删除闹钟确认弹窗标题 + /// + /// In zh, this message translates to: + /// **'确定删除该闹钟吗?'** + String get alarmDeleteConfirm; + + /// 删除闹钟按钮 + /// + /// In zh, this message translates to: + /// **'删除闹钟'** + String get alarmDelete; + /// 相册页标题 /// /// In zh, this message translates to: /// **'相册'** String get albumTitle; + /// 相册:发送图片到设备 + /// + /// In zh, this message translates to: + /// **'发送到设备'** + String get albumSendToDevice; + + /// 相册:图片发送成功提示 + /// + /// In zh, this message translates to: + /// **'已发送到设备'** + String get albumSendSuccess; + + /// 相册:获取图片文件失败提示 + /// + /// In zh, this message translates to: + /// **'获取图片文件失败'** + String get albumSendGetFileFailed; + + /// 相册:已上传图片列表为空提示 + /// + /// In zh, this message translates to: + /// **'暂无已上传的图片,可在「相簿」中选择照片发送到设备'** + String get albumUploadedEmpty; + + /// 相册:已上传图片数量与总大小统计 + /// + /// In zh, this message translates to: + /// **'已上传的图片 · %1\$d 张 · 共 %2\$s'** + String albumUploadedStats(int count, String size); + + /// 相册:收藏列表为空提示 + /// + /// In zh, this message translates to: + /// **'暂无收藏的图片,在「全部」中点击图片可收藏'** + String get albumFavoriteEmpty; + + /// 相册:收藏图片数量与总大小统计 + /// + /// In zh, this message translates to: + /// **'收藏的图片 · %1\$d 张 · 共 %2\$s'** + String albumFavoriteStats(int count, String size); + + /// 相簿分段:权限被拒引导标题 + /// + /// In zh, this message translates to: + /// **'需要相册访问权限才能查看本机照片'** + String get albumPermissionTitle; + + /// 相簿分段:权限可再次申请时的副文案 + /// + /// In zh, this message translates to: + /// **'请在弹窗中允许访问相册后重试'** + String get albumPermissionSub; + + /// 相簿分段:权限永久拒绝时的副文案 + /// + /// In zh, this message translates to: + /// **'权限已被永久拒绝,请前往系统设置开启'** + String get albumPermissionPermanentSub; + + /// 相簿分段:打开系统设置按钮 + /// + /// In zh, this message translates to: + /// **'去设置'** + String get albumOpenSettings; + + /// 相簿分段:重新申请权限按钮 + /// + /// In zh, this message translates to: + /// **'重新申请'** + String get albumRetryRequest; + + /// 相簿列表为空 + /// + /// In zh, this message translates to: + /// **'暂无相簿'** + String get albumEmpty; + + /// 相簿内没有照片 + /// + /// In zh, this message translates to: + /// **'此相簿暂无照片'** + String get albumFolderEmpty; + + /// 相簿名称为空时显示 + /// + /// In zh, this message translates to: + /// **'未命名'** + String get albumUnknownFolder; + + /// 相簿内媒体数量 + /// + /// In zh, this message translates to: + /// **'{count} 项'** + String albumAssetCount(int count); + + /// 相簿列表加载失败 + /// + /// In zh, this message translates to: + /// **'相簿加载失败,请重试'** + String get albumLoadFailed; + + /// 相簿内容加载失败 + /// + /// In zh, this message translates to: + /// **'相簿内容加载失败,请重试'** + String get albumFolderLoadFailed; + + /// 相簿提示弹窗确认按钮 + /// + /// In zh, this message translates to: + /// **'知道了'** + String get albumGotIt; + /// 应用页标题 /// /// In zh, this message translates to: @@ -668,6 +854,30 @@ abstract class AppLocalizations { /// **'联系人详情'** String get contactDetailTitle; + /// 详情页编辑按钮 + /// + /// In zh, this message translates to: + /// **'编辑'** + String get contactEdit; + + /// 联系人详情:拨打电话按钮 + /// + /// In zh, this message translates to: + /// **'拨打电话'** + String get contactCall; + + /// 联系人详情:反向拨号按钮 + /// + /// In zh, this message translates to: + /// **'反向拨号'** + String get contactReverseDial; + + /// 联系人详情:反向拨号指令发送成功提示 + /// + /// In zh, this message translates to: + /// **'拨号指令已发送,设备将呼叫该联系人'** + String get contactReverseDialSent; + /// 详情页:紧急联系人标签 /// /// In zh, this message translates to: @@ -734,6 +944,24 @@ abstract class AppLocalizations { /// **'在线'** String get homeOnline; + /// 首页未绑定设备提示 + /// + /// In zh, this message translates to: + /// **'还没有绑定设备'** + String get homeNoDevice; + + /// 首页未绑定设备时的辅助说明 + /// + /// In zh, this message translates to: + /// **'绑定后可查看设备位置、截屏与远程操作'** + String get homeNoDeviceTip; + + /// 首页未绑定设备时去绑定按钮 + /// + /// In zh, this message translates to: + /// **'去绑定'** + String get homeBindDevice; + /// 首页常用功能 /// /// In zh, this message translates to: @@ -1040,6 +1268,330 @@ abstract class AppLocalizations { /// **'应用锁'** String get cfAppLock; + /// 常用功能:系统设置 + /// + /// In zh, this message translates to: + /// **'系统设置'** + String get cfSystemSettings; + + /// 常用功能:壁纸设置 + /// + /// In zh, this message translates to: + /// **'壁纸设置'** + String get cfWallpaper; + + /// 壁纸设置页标题 + /// + /// In zh, this message translates to: + /// **'壁纸设置'** + String get wallpaperTitle; + + /// 壁纸设置:单个模式 + /// + /// In zh, this message translates to: + /// **'单个'** + String get wallpaperSingle; + + /// 壁纸设置:轮换模式 + /// + /// In zh, this message translates to: + /// **'轮换'** + String get wallpaperRotate; + + /// 壁纸设置:更换按钮 + /// + /// In zh, this message translates to: + /// **'更换'** + String get wallpaperChange; + + /// 壁纸设置:新增按钮 + /// + /// In zh, this message translates to: + /// **'新增'** + String get wallpaperAdd; + + /// 壁纸设置:轮换列表长按拖动排序提示 + /// + /// In zh, this message translates to: + /// **'长按拖动可调整顺序'** + String get wallpaperDragTip; + + /// 壁纸设置:达到数量上限提示 + /// + /// In zh, this message translates to: + /// **'最多只能添加 7 张壁纸'** + String get wallpaperMaxLimit; + + /// 壁纸设置:轮换列表为空提示 + /// + /// In zh, this message translates to: + /// **'暂无壁纸,点击「新增」添加'** + String get wallpaperEmpty; + + /// 壁纸设置:单个模式未选择图片提示 + /// + /// In zh, this message translates to: + /// **'暂无壁纸,点击「更换」选择图片'** + String get wallpaperEmptySingle; + + /// 壁纸设置:保存成功提示 + /// + /// In zh, this message translates to: + /// **'壁纸已保存'** + String get wallpaperSaved; + + /// 系统设置页标题 + /// + /// In zh, this message translates to: + /// **'系统设置'** + String get ssTitle; + + /// 系统设置加载失败提示 + /// + /// In zh, this message translates to: + /// **'系统设置加载失败'** + String get ssLoadFailed; + + /// 系统设置分组:网络 + /// + /// In zh, this message translates to: + /// **'网络'** + String get ssGrpNetwork; + + /// 系统设置分组:显示 + /// + /// In zh, this message translates to: + /// **'显示'** + String get ssGrpDisplay; + + /// 系统设置分组:系统 + /// + /// In zh, this message translates to: + /// **'系统'** + String get ssGrpSystem; + + /// 系统设置分组:存储与USB + /// + /// In zh, this message translates to: + /// **'存储与USB'** + String get ssGrpStorage; + + /// 系统设置分组:应用与权限 + /// + /// In zh, this message translates to: + /// **'应用与权限'** + String get ssGrpApp; + + /// 系统设置:WiFi热点开关 + /// + /// In zh, this message translates to: + /// **'WiFi热点'** + String get ssWifiHotspot; + + /// 系统设置:蓝牙开关 + /// + /// In zh, this message translates to: + /// **'蓝牙开关'** + String get ssBluetooth; + + /// 系统设置:蓝牙对外分享 + /// + /// In zh, this message translates to: + /// **'蓝牙对外分享'** + String get ssBluetoothSharing; + + /// 系统设置:切换飞行模式 + /// + /// In zh, this message translates to: + /// **'飞行模式'** + String get ssAirplaneMode; + + /// 系统设置:修改移动网络/APN + /// + /// In zh, this message translates to: + /// **'修改移动网络/APN'** + String get ssModifyApn; + + /// 系统设置:重置网络设置 + /// + /// In zh, this message translates to: + /// **'重置网络设置'** + String get ssResetNetwork; + + /// 系统设置:壁纸功能 + /// + /// In zh, this message translates to: + /// **'壁纸功能'** + String get ssWallpaper; + + /// 系统设置:通知栏显示 + /// + /// In zh, this message translates to: + /// **'通知栏显示'** + String get ssNotificationBar; + + /// 系统设置:状态栏下拉开关 + /// + /// In zh, this message translates to: + /// **'状态栏下拉'** + String get ssStatusBarPullDown; + + /// 系统设置:自动旋转 + /// + /// In zh, this message translates to: + /// **'自动旋转'** + String get ssAutoRotate; + + /// 系统设置:自动亮度 + /// + /// In zh, this message translates to: + /// **'自动亮度'** + String get ssAutoBrightness; + + /// 系统设置:手动调整系统亮度 + /// + /// In zh, this message translates to: + /// **'手动调亮度'** + String get ssManualBrightness; + + /// 系统设置:护眼模式 + /// + /// In zh, this message translates to: + /// **'护眼模式'** + String get ssEyeProtection; + + /// 系统设置:深色模式 + /// + /// In zh, this message translates to: + /// **'深色模式'** + String get ssDarkMode; + + /// 系统设置:修改屏幕超时休眠时间 + /// + /// In zh, this message translates to: + /// **'修改屏幕超时'** + String get ssScreenTimeout; + + /// 系统设置:时间设置管控 + /// + /// In zh, this message translates to: + /// **'时间设置管控'** + String get ssTimeSetting; + + /// 系统设置:手动调整时间与时区 + /// + /// In zh, this message translates to: + /// **'手动调时区'** + String get ssManualTimeZone; + + /// 系统设置:修改系统时间与时区 + /// + /// In zh, this message translates to: + /// **'修改时间与时区'** + String get ssModifyTimeZone; + + /// 系统设置:修改系统语言与区域 + /// + /// In zh, this message translates to: + /// **'修改系统语言'** + String get ssModifyLanguage; + + /// 系统设置:系统导航条显示 + /// + /// In zh, this message translates to: + /// **'系统导航条显示'** + String get ssNavBarShow; + + /// 系统设置:系统导航栏设置 + /// + /// In zh, this message translates to: + /// **'系统导航栏设置'** + String get ssNavBarSetting; + + /// 系统设置:导航条选项 + /// + /// In zh, this message translates to: + /// **'导航条选项'** + String get ssNavBarOptions; + + /// 系统设置:允许进入安全模式 + /// + /// In zh, this message translates to: + /// **'安全模式'** + String get ssSafeBoot; + + /// 系统设置:OTA升级管控 + /// + /// In zh, this message translates to: + /// **'OTA升级管控'** + String get ssOtaUpgrade; + + /// 系统设置:USB偏好设置 + /// + /// In zh, this message translates to: + /// **'USB偏好设置'** + String get ssUsbData; + + /// 系统设置:USB文件传输(MTP) + /// + /// In zh, this message translates to: + /// **'USB文件传输'** + String get ssUsbFileTransfer; + + /// 系统设置:存储卡 + /// + /// In zh, this message translates to: + /// **'存储卡'** + String get ssStorageCard; + + /// 系统设置:挂载外部存储(SD卡/U盘) + /// + /// In zh, this message translates to: + /// **'挂载外部存储'** + String get ssMountPhysicalStorage; + + /// 系统设置:恢复出厂 + /// + /// In zh, this message translates to: + /// **'恢复出厂设置'** + String get ssFactoryReset; + + /// 系统设置:开启ADB/USB调试 + /// + /// In zh, this message translates to: + /// **'ADB/USB调试'** + String get ssAdbUsbDebug; + + /// 系统设置:应用安装开关 + /// + /// In zh, this message translates to: + /// **'应用安装'** + String get ssInstallApps; + + /// 系统设置:卸载应用开关 + /// + /// In zh, this message translates to: + /// **'应用卸载'** + String get ssUninstallApps; + + /// 系统设置:摄像头开关 + /// + /// In zh, this message translates to: + /// **'摄像头'** + String get ssCamera; + + /// 系统设置:修改定位开关 + /// + /// In zh, this message translates to: + /// **'修改定位开关'** + String get ssModifyLocation; + + /// 系统设置:调节全局音量 + /// + /// In zh, this message translates to: + /// **'调节全局音量'** + String get ssGlobalVolume; + /// 消息:设备上线 /// /// In zh, this message translates to: @@ -1250,6 +1802,12 @@ abstract class AppLocalizations { /// **'设备序列号(SN)'** String get deviceBindSnLabel; + /// 绑定设备页 SN 输入框区分大小写提示 + /// + /// In zh, this message translates to: + /// **'区分大小写'** + String get deviceBindSnCaseSensitive; + /// 绑定设备页 SN 输入框占位符 /// /// In zh, this message translates to: @@ -1286,10 +1844,10 @@ abstract class AppLocalizations { /// **'请输入设备序列号'** String get deviceBindSnEmpty; - /// 绑定成功提示 + /// 绑定请求已发送提示(设备端确认后完成绑定) /// /// In zh, this message translates to: - /// **'设备绑定成功'** + /// **'绑定请求已发送,请等待设备端确认'** String get deviceBindSuccess; /// 绑定设备页说明文案 diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 0520a9a..a77798d 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -158,9 +158,114 @@ class AppLocalizationsEn extends AppLocalizations { @override String get addAlarm => 'Add Alarm'; + @override + String get alarmEditTitle => 'Edit Alarm'; + + @override + String get alarmEmpty => 'No alarms yet. Tap Add Alarm to create one'; + + @override + String get alarmTime => 'Time'; + + @override + String get alarmLabel => 'Label (e.g., Wake up)'; + + @override + String get alarmRepeat => 'Repeat'; + + @override + String get alarmRepeatOnce => 'Once'; + + @override + String get alarmRepeatEveryday => 'Daily'; + + @override + String get alarmRepeatWeekdays => 'Weekdays'; + + @override + String get alarmRepeatCustom => 'Custom'; + + @override + String get alarmEnabled => 'Enable Alarm'; + + @override + String get alarmDeleteConfirm => 'Delete this alarm?'; + + @override + String get alarmDelete => 'Delete Alarm'; + @override String get albumTitle => 'Album'; + @override + String get albumSendToDevice => 'Send to Device'; + + @override + String get albumSendSuccess => 'Sent to device'; + + @override + String get albumSendGetFileFailed => 'Failed to load the image'; + + @override + String get albumUploadedEmpty => + 'No uploaded images yet. Pick a photo in Albums to send'; + + @override + String albumUploadedStats(int count, String size) { + return 'Uploaded images · %1\$d · %2\$s total'; + } + + @override + String get albumFavoriteEmpty => + 'No favorite images. Tap an image in All to favorite it'; + + @override + String albumFavoriteStats(int count, String size) { + return 'Favorite images · %1\$d · %2\$s total'; + } + + @override + String get albumPermissionTitle => + 'Photo library access is required to view your photos'; + + @override + String get albumPermissionSub => + 'Allow photo library access in the dialog to retry'; + + @override + String get albumPermissionPermanentSub => + 'Permission is permanently denied. Please enable it in system settings'; + + @override + String get albumOpenSettings => 'Settings'; + + @override + String get albumRetryRequest => 'Request Again'; + + @override + String get albumEmpty => 'No albums'; + + @override + String get albumFolderEmpty => 'No photos in this album'; + + @override + String get albumUnknownFolder => 'Untitled'; + + @override + String albumAssetCount(int count) { + return '$count items'; + } + + @override + String get albumLoadFailed => 'Failed to load albums, please retry'; + + @override + String get albumFolderLoadFailed => + 'Failed to load album contents, please retry'; + + @override + String get albumGotIt => 'Got it'; + @override String get appsTitle => 'Apps'; @@ -298,6 +403,19 @@ class AppLocalizationsEn extends AppLocalizations { @override String get contactDetailTitle => 'Contact Details'; + @override + String get contactEdit => 'Edit'; + + @override + String get contactCall => 'Make Call'; + + @override + String get contactReverseDial => 'Reverse Dial'; + + @override + String get contactReverseDialSent => + 'Dial command sent, the device will call this contact'; + @override String get contactIsEmergency => 'Emergency Contact'; @@ -331,6 +449,16 @@ class AppLocalizationsEn extends AppLocalizations { @override String get homeOnline => 'Online'; + @override + String get homeNoDevice => 'No device bound yet'; + + @override + String get homeNoDeviceTip => + 'After binding, you can view the device location, screenshots and remote operations'; + + @override + String get homeBindDevice => 'Go to Bind'; + @override String get homeCommon => 'Common Apps'; @@ -487,6 +615,169 @@ class AppLocalizationsEn extends AppLocalizations { @override String get cfAppLock => 'App Lock'; + @override + String get cfSystemSettings => 'System Settings'; + + @override + String get cfWallpaper => 'Wallpaper'; + + @override + String get wallpaperTitle => 'Wallpaper Settings'; + + @override + String get wallpaperSingle => 'Single'; + + @override + String get wallpaperRotate => 'Rotation'; + + @override + String get wallpaperChange => 'Change'; + + @override + String get wallpaperAdd => 'Add'; + + @override + String get wallpaperDragTip => 'Long press and drag to reorder'; + + @override + String get wallpaperMaxLimit => 'You can add up to 7 wallpapers'; + + @override + String get wallpaperEmpty => 'No wallpapers yet. Tap Add to pick one.'; + + @override + String get wallpaperEmptySingle => + 'No wallpaper yet. Tap Change to pick one.'; + + @override + String get wallpaperSaved => 'Wallpaper saved'; + + @override + String get ssTitle => 'System Settings'; + + @override + String get ssLoadFailed => 'Failed to load system settings'; + + @override + String get ssGrpNetwork => 'Network'; + + @override + String get ssGrpDisplay => 'Display'; + + @override + String get ssGrpSystem => 'System'; + + @override + String get ssGrpStorage => 'Storage & USB'; + + @override + String get ssGrpApp => 'Apps & Permissions'; + + @override + String get ssWifiHotspot => 'Wi-Fi Hotspot'; + + @override + String get ssBluetooth => 'Bluetooth'; + + @override + String get ssBluetoothSharing => 'Bluetooth Sharing'; + + @override + String get ssAirplaneMode => 'Airplane Mode'; + + @override + String get ssModifyApn => 'Modify Network/APN'; + + @override + String get ssResetNetwork => 'Reset Network Settings'; + + @override + String get ssWallpaper => 'Wallpaper'; + + @override + String get ssNotificationBar => 'Notification Bar'; + + @override + String get ssStatusBarPullDown => 'Status Bar Pull-down'; + + @override + String get ssAutoRotate => 'Auto-rotate'; + + @override + String get ssAutoBrightness => 'Auto Brightness'; + + @override + String get ssManualBrightness => 'Manual Brightness'; + + @override + String get ssEyeProtection => 'Eye Protection'; + + @override + String get ssDarkMode => 'Dark Mode'; + + @override + String get ssScreenTimeout => 'Screen Timeout'; + + @override + String get ssTimeSetting => 'Time Settings'; + + @override + String get ssManualTimeZone => 'Manual Time Zone'; + + @override + String get ssModifyTimeZone => 'Modify Time & Zone'; + + @override + String get ssModifyLanguage => 'Modify Language'; + + @override + String get ssNavBarShow => 'Show System Nav Bar'; + + @override + String get ssNavBarSetting => 'System Nav Bar Settings'; + + @override + String get ssNavBarOptions => 'Nav Bar Options'; + + @override + String get ssSafeBoot => 'Safe Mode'; + + @override + String get ssOtaUpgrade => 'OTA Upgrade'; + + @override + String get ssUsbData => 'USB Preference'; + + @override + String get ssUsbFileTransfer => 'USB File Transfer'; + + @override + String get ssStorageCard => 'Storage Card'; + + @override + String get ssMountPhysicalStorage => 'Mount External Storage'; + + @override + String get ssFactoryReset => 'Factory Reset'; + + @override + String get ssAdbUsbDebug => 'ADB/USB Debugging'; + + @override + String get ssInstallApps => 'Install Apps'; + + @override + String get ssUninstallApps => 'Uninstall Apps'; + + @override + String get ssCamera => 'Camera'; + + @override + String get ssModifyLocation => 'Modify Location Switch'; + + @override + String get ssGlobalVolume => 'Global Volume'; + @override String get msgOnline => 'Device Online Alert'; @@ -594,6 +885,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get deviceBindSnLabel => 'Serial Number (SN)'; + @override + String get deviceBindSnCaseSensitive => 'Case sensitive'; + @override String get deviceBindSnHint => 'Enter the SN on the device or package'; @@ -613,7 +907,8 @@ class AppLocalizationsEn extends AppLocalizations { String get deviceBindSnEmpty => 'Please enter the serial number'; @override - String get deviceBindSuccess => 'Device bound successfully'; + String get deviceBindSuccess => + 'Binding request sent, waiting for the device to confirm'; @override String get deviceBindTip => diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index dbf9784..706f62c 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -157,9 +157,108 @@ class AppLocalizationsZh extends AppLocalizations { @override String get addAlarm => '添加闹钟'; + @override + String get alarmEditTitle => '编辑闹钟'; + + @override + String get alarmEmpty => '暂无闹钟,点击「添加闹钟」创建'; + + @override + String get alarmTime => '时间'; + + @override + String get alarmLabel => '标签(如:起床)'; + + @override + String get alarmRepeat => '重复'; + + @override + String get alarmRepeatOnce => '只响一次'; + + @override + String get alarmRepeatEveryday => '每天'; + + @override + String get alarmRepeatWeekdays => '工作日'; + + @override + String get alarmRepeatCustom => '自定义'; + + @override + String get alarmEnabled => '开启闹钟'; + + @override + String get alarmDeleteConfirm => '确定删除该闹钟吗?'; + + @override + String get alarmDelete => '删除闹钟'; + @override String get albumTitle => '相册'; + @override + String get albumSendToDevice => '发送到设备'; + + @override + String get albumSendSuccess => '已发送到设备'; + + @override + String get albumSendGetFileFailed => '获取图片文件失败'; + + @override + String get albumUploadedEmpty => '暂无已上传的图片,可在「相簿」中选择照片发送到设备'; + + @override + String albumUploadedStats(int count, String size) { + return '已上传的图片 · %1\$d 张 · 共 %2\$s'; + } + + @override + String get albumFavoriteEmpty => '暂无收藏的图片,在「全部」中点击图片可收藏'; + + @override + String albumFavoriteStats(int count, String size) { + return '收藏的图片 · %1\$d 张 · 共 %2\$s'; + } + + @override + String get albumPermissionTitle => '需要相册访问权限才能查看本机照片'; + + @override + String get albumPermissionSub => '请在弹窗中允许访问相册后重试'; + + @override + String get albumPermissionPermanentSub => '权限已被永久拒绝,请前往系统设置开启'; + + @override + String get albumOpenSettings => '去设置'; + + @override + String get albumRetryRequest => '重新申请'; + + @override + String get albumEmpty => '暂无相簿'; + + @override + String get albumFolderEmpty => '此相簿暂无照片'; + + @override + String get albumUnknownFolder => '未命名'; + + @override + String albumAssetCount(int count) { + return '$count 项'; + } + + @override + String get albumLoadFailed => '相簿加载失败,请重试'; + + @override + String get albumFolderLoadFailed => '相簿内容加载失败,请重试'; + + @override + String get albumGotIt => '知道了'; + @override String get appsTitle => '应用'; @@ -297,6 +396,18 @@ class AppLocalizationsZh extends AppLocalizations { @override String get contactDetailTitle => '联系人详情'; + @override + String get contactEdit => '编辑'; + + @override + String get contactCall => '拨打电话'; + + @override + String get contactReverseDial => '反向拨号'; + + @override + String get contactReverseDialSent => '拨号指令已发送,设备将呼叫该联系人'; + @override String get contactIsEmergency => '紧急联系人'; @@ -330,6 +441,15 @@ class AppLocalizationsZh extends AppLocalizations { @override String get homeOnline => '在线'; + @override + String get homeNoDevice => '还没有绑定设备'; + + @override + String get homeNoDeviceTip => '绑定后可查看设备位置、截屏与远程操作'; + + @override + String get homeBindDevice => '去绑定'; + @override String get homeCommon => '常用功能'; @@ -483,6 +603,168 @@ class AppLocalizationsZh extends AppLocalizations { @override String get cfAppLock => '应用锁'; + @override + String get cfSystemSettings => '系统设置'; + + @override + String get cfWallpaper => '壁纸设置'; + + @override + String get wallpaperTitle => '壁纸设置'; + + @override + String get wallpaperSingle => '单个'; + + @override + String get wallpaperRotate => '轮换'; + + @override + String get wallpaperChange => '更换'; + + @override + String get wallpaperAdd => '新增'; + + @override + String get wallpaperDragTip => '长按拖动可调整顺序'; + + @override + String get wallpaperMaxLimit => '最多只能添加 7 张壁纸'; + + @override + String get wallpaperEmpty => '暂无壁纸,点击「新增」添加'; + + @override + String get wallpaperEmptySingle => '暂无壁纸,点击「更换」选择图片'; + + @override + String get wallpaperSaved => '壁纸已保存'; + + @override + String get ssTitle => '系统设置'; + + @override + String get ssLoadFailed => '系统设置加载失败'; + + @override + String get ssGrpNetwork => '网络'; + + @override + String get ssGrpDisplay => '显示'; + + @override + String get ssGrpSystem => '系统'; + + @override + String get ssGrpStorage => '存储与USB'; + + @override + String get ssGrpApp => '应用与权限'; + + @override + String get ssWifiHotspot => 'WiFi热点'; + + @override + String get ssBluetooth => '蓝牙开关'; + + @override + String get ssBluetoothSharing => '蓝牙对外分享'; + + @override + String get ssAirplaneMode => '飞行模式'; + + @override + String get ssModifyApn => '修改移动网络/APN'; + + @override + String get ssResetNetwork => '重置网络设置'; + + @override + String get ssWallpaper => '壁纸功能'; + + @override + String get ssNotificationBar => '通知栏显示'; + + @override + String get ssStatusBarPullDown => '状态栏下拉'; + + @override + String get ssAutoRotate => '自动旋转'; + + @override + String get ssAutoBrightness => '自动亮度'; + + @override + String get ssManualBrightness => '手动调亮度'; + + @override + String get ssEyeProtection => '护眼模式'; + + @override + String get ssDarkMode => '深色模式'; + + @override + String get ssScreenTimeout => '修改屏幕超时'; + + @override + String get ssTimeSetting => '时间设置管控'; + + @override + String get ssManualTimeZone => '手动调时区'; + + @override + String get ssModifyTimeZone => '修改时间与时区'; + + @override + String get ssModifyLanguage => '修改系统语言'; + + @override + String get ssNavBarShow => '系统导航条显示'; + + @override + String get ssNavBarSetting => '系统导航栏设置'; + + @override + String get ssNavBarOptions => '导航条选项'; + + @override + String get ssSafeBoot => '安全模式'; + + @override + String get ssOtaUpgrade => 'OTA升级管控'; + + @override + String get ssUsbData => 'USB偏好设置'; + + @override + String get ssUsbFileTransfer => 'USB文件传输'; + + @override + String get ssStorageCard => '存储卡'; + + @override + String get ssMountPhysicalStorage => '挂载外部存储'; + + @override + String get ssFactoryReset => '恢复出厂设置'; + + @override + String get ssAdbUsbDebug => 'ADB/USB调试'; + + @override + String get ssInstallApps => '应用安装'; + + @override + String get ssUninstallApps => '应用卸载'; + + @override + String get ssCamera => '摄像头'; + + @override + String get ssModifyLocation => '修改定位开关'; + + @override + String get ssGlobalVolume => '调节全局音量'; + @override String get msgOnline => '设备上线提醒'; @@ -590,6 +872,9 @@ class AppLocalizationsZh extends AppLocalizations { @override String get deviceBindSnLabel => '设备序列号(SN)'; + @override + String get deviceBindSnCaseSensitive => '区分大小写'; + @override String get deviceBindSnHint => '请输入设备机身或包装上的 SN'; @@ -609,7 +894,7 @@ class AppLocalizationsZh extends AppLocalizations { String get deviceBindSnEmpty => '请输入设备序列号'; @override - String get deviceBindSuccess => '设备绑定成功'; + String get deviceBindSuccess => '绑定请求已发送,请等待设备端确认'; @override String get deviceBindTip => 'SN 通常位于设备背面标签或设置-关于本机中。'; diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 00b41ee..9e35f81 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -49,7 +49,38 @@ "privacyPolicyContent": "Privacy Policy\n\nWe take your privacy seriously. This policy explains how we collect, use, store, and protect your personal information.\n\n1. Information We Collect\nWe may collect information you provide (e.g., phone number, nickname) and device/log data for security and troubleshooting.\n\n2. How We Use Information\nYour information is used solely to provide and improve the service, secure your account, and send necessary notices.\n\n3. Storage\nWe apply reasonable safeguards such as encryption and retain information only as long as necessary, then delete or anonymize it.\n\n4. Sharing\nWe do not disclose personal information to third parties except as required by law or to fulfill a service you requested.\n\n5. Your Rights\nYou may access, correct, or delete your personal information and withdraw granted consents.\n\n6. Changes\nWe will update this policy within the App; please review it periodically.", "alarmTitle": "Alarms", "addAlarm": "Add Alarm", + "alarmEditTitle": "Edit Alarm", + "alarmEmpty": "No alarms yet. Tap Add Alarm to create one", + "alarmTime": "Time", + "alarmLabel": "Label (e.g., Wake up)", + "alarmRepeat": "Repeat", + "alarmRepeatOnce": "Once", + "alarmRepeatEveryday": "Daily", + "alarmRepeatWeekdays": "Weekdays", + "alarmRepeatCustom": "Custom", + "alarmEnabled": "Enable Alarm", + "alarmDeleteConfirm": "Delete this alarm?", + "alarmDelete": "Delete Alarm", "albumTitle": "Album", + "albumSendToDevice": "Send to Device", + "albumSendSuccess": "Sent to device", + "albumSendGetFileFailed": "Failed to load the image", + "albumUploadedEmpty": "No uploaded images yet. Pick a photo in Albums to send", + "albumUploadedStats": "Uploaded images · %1$d · %2$s total", + "albumFavoriteEmpty": "No favorite images. Tap an image in All to favorite it", + "albumFavoriteStats": "Favorite images · %1$d · %2$s total", + "albumPermissionTitle": "Photo library access is required to view your photos", + "albumPermissionSub": "Allow photo library access in the dialog to retry", + "albumPermissionPermanentSub": "Permission is permanently denied. Please enable it in system settings", + "albumOpenSettings": "Settings", + "albumRetryRequest": "Request Again", + "albumEmpty": "No albums", + "albumFolderEmpty": "No photos in this album", + "albumUnknownFolder": "Untitled", + "albumAssetCount": "{count} items", + "albumLoadFailed": "Failed to load albums, please retry", + "albumFolderLoadFailed": "Failed to load album contents, please retry", + "albumGotIt": "Got it", "appsTitle": "Apps", "appsLoadFailed": "Failed to load apps", "appsEmpty": "No installed apps", @@ -110,6 +141,10 @@ "@contactEmergencyNo": { "description": "详情页:紧急联系人状态-否" }, + "contactCall": "Make Call", + "contactReverseDial": "Reverse Dial", + "contactReverseDialSent": "Dial command sent, the device will call this contact", + "contactEdit": "Edit", "commonEdit": "Edit Contact", "commonDelete": "Delete", "grpFavorite": "★ Favorites", @@ -118,6 +153,9 @@ "tabManage": "Manage", "homeDeviceName": "My Tablet", "homeOnline": "Online", + "homeNoDevice": "No device bound yet", + "homeNoDeviceTip": "After binding, you can view the device location, screenshots and remote operations", + "homeBindDevice": "Go to Bind", "homeCommon": "Common Apps", "homeLocation": "Live Location", "homeLocating": "Locating…", @@ -169,6 +207,60 @@ "cfLost": "Lost Mode", "cfScreenLock": "Screen Lock", "cfAppLock": "App Lock", + "cfSystemSettings": "System Settings", + "cfWallpaper": "Wallpaper", + "wallpaperTitle": "Wallpaper Settings", + "wallpaperSingle": "Single", + "wallpaperRotate": "Rotation", + "wallpaperChange": "Change", + "wallpaperAdd": "Add", + "wallpaperDragTip": "Long press and drag to reorder", + "wallpaperMaxLimit": "You can add up to 7 wallpapers", + "wallpaperEmpty": "No wallpapers yet. Tap Add to pick one.", + "wallpaperEmptySingle": "No wallpaper yet. Tap Change to pick one.", + "wallpaperSaved": "Wallpaper saved", + "ssTitle": "System Settings", + "ssLoadFailed": "Failed to load system settings", + "ssGrpNetwork": "Network", + "ssGrpDisplay": "Display", + "ssGrpSystem": "System", + "ssGrpStorage": "Storage & USB", + "ssGrpApp": "Apps & Permissions", + "ssWifiHotspot": "Wi-Fi Hotspot", + "ssBluetooth": "Bluetooth", + "ssBluetoothSharing": "Bluetooth Sharing", + "ssAirplaneMode": "Airplane Mode", + "ssModifyApn": "Modify Network/APN", + "ssResetNetwork": "Reset Network Settings", + "ssWallpaper": "Wallpaper", + "ssNotificationBar": "Notification Bar", + "ssStatusBarPullDown": "Status Bar Pull-down", + "ssAutoRotate": "Auto-rotate", + "ssAutoBrightness": "Auto Brightness", + "ssManualBrightness": "Manual Brightness", + "ssEyeProtection": "Eye Protection", + "ssDarkMode": "Dark Mode", + "ssScreenTimeout": "Screen Timeout", + "ssTimeSetting": "Time Settings", + "ssManualTimeZone": "Manual Time Zone", + "ssModifyTimeZone": "Modify Time & Zone", + "ssModifyLanguage": "Modify Language", + "ssNavBarShow": "Show System Nav Bar", + "ssNavBarSetting": "System Nav Bar Settings", + "ssNavBarOptions": "Nav Bar Options", + "ssSafeBoot": "Safe Mode", + "ssOtaUpgrade": "OTA Upgrade", + "ssUsbData": "USB Preference", + "ssUsbFileTransfer": "USB File Transfer", + "ssStorageCard": "Storage Card", + "ssMountPhysicalStorage": "Mount External Storage", + "ssFactoryReset": "Factory Reset", + "ssAdbUsbDebug": "ADB/USB Debugging", + "ssInstallApps": "Install Apps", + "ssUninstallApps": "Uninstall Apps", + "ssCamera": "Camera", + "ssModifyLocation": "Modify Location Switch", + "ssGlobalVolume": "Global Volume", "msgOnline": "Device Online Alert", "msgScreenshot": "Screenshot Sync", "msgRemote": "Remote Help", @@ -204,13 +296,14 @@ "deviceUnbindSuccess": "Device unbound", "deviceBindTitle": "Bind Device", "deviceBindSnLabel": "Serial Number (SN)", + "deviceBindSnCaseSensitive": "Case sensitive", "deviceBindSnHint": "Enter the SN on the device or package", "deviceBindRemarkLabel": "Remark (optional)", "deviceBindRemarkHint": "e.g. Mom's tablet", "deviceBindConfirm": "Confirm Binding", "deviceBindScan": "Scan QR Code", "deviceBindSnEmpty": "Please enter the serial number", - "deviceBindSuccess": "Device bound successfully", + "deviceBindSuccess": "Binding request sent, waiting for the device to confirm", "deviceBindTip": "The SN is usually on the label on the back of the device or in Settings - About.", "scanTitle": "Scan QR Code", "scanHint": "Place the device QR code inside the frame to scan automatically", diff --git a/lib/l10n/intl_zh.arb b/lib/l10n/intl_zh.arb index d6386f6..04cf496 100644 --- a/lib/l10n/intl_zh.arb +++ b/lib/l10n/intl_zh.arb @@ -196,10 +196,155 @@ "@addAlarm": { "description": "添加闹钟按钮" }, + "alarmEditTitle": "编辑闹钟", + "@alarmEditTitle": { + "description": "编辑闹钟页标题" + }, + "alarmEmpty": "暂无闹钟,点击「添加闹钟」创建", + "@alarmEmpty": { + "description": "闹钟列表为空提示" + }, + "alarmTime": "时间", + "@alarmTime": { + "description": "闹钟时间选择标签" + }, + "alarmLabel": "标签(如:起床)", + "@alarmLabel": { + "description": "闹钟标签输入占位" + }, + "alarmRepeat": "重复", + "@alarmRepeat": { + "description": "闹钟重复选择标签" + }, + "alarmRepeatOnce": "只响一次", + "@alarmRepeatOnce": { + "description": "重复类型-只响一次" + }, + "alarmRepeatEveryday": "每天", + "@alarmRepeatEveryday": { + "description": "重复类型-每天" + }, + "alarmRepeatWeekdays": "工作日", + "@alarmRepeatWeekdays": { + "description": "重复类型-工作日" + }, + "alarmRepeatCustom": "自定义", + "@alarmRepeatCustom": { + "description": "重复类型-自定义" + }, + "alarmEnabled": "开启闹钟", + "@alarmEnabled": { + "description": "闹钟开关标签" + }, + "alarmDeleteConfirm": "确定删除该闹钟吗?", + "@alarmDeleteConfirm": { + "description": "删除闹钟确认弹窗标题" + }, + "alarmDelete": "删除闹钟", + "@alarmDelete": { + "description": "删除闹钟按钮" + }, "albumTitle": "相册", "@albumTitle": { "description": "相册页标题" }, + "albumSendToDevice": "发送到设备", + "@albumSendToDevice": { + "description": "相册:发送图片到设备" + }, + "albumSendSuccess": "已发送到设备", + "@albumSendSuccess": { + "description": "相册:图片发送成功提示" + }, + "albumSendGetFileFailed": "获取图片文件失败", + "@albumSendGetFileFailed": { + "description": "相册:获取图片文件失败提示" + }, + "albumUploadedEmpty": "暂无已上传的图片,可在「相簿」中选择照片发送到设备", + "@albumUploadedEmpty": { + "description": "相册:已上传图片列表为空提示" + }, + "albumUploadedStats": "已上传的图片 · %1$d 张 · 共 %2$s", + "@albumUploadedStats": { + "description": "相册:已上传图片数量与总大小统计", + "placeholders": { + "count": { + "type": "int" + }, + "size": { + "type": "String" + } + } + }, + "albumFavoriteEmpty": "暂无收藏的图片,在「全部」中点击图片可收藏", + "@albumFavoriteEmpty": { + "description": "相册:收藏列表为空提示" + }, + "albumFavoriteStats": "收藏的图片 · %1$d 张 · 共 %2$s", + "@albumFavoriteStats": { + "description": "相册:收藏图片数量与总大小统计", + "placeholders": { + "count": { + "type": "int" + }, + "size": { + "type": "String" + } + } + }, + "albumPermissionTitle": "需要相册访问权限才能查看本机照片", + "@albumPermissionTitle": { + "description": "相簿分段:权限被拒引导标题" + }, + "albumPermissionSub": "请在弹窗中允许访问相册后重试", + "@albumPermissionSub": { + "description": "相簿分段:权限可再次申请时的副文案" + }, + "albumPermissionPermanentSub": "权限已被永久拒绝,请前往系统设置开启", + "@albumPermissionPermanentSub": { + "description": "相簿分段:权限永久拒绝时的副文案" + }, + "albumOpenSettings": "去设置", + "@albumOpenSettings": { + "description": "相簿分段:打开系统设置按钮" + }, + "albumRetryRequest": "重新申请", + "@albumRetryRequest": { + "description": "相簿分段:重新申请权限按钮" + }, + "albumEmpty": "暂无相簿", + "@albumEmpty": { + "description": "相簿列表为空" + }, + "albumFolderEmpty": "此相簿暂无照片", + "@albumFolderEmpty": { + "description": "相簿内没有照片" + }, + "albumUnknownFolder": "未命名", + "@albumUnknownFolder": { + "description": "相簿名称为空时显示" + }, + "albumAssetCount": "{count} 项", + "@albumAssetCount": { + "description": "相簿内媒体数量", + "placeholders": { + "count": { + "type": "int" + } + } + }, + "albumLoadFailed": "相簿加载失败,请重试", + "@albumLoadFailed": { + "description": "相簿列表加载失败" + }, + "albumFolderLoadFailed": "相簿内容加载失败,请重试", + "@albumFolderLoadFailed": { + "description": "相簿内容加载失败" + }, + "albumGotIt": "知道了", + "@albumGotIt": { + "description": "相簿提示弹窗确认按钮" + }, "appsTitle": "应用", "@appsTitle": { "description": "应用页标题" @@ -380,6 +525,22 @@ "@contactDetailTitle": { "description": "联系人详情页标题" }, + "contactEdit": "编辑", + "@contactEdit": { + "description": "详情页编辑按钮" + }, + "contactCall": "拨打电话", + "@contactCall": { + "description": "联系人详情:拨打电话按钮" + }, + "contactReverseDial": "反向拨号", + "@contactReverseDial": { + "description": "联系人详情:反向拨号按钮" + }, + "contactReverseDialSent": "拨号指令已发送,设备将呼叫该联系人", + "@contactReverseDialSent": { + "description": "联系人详情:反向拨号指令发送成功提示" + }, "contactIsEmergency": "紧急联系人", "@contactIsEmergency": { "description": "详情页:紧急联系人标签" @@ -424,6 +585,18 @@ "@homeOnline": { "description": "设备在线状态" }, + "homeNoDevice": "还没有绑定设备", + "@homeNoDevice": { + "description": "首页未绑定设备提示" + }, + "homeNoDeviceTip": "绑定后可查看设备位置、截屏与远程操作", + "@homeNoDeviceTip": { + "description": "首页未绑定设备时的辅助说明" + }, + "homeBindDevice": "去绑定", + "@homeBindDevice": { + "description": "首页未绑定设备时去绑定按钮" + }, "homeCommon": "常用功能", "@homeCommon": { "description": "首页常用功能" @@ -628,6 +801,222 @@ "@cfAppLock": { "description": "常用功能:应用锁" }, + "cfSystemSettings": "系统设置", + "@cfSystemSettings": { + "description": "常用功能:系统设置" + }, + "cfWallpaper": "壁纸设置", + "@cfWallpaper": { + "description": "常用功能:壁纸设置" + }, + "wallpaperTitle": "壁纸设置", + "@wallpaperTitle": { + "description": "壁纸设置页标题" + }, + "wallpaperSingle": "单个", + "@wallpaperSingle": { + "description": "壁纸设置:单个模式" + }, + "wallpaperRotate": "轮换", + "@wallpaperRotate": { + "description": "壁纸设置:轮换模式" + }, + "wallpaperChange": "更换", + "@wallpaperChange": { + "description": "壁纸设置:更换按钮" + }, + "wallpaperAdd": "新增", + "@wallpaperAdd": { + "description": "壁纸设置:新增按钮" + }, + "wallpaperDragTip": "长按拖动可调整顺序", + "@wallpaperDragTip": { + "description": "壁纸设置:轮换列表长按拖动排序提示" + }, + "wallpaperMaxLimit": "最多只能添加 7 张壁纸", + "@wallpaperMaxLimit": { + "description": "壁纸设置:达到数量上限提示" + }, + "wallpaperEmpty": "暂无壁纸,点击「新增」添加", + "@wallpaperEmpty": { + "description": "壁纸设置:轮换列表为空提示" + }, + "wallpaperEmptySingle": "暂无壁纸,点击「更换」选择图片", + "@wallpaperEmptySingle": { + "description": "壁纸设置:单个模式未选择图片提示" + }, + "wallpaperSaved": "壁纸已保存", + "@wallpaperSaved": { + "description": "壁纸设置:保存成功提示" + }, + "ssTitle": "系统设置", + "@ssTitle": { + "description": "系统设置页标题" + }, + "ssLoadFailed": "系统设置加载失败", + "@ssLoadFailed": { + "description": "系统设置加载失败提示" + }, + "ssGrpNetwork": "网络", + "@ssGrpNetwork": { + "description": "系统设置分组:网络" + }, + "ssGrpDisplay": "显示", + "@ssGrpDisplay": { + "description": "系统设置分组:显示" + }, + "ssGrpSystem": "系统", + "@ssGrpSystem": { + "description": "系统设置分组:系统" + }, + "ssGrpStorage": "存储与USB", + "@ssGrpStorage": { + "description": "系统设置分组:存储与USB" + }, + "ssGrpApp": "应用与权限", + "@ssGrpApp": { + "description": "系统设置分组:应用与权限" + }, + "ssWifiHotspot": "WiFi热点", + "@ssWifiHotspot": { + "description": "系统设置:WiFi热点开关" + }, + "ssBluetooth": "蓝牙开关", + "@ssBluetooth": { + "description": "系统设置:蓝牙开关" + }, + "ssBluetoothSharing": "蓝牙对外分享", + "@ssBluetoothSharing": { + "description": "系统设置:蓝牙对外分享" + }, + "ssAirplaneMode": "飞行模式", + "@ssAirplaneMode": { + "description": "系统设置:切换飞行模式" + }, + "ssModifyApn": "修改移动网络/APN", + "@ssModifyApn": { + "description": "系统设置:修改移动网络/APN" + }, + "ssResetNetwork": "重置网络设置", + "@ssResetNetwork": { + "description": "系统设置:重置网络设置" + }, + "ssWallpaper": "壁纸功能", + "@ssWallpaper": { + "description": "系统设置:壁纸功能" + }, + "ssNotificationBar": "通知栏显示", + "@ssNotificationBar": { + "description": "系统设置:通知栏显示" + }, + "ssStatusBarPullDown": "状态栏下拉", + "@ssStatusBarPullDown": { + "description": "系统设置:状态栏下拉开关" + }, + "ssAutoRotate": "自动旋转", + "@ssAutoRotate": { + "description": "系统设置:自动旋转" + }, + "ssAutoBrightness": "自动亮度", + "@ssAutoBrightness": { + "description": "系统设置:自动亮度" + }, + "ssManualBrightness": "手动调亮度", + "@ssManualBrightness": { + "description": "系统设置:手动调整系统亮度" + }, + "ssEyeProtection": "护眼模式", + "@ssEyeProtection": { + "description": "系统设置:护眼模式" + }, + "ssDarkMode": "深色模式", + "@ssDarkMode": { + "description": "系统设置:深色模式" + }, + "ssScreenTimeout": "修改屏幕超时", + "@ssScreenTimeout": { + "description": "系统设置:修改屏幕超时休眠时间" + }, + "ssTimeSetting": "时间设置管控", + "@ssTimeSetting": { + "description": "系统设置:时间设置管控" + }, + "ssManualTimeZone": "手动调时区", + "@ssManualTimeZone": { + "description": "系统设置:手动调整时间与时区" + }, + "ssModifyTimeZone": "修改时间与时区", + "@ssModifyTimeZone": { + "description": "系统设置:修改系统时间与时区" + }, + "ssModifyLanguage": "修改系统语言", + "@ssModifyLanguage": { + "description": "系统设置:修改系统语言与区域" + }, + "ssNavBarShow": "系统导航条显示", + "@ssNavBarShow": { + "description": "系统设置:系统导航条显示" + }, + "ssNavBarSetting": "系统导航栏设置", + "@ssNavBarSetting": { + "description": "系统设置:系统导航栏设置" + }, + "ssNavBarOptions": "导航条选项", + "@ssNavBarOptions": { + "description": "系统设置:导航条选项" + }, + "ssSafeBoot": "安全模式", + "@ssSafeBoot": { + "description": "系统设置:允许进入安全模式" + }, + "ssOtaUpgrade": "OTA升级管控", + "@ssOtaUpgrade": { + "description": "系统设置:OTA升级管控" + }, + "ssUsbData": "USB偏好设置", + "@ssUsbData": { + "description": "系统设置:USB偏好设置" + }, + "ssUsbFileTransfer": "USB文件传输", + "@ssUsbFileTransfer": { + "description": "系统设置:USB文件传输(MTP)" + }, + "ssStorageCard": "存储卡", + "@ssStorageCard": { + "description": "系统设置:存储卡" + }, + "ssMountPhysicalStorage": "挂载外部存储", + "@ssMountPhysicalStorage": { + "description": "系统设置:挂载外部存储(SD卡/U盘)" + }, + "ssFactoryReset": "恢复出厂设置", + "@ssFactoryReset": { + "description": "系统设置:恢复出厂" + }, + "ssAdbUsbDebug": "ADB/USB调试", + "@ssAdbUsbDebug": { + "description": "系统设置:开启ADB/USB调试" + }, + "ssInstallApps": "应用安装", + "@ssInstallApps": { + "description": "系统设置:应用安装开关" + }, + "ssUninstallApps": "应用卸载", + "@ssUninstallApps": { + "description": "系统设置:卸载应用开关" + }, + "ssCamera": "摄像头", + "@ssCamera": { + "description": "系统设置:摄像头开关" + }, + "ssModifyLocation": "修改定位开关", + "@ssModifyLocation": { + "description": "系统设置:修改定位开关" + }, + "ssGlobalVolume": "调节全局音量", + "@ssGlobalVolume": { + "description": "系统设置:调节全局音量" + }, "msgOnline": "设备上线提醒", "@msgOnline": { "description": "消息:设备上线" @@ -773,6 +1162,10 @@ "@deviceBindSnLabel": { "description": "绑定设备页 SN 输入框标签" }, + "deviceBindSnCaseSensitive": "区分大小写", + "@deviceBindSnCaseSensitive": { + "description": "绑定设备页 SN 输入框区分大小写提示" + }, "deviceBindSnHint": "请输入设备机身或包装上的 SN", "@deviceBindSnHint": { "description": "绑定设备页 SN 输入框占位符" @@ -797,9 +1190,9 @@ "@deviceBindSnEmpty": { "description": "SN 为空校验提示" }, - "deviceBindSuccess": "设备绑定成功", + "deviceBindSuccess": "绑定请求已发送,请等待设备端确认", "@deviceBindSuccess": { - "description": "绑定成功提示" + "description": "绑定请求已发送提示(设备端确认后完成绑定)" }, "deviceBindTip": "SN 通常位于设备背面标签或设置-关于本机中。", "@deviceBindTip": { diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index c59e5c3..b3d2c10 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -11,6 +11,7 @@ import flutter_secure_storage_darwin import flutter_webrtc import mmkv_ios import mobile_scanner +import photo_manager import shared_preferences_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -20,5 +21,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FlutterWebRTCPlugin.register(with: registry.registrar(forPlugin: "FlutterWebRTCPlugin")) MMKVPlugin.register(with: registry.registrar(forPlugin: "MMKVPlugin")) MobileScannerPlugin.register(with: registry.registrar(forPlugin: "MobileScannerPlugin")) + PhotoManagerPlugin.register(with: registry.registrar(forPlugin: "PhotoManagerPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index bb2b732..722f814 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -85,10 +85,10 @@ packages: dependency: transitive description: name: build_daemon - sha256: "79e05eaf15a48d7230b053a4363b8eaac0cc234bbd0134c3229455481f55cbc6" + sha256: "39ab65f7c60c19af64b9ef96e6a5d3ab48355f7dddfd98a9079d55a8cb6628fc" url: "https://pub.flutter-io.cn" source: hosted - version: "4.1.5" + version: "4.1.7" build_resolvers: dependency: transitive description: @@ -117,18 +117,18 @@ packages: dependency: transitive description: name: built_collection - sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + sha256: "44922ecebd8e3d0cef743dadd3b54df4e87e2a4c52a29465a1872aa9e192caa8" url: "https://pub.flutter-io.cn" source: hosted - version: "5.1.1" + version: "5.1.2" built_value: dependency: transitive description: name: built_value - sha256: "31b24be6615ec7fcf70b3aa5a7469fe35826485e639a16dd7eb83ba30e4cc6a8" + sha256: f87ea98192116f7093cb214551ce1929caae0681fdba282b3d8b4462adee7bb7 url: "https://pub.flutter-io.cn" source: hosted - version: "8.12.7" + version: "8.13.0" characters: dependency: transitive description: @@ -149,26 +149,26 @@ packages: dependency: transitive description: name: clock - sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + sha256: e51d50bca3217c9a9fa2b41a30e4a38971133f5f9ec7a3d57bae095007f1d28e url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.2" + version: "1.1.3" code_assets: dependency: transitive description: name: code_assets - sha256: cfd4f5f575a49c5f10ca856e9846073f1e6c3ee94912377eea5f6cefc5272941 + sha256: "828110d598123b5ea96c00c9f3c72105bf79f8ee36c20a39b26209ade421ec57" url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.0" + version: "2.1.0" code_builder: dependency: transitive description: name: code_builder - sha256: "6a6cab2ba4680d6423f34a9b972a4c9a94ebe1b62ecec4e1a1f2cba91fd1319d" + sha256: "811709c1badd02fc054039a13f66e0db1961865f9a314175f68c3eaeebec786f" url: "https://pub.flutter-io.cn" source: hosted - version: "4.11.1" + version: "4.13.0" collection: dependency: transitive description: @@ -213,10 +213,10 @@ packages: dependency: "direct main" description: name: cupertino_ui - sha256: "2137c0d41f3b62cc4d3d2495e6c354bd6b6133cd21c6bb155736cc31dbd49a11" + sha256: "8e14acc2817ff469b925b0e275ab85ecc6c769621360dd0af1331c47f916e247" url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.1" + version: "1.1.3" custom_lint_core: dependency: transitive description: @@ -245,18 +245,18 @@ packages: dependency: transitive description: name: dart_webrtc - sha256: f6d615bddea5e458ce180a914f3055c234ffb52fb7397a51b3491e76d6d7edb2 + sha256: "078e3c431500147e5cc52b3c6ea41ed538f30c7720cc2467d2186c9251e62716" url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.1" + version: "1.8.2" device_info_plus: dependency: "direct main" description: name: device_info_plus - sha256: "0891702f96b2e465fe567b7ec448380e6b1c14f60af552a8536d9f583b6b8442" + sha256: ade1c36f8355d6284c98e4a47992ea263887ed3d1acb281e37635dd45f04c4aa url: "https://pub.flutter-io.cn" source: hosted - version: "13.2.0" + version: "13.3.0" device_info_plus_platform_interface: dependency: transitive description: @@ -269,18 +269,26 @@ packages: dependency: "direct main" description: name: dio - sha256: "0df44ebba85e503958eb75d07eedd3c86275a58c1d3eda2f2ce8f0a2c3abbb3c" + sha256: "852ec3b48cc431ac04fff978413c541502b67ffc3e26921e74e3d994694192c1" url: "https://pub.flutter-io.cn" source: hosted - version: "5.11.0" + version: "5.11.1" dio_web_adapter: dependency: transitive description: name: dio_web_adapter - sha256: "0786d0b7295a373de356fc0af4f6f1d0ab2844ed31b19dfc5e7556b70e24212c" + sha256: "3a1b2cd7be71086f38504956e3ebcd2837288d231ff454bafa78021244102bfc" url: "https://pub.flutter-io.cn" source: hosted - version: "2.2.1" + version: "2.2.2" + easy_image_viewer: + dependency: "direct main" + description: + name: easy_image_viewer + sha256: fb6cb123c3605552cc91150dcdb50ca977001dcddfb71d20caa0c5edc9a80947 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.5.1" fake_async: dependency: transitive description: @@ -317,18 +325,18 @@ packages: dependency: transitive description: name: file_selector_linux - sha256: "2567f398e06ac72dcf2e98a0c95df2a9edd03c2c2e0cacd4780f20cdf56263a0" + sha256: da76400e7872ce7637ffdce12749ec24169c25f6195c28372208e65a24bcd2ab url: "https://pub.flutter-io.cn" source: hosted - version: "0.9.4" + version: "0.9.4+1" file_selector_macos: dependency: transitive description: name: file_selector_macos - sha256: "5e0bbe9c312416f1787a68259ea1505b52f258c587f12920422671807c4d618a" + sha256: d57c62362766b5e7ae739448650b66c6aab7a68ba7ecc65e04018652645ae0f4 url: "https://pub.flutter-io.cn" source: hosted - version: "0.9.5" + version: "0.9.5+1" file_selector_platform_interface: dependency: transitive description: @@ -341,10 +349,10 @@ packages: dependency: transitive description: name: file_selector_windows - sha256: "62197474ae75893a62df75939c777763d39c2bc5f73ce5b88497208bc269abfd" + sha256: fbefc5fb92c6d3cbe8d284a2cd971b593bb07d2cd6da8557b81a862250b4acec url: "https://pub.flutter-io.cn" source: hosted - version: "0.9.3+5" + version: "0.9.3+6" fixnum: dependency: "direct main" description: @@ -378,10 +386,10 @@ packages: dependency: "direct main" description: name: flutter_bmflocation - sha256: c7af05b856f058603fd648bfe3786a6395f2ae5a6efaabaab8b3f9c96cdb8f3f + sha256: "3520fb9d6de25bc8a20bfdbcfc23dfd255927e4ee8734d1ad3e207414c409e06" url: "https://pub.flutter-io.cn" source: hosted - version: "3.8.4+1" + version: "3.8.5" flutter_displaymode: dependency: "direct main" description: @@ -423,34 +431,34 @@ packages: dependency: "direct main" description: name: flutter_secure_storage - sha256: "15e8c8fe269fdf7d469b23008ab3df521c8b826ed345820532364c31bdebace6" + sha256: d4e1fb6b2cb524868929e78dc0282fa000554b22060fb53789dc481c9fc95bb8 url: "https://pub.flutter-io.cn" source: hosted - version: "11.0.0" + version: "11.2.0" flutter_secure_storage_darwin: dependency: transitive description: name: flutter_secure_storage_darwin - sha256: ac6d76a752de0cd738334eb4b21743fc4943f449f5b6e308f18838b048c02ac0 + sha256: a031ceac9b070e62ef183cd7f7d1a8798ebde402d5049f0fe6eb3a51bd797a21 url: "https://pub.flutter-io.cn" source: hosted - version: "0.4.0" + version: "0.4.3" flutter_secure_storage_linux: dependency: transitive description: name: flutter_secure_storage_linux - sha256: "76fa9c841b3b1619fc5b5bc36efc7d158fa2356f223b6caeb1d0c80a54168546" + sha256: caa75bd78f017422912e3a904933113b2428eb79f981ac37acd2dd2a700458ea url: "https://pub.flutter-io.cn" source: hosted - version: "3.0.2" + version: "3.0.3" flutter_secure_storage_platform_interface: dependency: transitive description: name: flutter_secure_storage_platform_interface - sha256: "788060052712555182aba55ecb5f8b6e5cb9cfe8f776c83249a61fe3ce877db4" + sha256: "64951127f001f546891c86f414972bf49ef2c4c8a4c92c65f5790cc0c9100045" url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.3" + version: "2.1.1" flutter_secure_storage_web: dependency: transitive description: @@ -481,10 +489,10 @@ packages: dependency: "direct main" description: name: flutter_webrtc - sha256: e997161d7da3adedd3d430691b20931b0b4d96fa48bb60938d9ba0bf6fca98be + sha256: ebf5ceef2897caae425ed65a38b2961c29d9d9a626159418ed460e1a65038c00 url: "https://pub.flutter-io.cn" source: hosted - version: "1.6.0" + version: "1.6.2+hotfix.4" freezed: dependency: "direct dev" description: @@ -505,18 +513,18 @@ packages: dependency: transitive description: name: frontend_server_client - sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + sha256: "404dbf9bce29beafbe9dcb19219447b6f7d49900cd42b8d3b7af102b24508e25" url: "https://pub.flutter-io.cn" source: hosted - version: "4.0.0" + version: "4.1.0" glob: dependency: transitive description: name: glob - sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + sha256: "218aeb56050c714f62a3182775320dfa04602b55074873e24e31bbd39bda96fb" url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.3" + version: "2.2.0" go_router: dependency: "direct main" description: @@ -569,18 +577,18 @@ packages: dependency: "direct main" description: name: image_picker - sha256: d8402284df184bc05f4a2210c6c23983b0720f4cd87cbd05c5390a78af602667 + sha256: e71b1bd9e40124041128d60fc3034c7b1598e1bba4e570bba0c70301c817013a url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.3" + version: "1.2.4" image_picker_android: dependency: transitive description: name: image_picker_android - sha256: "6f3a1995eafb000333174fae92202622033b0ee7fd917a6cd3730295264df84a" + sha256: "8a7823d5d3e884f7780829d85d92110d072bdcd9ed48e2be158d2abe91a912d4" url: "https://pub.flutter-io.cn" source: hosted - version: "0.8.13+19" + version: "0.8.13+25" image_picker_for_web: dependency: transitive description: @@ -593,10 +601,10 @@ packages: dependency: transitive description: name: image_picker_ios - sha256: b9c4a438a9ff4f60808c9cf0039b93a42bb6c2211ef6ebb647394b2b3fa84588 + sha256: "592e5cfed81d73c2784bcaa04db9d06b19371faf036f2afa7f650452025db180" url: "https://pub.flutter-io.cn" source: hosted - version: "0.8.13+6" + version: "0.8.13+12" image_picker_linux: dependency: transitive description: @@ -617,10 +625,10 @@ packages: dependency: transitive description: name: image_picker_platform_interface - sha256: "567e056716333a1647c64bb6bd873cff7622233a5c3f694be28a583d4715690c" + sha256: "2dee4b4e3be429db71472c9c559c981498070a61af1ba82e0e4986fc5dadc042" url: "https://pub.flutter-io.cn" source: hosted - version: "2.11.1" + version: "2.11.2" image_picker_windows: dependency: transitive description: @@ -641,26 +649,26 @@ packages: dependency: transitive description: name: io - sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + sha256: "2635216ca6a737e60de577ffa1a48a0bec76ca8a62917cfc1bb88c14c570646f" url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.5" + version: "1.1.0" jni: dependency: transitive description: name: jni - sha256: f038e58b4dc2c9037f50e233175086337e0b305e356d28211bf55f21c504cbd3 + sha256: "6b9ca0602fef0230e83149afbe3f9f8227e94f2bbe84a1da4f14d699742f402d" url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.3" + version: "1.1.0" jni_flutter: dependency: transitive description: name: jni_flutter - sha256: "7b717011ea40d04fd47c2731d3d1d36eb99eba3435c2753d62489e8c3c9991d5" + sha256: "0dd33d67797560f66e961a6053882d4df54bd345bf063b8fe7ea133f7ad8b191" url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.2" + version: "1.0.4+1" jni_util: dependency: transitive description: @@ -729,10 +737,10 @@ packages: dependency: transitive description: name: logger - sha256: "25aee487596a6257655a1e091ec2ae66bc30e7af663592cc3a27e6591e05035c" + sha256: "2a0dc097e7b01d942475bdd552356db2d0f768b05540bd4b2b53f1840f2239a7" url: "https://pub.flutter-io.cn" source: hosted - version: "2.7.0" + version: "2.8.0" logging: dependency: transitive description: @@ -769,10 +777,10 @@ packages: dependency: "direct main" description: name: material_ui - sha256: "7ba1ca315d50a004791dbab290417c52a61466d56db2822fe3c5c2994903110c" + sha256: "27ea1af251a79728ee63068417f2ab469d294931a9bb8366ba8b85b0ef839060" url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0" + version: "1.7.0" meta: dependency: transitive description: @@ -785,50 +793,50 @@ packages: dependency: transitive description: name: mime - sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + sha256: bd47de35f07e27267e69c8c8b22edf9473bfee170a60d60fcc93730c5144b7f6 url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.0" + version: "2.1.0" mmkv: dependency: "direct main" description: name: mmkv - sha256: "35ac6a8a82c478ad27da0a80f1a13b4294a43d44190e07cd90cfae5701da8cce" + sha256: "24425555dfba986426a44aaf3fd33db7257b4f6609afc31325f9abe842e767ee" url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.4.3" mmkv_android: dependency: transitive description: name: mmkv_android - sha256: "57a834577adc2dcb9fb7f5b4336dc2320c0cdbe85c54f6a979f29a9b3ca61a27" + sha256: "390f453ba1bd6691eaf921ceaf9c18abde4ca9c99a6f0e9c621277d9d6dd0baa" url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.4.3" mmkv_ios: dependency: transitive description: name: mmkv_ios - sha256: "0d5aa7c3fd181b31a13297ab90dc6daab97324c7fc1c0c2897490c05649da12b" + sha256: "503a330672e7a6e90feedd0615ac1e427ac756aebfc9d0cda3c0af9aaa9cdee3" url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.4.3" mmkv_linux: dependency: transitive description: name: mmkv_linux - sha256: b8dd1e6d36aa96d8bfb88bf68ebe16c420a37f3f6b2dc5223f81c151e4b27bd1 + sha256: "65fd6cad917b55a03f2c44cf3db7cf95e6eae014942e08db1fa36ab4d6fbc39b" url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.4.3" mmkv_ohos: dependency: transitive description: name: mmkv_ohos - sha256: b9b561776ff38e029ead03dda0af716d02b3b6cd698f8de8c599cbe3c9b571cb + sha256: "4d1850a6d579584efc0ee284500087249faba60ef025ec1733c7688242d64818" url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.4.3" mmkv_platform_interface: dependency: transitive description: @@ -841,10 +849,10 @@ packages: dependency: transitive description: name: mmkv_win32 - sha256: "544f708d6e8821eb4ba10c07a23a049d7d6155eb81f89edfedbda1b0f4647447" + sha256: d5db1c2e0198fb85b1ab7062cb48e2030512d6b510aac1fd0d78e195e2d35e46 url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.4.3" mobile_scanner: dependency: "direct main" description: @@ -857,10 +865,10 @@ packages: dependency: transitive description: name: objective_c - sha256: ad56fd53a78ff6b1472fa59ff2a4e8b8ccabafc586fc263a1dfad0b99b5553e3 + sha256: "5c80c2ad6e2c0397de5db38c6d653e69616a3397e13aa7633bf39eb668f2041b" url: "https://pub.flutter-io.cn" source: hosted - version: "9.6.0" + version: "9.6.2" package_config: dependency: transitive description: @@ -945,10 +953,10 @@ packages: dependency: transitive description: name: permission_handler_apple - sha256: f49cb15a064ea9d974fc7fbb302099353b7b170d07284e86e264561579e5bcf8 + sha256: "066bbbc60031b63b916a3871e7bb4b6a8c5e7cec8146dafec53d1da304eff0a5" url: "https://pub.flutter-io.cn" source: hosted - version: "9.6.1" + version: "9.6.2" permission_handler_html: dependency: transitive description: @@ -961,10 +969,10 @@ packages: dependency: transitive description: name: permission_handler_platform_interface - sha256: a5c8a97ecf5616112a5b16d4b8e9ec0e5ae90ef63ac69c0d7b8ae240be760b23 + sha256: ed86a61c190258fdd65de395ea0632822e3415c1faec38eae0c31b479c28a531 url: "https://pub.flutter-io.cn" source: hosted - version: "4.4.0" + version: "4.4.1" permission_handler_windows: dependency: transitive description: @@ -973,14 +981,22 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.2.2" + photo_manager: + dependency: "direct main" + description: + name: photo_manager + sha256: "2d00a785b501bf1e5f6180bbef772846e767be11d45d11112b63092ef54a419e" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.12.0" platform: dependency: transitive description: name: platform - sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + sha256: a36d119c13416516a7b5913fbe8af8531e11633d784c550b2125f76c758524ec url: "https://pub.flutter-io.cn" source: hosted - version: "3.1.6" + version: "3.2.0" plugin_platform_interface: dependency: transitive description: @@ -993,34 +1009,34 @@ packages: dependency: transitive description: name: pool - sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d" + sha256: "4177f68c237ea2128d1bee66ac17b2ce05ba3dbaafcbdd54c5d40a39d0b6b11c" url: "https://pub.flutter-io.cn" source: hosted - version: "1.5.2" + version: "1.5.3" protobuf: dependency: "direct main" description: name: protobuf - sha256: "75ec242d22e950bdcc79ee38dd520ce4ee0bc491d7fadc4ea47694604d22bf06" + sha256: "13b6717366aa7ec3792dd62c19c7d33a785708224365f2db23c5ca01f1c1a0f2" url: "https://pub.flutter-io.cn" source: hosted - version: "6.0.0" + version: "6.1.0" pub_semver: dependency: transitive description: name: pub_semver - sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + sha256: "261236774e8b1d69cfc6b9eabbc96c40f25e7a2d6b171f3385d4f65d5734fb24" url: "https://pub.flutter-io.cn" source: hosted - version: "2.2.0" + version: "2.2.1" pubspec_parse: dependency: transitive description: name: pubspec_parse - sha256: "0560ba233314abbed0a48a2956f7f022cce7c3e1e73df540277da7544cad4082" + sha256: c38b81cbf34450b67e0265d73433569d12e34782e30ed769c9cc99c9d5f2e796 url: "https://pub.flutter-io.cn" source: hosted - version: "1.5.0" + version: "1.6.0" record_use: dependency: transitive description: @@ -1073,26 +1089,26 @@ packages: dependency: "direct main" description: name: shared_preferences - sha256: c3025c5534b01739267eb7d76959bbc25a6d10f6988e1c2a3036940133dd10bf + sha256: "1e85e0dccf5b4a016077fea7dfbb4a7cb39c759ac1596fcf60c06deadb7da91f" url: "https://pub.flutter-io.cn" source: hosted - version: "2.5.5" + version: "2.5.6" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "0634e64bd719f89c012f392938e173521f535d3ecaf66558fa94a056d22b5cc7" + sha256: b90caa27669d5f3ef9918d55343b44000f088ee9d4685ed822310848004c793e url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.27" + version: "2.5.0" shared_preferences_foundation: dependency: transitive description: name: shared_preferences_foundation - sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f" + sha256: c2c02dd59bd7b3bb6bfb77aa7ad4a7886b24ee40e95dcaea754b83274b567ff5 url: "https://pub.flutter-io.cn" source: hosted - version: "2.5.6" + version: "2.6.0" shared_preferences_linux: dependency: transitive description: @@ -1129,10 +1145,10 @@ packages: dependency: transitive description: name: shelf - sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + sha256: e75e9cf311d7fd712048038cc17c25199c38536c20330d53e7db058b543d5a48 url: "https://pub.flutter-io.cn" source: hosted - version: "1.4.2" + version: "1.4.3" shelf_web_socket: dependency: transitive description: @@ -1174,10 +1190,10 @@ packages: dependency: transitive description: name: stack_trace - sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + sha256: "277654b3034d17ac6f9f1cb5595db011b1d5d41e8806866db28e0abaa101c490" url: "https://pub.flutter-io.cn" source: hosted - version: "1.12.1" + version: "1.12.2" state_notifier: dependency: transitive description: @@ -1198,10 +1214,10 @@ packages: dependency: transitive description: name: stream_transform - sha256: ad47125e588cfd37a9a7f86c7d6356dde8dfe89d071d293f80ca9e9273a33871 + sha256: a00e5f18bffc764f923e7dec1038527f7fe7a1791361a7117f0358193f13d53a url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -1214,10 +1230,10 @@ packages: dependency: transitive description: name: synchronized - sha256: "3a7b5d17422dd0f8d5c6c14feaa5a1c65638b9455f871a96f08437562c046931" + sha256: b3d516dbd3757ff2a458735e4f6cbac9ff261f576f6e87bcb17feabb39e657c5 url: "https://pub.flutter-io.cn" source: hosted - version: "3.4.1+2" + version: "3.5.0" term_glyph: dependency: transitive description: @@ -1262,18 +1278,18 @@ packages: dependency: transitive description: name: vector_math - sha256: f36f9f3be64c6198714492bb455c11056e33e2f85d9a0b676a48301e44fdcf47 + sha256: "92b9910f66ed1057fd4da7b040ae7c74cafacf885bdc81be496928d5049b032d" url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.4.3" vm_service: dependency: transitive description: name: vm_service - sha256: "5f37239c4851efcef929cea7824e76df7f2f0970aef85d66bbc430afa40e72f0" + sha256: "89b11d62e1040ee681af3b4f1c97a803ecbf010c6e8b9c5896ee5b08c3bf7b78" url: "https://pub.flutter-io.cn" source: hosted - version: "15.3.0" + version: "15.4.0" watcher: dependency: transitive description: @@ -1342,10 +1358,10 @@ packages: dependency: transitive description: name: yaml - sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + sha256: f67cdd8e07d3c6329146aaef1ba043542b3134c12489f553ca9a7435d1068aea url: "https://pub.flutter-io.cn" source: hosted - version: "3.1.3" + version: "3.1.4" sdks: - dart: ">=3.12.2 <4.0.0" - flutter: ">=3.44.0" + dart: ">=3.13.0 <4.0.0" + flutter: ">=3.47.0" diff --git a/pubspec.yaml b/pubspec.yaml index 7c6c051..2b21fb4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -93,11 +93,18 @@ dependencies: azlistview_plus: ^3.0.0 + # 访问本机相册(读取照片/视频、按文件夹分组、按时间排序), + # 统一处理 Android(6.0~12 READ_EXTERNAL_STORAGE / 13+ READ_MEDIA_IMAGES、READ_MEDIA_VIDEO) + # 与 iOS(PhotoKit,含 limited 授权状态)的相册权限与读取。 + photo_manager: ^3.6.0 + cupertino_ui: any material_ui: any intl: any lpinyin: ^2.0.3 flutter_displaymode: ^0.7.0 + easy_image_viewer: ^1.5.1 + dev_dependencies: flutter_test: sdk: flutter