diff options
author | Vitaly Takmazov | 2018-04-28 04:45:13 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-04-28 04:45:13 +0300 |
commit | 05520b1f723b021bb57972b71cbe13684ab2195b (patch) | |
tree | 5bb39543164001537552e41cdb7e03a797398697 | |
parent | f6fed5b2374c7d847c68efccce363f9513aa2efb (diff) |
Blog view
-rw-r--r-- | Juick.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | Juick/Main.storyboard | 5 | ||||
-rw-r--r-- | Juick/ViewControllers/BlogViewController.h | 16 | ||||
-rw-r--r-- | Juick/ViewControllers/BlogViewController.m | 17 | ||||
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.h | 2 | ||||
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.m | 20 | ||||
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.h | 1 | ||||
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.m | 2 | ||||
-rw-r--r-- | Juick/Views/MessageCell.h | 6 | ||||
-rw-r--r-- | Juick/Views/MessageCell.m | 8 |
10 files changed, 79 insertions, 4 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index b49ed47..b03b74e 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -49,6 +49,7 @@ 77B099A6189D57F000A84F59 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B099A5189D57F000A84F59 /* User.m */; }; 77B8B399207A52BD005CB20C /* MessageInputView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 77B8B398207A52BD005CB20C /* MessageInputView.xib */; }; 77B8B39C207A5629005CB20C /* MessageInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B8B39B207A5629005CB20C /* MessageInputView.m */; }; + 77B8DCD62093FC03000DBB04 /* BlogViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B8DCD52093FC03000DBB04 /* BlogViewController.m */; }; 77C67EE51828342000427098 /* NSURL+PathParameters.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C67EE41828342000427098 /* NSURL+PathParameters.m */; }; 77C67EE81828379700427098 /* ColorScheme.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C67EE71828379700427098 /* ColorScheme.m */; }; 77C67EEA18283C8D00427098 /* buttons.png in Resources */ = {isa = PBXBuildFile; fileRef = 77C67EE918283C8D00427098 /* buttons.png */; }; @@ -137,6 +138,8 @@ 77B8B398207A52BD005CB20C /* MessageInputView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MessageInputView.xib; sourceTree = "<group>"; }; 77B8B39A207A5629005CB20C /* MessageInputView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageInputView.h; sourceTree = "<group>"; }; 77B8B39B207A5629005CB20C /* MessageInputView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageInputView.m; sourceTree = "<group>"; }; + 77B8DCD42093FC03000DBB04 /* BlogViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BlogViewController.h; sourceTree = "<group>"; }; + 77B8DCD52093FC03000DBB04 /* BlogViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BlogViewController.m; sourceTree = "<group>"; }; 77C67EE31828342000427098 /* NSURL+PathParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSURL+PathParameters.h"; sourceTree = "<group>"; }; 77C67EE41828342000427098 /* NSURL+PathParameters.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURL+PathParameters.m"; sourceTree = "<group>"; }; 77C67EE61828379700427098 /* ColorScheme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorScheme.h; sourceTree = "<group>"; }; @@ -318,6 +321,8 @@ 773E6399204BCE6D008B8F8D /* DialogsViewController.m */, 773E639E204BDF16008B8F8D /* ChatViewController.h */, 773E639F204BDF16008B8F8D /* ChatViewController.m */, + 77B8DCD42093FC03000DBB04 /* BlogViewController.h */, + 77B8DCD52093FC03000DBB04 /* BlogViewController.m */, ); path = ViewControllers; sourceTree = "<group>"; @@ -558,6 +563,7 @@ 77A0954A181F1F25002BDECD /* Message.m in Sources */, 773E63A0204BDF16008B8F8D /* ChatViewController.m in Sources */, 773E639D204BD0F2008B8F8D /* Chat.m in Sources */, + 77B8DCD62093FC03000DBB04 /* BlogViewController.m in Sources */, 773E639A204BCE6D008B8F8D /* DialogsViewController.m in Sources */, 774528C51F93AC0F004D110B /* CoreDataStack.m in Sources */, 77B09994189D0B9900A84F59 /* UIImage+Utils.m in Sources */, diff --git a/Juick/Main.storyboard b/Juick/Main.storyboard index ad76e28..6b8d09b 100644 --- a/Juick/Main.storyboard +++ b/Juick/Main.storyboard @@ -100,6 +100,9 @@ </connections> </barButtonItem> </navigationItem> + <connections> + <segue destination="NJR-jw-Kd1" kind="push" identifier="profileSegue" id="2WV-Sf-vec"/> + </connections> </tableViewController> <placeholder placeholderIdentifier="IBFirstResponder" id="skE-j1-NV7" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> @@ -203,7 +206,7 @@ <!--Profile--> <scene sceneID="pZT-hd-B6F"> <objects> - <tableViewController title="Profile" id="NJR-jw-Kd1" sceneMemberID="viewController"> + <tableViewController title="Profile" id="NJR-jw-Kd1" customClass="BlogViewController" sceneMemberID="viewController"> <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="UQ6-nv-K3A"> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> diff --git a/Juick/ViewControllers/BlogViewController.h b/Juick/ViewControllers/BlogViewController.h new file mode 100644 index 0000000..e428ab5 --- /dev/null +++ b/Juick/ViewControllers/BlogViewController.h @@ -0,0 +1,16 @@ +// +// BlogViewController.h +// Juick +// +// Created by Vitaly Takmazov on 28/04/2018. +// Copyright © 2018 com.juick. All rights reserved. +// + +#import "MessagesViewController.h" +#import "User.h" + +@interface BlogViewController : MessagesViewController + +@property(nonatomic, strong) NSString *uname; + +@end diff --git a/Juick/ViewControllers/BlogViewController.m b/Juick/ViewControllers/BlogViewController.m new file mode 100644 index 0000000..7e23556 --- /dev/null +++ b/Juick/ViewControllers/BlogViewController.m @@ -0,0 +1,17 @@ +// +// BlogViewController.m +// Juick +// +// Created by Vitaly Takmazov on 28/04/2018. +// Copyright © 2018 com.juick. All rights reserved. +// + +#import "BlogViewController.h" + +@interface BlogViewController () + +@end + +@implementation BlogViewController + +@end diff --git a/Juick/ViewControllers/DiscoverViewController.h b/Juick/ViewControllers/DiscoverViewController.h index 9f96b98..bb34d5e 100644 --- a/Juick/ViewControllers/DiscoverViewController.h +++ b/Juick/ViewControllers/DiscoverViewController.h @@ -9,6 +9,6 @@ #import <UIKit/UIKit.h> #import "MessagesViewController.h" -@interface DiscoverViewController : MessagesViewController<MessagesDelegate> +@interface DiscoverViewController : MessagesViewController<MessagesDelegate, MessageCellDelegate> @end diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m index d57947e..a02f23c 100644 --- a/Juick/ViewControllers/DiscoverViewController.m +++ b/Juick/ViewControllers/DiscoverViewController.m @@ -8,6 +8,7 @@ #import "DiscoverViewController.h" #import "ThreadViewController.h" +#import "BlogViewController.h" #import "MessageCell.h" #import "APIClient.h" #import "AppDelegate.h" @@ -16,7 +17,7 @@ @interface DiscoverViewController () @property(nonatomic, strong) AppDelegate *appDelegate; - +@property NSString *selectedUser; @end @implementation DiscoverViewController @@ -54,6 +55,16 @@ MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; [self performSegueWithIdentifier:@"threadViewSegue" sender:cell]; } +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + MessageCell *cell = (MessageCell *)[super tableView:tableView cellForRowAtIndexPath:indexPath]; + cell.delegate = self; + return cell; +} + +-(void)avatarClicked:(NSString *)uname { + self.selectedUser = uname; + [self performSegueWithIdentifier:@"profileSegue" sender:self]; +} -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqual: @"threadViewSegue"]) { @@ -73,6 +84,13 @@ [threadVC setParams:@{@"mid": mid }]; [threadVC refreshData:scrollToEnd]; } + if ([segue.identifier isEqual: @"profileSegue"]) { + BlogViewController *blogVC = (BlogViewController *)segue.destinationViewController; + [blogVC setUname:self.selectedUser]; + [blogVC setTitle:self.selectedUser]; + blogVC.path = [NSString stringWithFormat:@"/messages?uname=%@", self.selectedUser]; + [blogVC refreshData:NO]; + } } - (IBAction)filterAction:(id)sender { if (![User isAuthenticated]) { diff --git a/Juick/ViewControllers/MessagesViewController.h b/Juick/ViewControllers/MessagesViewController.h index 2259b91..688336b 100644 --- a/Juick/ViewControllers/MessagesViewController.h +++ b/Juick/ViewControllers/MessagesViewController.h @@ -7,6 +7,7 @@ // #import <UIKit/UIKit.h> +#import "MessageCell.h" @protocol MessagesDelegate -(void) loadMore; diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index c718336..a37f502 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -16,11 +16,11 @@ #import "NewPostViewController.h" #import "LoginViewController.h" #import "ThreadViewController.h" +#import "BlogViewController.h" #import "NSURL+PathParameters.h" - @implementation MessagesViewController -(void) refreshData { diff --git a/Juick/Views/MessageCell.h b/Juick/Views/MessageCell.h index 737ec89..475eea3 100644 --- a/Juick/Views/MessageCell.h +++ b/Juick/Views/MessageCell.h @@ -11,6 +11,10 @@ @import TagListView_ObjC; #import "Message.h" +@protocol MessageCellDelegate +-(void) avatarClicked:(NSString *)uname; +@end + @interface MessageCell : UITableViewCell<TTTAttributedLabelDelegate> @property (weak, nonatomic) IBOutlet UIImageView *avatar; @@ -22,5 +26,7 @@ @property (weak, nonatomic) IBOutlet NSLayoutConstraint *attachmentHeight; @property (weak, nonatomic) IBOutlet UILabel *summary; +@property (nonatomic, strong) id<MessageCellDelegate> delegate; + - (void) configureWithMessage:(Message *)msg; @end diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m index 2f00d7e..c304f37 100644 --- a/Juick/Views/MessageCell.m +++ b/Juick/Views/MessageCell.m @@ -28,6 +28,10 @@ self.timestamp.textColor = [UIColor grayColor]; self.summary.textColor = [UIColor grayColor]; self.tags.textFont = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; + UIGestureRecognizer *avatarTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarClicked:)]; + [avatarTapRecognizer setEnabled:YES]; + [self.avatar addGestureRecognizer:avatarTapRecognizer]; + [self.avatar setUserInteractionEnabled:YES]; } - (void) configureWithMessage:(Message *)msg { @@ -66,5 +70,9 @@ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; } +-(void) avatarClicked:(UIGestureRecognizer *)gestureRecognizer { + [self.delegate avatarClicked:self.title.text]; +} + @end |