RQSettingViewController.m 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // RQSettingViewController.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/5/5.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQSettingViewController.h"
  9. @interface RQSettingViewController ()
  10. /// viewModel
  11. @property (nonatomic, readonly, strong) RQSettingViewModel *viewModel;
  12. @end
  13. @implementation RQSettingViewController
  14. @dynamic viewModel;
  15. #pragma mark - SystemMethod
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view.
  19. }
  20. #pragma mark - OverrideMethods
  21. - (void)bindViewModel{
  22. [super bindViewModel];
  23. @weakify(self);
  24. /// show HUD
  25. [[self.viewModel.logoutCommand.executing
  26. skip:1]
  27. subscribeNext:^(NSNumber * showHud) {
  28. if (showHud.boolValue) {
  29. [MBProgressHUD rq_showProgressHUD:@"正在退出..."];
  30. }else{
  31. [MBProgressHUD rq_hideHUD];
  32. }
  33. }];
  34. /// 点击退出登录回调
  35. [self.viewModel.logoutSubject subscribeNext:^(id input) {
  36. // @strongify(self);
  37. // @weakify(self);
  38. LCActionSheet *sheet = [LCActionSheet sheetWithTitle:@"退出后不会删除任何历史数据,下次登录依然可以使用本账号" cancelButtonTitle:@"取消" clicked:^(LCActionSheet * _Nonnull actionSheet, NSInteger buttonIndex) {
  39. if (buttonIndex == 0) return ;
  40. /// 退出账号
  41. @strongify(self)
  42. [self.viewModel.logoutCommand execute:nil];
  43. } otherButtonTitles:@"退出登录", nil];
  44. NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] init];
  45. [indexSet addIndex:1];
  46. sheet.destructiveButtonIndexSet = indexSet;
  47. [sheet show];
  48. }];
  49. }
  50. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  51. switch (indexPath.section) {
  52. case 1 : {
  53. RQProfileLogoutCell *cell = [RQProfileLogoutCell cellWithTableView:tableView];
  54. return cell;
  55. }
  56. default:
  57. return [super tableView:tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
  58. }
  59. }
  60. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  61. switch (indexPath.section) {
  62. case 1 : {
  63. RQProfileLogoutCell *profileLogoutCell = (RQProfileLogoutCell *)cell;
  64. [profileLogoutCell bindViewModel:object];
  65. break;
  66. }
  67. default: {
  68. [super configureCell:cell atIndexPath:indexPath withObject:object];
  69. break;
  70. }
  71. }
  72. }
  73. @end