fix:登录退出页

This commit is contained in:
jingyun
2026-06-07 11:38:08 +08:00
parent 6a7fa5a067
commit 6c943f8394
8 changed files with 356 additions and 38 deletions
+28 -30
View File
@@ -55,7 +55,7 @@ class ProfilePage extends ConsumerWidget {
children: [
const PageHeader(title: '我的'),
if (auth.loggedIn) ...[
const _LoggedInHeader(),
_LoggedInHeader(auth: auth),
const SizedBox(height: YantingSpacing.x3),
_StatsCard(
favoriteCount: favoriteCount,
@@ -103,12 +103,7 @@ class ProfilePage extends ConsumerWidget {
AppButton(
label: '登录 / 注册',
expand: true,
onPressed: () => showLoginSheet(
context,
reason: '登录后同步收藏、历史和听单',
onPhoneLogin: () => _login(ref, LoginMethod.phone),
onSecondaryLogin: () => _login(ref, LoginMethod.wechat),
),
onPressed: () => context.push(AppRoutes.login),
),
],
const SizedBox(height: 18),
@@ -177,18 +172,6 @@ class ProfilePage extends ConsumerWidget {
title: '退出登录',
onTap: () => ref.read(authControllerProvider.notifier).logout(),
),
_MenuRow(
icon: AppIcons.fileList,
title: '用户协议',
onTap: () =>
_showOutbound(context, ref, 'user_agreement', '用户协议'),
),
_MenuRow(
icon: AppIcons.shield,
title: '隐私政策',
onTap: () =>
_showOutbound(context, ref, 'privacy_policy', '隐私政策'),
),
],
),
const SizedBox(height: YantingSpacing.x3),
@@ -337,24 +320,34 @@ class ProfilePage extends ConsumerWidget {
}
class _LoggedInHeader extends StatelessWidget {
const _LoggedInHeader();
const _LoggedInHeader({required this.auth});
final AuthState auth;
@override
Widget build(BuildContext context) {
final colors = ShadTheme.of(context).colorScheme;
final phone = auth.phone;
final methodLabel = switch (auth.loginMethod) {
LoginMethod.phone => '手机号',
LoginMethod.wechat => '微信',
LoginMethod.apple => 'Apple',
_ => '本地登录',
};
return AppCard(
color: const Color(0xFF133D00),
borderColor: const Color(0xFF133D00),
color: colors.brandSoft,
borderColor: colors.brandSoftBorder,
padding: const EdgeInsets.symmetric(horizontal: 28, vertical: 30),
child: Row(
children: [
CircleAvatar(
radius: 34,
backgroundColor: const Color(0xFF385E26),
foregroundColor: YantingColors.primary,
backgroundColor: colors.background,
foregroundColor: colors.primary,
child: Text(
'',
phone == null || phone.isEmpty ? '' : phone.characters.first,
style: YantingText.sectionTitle.copyWith(
color: YantingColors.primary,
color: colors.primary,
fontSize: 27,
),
),
@@ -365,17 +358,17 @@ class _LoggedInHeader extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'研界用户',
phone == null || phone.isEmpty ? '研界用户' : '手机号用户',
style: YantingText.sectionTitle.copyWith(
color: Colors.white,
color: colors.foreground,
fontSize: 22,
),
),
const SizedBox(height: 4),
Text(
'已登录 · 手机号',
'已登录 · $methodLabel${phone == null || phone.isEmpty ? '' : ' · ${_maskPhone(phone)}'}',
style: YantingText.body.copyWith(
color: Colors.white.withValues(alpha: 0.75),
color: colors.mutedForeground,
fontSize: 15,
),
),
@@ -388,6 +381,11 @@ class _LoggedInHeader extends StatelessWidget {
}
}
String _maskPhone(String phone) {
if (phone.length < 7) return phone;
return '${phone.substring(0, 3)}****${phone.substring(phone.length - 4)}';
}
class _StatsCard extends StatelessWidget {
const _StatsCard({
required this.favoriteCount,