Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lilthree committed Jun 3, 2018
1 parent a4c589a commit 5dd8a7f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
2 changes: 0 additions & 2 deletions common/Classes/UIViewController+Extend.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,4 @@
- (BOOL)checkNetworkStatus;

- (void)popupTwoStepVerificationViewHandler:(void (^)(NSString *input,BOOL remember))handler;

- (UIViewController *)topViewControllerIn:(UIViewController*)rootViewRootVC;
@end
21 changes: 0 additions & 21 deletions common/Classes/UIViewController+Extend.m
Original file line number Diff line number Diff line change
Expand Up @@ -236,25 +236,4 @@ - (BOOL)checkNetworkStatus
return YES;
}

#pragma mark topViewController
- (UIViewController *)topViewControllerIn:(UIViewController*)rootViewRootVC {
UIViewController *topVC;
topVC = [self findTopViewController:rootViewRootVC];
while (topVC.presentedViewController) {
topVC = [self findTopViewController:topVC.presentedViewController];
}
return topVC;
}

- (UIViewController *)findTopViewController:(UIViewController *)vc {
if ([vc isKindOfClass:[UINavigationController class]]) {
return [self findTopViewController:[(UINavigationController *)vc topViewController]];
} else if ([vc isKindOfClass:[UITabBarController class]]) {
return [self findTopViewController:[(UITabBarController *)vc selectedViewController]];
} else {
return vc;
}
return nil;
}

@end
1 change: 1 addition & 0 deletions seafile/SeafAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ enum {
- (void)stopSignificantChangeUpdates;
- (void)checkBackgroundUploadStatus;

+ (UIViewController *)topViewController;
+ (void)checkOpenLink:(SeafFileViewController *)c;

@end
26 changes: 26 additions & 0 deletions seafile/SeafAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -681,4 +681,30 @@ - (void)onResp:(BaseResp *)resp {
}
}

#pragma mark topViewController
+ (UIViewController *)topViewController {
SeafAppDelegate *delegate = (SeafAppDelegate*)[UIApplication sharedApplication].delegate;
return [delegate topViewController];
}

- (UIViewController *)topViewController {
UIViewController *rootVC = [self.window rootViewController];
UIViewController *topVC = [self findTopViewController:rootVC];
while (topVC.presentedViewController) {
topVC = [self findTopViewController:topVC.presentedViewController];
}
return topVC;
}

- (UIViewController *)findTopViewController:(UIViewController *)vc {
if ([vc isKindOfClass:[UINavigationController class]]) {
return [self findTopViewController:[(UINavigationController *)vc topViewController]];
} else if ([vc isKindOfClass:[UITabBarController class]]) {
return [self findTopViewController:[(UITabBarController *)vc selectedViewController]];
} else {
return vc;
}
return nil;
}

@end
4 changes: 1 addition & 3 deletions seafile/SeafFileViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,7 @@ - (void)showSheetWithTitles:(NSArray*)titles andFromView:(id)view

[actionSheet showFromPoint:point inView:self.navigationController.view arrowDirection:SFActionSheetArrowDirectionTop animated:YES];
} else {
UIViewController *topVC = [self topViewControllerIn:[[[[UIApplication sharedApplication] delegate] window] rootViewController]];

[actionSheet showInView:topVC.view.window animated:YES];
[actionSheet showInView:[SeafAppDelegate topViewController].view.window animated:YES];
}
}

Expand Down

0 comments on commit 5dd8a7f

Please sign in to comment.