bbea1dd364
Co-Authored-By: Claude Code <noreply@anthropic.com>
114 lines
3.3 KiB
Dart
114 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../core/api_client.dart';
|
|
import '../l10n/app_localizations.dart';
|
|
import 'albums_tab.dart';
|
|
|
|
/// 主壳:底部导航(相册 / 队列 / 设置)。
|
|
class HomePage extends StatefulWidget {
|
|
const HomePage({super.key});
|
|
|
|
@override
|
|
State<HomePage> createState() => _HomePageState();
|
|
}
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
int _selectedIndex = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context);
|
|
return Scaffold(
|
|
body: IndexedStack(
|
|
index: _selectedIndex,
|
|
children: const [
|
|
AlbumsTab(),
|
|
QueueTab(),
|
|
SettingsTab(),
|
|
],
|
|
),
|
|
bottomNavigationBar: NavigationBar(
|
|
selectedIndex: _selectedIndex,
|
|
onDestinationSelected: (index) =>
|
|
setState(() => _selectedIndex = index),
|
|
destinations: [
|
|
NavigationDestination(
|
|
icon: const Icon(Icons.photo_library_outlined),
|
|
selectedIcon: const Icon(Icons.photo_library),
|
|
label: l10n.homeTabAlbums,
|
|
),
|
|
NavigationDestination(
|
|
icon: const Icon(Icons.cloud_upload_outlined),
|
|
selectedIcon: const Icon(Icons.cloud_upload),
|
|
label: l10n.homeTabQueue,
|
|
),
|
|
NavigationDestination(
|
|
icon: const Icon(Icons.settings_outlined),
|
|
selectedIcon: const Icon(Icons.settings),
|
|
label: l10n.homeTabSettings,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 上传队列(桩)。Task 6/9:状态机展示、筛选与重试。
|
|
class QueueTab extends StatelessWidget {
|
|
const QueueTab({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context);
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text(l10n.queue)),
|
|
body: Center(
|
|
child: Text(
|
|
l10n.queue,
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// 设置页(P3 Task 3:修改密码入口 + 退出登录;Task 10 补语言切换持久化)。
|
|
class SettingsTab extends ConsumerWidget {
|
|
const SettingsTab({super.key});
|
|
|
|
Future<void> _logout(BuildContext context, WidgetRef ref) async {
|
|
// api.logout 尽力而为(服务端撤销失败也照常本地清会话——客户端内已处理)。
|
|
await ref.read(apiClientProvider).logout();
|
|
if (!context.mounted) return;
|
|
Navigator.of(context).pushNamedAndRemoveUntil('/login', (route) => false);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final l10n = AppLocalizations.of(context);
|
|
return Scaffold(
|
|
appBar: AppBar(title: Text(l10n.settings)),
|
|
body: ListView(
|
|
children: [
|
|
ListTile(
|
|
leading: const Icon(Icons.language),
|
|
title: Text(l10n.language),
|
|
subtitle: Text(l10n.localeFollowSystem),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.password_outlined),
|
|
title: Text(l10n.passwordChangeTitle),
|
|
onTap: () => Navigator.of(context).pushNamed('/password-change'),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.logout),
|
|
title: Text(l10n.logout),
|
|
onTap: () => _logout(context, ref),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|