RQProfileViewController.m 2.9 KB

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