feat(mobile): UI-01 upload center, capture and auxiliary pages

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-21 17:20:43 +08:00
parent f6929ae18f
commit 1f67b7c818
26 changed files with 2144 additions and 771 deletions
+65 -95
View File
@@ -1,9 +1,10 @@
/// 服务端上传历史页(P3 计划 Task 6,A19 语义)。
/// 服务端上传历史页(UI-01 §4.4 主题统一,P3 计划 Task 6 / A19 语义)。
///
/// GET /uploads(operationId listUploads)游标分页展示**当前账号跨设备**
/// 的上传会话记录:会话状态 / photo.processingState / sourceDeviceId /
/// 创建时间。顶部横幅明确标注「本机待传队列不在此列」——本机队列是
/// drift 任务库(TaskStore),两者数据源与生命周期不同(A19 标注要求)。
/// 创建时间。页面标题即「服务端历史(跨设备)」,顶部说明条明确「本机
/// 待传队列在上传页」——本机队列是 drift 任务库(TaskStore),两者数据源
/// 与生命周期不同,不合并统计(A19 标注要求)。
///
/// 记录不含 filename(契约 UploadSessionRecord 无该字段),行首展示
/// clientTaskId 前 8 位作识别;sourceDeviceId 与本机 [DeviceId] 一致时
@@ -23,6 +24,10 @@ import '../core/error_l10n.dart';
import '../features/photos/models.dart';
import '../features/uploads/models.dart';
import '../l10n/app_localizations.dart';
import '../ui/components/empty_state.dart';
import '../ui/components/error_state.dart';
import '../ui/components/state_badge.dart';
import '../ui/tokens.dart';
/// 服务端上传历史(从队列页占位入口进入)。
class ServerHistoryPage extends ConsumerStatefulWidget {
@@ -139,11 +144,11 @@ class _ServerHistoryPageState extends ConsumerState<ServerHistoryPage> {
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// A19 标注横幅:与「队列」页(本机任务库)的数据源区分。
// A19 标注说明条:与「上传」页(本机任务库)的数据源区分。
Card(
margin: const EdgeInsets.fromLTRB(12, 12, 12, 0),
margin: const EdgeInsets.fromLTRB(kSpace16, kSpace12, kSpace16, 0),
child: Padding(
padding: const EdgeInsets.all(12),
padding: const EdgeInsets.all(kSpace12),
child: Row(
children: [
Icon(
@@ -151,7 +156,7 @@ class _ServerHistoryPageState extends ConsumerState<ServerHistoryPage> {
size: 18,
color: theme.colorScheme.onSurfaceVariant,
),
const SizedBox(width: 8),
const SizedBox(width: kSpace8),
Expanded(
child: Text(
l10n.serverHistoryBanner,
@@ -167,61 +172,44 @@ class _ServerHistoryPageState extends ConsumerState<ServerHistoryPage> {
Expanded(
child: _loading
? const Center(child: CircularProgressIndicator())
: _items.isEmpty && _errorCode != null
? Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.cloud_off, size: 48),
const SizedBox(height: 12),
Text(l10n.messageForErrorCode(_errorCode!)),
const SizedBox(height: 12),
FilledButton.icon(
onPressed: _reload,
icon: const Icon(Icons.refresh),
label: Text(l10n.retry),
),
],
),
: _errorCode != null
? ErrorState(
message: l10n.messageForErrorCode(_errorCode!),
onRetry: _reload,
)
: ListView.builder(
itemCount: _items.length +
(_items.isEmpty || _hasMore || _loadingMore ? 1 : 0),
itemBuilder: (context, index) {
if (_items.isEmpty) {
return Padding(
padding: const EdgeInsets.all(32),
child: Text(
l10n.serverHistoryEmpty,
textAlign: TextAlign.center,
style: theme.textTheme.bodySmall,
),
);
}
if (index >= _items.length) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Center(
child: SizedBox(
height: 24,
width: 24,
child: CircularProgressIndicator(
strokeWidth: 2,
: _items.isEmpty
? EmptyState(
icon: Icons.cloud_done_outlined,
title: l10n.serverHistoryEmpty,
)
: ListView.builder(
itemCount: _items.length +
(_hasMore || _loadingMore ? 1 : 0),
itemBuilder: (context, index) {
if (index >= _items.length) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
child: Center(
child: SizedBox(
height: 24,
width: 24,
child: CircularProgressIndicator(
strokeWidth: 2,
),
),
),
),
),
);
}
if (index >= _items.length - 3 &&
_hasMore &&
!_loadingMore) {
WidgetsBinding.instance.addPostFrameCallback(
(_) => _loadMore(),
);
}
return _sessionTile(l10n, theme, _items[index]);
},
),
);
}
if (index >= _items.length - 3 &&
_hasMore &&
!_loadingMore) {
WidgetsBinding.instance.addPostFrameCallback(
(_) => _loadMore(),
);
}
return _sessionTile(l10n, theme, _items[index]);
},
),
),
],
),
@@ -260,14 +248,26 @@ class _ServerHistoryPageState extends ConsumerState<ServerHistoryPage> {
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
_HistoryTag(
StateBadge(
compact: true,
variant: switch (record.state) {
UploadSessionState.confirmed => BadgeVariant.success,
UploadSessionState.pending => BadgeVariant.info,
UploadSessionState.cancelled ||
UploadSessionState.expired => BadgeVariant.neutral,
},
label: _sessionStateLabel(l10n, record.state),
highlight: record.state == UploadSessionState.confirmed,
),
_HistoryTag(
StateBadge(
compact: true,
variant: switch (record.photo.processingState) {
PhotoProcessingState.ready => BadgeVariant.success,
PhotoProcessingState.processing ||
PhotoProcessingState.uploaded => BadgeVariant.info,
PhotoProcessingState.pendingUpload => BadgeVariant.warning,
PhotoProcessingState.processingFailed => BadgeVariant.error,
},
label: _processingLabel(l10n, record.photo.processingState),
highlight: record.photo.processingState ==
PhotoProcessingState.ready,
),
],
),
@@ -308,33 +308,3 @@ class _ServerHistoryPageState extends ConsumerState<ServerHistoryPage> {
}
}
}
/// 会话记录标签(会话状态/处理状态)。
class _HistoryTag extends StatelessWidget {
const _HistoryTag({required this.label, required this.highlight});
final String label;
final bool highlight;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: highlight
? theme.colorScheme.secondaryContainer
: theme.colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(999),
),
child: Text(
label,
style: theme.textTheme.labelSmall?.copyWith(
color: highlight
? theme.colorScheme.onSecondaryContainer
: theme.colorScheme.onSurfaceVariant,
),
),
);
}
}