123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- //
- // RQProfileLogouItemViewModel.m
- // SDJK
- //
- // Created by 张嵘 on 2021/8/2.
- //
- #import "RQProfileLogouItemViewModel.h"
- @interface RQProfileLogouItemViewModel ()
- /// 退出登录的命令
- @property (nonatomic, readwrite, strong) RACCommand *logoutCommand;
- /// 注销账号的命令
- @property (nonatomic, readwrite, strong) RACCommand *signoutCommand;
- @end
- @implementation RQProfileLogouItemViewModel
- - (instancetype)initWithTitle:(NSString *)title {
- if (self = [super init]) {
- self.title = title;
- self.rowHeight = RQ_FIT_HORIZONTAL(82.f);
- }
- return self;
- }
- /// 退出登录的命令
- - (RACCommand *)logoutCommand {
- if (!_logoutCommand) {
- _logoutCommand =[[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
- /// 删除账号
- [SAMKeychain deleteRawLogin];
- /// 先退出用户
- [RQ_USER_MANAGER logoutUser];
-
- return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
- /// 延迟一段时间
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- /// 这里切换 到账号登录的界面
- [RQNotificationCenter postNotificationName:RQSwitchRootViewControllerNotification object:nil userInfo:@{RQSwitchRootViewControllerUserInfoKey:@(RQSwitchRootViewControllerFromTypeLogout)}];
- [subscriber sendNext:nil];
- [subscriber sendCompleted];
- });
- return [RACDisposable disposableWithBlock:^{
-
- }];
- }];
- }];
- }
- return _logoutCommand;
- }
- /// 退出登录的命令
- - (RACCommand *)signoutCommand {
- if (!_signoutCommand) {
- _signoutCommand =[[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
- /// 删除账号
- [SAMKeychain deleteRawLogin];
- /// 先退出用户
- [RQ_USER_MANAGER logoutUser];
-
- return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
- /// 延迟一段时间
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- /// 这里切换 到账号登录的界面
- [RQNotificationCenter postNotificationName:RQSwitchRootViewControllerNotification object:nil userInfo:@{RQSwitchRootViewControllerUserInfoKey:@(RQSwitchRootViewControllerFromTypeLogout)}];
- [subscriber sendNext:nil];
- [subscriber sendCompleted];
- });
- return [RACDisposable disposableWithBlock:^{
-
- }];
- }];
- }];
- }
- return _signoutCommand;
- }
- - (NSString *)itemClassName {
- return @"RQProfileLogoutCell";
- }
- @end
|