From 05520b1f723b021bb57972b71cbe13684ab2195b Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sat, 28 Apr 2018 04:45:13 +0300
Subject: Blog view
---
Juick/Main.storyboard | 5 ++++-
Juick/ViewControllers/BlogViewController.h | 16 ++++++++++++++++
Juick/ViewControllers/BlogViewController.m | 17 +++++++++++++++++
Juick/ViewControllers/DiscoverViewController.h | 2 +-
Juick/ViewControllers/DiscoverViewController.m | 20 +++++++++++++++++++-
Juick/ViewControllers/MessagesViewController.h | 1 +
Juick/ViewControllers/MessagesViewController.m | 2 +-
Juick/Views/MessageCell.h | 6 ++++++
Juick/Views/MessageCell.m | 8 ++++++++
9 files changed, 73 insertions(+), 4 deletions(-)
create mode 100644 Juick/ViewControllers/BlogViewController.h
create mode 100644 Juick/ViewControllers/BlogViewController.m
(limited to 'Juick')
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 @@
+
+
+
@@ -203,7 +206,7 @@
-
+
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
#import "MessagesViewController.h"
-@interface DiscoverViewController : MessagesViewController
+@interface DiscoverViewController : MessagesViewController
@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
+#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
@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 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
--
cgit v1.2.3