profile_page.dart 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_riverpod/flutter_riverpod.dart';
  3. import 'package:asr_client/pages/profile/widgets/profile_hero_card.dart';
  4. import 'package:asr_client/pages/profile/widgets/server_settings_dialog.dart';
  5. import 'package:asr_client/pages/profile/widgets/settings_section.dart';
  6. import 'package:asr_client/pages/profile/widgets/stats_row.dart';
  7. import 'package:asr_client/providers/profile_providers.dart';
  8. import 'package:asr_client/services/mock_data_service.dart';
  9. import 'package:asr_client/theme/app_colors.dart';
  10. class ProfilePage extends ConsumerWidget {
  11. const ProfilePage({super.key});
  12. @override
  13. Widget build(BuildContext context, WidgetRef ref) {
  14. final profile = ref.watch(userProfileProvider);
  15. final settingsSections = MockDataService.settingsSections(
  16. () => _showServerDialog(context),
  17. );
  18. return Scaffold(
  19. backgroundColor: AppColors.bg,
  20. appBar: AppBar(
  21. backgroundColor: AppColors.card,
  22. foregroundColor: AppColors.ink,
  23. elevation: 0,
  24. title: const Text(
  25. '我的',
  26. style: TextStyle(fontSize: 17, fontWeight: FontWeight.w700),
  27. ),
  28. centerTitle: true,
  29. actions: [
  30. IconButton(
  31. icon: const Icon(Icons.settings, color: AppColors.ink2),
  32. onPressed: () => _showServerDialog(context),
  33. ),
  34. ],
  35. ),
  36. body: ListView(
  37. children: [
  38. ProfileHeroCard(profile: profile),
  39. StatsRow(profile: profile),
  40. ...settingsSections.map(
  41. (section) => SettingsSectionWidget(section: section),
  42. ),
  43. const SizedBox(height: 24),
  44. ],
  45. ),
  46. );
  47. }
  48. void _showServerDialog(BuildContext context) {
  49. showDialog(context: context, builder: (_) => const ServerSettingsDialog());
  50. }
  51. }