summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/Main.storyboard5
-rw-r--r--Juick/ViewControllers/BlogViewController.h16
-rw-r--r--Juick/ViewControllers/BlogViewController.m17
-rw-r--r--Juick/ViewControllers/DiscoverViewController.h2
-rw-r--r--Juick/ViewControllers/DiscoverViewController.m20
-rw-r--r--Juick/ViewControllers/MessagesViewController.h1
-rw-r--r--Juick/ViewControllers/MessagesViewController.m2
-rw-r--r--Juick/Views/MessageCell.h6
-rw-r--r--Juick/Views/MessageCell.m8
9 files changed, 73 insertions, 4 deletions
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