feat(mobile): upload queue ui and continuous capture page

Task 9 (P3 plan): queue tab replaces the stub, continuous capture page
enqueues per shot, album detail gains an upload FAB, and the upload
engine lifecycle is now bound to the login session.

- Engine scope: session account drives UploadEngine start/stop; wired
  from app boot, login success, logout, and 401 eviction. Tasks stay in
  the store across logout (accountId hard isolation).
- Queue tab: album x state x time filter bar, task rows with thumbnail,
  state chip, localized error copy, attempt count, per-row progress via
  a broadcast progress hub, state-dependent actions (re-pick retry,
  retryNow, cancel, delete), batch retry bar, 200ms-debounced live
  refresh from drift table updates.
- Capture page: camera preview via injected CaptureSource, one enqueue
  per shutter press, persistent album/category/badges overlay with a
  switch-only-affects-new-shots hint, gallery multi-pick, exit confirm
  while uploads are pending, permission-denied and init-failure views.
- POST_NOTIFICATIONS runtime permission via a small MethodChannel
  (photolive/permissions) + PermissionPlugin.kt: single runtime
  permission need, avoids permission_handler dependency; requested once
  on first enqueue, silent degradation when denied or unavailable.
- Album detail FAB: capture-and-upload / pick-from-gallery sheet.
- l10n: ~50 new keys in zh/en arbs; tests: +45 (filter matrix, engine
  scope lifecycle, permission gate, queue tab, capture page, FAB entry);
  existing page tests updated to inject session/task-store fakes.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-19 04:47:31 +08:00
parent 42e1c2e34b
commit 955f9b13c1
30 changed files with 4206 additions and 51 deletions
+30
View File
@@ -9,7 +9,11 @@ import 'dart:async';
import 'dart:convert';
import 'package:dio/dio.dart';
import 'package:drift/drift.dart' show driftRuntimeOptions;
import 'package:photo_live/core/api_client.dart';
import 'package:photo_live/core/session_store.dart';
import 'package:photo_live/features/uploads/providers.dart';
import 'package:photo_live/features/uploads/task_store.dart';
/// 内存会话存储(测试替身)。
class FakeSessionStore implements SessionStore {
@@ -25,6 +29,32 @@ class FakeSessionStore implements SessionStore {
Future<void> clear() async => session = null;
}
/// Widget 测试通用 overrides(P3 Task 9 起,登录页/主壳会触达
/// sessionAccountProvider 与任务库 Provider——真实 flutter_secure_storage
/// 与 path_provider 的平台通道在测试环境挂起,凡 pump 到相关页面均需
/// 注入替身)。
///
/// 返回 [FakeSessionStore] + 内存 [TaskStore] + 可选 FakeAdapter ApiClient
/// 的 override 列表。Riverpod 3 已不公开 `Override` 类型(无法作签名注解),
/// 故元素类型为 dynamic——调用点以 spread 展开进 ProviderScope.overrides
/// (元素真实类型即 Override,展开本身类型安全):
/// `ProviderScope(overrides: [...pageTestOverrides(...), 其他], ...)`。
List<dynamic> pageTestOverrides({
FakeSessionStore? session,
TaskStore? taskStore,
ApiClient? client,
}) {
// 每个测试各自 new 一块内存库(独立 QueryExecutor,随容器销毁),
// drift 的“多实例同执行器”告警在此是误报——测试输出降噪。
driftRuntimeOptions.dontWarnAboutMultipleDatabases = true;
final store = taskStore ?? TaskStore.memory();
return <dynamic>[
if (session != null) sessionStoreProvider.overrideWithValue(session),
taskStoreProvider.overrideWithValue(store),
if (client != null) apiClientProvider.overrideWith((ref) => client),
];
}
/// 记录到适配器的请求快照。
class RecordedRequest {
const RecordedRequest({