diff options
author | Vitaly Takmazov | 2019-10-02 17:16:01 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-10-02 17:16:01 +0300 |
commit | bf573afb9d05ce34ecd22b3dca85aca2c3896ae6 (patch) | |
tree | 2b55dfddb6d31f81294f2554d85bf41607a63f07 /Juick/ViewControllers | |
parent | 33539a3c9c8534776722aa1148499f984e0019e7 (diff) |
Shared navigation
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r-- | Juick/ViewControllers/ChatViewController.m | 2 | ||||
-rw-r--r-- | Juick/ViewControllers/DialogsViewController.m | 2 | ||||
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.m | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/DiscussionsController.m | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/FeedViewController.m | 14 | ||||
-rw-r--r-- | Juick/ViewControllers/JuickNavigationController.h | 17 | ||||
-rw-r--r-- | Juick/ViewControllers/JuickNavigationController.m | 65 | ||||
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.m | 13 | ||||
-rw-r--r-- | Juick/ViewControllers/ThreadViewController.m | 12 |
9 files changed, 94 insertions, 33 deletions
diff --git a/Juick/ViewControllers/ChatViewController.m b/Juick/ViewControllers/ChatViewController.m index 989b531..4f9481c 100644 --- a/Juick/ViewControllers/ChatViewController.m +++ b/Juick/ViewControllers/ChatViewController.m @@ -21,7 +21,7 @@ - (void)viewDidLoad { [super viewDidLoad]; - [self.navigationController.visibleViewController setTitle:self.uname]; + [self.navigationController.navigationItem setTitle:self.uname]; [self.tableView registerNib:[UINib nibWithNibName:@"BubbleMessageCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"bubbleMessageCell"]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; diff --git a/Juick/ViewControllers/DialogsViewController.m b/Juick/ViewControllers/DialogsViewController.m index 1e5d3c2..31a4e8b 100644 --- a/Juick/ViewControllers/DialogsViewController.m +++ b/Juick/ViewControllers/DialogsViewController.m @@ -15,7 +15,7 @@ @implementation DialogsViewController - (void)viewDidLoad { [super viewDidLoad]; - self.navigationController.visibleViewController.navigationItem.title = @"Chats"; + self.navigationController.visibleViewController.title = @"Chats"; [self.view setBackgroundColor:[UIColor colorNamed:@"Background"]]; [self.tableView registerNib:[UINib nibWithNibName:@"ConversationCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"notificationCell"]; [self refreshData]; diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m index 7bf9f74..2b69c6f 100644 --- a/Juick/ViewControllers/DiscoverViewController.m +++ b/Juick/ViewControllers/DiscoverViewController.m @@ -19,6 +19,7 @@ self.title = @"Discover"; self.path = [APIClient messagesUrl]; [self setShouldScrollToUnreadOnRefresh:NO]; + self.navigationController.visibleViewController.title = @"Discover"; [super viewDidLoad]; } diff --git a/Juick/ViewControllers/DiscussionsController.m b/Juick/ViewControllers/DiscussionsController.m index 607ac26..03226ae 100644 --- a/Juick/ViewControllers/DiscussionsController.m +++ b/Juick/ViewControllers/DiscussionsController.m @@ -20,6 +20,7 @@ self.title = @"Discussions"; self.path = [APIClient discussionsUrl]; [self setShouldScrollToUnreadOnRefresh:NO]; + self.navigationController.visibleViewController.title = @"Discussions"; [super viewDidLoad]; } diff --git a/Juick/ViewControllers/FeedViewController.m b/Juick/ViewControllers/FeedViewController.m index a5f7a43..f1fdb0a 100644 --- a/Juick/ViewControllers/FeedViewController.m +++ b/Juick/ViewControllers/FeedViewController.m @@ -25,7 +25,7 @@ NSString * const UserNotAuthenticatedNotificationName = @"UserNotAuthenticated"; -(void) viewDidLoad { self.messagesDelegate = self; - self.title = @"Today"; + self.navigationController.visibleViewController.title = @"Today"; [self refreshPath]; [self setShouldScrollToUnreadOnRefresh:NO]; [super viewDidLoad]; @@ -47,17 +47,7 @@ NSString * const UserNotAuthenticatedNotificationName = @"UserNotAuthenticated"; } } -- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { - if ([identifier isEqualToString:@"newPostSegue"]) { - if ([[APIClient sharedClient] isAuthenticated]) { - return YES; - } else { - [[AppDelegate shared] presentLoginView:self]; - return NO; - } - } - return YES; -} + - (void)didReceiveChallenge { diff --git a/Juick/ViewControllers/JuickNavigationController.h b/Juick/ViewControllers/JuickNavigationController.h new file mode 100644 index 0000000..b508466 --- /dev/null +++ b/Juick/ViewControllers/JuickNavigationController.h @@ -0,0 +1,17 @@ +// +// JuickNavigationController.h +// Juick +// +// Created by Vitaly Takmazov on 02/10/2019. +// Copyright © 2019 com.juick. All rights reserved. +// + +#import <UIKit/UIKit.h> + +NS_ASSUME_NONNULL_BEGIN + +@interface JuickNavigationController : UITabBarController +- (IBAction)newMessage:(id)sender; +@end + +NS_ASSUME_NONNULL_END diff --git a/Juick/ViewControllers/JuickNavigationController.m b/Juick/ViewControllers/JuickNavigationController.m new file mode 100644 index 0000000..a066dbd --- /dev/null +++ b/Juick/ViewControllers/JuickNavigationController.m @@ -0,0 +1,65 @@ +// +// JuickNavigationController.m +// Juick +// +// Created by Vitaly Takmazov on 02/10/2019. +// Copyright © 2019 com.juick. All rights reserved. +// + +#import "JuickNavigationController.h" + +#import "AppDelegate.h" +#import "APIClient.h" +#import "MessagesViewController.h" +#import "ThreadViewController.h" + +#import "Message.h" + +@interface JuickNavigationController () + + +@end + +@implementation JuickNavigationController + +- (void)viewDidLoad { + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +#pragma mark - Navigation + +- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { + if ([identifier isEqualToString:@"editorSegue"]) { + if ([[APIClient sharedClient] isAuthenticated]) { + return YES; + } else { + [[AppDelegate shared] presentLoginView:self]; + return NO; + } + } + return YES; +} + +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + if ([segue.identifier isEqualToString:@"threadSegue"]) { + if ([sender isKindOfClass:[MessagesViewController class]]) { + MessagesViewController *vc = (MessagesViewController *) sender; + Message *msg = vc.messages[vc.tableView.indexPathForSelectedRow.row]; + ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController; + [threadVC setMessages:[@[msg] mutableCopy]]; + [threadVC setParams:@{@"mid": msg.mid }]; + [threadVC setShouldScrollToUnreadOnRefresh:NO]; + } + /* + if (rid) { + [threadVC setFirstUnread:rid]; + [threadVC setShouldScrollToUnreadOnRefresh:YES]; + }*/ + } +} + +- (IBAction)newMessage:(id)sender { + [[AppDelegate shared] presentLoginView:self]; +} +@end diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index ad28484..5dfbf8f 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -161,18 +161,7 @@ NSString* const messageCellIdentifier = @"messageCell"; } -(void) viewThreadForMessage:(Message *)msg mid:(NSNumber *)mid scrollTo:(NSNumber *)rid { - ThreadViewController *threadVC = [AppDelegate threadViewController]; - if (msg) { - [threadVC setMessages:[@[msg] mutableCopy]]; - } - [threadVC setParams:@{@"mid": mid }]; - if (rid) { - [threadVC setFirstUnread:rid]; - [threadVC setShouldScrollToUnreadOnRefresh:YES]; - } else { - [threadVC setShouldScrollToUnreadOnRefresh:NO]; - } - [self.navigationController pushViewController:threadVC animated:YES]; + [[AppDelegate shared] presentThread:self]; } -(void) newMessage:(NSNotification *)obj { diff --git a/Juick/ViewControllers/ThreadViewController.m b/Juick/ViewControllers/ThreadViewController.m index 41e9503..60a115f 100644 --- a/Juick/ViewControllers/ThreadViewController.m +++ b/Juick/ViewControllers/ThreadViewController.m @@ -24,23 +24,21 @@ } -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:messageCellIdentifier forIndexPath:indexPath]; - if ([self shouldPerformSegueWithIdentifier:@"replySegue" sender:self]){ - [self performSegueWithIdentifier:@"replySegue" sender:cell]; + if ([self shouldPerformSegueWithIdentifier:@"editorSegue" sender:self]){ + [[AppDelegate shared] presentEditor:self]; } } -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - if ([segue.identifier isEqual: @"replySegue"]) { + if ([segue.identifier isEqual: @"editorSegue"]) { Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row]; - NewPostViewController *postVC = (NewPostViewController *)[((UINavigationController *)segue.destinationViewController) - .viewControllers firstObject]; + NewPostViewController *postVC = (NewPostViewController *)segue.destinationViewController; [postVC setReplyTo:msg]; } } - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { - if ([identifier isEqualToString:@"replySegue"]) { + if ([identifier isEqualToString:@"editorSegue"]) { if ([[APIClient sharedClient] isAuthenticated]) { return YES; } else { |