me_view_model.dart 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'package:domain/repository/profile_repository.dart';
  2. import 'package:plugin_basic/provider/user_config/user_config_service.dart';
  3. import 'package:riverpod_annotation/riverpod_annotation.dart';
  4. import 'package:router/componentRouter/component_service_manager.dart';
  5. import 'package:shared/utils/log_utils.dart';
  6. import 'package:widgets/widget_export.dart';
  7. part 'me_view_model.g.dart';
  8. @riverpod
  9. class MeViewModel extends _$MeViewModel {
  10. late final ProfileRepository _profileRepository;
  11. @override
  12. void build() {
  13. _profileRepository = ref.read(profileRepositoryProvider);
  14. }
  15. // Refresh 控制器
  16. final EasyRefreshController refreshController = EasyRefreshController(
  17. controlFinishRefresh: true, //允许刷新
  18. controlFinishLoad: false, //允许加载
  19. );
  20. // Refresh 刷新事件
  21. Future onRefresh() async {
  22. final result = await _profileRepository.fetchUserInfo();
  23. if (result.isSuccess) {
  24. UserConfigService.getInstance().setUserInfo(result.data);
  25. } else {
  26. Log.e(result.errorMsg ?? "UnKnow Error");
  27. }
  28. refreshController.finishRefresh();
  29. }
  30. //去我的房产页面
  31. void gotoMyEstatePage() {
  32. ComponentServiceManager().profileService.startMyEstatePage();
  33. }
  34. //去我的家庭成员页面
  35. void gotoMyHouseholdPage() {
  36. ComponentServiceManager().profileService.startMyHouseHoldPage();
  37. }
  38. //去我的发布页面
  39. void gotoMyPostPage() {
  40. // ToastEngine.show("去我的发布页面");
  41. ComponentServiceManager().communityService.startMyPostsPage();
  42. }
  43. //去设置页面
  44. void gotoSettingPage() {
  45. ComponentServiceManager().profileService.startSettingPage();
  46. }
  47. //我的关注Tab
  48. void gotoFollowingPage() {
  49. // ToastEngine.show("我的关注Tab");
  50. ComponentServiceManager().communityService.startMyFollowPage();
  51. }
  52. //我的粉丝Tab
  53. void gotoFollowerPage() {
  54. // ToastEngine.show("我的粉丝Tab");
  55. ComponentServiceManager().communityService.startMyFollowerPage();
  56. }
  57. //编辑附加信息
  58. void gotoEditProfilePage() {
  59. ComponentServiceManager().profileService.startEditProfilePage();
  60. }
  61. }