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:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../core/api_client.dart';
|
||||
import '../features/uploads/engine_scope.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../pages/home_page.dart';
|
||||
import '../pages/login_page.dart';
|
||||
@@ -14,12 +15,15 @@ import 'theme.dart';
|
||||
final GlobalKey<NavigatorState> rootNavigatorKey =
|
||||
GlobalKey<NavigatorState>();
|
||||
|
||||
/// App 根组件:主题 + l10n 委托 + 命名路由 + 401 驱逐接线。
|
||||
/// App 根组件:主题 + l10n 委托 + 命名路由 + 401 驱逐接线 + 引擎生命周期。
|
||||
///
|
||||
/// 基线路由为命名路由(/login → /home → /password-change);随页面增长再
|
||||
/// 评估是否迁移 go_router,当前保持零额外依赖。
|
||||
/// initState 注册 [ApiClient.onUnauthorized]:任意业务端点 401(会话过期)
|
||||
/// 即清空栈回到 /login(登录/修改密码端点自身的 401 不触发,见 ApiClient)。
|
||||
/// 即清空栈回到 /login(登录/修改密码端点自身的 401 不触发,见 ApiClient),
|
||||
/// 并同步刷新会话账号(引擎 stop,任务保留库内)。
|
||||
/// build watch [uploadEngineScopeProvider]——App 存续期间引擎随登录态
|
||||
/// start/stop(Task 9 接线,见 engine_scope.dart)。
|
||||
class PhotoLiveApp extends ConsumerStatefulWidget {
|
||||
const PhotoLiveApp({super.key});
|
||||
|
||||
@@ -34,12 +38,16 @@ class _PhotoLiveAppState extends ConsumerState<PhotoLiveApp> {
|
||||
ref.read(apiClientProvider).onUnauthorized = () {
|
||||
rootNavigatorKey.currentState
|
||||
?.pushNamedAndRemoveUntil('/login', (route) => false);
|
||||
// 401 已清会话(ApiClient):刷新账号观察 → 引擎 stop。
|
||||
ref.read(sessionAccountProvider.notifier).refresh();
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final locale = ref.watch(localeSettingsProvider);
|
||||
// 引擎生命周期绑定(常驻 watch;账号在场 start / 离场 stop)。
|
||||
ref.watch(uploadEngineScopeProvider);
|
||||
return MaterialApp(
|
||||
navigatorKey: rootNavigatorKey,
|
||||
onGenerateTitle: (context) => AppLocalizations.of(context).appName,
|
||||
|
||||
Reference in New Issue
Block a user