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
+34 -26
View File
@@ -1,3 +1,12 @@
/// 登录页(UI-01 §4.5 主题统一,P3 计划 Task 3 基础)。
///
/// 账号/密码表单 → [ApiClient.login](会话由客户端自动持久化到
/// SessionStore)→ 成功 pushReplacement /home;失败以内联 StateBadge
/// (图标 + 文案 + 错误色)展示错误码本地化文案(AUTH_RATE_LIMITED 文案
/// 自带「稍后再试」;网络/校验错误各有专属文案)。提交期间按钮进入
/// 加载态防重复提交。
library;
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -6,13 +15,10 @@ import '../core/app_exception.dart';
import '../core/error_l10n.dart';
import '../features/uploads/engine_scope.dart';
import '../l10n/app_localizations.dart';
import '../ui/components/state_badge.dart';
import '../ui/tokens.dart';
/// 登录页(P3 计划 Task 3)。
///
/// 账号/密码表单 → [ApiClient.login](会话由客户端自动持久化到
/// SessionStore)→ 成功 pushReplacement /home;失败按错误码本地化提示
/// (AUTH_RATE_LIMITED 文案自带「稍后再试」;网络/校验错误各有专属文案)。
/// 提交期间按钮进入加载态防重复提交。
/// 登录页。
class LoginPage extends ConsumerStatefulWidget {
const LoginPage({super.key});
@@ -27,6 +33,9 @@ class _LoginPageState extends ConsumerState<LoginPage> {
bool _submitting = false;
/// 最近一次提交失败文案(内联 StateBadge 展示;null = 无错误)。
String? _errorText;
@override
void dispose() {
_accountController.dispose();
@@ -36,9 +45,11 @@ class _LoginPageState extends ConsumerState<LoginPage> {
Future<void> _submit() async {
if (!_formKey.currentState!.validate()) return;
setState(() => _submitting = true);
setState(() {
_submitting = true;
_errorText = null;
});
final l10n = AppLocalizations.of(context);
final messenger = ScaffoldMessenger.of(context);
final navigator = Navigator.of(context);
try {
await ref.read(apiClientProvider).login(
@@ -51,13 +62,9 @@ class _LoginPageState extends ConsumerState<LoginPage> {
} on AppException catch (error) {
// 429(AUTH_RATE_LIMITED)等文案经错误码映射;登录页的
// AUTH_INVALID_CREDENTIALS 即「账号或密码错误」。
messenger.showSnackBar(
SnackBar(content: Text(l10n.messageForError(error))),
);
if (mounted) setState(() => _errorText = l10n.messageForError(error));
} on Object {
messenger.showSnackBar(
SnackBar(content: Text(l10n.errorGeneric)),
);
if (mounted) setState(() => _errorText = l10n.errorGeneric);
} finally {
if (mounted) setState(() => _submitting = false);
}
@@ -72,7 +79,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 420),
child: Padding(
padding: const EdgeInsets.all(24),
padding: const EdgeInsets.all(kSpace24),
child: Form(
key: _formKey,
autovalidateMode: AutovalidateMode.onUserInteraction,
@@ -83,16 +90,13 @@ class _LoginPageState extends ConsumerState<LoginPage> {
TextFormField(
controller: _accountController,
autofillHints: const [AutofillHints.username],
decoration: InputDecoration(
labelText: l10n.username,
border: const OutlineInputBorder(),
),
decoration: InputDecoration(labelText: l10n.username),
validator: (value) =>
(value == null || value.trim().isEmpty)
? l10n.fieldRequired
: null,
),
const SizedBox(height: 16),
const SizedBox(height: kSpace16),
TextFormField(
controller: _passwordController,
obscureText: true,
@@ -100,15 +104,19 @@ class _LoginPageState extends ConsumerState<LoginPage> {
autocorrect: false,
autofillHints: const [AutofillHints.password],
onFieldSubmitted: (_) => _submitting ? null : _submit(),
decoration: InputDecoration(
labelText: l10n.password,
border: const OutlineInputBorder(),
),
decoration: InputDecoration(labelText: l10n.password),
validator: (value) => (value == null || value.isEmpty)
? l10n.fieldRequired
: null,
),
const SizedBox(height: 24),
if (_errorText != null) ...[
const SizedBox(height: kSpace16),
StateBadge(
variant: BadgeVariant.error,
label: _errorText!,
),
],
const SizedBox(height: kSpace24),
FilledButton(
onPressed: _submitting ? null : _submit,
child: _submitting
@@ -119,7 +127,7 @@ class _LoginPageState extends ConsumerState<LoginPage> {
)
: Text(l10n.login),
),
const SizedBox(height: 12),
const SizedBox(height: kSpace12),
Text(
l10n.loginHint,
textAlign: TextAlign.center,