feat: 设置页面增强,支持用户信息展示和密码修改
This commit is contained in:
@@ -1,11 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../../core/di/injection.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../shared/widgets/page_header.dart' as widgets;
|
||||
import '../../../users/data/models/user_response.dart';
|
||||
import '../../../users/data/users_api.dart';
|
||||
|
||||
class SettingsScreen extends StatelessWidget {
|
||||
class SettingsScreen extends StatefulWidget {
|
||||
const SettingsScreen({super.key});
|
||||
|
||||
@override
|
||||
State<SettingsScreen> createState() => _SettingsScreenState();
|
||||
}
|
||||
|
||||
class _SettingsScreenState extends State<SettingsScreen> {
|
||||
UserResponse? _user;
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadUser();
|
||||
}
|
||||
|
||||
Future<void> _loadUser() async {
|
||||
try {
|
||||
final usersApi = sl<UsersApi>();
|
||||
final user = await usersApi.getMe();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_user = user;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -38,6 +74,22 @@ class SettingsScreen extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildProfileHero() {
|
||||
if (_isLoading) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: 100,
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.white,
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
),
|
||||
child: const Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
final username = _user?.username ?? '未设置';
|
||||
final email = _user?.email ?? '未设置';
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(20),
|
||||
@@ -83,9 +135,9 @@ class SettingsScreen extends StatelessWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text(
|
||||
'Qiuzhiliang',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
username,
|
||||
style: const TextStyle(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.slate900,
|
||||
@@ -113,9 +165,9 @@ class SettingsScreen extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
const Text(
|
||||
'qiuzhiliang@xunmee.com',
|
||||
style: TextStyle(
|
||||
Text(
|
||||
email,
|
||||
style: const TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.slate500,
|
||||
@@ -252,7 +304,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'已用积分 320 / 1000',
|
||||
'∞ / ∞',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -262,10 +314,10 @@ class SettingsScreen extends StatelessWidget {
|
||||
const SizedBox(height: 8),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(999),
|
||||
child: const LinearProgressIndicator(
|
||||
value: 0.32,
|
||||
backgroundColor: Color(0xFFE8EEF8),
|
||||
valueColor: AlwaysStoppedAnimation(AppColors.blue400),
|
||||
child: LinearProgressIndicator(
|
||||
value: 0,
|
||||
backgroundColor: const Color(0xFFE8EEF8),
|
||||
valueColor: const AlwaysStoppedAnimation(AppColors.blue400),
|
||||
minHeight: 8,
|
||||
),
|
||||
),
|
||||
@@ -273,24 +325,21 @@ class SettingsScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
width: 72,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surfaceInfo,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: AppColors.borderQuaternary),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'升级',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: AppColors.blue600,
|
||||
),
|
||||
Container(
|
||||
width: 72,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFE2E8F0),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(color: const Color(0xFFCBD5E1)),
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'升级',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF94A3B8),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -309,16 +358,9 @@ class SettingsScreen extends StatelessWidget {
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildMenuItem(
|
||||
icon: Icons.calendar_today,
|
||||
title: '日历',
|
||||
trailing: 'Toki',
|
||||
onTap: () {},
|
||||
),
|
||||
_buildDivider(),
|
||||
_buildMenuItem(
|
||||
icon: Icons.notifications,
|
||||
title: '日程通知',
|
||||
title: '提醒设置',
|
||||
onTap: () {},
|
||||
),
|
||||
_buildDivider(),
|
||||
|
||||
Reference in New Issue
Block a user