123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- //
- // RQProfileViewController.m
- // RQCommon
- //
- // Created by 张嵘 on 2018/11/21.
- // Copyright © 2018 张嵘. All rights reserved.
- //
- #import "RQProfileViewController.h"
- @interface RQProfileViewController ()
- /// viewModel
- @property (nonatomic, readonly, strong) RQProfileViewModel *viewModel;
- @end
- @implementation RQProfileViewController
- @dynamic viewModel;
- #pragma mark - SystemMethod
- - (void)viewDidLoad {
- [super viewDidLoad];
- }
- #pragma mark - OverrideMethods
- - (void)bindViewModel{
- [super bindViewModel];
- @weakify(self);
- /// show HUD
- [[self.viewModel.logoutCommand.executing
- skip:1]
- subscribeNext:^(NSNumber * showHud) {
- if (showHud.boolValue) {
- [MBProgressHUD rq_showProgressHUD:@"正在退出..."];
- }else{
- [MBProgressHUD rq_hideHUD];
- }
- }];
-
- /// 点击退出登录回调
- [self.viewModel.logoutSubject subscribeNext:^(id input) {
- // @strongify(self);
- // @weakify(self);
- LCActionSheet *sheet = [LCActionSheet sheetWithTitle:@"退出后不会删除任何历史数据,下次登录依然可以使用本账号" cancelButtonTitle:@"取消" clicked:^(LCActionSheet * _Nonnull actionSheet, NSInteger buttonIndex) {
- if (buttonIndex == 0) return ;
- /// 退出账号
- @strongify(self)
- [self.viewModel.logoutCommand execute:nil];
-
- } otherButtonTitles:@"退出登录", nil];
- NSMutableIndexSet *indexSet = [[NSMutableIndexSet alloc] init];
- [indexSet addIndex:1];
- sheet.destructiveButtonIndexSet = indexSet;
- [sheet show];
- }];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
- switch (indexPath.section) {
- case 0: {
- RQProfileUserInfoCell *cell = [RQProfileUserInfoCell cellWithTableView:tableView];
- return cell;
- }
- case 3 : {
- RQProfileLogoutCell *cell = [RQProfileLogoutCell cellWithTableView:tableView];
- return cell;
- }
-
- default:
- return [super tableView:tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
- }
-
- }
- - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
- switch (indexPath.section) {
- case 0: {
- RQProfileUserInfoCell *profileUserInfoCell = (RQProfileUserInfoCell *)cell;
- [profileUserInfoCell bindViewModel:object];
- break;
- }
- case 3 : {
- RQProfileLogoutCell *profileLogoutCell = (RQProfileLogoutCell *)cell;
- [profileLogoutCell bindViewModel:object];
- break;
- }
-
- default: {
- [super configureCell:cell atIndexPath:indexPath withObject:object];
- break;
- }
- }
-
- }
- @end
|