96 lines
3.3 KiB
Dart
96 lines
3.3 KiB
Dart
import 'package:cupertino_ui/cupertino_ui.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import '../../../core/widgets/feature_ui.dart';
|
|
import '../../../core/widgets/settings_ui.dart';
|
|
import '../../../l10n/app_localizations.dart';
|
|
import '../data/account_providers.dart';
|
|
|
|
/// 账号与安全页(我的 → 设置 → 账号与安全)。
|
|
///
|
|
/// 汇总入口:登录设备、修改密码、更换手机、微信绑定;
|
|
/// 每个入口对应一个独立子页面。
|
|
class SecurityPage extends ConsumerWidget {
|
|
const SecurityPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final l10n = AppLocalizations.of(context);
|
|
final wechatAsync = ref.watch(wechatBindingProvider);
|
|
final wechatValue = wechatAsync.maybeWhen(
|
|
data: (b) => b.bound ? l10n.wechatBound : l10n.wechatUnbound,
|
|
orElse: () => null,
|
|
);
|
|
|
|
return PopScope(
|
|
canPop: false,
|
|
onPopInvokedWithResult: (didPop, _) {
|
|
if (didPop) return;
|
|
if (context.canPop()) {
|
|
context.pop();
|
|
} else {
|
|
context.go('/profile');
|
|
}
|
|
},
|
|
child: CupertinoPageScaffold(
|
|
navigationBar: CupertinoNavigationBar(
|
|
middle: Text(l10n.securityTitle),
|
|
leading: CupertinoButton(
|
|
padding: EdgeInsets.zero,
|
|
child: const Icon(CupertinoIcons.back),
|
|
onPressed: () => context.pop(),
|
|
),
|
|
),
|
|
child: SafeArea(
|
|
child: ListView(
|
|
padding: const EdgeInsets.only(bottom: 24),
|
|
children: [
|
|
SectionTitle(l10n.securityTitle),
|
|
CardBox(
|
|
padding: EdgeInsets.zero,
|
|
child: Column(
|
|
children: [
|
|
SettingsRow(
|
|
emoji: '💻',
|
|
color: AppColors.blue,
|
|
title: l10n.securityLoginDevices,
|
|
subtitle: l10n.securityLoginDevicesSub,
|
|
onTap: () => context.push('/security/login-devices'),
|
|
),
|
|
const AppDivider(),
|
|
SettingsRow(
|
|
emoji: '🔑',
|
|
color: AppColors.orange,
|
|
title: l10n.securityChangePassword,
|
|
subtitle: l10n.securityChangePasswordSub,
|
|
onTap: () => context.push('/security/password'),
|
|
),
|
|
const AppDivider(),
|
|
SettingsRow(
|
|
emoji: '📱',
|
|
color: AppColors.teal,
|
|
title: l10n.securityChangeMobile,
|
|
subtitle: l10n.securityChangeMobileSub,
|
|
onTap: () => context.push('/security/mobile'),
|
|
),
|
|
const AppDivider(),
|
|
SettingsRow(
|
|
emoji: '💬',
|
|
color: AppColors.green,
|
|
title: l10n.securityWechat,
|
|
subtitle: l10n.securityWechatSub,
|
|
value: wechatValue,
|
|
onTap: () => context.push('/security/wechat'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|