feat(mobile): flutter scaffold with env script and baseline nav
- scripts/flutter-env.sh: toolchain PATH/JAVA_HOME/ANDROID_HOME + pub 镜像 env - apps/mobile: flutter create (com.photolive.photo_live, android+ios) - Android minSdk 24 / targetSdk 36;INTERNET 权限(main manifest,debug+release) - iOS Info.plist:本地网络 ATS 例外 + 相册/相机用途说明(zh+en) - 依赖接入:riverpod / drift(+sqlite3_flutter_libs) / dio / secure_storage / image_picker / camera / qr_flutter / path_provider / path / intl - l10n:l10n.yaml + app_zh/app_en arb(20 键),gen-l10n(zh 模板,非空 getter) - 基线:Material 3 主题、/login→/home 命名路由、底部导航(相册/队列/设置桩)、 locale provider 脚手架(Task 10 完成切换) - flutter analyze 零问题;widget 测试通过;debug apk 构建成功 (MuMu 冒烟因宿主 commit 内存耗尽未完成,Task 2 重试) Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../pages/home_page.dart';
|
||||
import '../pages/login_page.dart';
|
||||
import 'locale_controller.dart';
|
||||
import 'theme.dart';
|
||||
|
||||
/// App 根组件:主题 + l10n 委托 + 基线路由。
|
||||
///
|
||||
/// 基线路由为命名路由(/login → /home);Task 3+ 随页面增长再评估
|
||||
/// 是否迁移 go_router,当前保持零额外依赖。
|
||||
class PhotoLiveApp extends ConsumerWidget {
|
||||
const PhotoLiveApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final locale = ref.watch(localeSettingsProvider);
|
||||
return MaterialApp(
|
||||
onGenerateTitle: (context) => AppLocalizations.of(context).appName,
|
||||
theme: AppTheme.light,
|
||||
darkTheme: AppTheme.dark,
|
||||
locale: locale,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
routes: {
|
||||
'/login': (context) => const LoginPage(),
|
||||
'/home': (context) => const HomePage(),
|
||||
},
|
||||
home: const LoginPage(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
/// App 语言设置(脚手架)。
|
||||
///
|
||||
/// `null` = 跟随系统;Task 10 补齐:持久化(settings 存储)、
|
||||
/// 设置页交互与全部页面的 l10n 覆盖检查。
|
||||
class LocaleSettings extends Notifier<Locale?> {
|
||||
@override
|
||||
Locale? build() => null;
|
||||
|
||||
void setLocale(Locale? locale) => state = locale;
|
||||
}
|
||||
|
||||
final localeSettingsProvider =
|
||||
NotifierProvider<LocaleSettings, Locale?>(LocaleSettings.new);
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// 基础主题(Material 3,种子色)。完整视觉规范随后续任务迭代。
|
||||
abstract final class AppTheme {
|
||||
static const Color seedColor = Color(0xFF1A73E8);
|
||||
|
||||
static ThemeData get light => ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: seedColor),
|
||||
);
|
||||
|
||||
static ThemeData get dark => ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: seedColor,
|
||||
brightness: Brightness.dark,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"@@locale": "en",
|
||||
"appName": "Photo Live",
|
||||
"login": "Sign in",
|
||||
"logout": "Sign out",
|
||||
"username": "Account",
|
||||
"password": "Password",
|
||||
"albums": "Albums",
|
||||
"albumDetail": "Album details",
|
||||
"queue": "Upload queue",
|
||||
"settings": "Settings",
|
||||
"language": "Language",
|
||||
"localeFollowSystem": "Follow system",
|
||||
"localeChinese": "中文",
|
||||
"localeEnglish": "English",
|
||||
"retry": "Retry",
|
||||
"cancel": "Cancel",
|
||||
"errorGeneric": "Something went wrong, please retry",
|
||||
"ok": "OK",
|
||||
"homeTabAlbums": "Albums",
|
||||
"homeTabQueue": "Queue",
|
||||
"homeTabSettings": "Settings",
|
||||
"loginHint": "Sign in with your staff account"
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
|
||||
import 'app_localizations_en.dart';
|
||||
import 'app_localizations_zh.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// Callers can lookup localized strings with an instance of AppLocalizations
|
||||
/// returned by `AppLocalizations.of(context)`.
|
||||
///
|
||||
/// Applications need to include `AppLocalizations.delegate()` in their app's
|
||||
/// `localizationDelegates` list, and the locales they support in the app's
|
||||
/// `supportedLocales` list. For example:
|
||||
///
|
||||
/// ```dart
|
||||
/// import 'l10n/app_localizations.dart';
|
||||
///
|
||||
/// return MaterialApp(
|
||||
/// localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
/// supportedLocales: AppLocalizations.supportedLocales,
|
||||
/// home: MyApplicationHome(),
|
||||
/// );
|
||||
/// ```
|
||||
///
|
||||
/// ## Update pubspec.yaml
|
||||
///
|
||||
/// Please make sure to update your pubspec.yaml to include the following
|
||||
/// packages:
|
||||
///
|
||||
/// ```yaml
|
||||
/// dependencies:
|
||||
/// # Internationalization support.
|
||||
/// flutter_localizations:
|
||||
/// sdk: flutter
|
||||
/// intl: any # Use the pinned version from flutter_localizations
|
||||
///
|
||||
/// # Rest of dependencies
|
||||
/// ```
|
||||
///
|
||||
/// ## iOS Applications
|
||||
///
|
||||
/// iOS applications define key application metadata, including supported
|
||||
/// locales, in an Info.plist file that is built into the application bundle.
|
||||
/// To configure the locales supported by your app, you’ll need to edit this
|
||||
/// file.
|
||||
///
|
||||
/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file.
|
||||
/// Then, in the Project Navigator, open the Info.plist file under the Runner
|
||||
/// project’s Runner folder.
|
||||
///
|
||||
/// Next, select the Information Property List item, select Add Item from the
|
||||
/// Editor menu, then select Localizations from the pop-up menu.
|
||||
///
|
||||
/// Select and expand the newly-created Localizations item then, for each
|
||||
/// locale your application supports, add a new item and select the locale
|
||||
/// you wish to add from the pop-up menu in the Value field. This list should
|
||||
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
|
||||
/// property.
|
||||
abstract class AppLocalizations {
|
||||
AppLocalizations(String locale)
|
||||
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
|
||||
|
||||
final String localeName;
|
||||
|
||||
static AppLocalizations of(BuildContext context) {
|
||||
return Localizations.of<AppLocalizations>(context, AppLocalizations)!;
|
||||
}
|
||||
|
||||
static const LocalizationsDelegate<AppLocalizations> delegate =
|
||||
_AppLocalizationsDelegate();
|
||||
|
||||
/// A list of this localizations delegate along with the default localizations
|
||||
/// delegates.
|
||||
///
|
||||
/// Returns a list of localizations delegates containing this delegate along with
|
||||
/// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
|
||||
/// and GlobalWidgetsLocalizations.delegate.
|
||||
///
|
||||
/// Additional delegates can be added by appending to this list in
|
||||
/// MaterialApp. This list does not have to be used at all if a custom list
|
||||
/// of delegates is preferred or required.
|
||||
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
|
||||
<LocalizationsDelegate<dynamic>>[
|
||||
delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
];
|
||||
|
||||
/// A list of this localizations delegate's supported locales.
|
||||
static const List<Locale> supportedLocales = <Locale>[
|
||||
Locale('en'),
|
||||
Locale('zh'),
|
||||
];
|
||||
|
||||
/// No description provided for @appName.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'现场影像'**
|
||||
String get appName;
|
||||
|
||||
/// No description provided for @login.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'登录'**
|
||||
String get login;
|
||||
|
||||
/// No description provided for @logout.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'退出登录'**
|
||||
String get logout;
|
||||
|
||||
/// No description provided for @username.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'账号'**
|
||||
String get username;
|
||||
|
||||
/// No description provided for @password.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'密码'**
|
||||
String get password;
|
||||
|
||||
/// No description provided for @albums.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'相册'**
|
||||
String get albums;
|
||||
|
||||
/// No description provided for @albumDetail.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'相册详情'**
|
||||
String get albumDetail;
|
||||
|
||||
/// No description provided for @queue.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'上传队列'**
|
||||
String get queue;
|
||||
|
||||
/// No description provided for @settings.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'设置'**
|
||||
String get settings;
|
||||
|
||||
/// No description provided for @language.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'语言'**
|
||||
String get language;
|
||||
|
||||
/// No description provided for @localeFollowSystem.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'跟随系统'**
|
||||
String get localeFollowSystem;
|
||||
|
||||
/// No description provided for @localeChinese.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'中文'**
|
||||
String get localeChinese;
|
||||
|
||||
/// No description provided for @localeEnglish.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'English'**
|
||||
String get localeEnglish;
|
||||
|
||||
/// No description provided for @retry.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'重试'**
|
||||
String get retry;
|
||||
|
||||
/// No description provided for @cancel.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'取消'**
|
||||
String get cancel;
|
||||
|
||||
/// No description provided for @errorGeneric.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'出错了,请重试'**
|
||||
String get errorGeneric;
|
||||
|
||||
/// No description provided for @ok.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'好的'**
|
||||
String get ok;
|
||||
|
||||
/// No description provided for @homeTabAlbums.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'相册'**
|
||||
String get homeTabAlbums;
|
||||
|
||||
/// No description provided for @homeTabQueue.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'队列'**
|
||||
String get homeTabQueue;
|
||||
|
||||
/// No description provided for @homeTabSettings.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'设置'**
|
||||
String get homeTabSettings;
|
||||
|
||||
/// No description provided for @loginHint.
|
||||
///
|
||||
/// In zh, this message translates to:
|
||||
/// **'使用工作人员账号登录'**
|
||||
String get loginHint;
|
||||
}
|
||||
|
||||
class _AppLocalizationsDelegate
|
||||
extends LocalizationsDelegate<AppLocalizations> {
|
||||
const _AppLocalizationsDelegate();
|
||||
|
||||
@override
|
||||
Future<AppLocalizations> load(Locale locale) {
|
||||
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
|
||||
}
|
||||
|
||||
@override
|
||||
bool isSupported(Locale locale) =>
|
||||
<String>['en', 'zh'].contains(locale.languageCode);
|
||||
|
||||
@override
|
||||
bool shouldReload(_AppLocalizationsDelegate old) => false;
|
||||
}
|
||||
|
||||
AppLocalizations lookupAppLocalizations(Locale locale) {
|
||||
// Lookup logic when only language code is specified.
|
||||
switch (locale.languageCode) {
|
||||
case 'en':
|
||||
return AppLocalizationsEn();
|
||||
case 'zh':
|
||||
return AppLocalizationsZh();
|
||||
}
|
||||
|
||||
throw FlutterError(
|
||||
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
|
||||
'an issue with the localizations generation tool. Please file an issue '
|
||||
'on GitHub with a reproducible sample app and the gen-l10n configuration '
|
||||
'that was used.',
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// ignore: unused_import
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
import 'app_localizations.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// The translations for English (`en`).
|
||||
class AppLocalizationsEn extends AppLocalizations {
|
||||
AppLocalizationsEn([String locale = 'en']) : super(locale);
|
||||
|
||||
@override
|
||||
String get appName => 'Photo Live';
|
||||
|
||||
@override
|
||||
String get login => 'Sign in';
|
||||
|
||||
@override
|
||||
String get logout => 'Sign out';
|
||||
|
||||
@override
|
||||
String get username => 'Account';
|
||||
|
||||
@override
|
||||
String get password => 'Password';
|
||||
|
||||
@override
|
||||
String get albums => 'Albums';
|
||||
|
||||
@override
|
||||
String get albumDetail => 'Album details';
|
||||
|
||||
@override
|
||||
String get queue => 'Upload queue';
|
||||
|
||||
@override
|
||||
String get settings => 'Settings';
|
||||
|
||||
@override
|
||||
String get language => 'Language';
|
||||
|
||||
@override
|
||||
String get localeFollowSystem => 'Follow system';
|
||||
|
||||
@override
|
||||
String get localeChinese => '中文';
|
||||
|
||||
@override
|
||||
String get localeEnglish => 'English';
|
||||
|
||||
@override
|
||||
String get retry => 'Retry';
|
||||
|
||||
@override
|
||||
String get cancel => 'Cancel';
|
||||
|
||||
@override
|
||||
String get errorGeneric => 'Something went wrong, please retry';
|
||||
|
||||
@override
|
||||
String get ok => 'OK';
|
||||
|
||||
@override
|
||||
String get homeTabAlbums => 'Albums';
|
||||
|
||||
@override
|
||||
String get homeTabQueue => 'Queue';
|
||||
|
||||
@override
|
||||
String get homeTabSettings => 'Settings';
|
||||
|
||||
@override
|
||||
String get loginHint => 'Sign in with your staff account';
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// ignore: unused_import
|
||||
import 'package:intl/intl.dart' as intl;
|
||||
import 'app_localizations.dart';
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
|
||||
/// The translations for Chinese (`zh`).
|
||||
class AppLocalizationsZh extends AppLocalizations {
|
||||
AppLocalizationsZh([String locale = 'zh']) : super(locale);
|
||||
|
||||
@override
|
||||
String get appName => '现场影像';
|
||||
|
||||
@override
|
||||
String get login => '登录';
|
||||
|
||||
@override
|
||||
String get logout => '退出登录';
|
||||
|
||||
@override
|
||||
String get username => '账号';
|
||||
|
||||
@override
|
||||
String get password => '密码';
|
||||
|
||||
@override
|
||||
String get albums => '相册';
|
||||
|
||||
@override
|
||||
String get albumDetail => '相册详情';
|
||||
|
||||
@override
|
||||
String get queue => '上传队列';
|
||||
|
||||
@override
|
||||
String get settings => '设置';
|
||||
|
||||
@override
|
||||
String get language => '语言';
|
||||
|
||||
@override
|
||||
String get localeFollowSystem => '跟随系统';
|
||||
|
||||
@override
|
||||
String get localeChinese => '中文';
|
||||
|
||||
@override
|
||||
String get localeEnglish => 'English';
|
||||
|
||||
@override
|
||||
String get retry => '重试';
|
||||
|
||||
@override
|
||||
String get cancel => '取消';
|
||||
|
||||
@override
|
||||
String get errorGeneric => '出错了,请重试';
|
||||
|
||||
@override
|
||||
String get ok => '好的';
|
||||
|
||||
@override
|
||||
String get homeTabAlbums => '相册';
|
||||
|
||||
@override
|
||||
String get homeTabQueue => '队列';
|
||||
|
||||
@override
|
||||
String get homeTabSettings => '设置';
|
||||
|
||||
@override
|
||||
String get loginHint => '使用工作人员账号登录';
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"@@locale": "zh",
|
||||
"appName": "现场影像",
|
||||
"login": "登录",
|
||||
"logout": "退出登录",
|
||||
"username": "账号",
|
||||
"password": "密码",
|
||||
"albums": "相册",
|
||||
"albumDetail": "相册详情",
|
||||
"queue": "上传队列",
|
||||
"settings": "设置",
|
||||
"language": "语言",
|
||||
"localeFollowSystem": "跟随系统",
|
||||
"localeChinese": "中文",
|
||||
"localeEnglish": "English",
|
||||
"retry": "重试",
|
||||
"cancel": "取消",
|
||||
"errorGeneric": "出错了,请重试",
|
||||
"ok": "好的",
|
||||
"homeTabAlbums": "相册",
|
||||
"homeTabQueue": "队列",
|
||||
"homeTabSettings": "设置",
|
||||
"loginHint": "使用工作人员账号登录"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'app/app.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const ProviderScope(child: PhotoLiveApp()));
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../l10n/app_localizations.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 4:游标分页、创建/编辑、二维码分享。
|
||||
class AlbumsTab extends StatelessWidget {
|
||||
const AlbumsTab({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(l10n.albums)),
|
||||
body: Center(
|
||||
child: Text(
|
||||
l10n.albums,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 上传队列(桩)。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,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 设置(桩)。Task 10:App 内语言切换(zh / en / 跟随系统)持久化。
|
||||
class SettingsTab extends StatelessWidget {
|
||||
const SettingsTab({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../l10n/app_localizations.dart';
|
||||
|
||||
/// 登录页(桩)。
|
||||
///
|
||||
/// Task 3 实现:真实登录、错误本地化(含 AUTH_RATE_LIMITED / 429 重试等待)、
|
||||
/// 会话持久化与退出登录。
|
||||
class LoginPage extends StatelessWidget {
|
||||
const LoginPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(l10n.appName)),
|
||||
body: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 420),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.username,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
obscureText: true,
|
||||
enableSuggestions: false,
|
||||
autocorrect: false,
|
||||
decoration: InputDecoration(
|
||||
labelText: l10n.password,
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
FilledButton(
|
||||
// 桩:直接进入主壳;Task 3 接真实认证。
|
||||
onPressed: () =>
|
||||
Navigator.of(context).pushReplacementNamed('/home'),
|
||||
child: Text(l10n.login),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
l10n.loginHint,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user