66 lines
1.9 KiB
Dart
66 lines
1.9 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../core/data/services/auth_controller.dart';
|
|
import '../../core/theme/app_dimens.dart';
|
|
import '../../core/theme/app_theme.dart';
|
|
import '../../core/widgets/auth_gate.dart';
|
|
import '../../core/widgets/plain_page_scaffold.dart';
|
|
import '../../l10n/app_localizations.dart';
|
|
import '../account/account_entry_card.dart';
|
|
import 'legal_links_card.dart';
|
|
|
|
/// 设置页:账号入口按列表展示,不提供通知和手动语言切换。
|
|
class SettingsPage extends StatelessWidget {
|
|
const SettingsPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final l10n = AppLocalizations.of(context)!;
|
|
final auth = context.watch<AuthController>();
|
|
return Theme(
|
|
data: AppTheme.dark(),
|
|
child: PlainPageScaffold(
|
|
pageKey: const Key('settings-page'),
|
|
backKey: const Key('settings-back'),
|
|
title: l10n.settings,
|
|
child: ListView(
|
|
padding: const EdgeInsets.fromLTRB(14, 8, 14, 28),
|
|
children: [
|
|
if (auth.isSignedIn) ...[
|
|
const AccountEntryCard(),
|
|
const SizedBox(height: AppDimens.spaceXl),
|
|
],
|
|
const LegalLinksCard(),
|
|
const SizedBox(height: AppDimens.spaceXl),
|
|
_authAction(context, l10n, auth),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _authAction(
|
|
BuildContext context,
|
|
AppLocalizations l10n,
|
|
AuthController auth,
|
|
) {
|
|
if (auth.isSignedIn) {
|
|
return OutlinedButton(
|
|
key: const Key('settings-sign-out'),
|
|
onPressed: () => unawaited(auth.signOut()),
|
|
child: Text(l10n.signOut),
|
|
);
|
|
}
|
|
return FilledButton(
|
|
key: const Key('settings-sign-in'),
|
|
onPressed: () => unawaited(openAuthPage(context)),
|
|
child: Text(l10n.signIn),
|
|
);
|
|
}
|
|
}
|