setting_view_model.dart 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/provider/user_config/user_config_service.dart';
  6. import 'package:plugin_platform/engine/dialog/dialog_engine.dart';
  7. import 'package:plugin_platform/engine/toast/toast_engine.dart';
  8. import 'package:riverpod_annotation/riverpod_annotation.dart';
  9. import 'package:router/componentRouter/component_service_manager.dart';
  10. import 'package:widgets/dialog/app_default_dialog.dart';
  11. part 'setting_view_model.g.dart';
  12. @riverpod
  13. class SettingViewModel extends _$SettingViewModel {
  14. @override
  15. SettingState build() {
  16. return SettingState();
  17. }
  18. void changeEnableNotification(bool value) {
  19. state = state.copyWith(enbaleNofitication: value);
  20. }
  21. //去修改手机号码的页面
  22. void gotoChangeMobilePage() {
  23. ChangeMobilePage.startInstance();
  24. }
  25. void gotoResetPasswordPage() {
  26. ResetPasswordPage.startInstance();
  27. }
  28. // 退出登录
  29. void doLogout() {
  30. DialogEngine.show(
  31. widget: AppDefaultDialog(
  32. message: "Are you sure you want to logout?",
  33. confirmAction: () {
  34. //清除用户登录信息
  35. UserConfigService.getInstance().handleLogoutParams();
  36. //清除全部页面栈去登录页面
  37. ComponentServiceManager().authService.startAndPopAllLoginPage();
  38. },
  39. ));
  40. }
  41. //删除账号的提示弹窗
  42. void doDeleteAccount() {
  43. DialogEngine.show(widget: AccountDeactivationDialog(
  44. confirmAction: () {
  45. //请求接口删除账号
  46. //清除用户登录信息
  47. UserConfigService.getInstance().handleLogoutParams();
  48. //清除全部页面栈去登录页面
  49. ComponentServiceManager().authService.startAndPopAllLoginPage();
  50. },
  51. ));
  52. }
  53. }