setting_view_model.dart 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import 'package:cpt_profile/modules/change_mobile/change_mobile_page.dart';
  2. import 'package:cpt_profile/modules/reset_password/reset_password_page.dart';
  3. import 'package:cpt_profile/modules/setting/dialog/account_deactivation_dialog.dart';
  4. import 'package:cpt_profile/modules/setting/setting_state.dart';
  5. import 'package:plugin_basic/constants/app_constant.dart';
  6. import 'package:plugin_basic/provider/user_config/user_config_service.dart';
  7. import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
  8. import 'package:plugin_platform/engine/sp/sp_util.dart';
  9. import 'package:plugin_platform/engine/toast/toast_engine.dart';
  10. import 'package:riverpod_annotation/riverpod_annotation.dart';
  11. import 'package:router/componentRouter/component_service_manager.dart';
  12. import 'package:shared/utils/event_bus.dart';
  13. import 'package:widgets/dialog/app_default_dialog.dart';
  14. part 'setting_view_model.g.dart';
  15. @riverpod
  16. class SettingViewModel extends _$SettingViewModel {
  17. @override
  18. SettingState build() {
  19. return SettingState();
  20. }
  21. void changeEnableNotification(bool value) {
  22. state = state.copyWith(enbaleNofitication: value);
  23. }
  24. //去修改手机号码的页面
  25. void gotoChangeMobilePage() {
  26. ChangeMobilePage.startInstance();
  27. }
  28. void gotoResetPasswordPage() {
  29. ResetPasswordPage.startInstance();
  30. }
  31. // 退出登录
  32. void doLogout() {
  33. DialogEngine.show(
  34. widget: AppDefaultDialog(
  35. message: "Are you sure you want to logout?",
  36. confirmAction: () {
  37. //清除用户登录信息
  38. UserConfigService.getInstance().handleLogoutParams();
  39. // 清除 garagesale category 缓存
  40. SPUtil.remove(AppConstant.storageGarageCategoryList);
  41. //清除全部页面栈去登录页面
  42. ComponentServiceManager().authService.startAndPopAllLoginPage();
  43. },
  44. ));
  45. }
  46. //删除账号的提示弹窗
  47. void doDeleteAccount() {
  48. DialogEngine.show(widget: AccountDeactivationDialog(
  49. confirmAction: () {
  50. //请求接口删除账号
  51. //清除用户登录信息
  52. UserConfigService.getInstance().handleLogoutParams();
  53. //清除全部页面栈去登录页面
  54. ComponentServiceManager().authService.startAndPopAllLoginPage();
  55. },
  56. ));
  57. }
  58. //评价我们,跳转到各平台的应用商城
  59. void rateUs() {
  60. bus.emit(AppConstant.eventProfileRefresh, true);
  61. }
  62. }