diff options
-rw-r--r-- | Juick.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | Juick/APIClient.m | 8 | ||||
-rw-r--r-- | Juick/AppDelegate.h | 6 | ||||
-rw-r--r-- | Juick/AppDelegate.m | 31 | ||||
-rw-r--r-- | Juick/Main.storyboard | 129 | ||||
-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 |
14 files changed, 163 insertions, 144 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index 8350c1f..c8bbfbd 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -40,6 +40,7 @@ 776C41BE1FD3EF180063B82E /* MessageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 776C41BC1FD3EF180063B82E /* MessageCell.xib */; }; 776C41C11FD3FF6E0063B82E /* FeedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 776C41C01FD3FF6E0063B82E /* FeedViewController.m */; }; 778560602343D24E00BB37A2 /* NSData+Hex.m in Sources */ = {isa = PBXBuildFile; fileRef = 7785605F2343D24E00BB37A2 /* NSData+Hex.m */; }; + 778560632344CF6F00BB37A2 /* JuickNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 778560622344CF6F00BB37A2 /* JuickNavigationController.m */; }; 77975A1D182B6E9A00410C2B /* NewPostViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77975A1C182B6E9A00410C2B /* NewPostViewController.m */; }; 77975A1F182BDCE900410C2B /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77975A1E182BDCE900410C2B /* SystemConfiguration.framework */; }; 77975A21182BDCF300410C2B /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77975A20182BDCF300410C2B /* MobileCoreServices.framework */; }; @@ -144,6 +145,8 @@ 776C41C01FD3FF6E0063B82E /* FeedViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FeedViewController.m; sourceTree = "<group>"; }; 7785605E2343D24E00BB37A2 /* NSData+Hex.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSData+Hex.h"; sourceTree = "<group>"; }; 7785605F2343D24E00BB37A2 /* NSData+Hex.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+Hex.m"; sourceTree = "<group>"; }; + 778560612344CF6F00BB37A2 /* JuickNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JuickNavigationController.h; sourceTree = "<group>"; }; + 778560622344CF6F00BB37A2 /* JuickNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JuickNavigationController.m; sourceTree = "<group>"; }; 77975A1B182B6E9A00410C2B /* NewPostViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewPostViewController.h; sourceTree = "<group>"; }; 77975A1C182B6E9A00410C2B /* NewPostViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewPostViewController.m; sourceTree = "<group>"; }; 77975A1E182BDCE900410C2B /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; @@ -331,6 +334,8 @@ 77C36494224417E90017522C /* DiscoverViewController.m */, 77C36496224417FC0017522C /* DiscussionsController.h */, 77C36497224417FC0017522C /* DiscussionsController.m */, + 778560612344CF6F00BB37A2 /* JuickNavigationController.h */, + 778560622344CF6F00BB37A2 /* JuickNavigationController.m */, ); path = ViewControllers; sourceTree = "<group>"; @@ -587,6 +592,7 @@ 77B8B39C207A5629005CB20C /* MessageInputView.m in Sources */, 77C3648C2241B3060017522C /* DeviceRegistration.m in Sources */, 774528C21F930C06004D110B /* Attachment.m in Sources */, + 778560632344CF6F00BB37A2 /* JuickNavigationController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Juick/APIClient.m b/Juick/APIClient.m index 848ea77..c7e22cf 100644 --- a/Juick/APIClient.m +++ b/Juick/APIClient.m @@ -175,10 +175,12 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler { if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodHTTPBasic) { - completionHandler(NSURLSessionAuthChallengeUseCredential, self.credential); - } else { - completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); + if (self.isAuthenticated) { + completionHandler(NSURLSessionAuthChallengeUseCredential, self.credential); + return; + } } + completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil); } -(void) fetchDataWithURL:(NSURL *) url data:(NSData *)postData boundary:(NSString *)boundary callback:(void(^)(NSData *, NSError *))callback { diff --git a/Juick/AppDelegate.h b/Juick/AppDelegate.h index 04a903a..8b89131 100644 --- a/Juick/AppDelegate.h +++ b/Juick/AppDelegate.h @@ -22,12 +22,14 @@ extern NSString * const UserUpdatedNotificationName; +(AppDelegate *) shared; -+(ThreadViewController *) threadViewController; +-(void) presentThread:(UIViewController *)vc; +-(void) presentEditor:(UIViewController *)vc; +-(void) presentLoginView:(UIViewController *)vc; @property (strong, nonatomic) NSNumber *pushedThread; @property (strong, nonatomic) NSString *pushedUname; @property (strong, nonatomic) NSNumber *pushedReplyId; -- (void) presentLoginView:(UIViewController *)vc; + @end 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 diff --git a/Juick/Main.storyboard b/Juick/Main.storyboard index 419e5a5..4ab443e 100644 --- a/Juick/Main.storyboard +++ b/Juick/Main.storyboard @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="XnR-Hh-t65"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Rbr-km-xhI"> <device id="retina4_7" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> @@ -24,9 +24,6 @@ <rect key="frame" x="0.0" y="0.0" width="347.5" height="43.5"/> <autoresizingMask key="autoresizingMask"/> </tableViewCellContentView> - <connections> - <segue destination="mKa-Ib-r2p" kind="modal" identifier="replySegue" id="gw8-QZ-Hrt"/> - </connections> </tableViewCell> </prototypes> <connections> @@ -41,24 +38,6 @@ <point key="canvasLocation" x="76" y="-889"/> </scene> <!--Today--> - <scene sceneID="NkO-CZ-YSO"> - <objects> - <navigationController id="k3X-uv-0IF" sceneMemberID="viewController"> - <tabBarItem key="tabBarItem" title="Today" image="ei-clock" id="Qml-qG-fK2"/> - <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="3ze-yo-W7s"> - <rect key="frame" x="0.0" y="0.0" width="375" height="44"/> - <autoresizingMask key="autoresizingMask"/> - <color key="barTintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> - </navigationBar> - <connections> - <segue destination="VCH-GK-jaH" kind="relationship" relationship="rootViewController" id="Rgn-In-COD"/> - </connections> - </navigationController> - <placeholder placeholderIdentifier="IBFirstResponder" id="fVV-xR-99a" userLabel="First Responder" sceneMemberID="firstResponder"/> - </objects> - <point key="canvasLocation" x="-809" y="-162"/> - </scene> - <!--Today--> <scene sceneID="uvH-u9-x7X"> <objects> <tableViewController title="Today" id="VCH-GK-jaH" customClass="FeedViewController" sceneMemberID="viewController"> @@ -84,11 +63,7 @@ <tabBarItem key="tabBarItem" title="Today" image="ei-clock" id="Je4-Zm-Zbu"/> <toolbarItems/> <navigationItem key="navigationItem" id="M2f-nV-K0C"> - <barButtonItem key="rightBarButtonItem" image="ei-pencil" id="ovc-xl-vHA"> - <connections> - <segue destination="mKa-Ib-r2p" kind="modal" identifier="newPostSegue" id="vj1-M0-h6U"/> - </connections> - </barButtonItem> + <barButtonItem key="rightBarButtonItem" image="ei-pencil" id="ovc-xl-vHA"/> </navigationItem> <connections> <segue destination="NJR-jw-Kd1" kind="push" identifier="profileSegue" id="2WV-Sf-vec"/> @@ -214,23 +189,6 @@ </objects> <point key="canvasLocation" x="-1052" y="599"/> </scene> - <!--Chats--> - <scene sceneID="slX-NB-ZJR"> - <objects> - <navigationController id="bqF-EV-jyA" sceneMemberID="viewController"> - <tabBarItem key="tabBarItem" title="Chats" image="ei-envelope" id="uDU-Ru-VA7"/> - <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="MLM-G7-sIv"> - <rect key="frame" x="0.0" y="0.0" width="375" height="44"/> - <autoresizingMask key="autoresizingMask"/> - </navigationBar> - <connections> - <segue destination="vqF-gx-pZG" kind="relationship" relationship="rootViewController" id="mX4-bY-xEX"/> - </connections> - </navigationController> - <placeholder placeholderIdentifier="IBFirstResponder" id="Naf-TD-SSX" userLabel="First Responder" sceneMemberID="firstResponder"/> - </objects> - <point key="canvasLocation" x="-356.80000000000001" y="599.10044977511245"/> - </scene> <!--Notifications--> <scene sceneID="CAp-HD-pIQ"> <objects> @@ -345,7 +303,7 @@ </objects> <point key="canvasLocation" x="1408.8" y="-162.3688155922039"/> </scene> - <!--Discover View Controller--> + <!--Discover--> <scene sceneID="g01-td-y6A"> <objects> <tableViewController id="q23-tm-nTI" customClass="DiscoverViewController" sceneMemberID="viewController"> @@ -368,35 +326,60 @@ <outlet property="delegate" destination="q23-tm-nTI" id="5xz-ha-vpb"/> </connections> </tableView> + <tabBarItem key="tabBarItem" title="Discover" image="ei-search" id="U28-Wj-ZTF"/> <navigationItem key="navigationItem" id="YuL-El-wFH"/> </tableViewController> <placeholder placeholderIdentifier="IBFirstResponder" id="Avi-e4-7zU" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> <point key="canvasLocation" x="-808.79999999999995" y="-856.82158920539734"/> </scene> - <!--Tab Bar Controller--> + <!--Navigation Controller--> + <scene sceneID="gpM-1r-1kk"> + <objects> + <navigationController id="Rbr-km-xhI" sceneMemberID="viewController"> + <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="4ih-yF-5aH"> + <rect key="frame" x="0.0" y="0.0" width="375" height="44"/> + <autoresizingMask key="autoresizingMask"/> + </navigationBar> + <connections> + <segue destination="XnR-Hh-t65" kind="relationship" relationship="rootViewController" id="ptu-0i-WFn"/> + </connections> + </navigationController> + <placeholder placeholderIdentifier="IBFirstResponder" id="YOF-5G-mW2" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="-3562" y="-176"/> + </scene> + <!--Juick Navigation Controller--> <scene sceneID="R7v-av-S80"> <objects> - <tabBarController id="XnR-Hh-t65" sceneMemberID="viewController"> + <tabBarController id="XnR-Hh-t65" customClass="JuickNavigationController" sceneMemberID="viewController"> <extendedEdge key="edgesForExtendedLayout"/> + <navigationItem key="navigationItem" id="Pgj-hT-yHb"> + <barButtonItem key="rightBarButtonItem" image="ei-pencil" id="fvy-mZ-USk"> + <connections> + <segue destination="mKa-Ib-r2p" kind="modal" identifier="editorSegue" id="mG5-hj-MTY"/> + </connections> + </barButtonItem> + </navigationItem> <tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Qqp-Yg-IzB"> <rect key="frame" x="0.0" y="0.0" width="375" height="49"/> <autoresizingMask key="autoresizingMask"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> </tabBar> <connections> - <segue destination="k3X-uv-0IF" kind="relationship" relationship="viewControllers" id="5rb-rf-WgC"/> - <segue destination="YkB-dq-pv4" kind="relationship" relationship="viewControllers" id="uQw-Xa-hwe"/> - <segue destination="bqF-EV-jyA" kind="relationship" relationship="viewControllers" id="L49-RF-BJa"/> - <segue destination="wJv-nS-OaN" kind="relationship" relationship="viewControllers" id="5Pl-1T-DRQ"/> <segue destination="J8f-Vc-5Bc" kind="modal" identifier="loginSegue" id="2pJ-ai-Rmu"/> + <segue destination="egN-ti-sbh" kind="push" identifier="threadSegue" id="Ia1-Ks-ouA"/> + <segue destination="VCH-GK-jaH" kind="relationship" relationship="viewControllers" id="hSa-HL-xQS"/> + <segue destination="irg-YA-Ovi" kind="relationship" relationship="viewControllers" id="nQ8-IT-Mr7"/> + <segue destination="vqF-gx-pZG" kind="relationship" relationship="viewControllers" id="1Tb-Zp-djC"/> + <segue destination="q23-tm-nTI" kind="relationship" relationship="viewControllers" id="IIO-y5-9ts"/> </connections> </tabBarController> <placeholder placeholderIdentifier="IBFirstResponder" id="AnM-ht-zf8" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> <point key="canvasLocation" x="-1886" y="-170"/> </scene> - <!--Discussions Controller--> + <!--Discussions--> <scene sceneID="m4V-XQ-WRo"> <objects> <tableViewController id="irg-YA-Ovi" customClass="DiscussionsController" sceneMemberID="viewController"> @@ -419,50 +402,13 @@ <outlet property="delegate" destination="irg-YA-Ovi" id="5yB-2P-9U5"/> </connections> </tableView> + <tabBarItem key="tabBarItem" title="Discussions" image="ei-bell" id="I0X-mp-28m"/> <navigationItem key="navigationItem" id="IAo-7r-IvK"/> </tableViewController> <placeholder placeholderIdentifier="IBFirstResponder" id="f9t-89-mMI" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> <point key="canvasLocation" x="-2610.4000000000001" y="-856.82158920539734"/> </scene> - <!--Discover--> - <scene sceneID="rTx-Xr-jP4"> - <objects> - <navigationController title="Discover" automaticallyAdjustsScrollViewInsets="NO" id="wJv-nS-OaN" sceneMemberID="viewController"> - <tabBarItem key="tabBarItem" title="Discover" image="ei-search" id="Hf1-fH-Ne9"/> - <toolbarItems/> - <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="HfH-EY-4C6"> - <rect key="frame" x="0.0" y="0.0" width="375" height="44"/> - <autoresizingMask key="autoresizingMask"/> - </navigationBar> - <nil name="viewControllers"/> - <connections> - <segue destination="q23-tm-nTI" kind="relationship" relationship="rootViewController" id="iLJ-IP-aY8"/> - </connections> - </navigationController> - <placeholder placeholderIdentifier="IBFirstResponder" id="iDs-Ig-15k" userLabel="First Responder" sceneMemberID="firstResponder"/> - </objects> - <point key="canvasLocation" x="-1748" y="-856.82158920539734"/> - </scene> - <!--Discussions--> - <scene sceneID="PRP-vE-Jhi"> - <objects> - <navigationController automaticallyAdjustsScrollViewInsets="NO" id="YkB-dq-pv4" sceneMemberID="viewController"> - <tabBarItem key="tabBarItem" title="Discussions" image="ei-bell" id="r5a-uD-dsg"/> - <toolbarItems/> - <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="1ry-Mk-20P"> - <rect key="frame" x="0.0" y="0.0" width="375" height="44"/> - <autoresizingMask key="autoresizingMask"/> - </navigationBar> - <nil name="viewControllers"/> - <connections> - <segue destination="irg-YA-Ovi" kind="relationship" relationship="rootViewController" id="pci-IM-sHP"/> - </connections> - </navigationController> - <placeholder placeholderIdentifier="IBFirstResponder" id="Eb9-pv-yRC" userLabel="First Responder" sceneMemberID="firstResponder"/> - </objects> - <point key="canvasLocation" x="-3551.1999999999998" y="-857.72113943028489"/> - </scene> <!--Navigation Controller--> <scene sceneID="tve-hL-kxy"> <objects> @@ -491,7 +437,4 @@ <image name="ei-pencil" width="23" height="22"/> <image name="ei-search" width="23" height="23"/> </resources> - <inferredMetricsTieBreakers> - <segue reference="vj1-M0-h6U"/> - </inferredMetricsTieBreakers> </document> 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 { |