123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- //
- // RDSRootControl.m
- // SmartLightForBigFish
- //
- // Created by coderYK on 2017/8/7.
- // Copyright © 2017年 RD-iOS. All rights reserved.
- //
- #import "RDSRootControl.h"
- #import "RDSNavController.h"
- #import "RDSLoginPwdCodeVC.h"
- #import "RDSLoginVerifyCodeVC.h"
- #import "RDSTabbarController.h"
- @interface RDSRootControl ()
- @property (nonatomic, strong) UIViewController *rootViewController;
- @property (nonatomic, strong) UIViewController *loginVC;
- //@property (nonatomic, strong) UIViewController *indexVC;
- @property (nonatomic, assign) BOOL needPushToHome; // ** <#注释#>*/
- @end
- @implementation RDSRootControl
- @synthesize isLoginSuccess = _isLoginSuccess;
- + (instancetype)shareControl {
-
- static RDSRootControl *_instance = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- _instance = [[self alloc] init];
- });
- return _instance;
- }
- - (UIViewController *)rootViewController {
-
- if (self.isLoginSuccess) {
- _rootViewController = [[RDSTabbarController alloc] init];
- _haveLogined = YES;
- }
- else {
- // 是否有设置过密码
- if(TheDataManager.isSetPassword){
- _rootViewController = [[RDSNavController alloc] initWithRootViewController:[[RDSLoginPwdCodeVC alloc] init]];
- }else{
- _rootViewController = [[RDSNavController alloc] initWithRootViewController:[[RDSLoginVerifyCodeVC alloc] init]];
- }
-
- }
- return _rootViewController;
- }
- - (UIViewController *)resetRootController{
- _rootViewController = [[RDSTabbarController alloc] init];
- _haveLogined = YES;
- return _rootViewController;
- }
- - (BOOL)isLoginSuccess{
- // _isLoginSuccess = TheDataManager.isStartAgain;
- return _isLoginSuccess;
- }
- - (void)setIsLoginSuccess:(BOOL)isLoginSuccess {
-
- if(isLoginSuccess == NO){
- [TheDataManager rds_cacheClean];
- }
-
- if (_isLoginSuccess != isLoginSuccess) {
- _isLoginSuccess = isLoginSuccess;
-
- // _rootViewController = self.indexVC;
-
- _needPushToHome = YES;
- [self p_chanceRootViewController:UIViewAnimationOptionTransitionCrossDissolve];
- }
- }
- - (void)p_chanceRootViewController:(UIViewAnimationOptions )options {
-
- typedef void (^Animation)(void);
- UIWindow* window = [[[UIApplication sharedApplication] delegate] window];
-
- // self.rootViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- RDS_WEAKSELF(weakSelf)
- Animation animation = ^{
- BOOL oldState = [UIView areAnimationsEnabled];
- [UIView setAnimationsEnabled:NO];
- window.rootViewController = weakSelf.rootViewController;
- [UIView setAnimationsEnabled:oldState];
- };
-
- [UIView transitionWithView:window
- duration:0.3f
- options:options
- animations:animation
- completion:nil];
- }
- @end
|