summaryrefslogtreecommitdiff
path: root/Juick/AppDelegate.m
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-10-02 17:16:01 +0300
committerGravatar Vitaly Takmazov2019-10-02 17:16:01 +0300
commitbf573afb9d05ce34ecd22b3dca85aca2c3896ae6 (patch)
tree2b55dfddb6d31f81294f2554d85bf41607a63f07 /Juick/AppDelegate.m
parent33539a3c9c8534776722aa1148499f984e0019e7 (diff)
Shared navigation
Diffstat (limited to 'Juick/AppDelegate.m')
-rw-r--r--Juick/AppDelegate.m31
1 files changed, 18 insertions, 13 deletions
diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m
index 3bdb774..fe1b0eb 100644
--- a/Juick/AppDelegate.m
+++ b/Juick/AppDelegate.m
@@ -85,18 +85,16 @@ NSString * const UserUpdatedNotificationName = @"UserUpdated";
NSDictionary *userInfo = response.notification.request.content.userInfo;
[self parseNotificationPayload:userInfo];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
- UITabBarController *main = (UITabBarController *)self.window.rootViewController;
+ UITabBarController *main = (UITabBarController *)[self navigator];
if ([self.pushedThread integerValue] > 0) {
[main setSelectedIndex:0];
- UINavigationController *discover = (UINavigationController *)[main.viewControllers objectAtIndex:0];
- [discover popToRootViewControllerAnimated:NO];
- MessagesViewController *msgVC = (MessagesViewController *)[discover.viewControllers objectAtIndex:0];
- [msgVC viewThreadForMessage:nil mid:self.pushedThread scrollTo:self.pushedReplyId];
+ MessagesViewController *discover = (MessagesViewController *)[main.viewControllers objectAtIndex:0];
+ [discover viewThreadForMessage:nil mid:self.pushedThread scrollTo:self.pushedReplyId];
[self cleanupPushedData];
} else {
[main setSelectedIndex:2];
- UINavigationController *dialogs = (UINavigationController *)[main.viewControllers objectAtIndex:2];
- [[dialogs.viewControllers objectAtIndex:0] performSegueWithIdentifier:@"chatSegue" sender:dialogs];
+ MessagesViewController *dialogs = (MessagesViewController *)[main.viewControllers objectAtIndex:2];
+ [dialogs performSegueWithIdentifier:@"chatSegue" sender:dialogs];
}
}];
completionHandler();
@@ -106,8 +104,8 @@ NSString * const UserUpdatedNotificationName = @"UserUpdated";
if (userInfo[@"service"]) {
User *user = [User fromJSON:userInfo[@"user"]];
application.applicationIconBadgeNumber = user.unreadCount;
- UITabBarController *main = (UITabBarController *)self.window.rootViewController;
- UINavigationController *discussions = [main.viewControllers objectAtIndex:1];
+ UITabBarController *main = (UITabBarController *)[self navigator];
+ UIViewController *discussions = [main.viewControllers objectAtIndex:1];
if (user.unreadCount > 0) {
[discussions tabBarItem].badgeColor = [UIColor colorNamed:@"Funny"];
[discussions tabBarItem].badgeValue = [NSString stringWithFormat:@"%ld", user.unreadCount];
@@ -142,13 +140,20 @@ NSString * const UserUpdatedNotificationName = @"UserUpdated";
return (AppDelegate *)[UIApplication sharedApplication].delegate;
}
-+ (id)threadViewController {
- UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
- return [mainStoryboard instantiateViewControllerWithIdentifier:@"threadViewControllerIdentifier"];
+- (UINavigationController *) navigator {
+ return [[(UINavigationController *)self.window.rootViewController viewControllers] firstObject];
+}
+
+- (void)presentThread:(UIViewController *)vc {
+ [[self navigator] performSegueWithIdentifier:@"threadSegue" sender:vc];
+}
+
+- (void) presentEditor:(UIViewController *)vc {
+ [[self navigator] performSegueWithIdentifier:@"editorSegue" sender:vc];
}
- (void) presentLoginView:(UIViewController *)vc {
- [self.window.rootViewController performSegueWithIdentifier:@"loginSegue" sender:vc];
+ [[self navigator] performSegueWithIdentifier:@"loginSegue" sender:vc];
}
@end