profile.dart 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import 'package:chicken_farm/core/config/app_config.dart';
  2. import 'package:chicken_farm/stores/auth_store.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_riverpod/flutter_riverpod.dart';
  5. import 'package:chicken_farm/pages/home/_profile/user_info_card.dart';
  6. import 'package:chicken_farm/pages/home/_profile/upload_data_button.dart';
  7. import 'package:chicken_farm/pages/home/_profile/clear_cache_button.dart';
  8. import 'package:chicken_farm/pages/home/_profile/config_button.dart';
  9. // import 'package:chicken_farm/pages/home/_profile/rfid_config_button.dart';
  10. // import 'package:chicken_farm/pages/home/_profile/scanner_light_button.dart';
  11. import 'package:chicken_farm/pages/home/_profile/logout_button.dart';
  12. class ProfilePage extends ConsumerWidget {
  13. const ProfilePage({super.key});
  14. @override
  15. Widget build(BuildContext context, WidgetRef ref) {
  16. final authState = ref.watch(authStoreProvider);
  17. return Scaffold(
  18. body: Padding(
  19. padding: const EdgeInsets.all(16.0),
  20. child: Column(
  21. crossAxisAlignment: CrossAxisAlignment.start,
  22. children: [
  23. const SizedBox(height: 20),
  24. if (authState.state == AuthState.authenticated &&
  25. authState.user != null) ...[
  26. Expanded(
  27. child: SingleChildScrollView(
  28. child: Column(
  29. crossAxisAlignment: CrossAxisAlignment.start,
  30. children: [
  31. UserInfoCard(user: authState.user!),
  32. const SizedBox(height: 20),
  33. if (AppConfig.isOffline) ...[
  34. const ClearCacheButton(),
  35. const SizedBox(height: 20),
  36. ] else ...[
  37. const UploadDataButton(),
  38. const SizedBox(height: 20),
  39. const ClearCacheButton(),
  40. const SizedBox(height: 20),
  41. const ConfigButton(),
  42. const SizedBox(height: 20),
  43. // const RfidConfigButton(),
  44. // const SizedBox(height: 20),
  45. // const ScannerLightButton(),
  46. // const SizedBox(height: 20),
  47. const LogoutButton(),
  48. const SizedBox(height: 20),
  49. ],
  50. ],
  51. ),
  52. ),
  53. ),
  54. ] else ...[
  55. const Center(child: Text('加载中...')),
  56. ],
  57. ],
  58. ),
  59. ),
  60. );
  61. }
  62. }