From e6fec9707f61b5d521bf1a2e6a85998f2466bdfa Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Thu, 21 Mar 2019 19:28:15 +0300
Subject: Update icons
---
Juick/AppDelegate.m | 2 +-
.../Images.xcassets/ei-bell.imageset/Contents.json | 16 ++
Juick/Images.xcassets/ei-bell.imageset/ei-bell.pdf | Bin 0 -> 4117 bytes
.../ei-clock.imageset/Contents.json | 11 +-
.../ei-comment.imageset/Contents.json | 11 +-
.../ei-envelope.imageset/Contents.json | 11 +-
.../Images.xcassets/ei-gear.imageset/Contents.json | 16 ++
Juick/Images.xcassets/ei-gear.imageset/ei-gear.pdf | Bin 0 -> 4743 bytes
.../ei-heart.imageset/Contents.json | 14 +-
.../Images.xcassets/ei-heart.imageset/ei-heart.pdf | Bin 4113 -> 4041 bytes
.../ei-navicon.imageset/Contents.json | 25 ---
.../ei-navicon.imageset/ei-navicon.pdf | Bin 3905 -> 0 bytes
.../ei-pencil.imageset/Contents.json | 11 +-
.../ei-search.imageset/Contents.json | 16 ++
.../ei-search.imageset/ei-search.pdf | Bin 0 -> 3998 bytes
Juick/Main.storyboard | 207 ++++++++++++++++++---
Juick/ViewControllers/DialogsViewController.m | 1 -
Juick/ViewControllers/DiscoverViewController.h | 14 --
Juick/ViewControllers/DiscoverViewController.m | 159 ----------------
Juick/ViewControllers/FeedViewController.h | 14 ++
Juick/ViewControllers/FeedViewController.m | 154 +++++++++++++++
21 files changed, 407 insertions(+), 275 deletions(-)
create mode 100644 Juick/Images.xcassets/ei-bell.imageset/Contents.json
create mode 100644 Juick/Images.xcassets/ei-bell.imageset/ei-bell.pdf
create mode 100644 Juick/Images.xcassets/ei-gear.imageset/Contents.json
create mode 100644 Juick/Images.xcassets/ei-gear.imageset/ei-gear.pdf
delete mode 100644 Juick/Images.xcassets/ei-navicon.imageset/Contents.json
delete mode 100644 Juick/Images.xcassets/ei-navicon.imageset/ei-navicon.pdf
create mode 100644 Juick/Images.xcassets/ei-search.imageset/Contents.json
create mode 100644 Juick/Images.xcassets/ei-search.imageset/ei-search.pdf
delete mode 100644 Juick/ViewControllers/DiscoverViewController.h
delete mode 100644 Juick/ViewControllers/DiscoverViewController.m
create mode 100644 Juick/ViewControllers/FeedViewController.h
create mode 100644 Juick/ViewControllers/FeedViewController.m
(limited to 'Juick')
diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m
index f1afdc1..b3f544c 100644
--- a/Juick/AppDelegate.m
+++ b/Juick/AppDelegate.m
@@ -16,7 +16,7 @@
#import "User.h"
#import "DeviceRegistration.h"
#import "NewPostViewController.h"
-#import "DiscoverViewController.h"
+#import "FeedViewController.h"
@interface AppDelegate()
-(void) parseNotificationPayload:(NSDictionary *)userInfo;
diff --git a/Juick/Images.xcassets/ei-bell.imageset/Contents.json b/Juick/Images.xcassets/ei-bell.imageset/Contents.json
new file mode 100644
index 0000000..8700d53
--- /dev/null
+++ b/Juick/Images.xcassets/ei-bell.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "ei-bell.pdf"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "properties" : {
+ "template-rendering-intent" : "template",
+ "preserves-vector-representation" : true
+ }
+}
\ No newline at end of file
diff --git a/Juick/Images.xcassets/ei-bell.imageset/ei-bell.pdf b/Juick/Images.xcassets/ei-bell.imageset/ei-bell.pdf
new file mode 100644
index 0000000..6475a0e
Binary files /dev/null and b/Juick/Images.xcassets/ei-bell.imageset/ei-bell.pdf differ
diff --git a/Juick/Images.xcassets/ei-clock.imageset/Contents.json b/Juick/Images.xcassets/ei-clock.imageset/Contents.json
index 5bcd7f5..9ab4b4d 100644
--- a/Juick/Images.xcassets/ei-clock.imageset/Contents.json
+++ b/Juick/Images.xcassets/ei-clock.imageset/Contents.json
@@ -2,16 +2,7 @@
"images" : [
{
"idiom" : "universal",
- "filename" : "ei-clock.pdf",
- "scale" : "1x"
- },
- {
- "idiom" : "universal",
- "scale" : "2x"
- },
- {
- "idiom" : "universal",
- "scale" : "3x"
+ "filename" : "ei-clock.pdf"
}
],
"info" : {
diff --git a/Juick/Images.xcassets/ei-comment.imageset/Contents.json b/Juick/Images.xcassets/ei-comment.imageset/Contents.json
index 6ba09ec..3515f97 100644
--- a/Juick/Images.xcassets/ei-comment.imageset/Contents.json
+++ b/Juick/Images.xcassets/ei-comment.imageset/Contents.json
@@ -2,16 +2,7 @@
"images" : [
{
"idiom" : "universal",
- "filename" : "ei-comment.pdf",
- "scale" : "1x"
- },
- {
- "idiom" : "universal",
- "scale" : "2x"
- },
- {
- "idiom" : "universal",
- "scale" : "3x"
+ "filename" : "ei-comment.pdf"
}
],
"info" : {
diff --git a/Juick/Images.xcassets/ei-envelope.imageset/Contents.json b/Juick/Images.xcassets/ei-envelope.imageset/Contents.json
index 2bba839..6c8816c 100644
--- a/Juick/Images.xcassets/ei-envelope.imageset/Contents.json
+++ b/Juick/Images.xcassets/ei-envelope.imageset/Contents.json
@@ -2,16 +2,7 @@
"images" : [
{
"idiom" : "universal",
- "filename" : "ei-envelope.pdf",
- "scale" : "1x"
- },
- {
- "idiom" : "universal",
- "scale" : "2x"
- },
- {
- "idiom" : "universal",
- "scale" : "3x"
+ "filename" : "ei-envelope.pdf"
}
],
"info" : {
diff --git a/Juick/Images.xcassets/ei-gear.imageset/Contents.json b/Juick/Images.xcassets/ei-gear.imageset/Contents.json
new file mode 100644
index 0000000..1154fdc
--- /dev/null
+++ b/Juick/Images.xcassets/ei-gear.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "ei-gear.pdf"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "properties" : {
+ "template-rendering-intent" : "template",
+ "preserves-vector-representation" : true
+ }
+}
\ No newline at end of file
diff --git a/Juick/Images.xcassets/ei-gear.imageset/ei-gear.pdf b/Juick/Images.xcassets/ei-gear.imageset/ei-gear.pdf
new file mode 100644
index 0000000..ab634d0
Binary files /dev/null and b/Juick/Images.xcassets/ei-gear.imageset/ei-gear.pdf differ
diff --git a/Juick/Images.xcassets/ei-heart.imageset/Contents.json b/Juick/Images.xcassets/ei-heart.imageset/Contents.json
index 07b3f90..6f2d978 100644
--- a/Juick/Images.xcassets/ei-heart.imageset/Contents.json
+++ b/Juick/Images.xcassets/ei-heart.imageset/Contents.json
@@ -2,16 +2,7 @@
"images" : [
{
"idiom" : "universal",
- "filename" : "ei-heart.pdf",
- "scale" : "1x"
- },
- {
- "idiom" : "universal",
- "scale" : "2x"
- },
- {
- "idiom" : "universal",
- "scale" : "3x"
+ "filename" : "ei-heart.pdf"
}
],
"info" : {
@@ -20,7 +11,6 @@
},
"properties" : {
"template-rendering-intent" : "template",
- "preserves-vector-representation" : true,
- "auto-scaling" : "auto"
+ "preserves-vector-representation" : true
}
}
\ No newline at end of file
diff --git a/Juick/Images.xcassets/ei-heart.imageset/ei-heart.pdf b/Juick/Images.xcassets/ei-heart.imageset/ei-heart.pdf
index ec617c0..8aafcd3 100644
Binary files a/Juick/Images.xcassets/ei-heart.imageset/ei-heart.pdf and b/Juick/Images.xcassets/ei-heart.imageset/ei-heart.pdf differ
diff --git a/Juick/Images.xcassets/ei-navicon.imageset/Contents.json b/Juick/Images.xcassets/ei-navicon.imageset/Contents.json
deleted file mode 100644
index b3ccd62..0000000
--- a/Juick/Images.xcassets/ei-navicon.imageset/Contents.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "images" : [
- {
- "idiom" : "universal",
- "filename" : "ei-navicon.pdf",
- "scale" : "1x"
- },
- {
- "idiom" : "universal",
- "scale" : "2x"
- },
- {
- "idiom" : "universal",
- "scale" : "3x"
- }
- ],
- "info" : {
- "version" : 1,
- "author" : "xcode"
- },
- "properties" : {
- "template-rendering-intent" : "template",
- "preserves-vector-representation" : true
- }
-}
\ No newline at end of file
diff --git a/Juick/Images.xcassets/ei-navicon.imageset/ei-navicon.pdf b/Juick/Images.xcassets/ei-navicon.imageset/ei-navicon.pdf
deleted file mode 100644
index c0a7d57..0000000
Binary files a/Juick/Images.xcassets/ei-navicon.imageset/ei-navicon.pdf and /dev/null differ
diff --git a/Juick/Images.xcassets/ei-pencil.imageset/Contents.json b/Juick/Images.xcassets/ei-pencil.imageset/Contents.json
index 9d27319..346053c 100644
--- a/Juick/Images.xcassets/ei-pencil.imageset/Contents.json
+++ b/Juick/Images.xcassets/ei-pencil.imageset/Contents.json
@@ -2,16 +2,7 @@
"images" : [
{
"idiom" : "universal",
- "filename" : "ei-pencil.pdf",
- "scale" : "1x"
- },
- {
- "idiom" : "universal",
- "scale" : "2x"
- },
- {
- "idiom" : "universal",
- "scale" : "3x"
+ "filename" : "ei-pencil.pdf"
}
],
"info" : {
diff --git a/Juick/Images.xcassets/ei-search.imageset/Contents.json b/Juick/Images.xcassets/ei-search.imageset/Contents.json
new file mode 100644
index 0000000..35807dd
--- /dev/null
+++ b/Juick/Images.xcassets/ei-search.imageset/Contents.json
@@ -0,0 +1,16 @@
+{
+ "images" : [
+ {
+ "idiom" : "universal",
+ "filename" : "ei-search.pdf"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "properties" : {
+ "template-rendering-intent" : "template",
+ "preserves-vector-representation" : true
+ }
+}
\ No newline at end of file
diff --git a/Juick/Images.xcassets/ei-search.imageset/ei-search.pdf b/Juick/Images.xcassets/ei-search.imageset/ei-search.pdf
new file mode 100644
index 0000000..6b57d81
Binary files /dev/null and b/Juick/Images.xcassets/ei-search.imageset/ei-search.pdf differ
diff --git a/Juick/Main.storyboard b/Juick/Main.storyboard
index e04800c..68df202 100644
--- a/Juick/Main.storyboard
+++ b/Juick/Main.storyboard
@@ -40,13 +40,15 @@
-
+
-
+
+
+
@@ -58,12 +60,12 @@
-
+
-
+
-
+
@@ -86,15 +88,12 @@
-
+
+
+
-
-
-
-
-
-
+
@@ -106,7 +105,7 @@
-
+
@@ -123,7 +122,7 @@
-
+
@@ -203,10 +202,10 @@
-
+
-
+
@@ -236,7 +235,9 @@
-
+
+
+
@@ -275,7 +276,10 @@
-
+
+
+
+
@@ -330,7 +334,7 @@
-
+
@@ -359,7 +363,65 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -373,18 +435,117 @@
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
diff --git a/Juick/ViewControllers/DialogsViewController.m b/Juick/ViewControllers/DialogsViewController.m
index c4ace7f..1f9f8e0 100644
--- a/Juick/ViewControllers/DialogsViewController.m
+++ b/Juick/ViewControllers/DialogsViewController.m
@@ -16,7 +16,6 @@
@implementation DialogsViewController
- (void)viewDidLoad {
[super viewDidLoad];
- [self.tabBarItem setTitle:@"Chats"];
self.navigationController.visibleViewController.navigationItem.title = @"Chats";
[self.view setBackgroundColor:[ColorScheme mainBackground]];
[self.tableView registerNib:[UINib nibWithNibName:@"ConversationCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"notificationCell"];
diff --git a/Juick/ViewControllers/DiscoverViewController.h b/Juick/ViewControllers/DiscoverViewController.h
deleted file mode 100644
index bb34d5e..0000000
--- a/Juick/ViewControllers/DiscoverViewController.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//
-// DiscoverViewController.h
-// Juick
-//
-// Created by Vitaly Takmazov on 03/12/2017.
-// Copyright © 2017 com.juick. All rights reserved.
-//
-
-#import
-#import "MessagesViewController.h"
-
-@interface DiscoverViewController : MessagesViewController
-
-@end
diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m
deleted file mode 100644
index 94e1d16..0000000
--- a/Juick/ViewControllers/DiscoverViewController.m
+++ /dev/null
@@ -1,159 +0,0 @@
-//
-// DiscoverViewController.m
-// Juick
-//
-// Created by Vitaly Takmazov on 03/12/2017.
-// Copyright © 2017 com.juick. All rights reserved.
-//
-
-#import "DiscoverViewController.h"
-#import "ThreadViewController.h"
-#import "BlogViewController.h"
-#import "MessageCell.h"
-#import "APIClient.h"
-#import "AppDelegate.h"
-#import "ColorScheme.h"
-
-@interface DiscoverViewController ()
-
-@property NSString *selectedUser;
-@end
-
-@implementation DiscoverViewController
-
--(void) viewDidLoad {
- self.messagesDelegate = self;
- if ([[APIClient sharedClient] isAuthenticated]) {
- [[APIClient sharedClient] authenticate:^(User *user, NSError *error) {
- if (user) {
- if ([self.path length] == 0) {
- self.path = [APIClient feedUrl];
- [self.tabBarItem setTitle:@"My feed"];
- self.navigationController.visibleViewController.navigationItem.title = @"My feed";
- }
- [self setShouldScrollToBottomOnRefresh:NO];
- [self refreshData];
- } else {
- [User throwUnableToLogin:self error:error];
- }
- }];
-
- } else {
- if ([self.path length] == 0) {
- self.path = [APIClient messagesUrl];
- [self.tabBarItem setTitle:@"Discover"];
- self.navigationController.visibleViewController.navigationItem.title = @"Discover";
- }
- [self setShouldScrollToBottomOnRefresh:NO];
- [self refreshData];
- }
- [super viewDidLoad];
-}
-
--(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- NSString * cellIdentifier = @"messageCell";
- MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
- [self performSegueWithIdentifier:@"threadViewSegue" sender:cell];
-}
-- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- if (!self.dataLoading) {
- MessageCell *cell = (MessageCell *)[super tableView:tableView cellForRowAtIndexPath:indexPath];
- cell.delegate = self;
- return cell;
- } else {
- return [super tableView:tableView cellForRowAtIndexPath:indexPath];
- }
-}
-
--(void)avatarClicked:(NSString *)uname {
- self.selectedUser = uname;
- [self performSegueWithIdentifier:@"profileSegue" sender:self];
-}
-
--(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- if ([segue.identifier isEqual: @"threadViewSegue"]) {
- NSNumber *mid;
- BOOL scrollToEnd = NO;
- if ([AppDelegate shared].pushedThread != nil) {
- mid = [[AppDelegate shared].pushedThread copy];
- [AppDelegate shared].pushedThread = nil;
- [AppDelegate shared].pushedUname = nil;
- scrollToEnd = YES;
- } else {
- Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row];
- mid = msg.mid;
- }
- if ([mid integerValue] > 0) {
- ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController;
- [threadVC setPath:[APIClient threadUrl]];
- [threadVC setParams:@{@"mid": mid }];
- [threadVC setShouldScrollToBottomOnRefresh: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 setShouldScrollToBottomOnRefresh:NO];
- }
-}
-- (IBAction)filterAction:(id)sender {
- if (![[APIClient sharedClient] isAuthenticated]) {
- [self.navigationController performSegueWithIdentifier:@"loginSegue" sender:self.navigationController];
- return;
- }
- UIAlertController *filterAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
- [filterAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
- [filterAlert addAction:[UIAlertAction actionWithTitle:@"My feed" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- self.path = [APIClient feedUrl];
- [self.tabBarItem setTitle:@"My feed"];
- self.navigationController.visibleViewController.navigationItem.title = @"My feed";
- self.params = nil;
- [self.messages removeAllObjects];
- [self.tableView reloadData];
- [self setShouldScrollToBottomOnRefresh:NO];
- }]];
- [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discover" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- self.path = [APIClient messagesUrl];
- [self.tabBarItem setTitle:@"Discover"];
- self.navigationController.visibleViewController.navigationItem.title = @"Discover";
- self.params = nil;
- [self.messages removeAllObjects];
- [self.tableView reloadData];
- [self setShouldScrollToBottomOnRefresh:NO];
- }]];
- [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discussions" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
- self.path = [APIClient discussionsUrl];
- [self.tabBarItem setTitle:@"Discussions"];
- self.navigationController.visibleViewController.navigationItem.title = @"Discussions";
- self.params = nil;
- [self.messages removeAllObjects];
- [self.tableView reloadData];
- [self setShouldScrollToBottomOnRefresh:NO];
- }]];
- [filterAlert.view setTintColor:[ColorScheme linkColor]];
- UIPopoverPresentationController *popover = [filterAlert popoverPresentationController];
- if (popover) {
- popover.sourceView = self.view;
- popover.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds), 0, 0);
- popover.permittedArrowDirections = UIPopoverArrowDirectionUp;
- }
- [self presentViewController:filterAlert animated:YES completion:nil];
-}
-
--(void) loadMore {
- Message *lastMsg = [self.messages lastObject];
- if (lastMsg != nil) {
- if ([self.path isEqualToString:[APIClient discussionsUrl]]) {
- NSDate *msgDate = [[APIClient sharedClient].dateFormatter dateFromString:lastMsg.timestamp];
- self.params = [@{@"to" : [NSString stringWithFormat:@"%.0f", [msgDate timeIntervalSince1970] * 1000]} mutableCopy];
- } else if (![self.path isEqualToString:[APIClient threadUrl]]) {
- NSNumber *lastMid = lastMsg.mid;
- self.params = [@{@"before_mid":lastMid} mutableCopy];
- }
- [self setShouldScrollToBottomOnRefresh:NO];
- }
-}
-
-@end
diff --git a/Juick/ViewControllers/FeedViewController.h b/Juick/ViewControllers/FeedViewController.h
new file mode 100644
index 0000000..76388aa
--- /dev/null
+++ b/Juick/ViewControllers/FeedViewController.h
@@ -0,0 +1,14 @@
+//
+// DiscoverViewController.h
+// Juick
+//
+// Created by Vitaly Takmazov on 03/12/2017.
+// Copyright © 2017 com.juick. All rights reserved.
+//
+
+#import
+#import "MessagesViewController.h"
+
+@interface FeedViewController : MessagesViewController
+
+@end
diff --git a/Juick/ViewControllers/FeedViewController.m b/Juick/ViewControllers/FeedViewController.m
new file mode 100644
index 0000000..67d80e1
--- /dev/null
+++ b/Juick/ViewControllers/FeedViewController.m
@@ -0,0 +1,154 @@
+//
+// DiscoverViewController.m
+// Juick
+//
+// Created by Vitaly Takmazov on 03/12/2017.
+// Copyright © 2017 com.juick. All rights reserved.
+//
+
+#import "FeedViewController.h"
+#import "ThreadViewController.h"
+#import "BlogViewController.h"
+#import "MessageCell.h"
+#import "APIClient.h"
+#import "AppDelegate.h"
+#import "ColorScheme.h"
+
+@interface FeedViewController ()
+
+@property NSString *selectedUser;
+@end
+
+@implementation FeedViewController
+
+-(void) viewDidLoad {
+ self.messagesDelegate = self;
+ if ([[APIClient sharedClient] isAuthenticated]) {
+ [[APIClient sharedClient] authenticate:^(User *user, NSError *error) {
+ if (user) {
+ if ([self.path length] == 0) {
+ self.path = [APIClient feedUrl];
+ self.navigationController.visibleViewController.navigationItem.title = @"My feed";
+ }
+ [self setShouldScrollToBottomOnRefresh:NO];
+ [self refreshData];
+ } else {
+ [User throwUnableToLogin:self error:error];
+ }
+ }];
+
+ } else {
+ if ([self.path length] == 0) {
+ self.path = [APIClient messagesUrl];
+ self.navigationController.visibleViewController.navigationItem.title = @"Discover";
+ }
+ [self setShouldScrollToBottomOnRefresh:NO];
+ [self refreshData];
+ }
+ [super viewDidLoad];
+}
+
+-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+ NSString * cellIdentifier = @"messageCell";
+ MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
+ [self performSegueWithIdentifier:@"threadViewSegue" sender:cell];
+}
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+ if (!self.dataLoading) {
+ MessageCell *cell = (MessageCell *)[super tableView:tableView cellForRowAtIndexPath:indexPath];
+ cell.delegate = self;
+ return cell;
+ } else {
+ return [super tableView:tableView cellForRowAtIndexPath:indexPath];
+ }
+}
+
+-(void)avatarClicked:(NSString *)uname {
+ self.selectedUser = uname;
+ [self performSegueWithIdentifier:@"profileSegue" sender:self];
+}
+
+-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+ if ([segue.identifier isEqual: @"threadViewSegue"]) {
+ NSNumber *mid;
+ BOOL scrollToEnd = NO;
+ if ([AppDelegate shared].pushedThread != nil) {
+ mid = [[AppDelegate shared].pushedThread copy];
+ [AppDelegate shared].pushedThread = nil;
+ [AppDelegate shared].pushedUname = nil;
+ scrollToEnd = YES;
+ } else {
+ Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row];
+ mid = msg.mid;
+ }
+ if ([mid integerValue] > 0) {
+ ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController;
+ [threadVC setPath:[APIClient threadUrl]];
+ [threadVC setParams:@{@"mid": mid }];
+ [threadVC setShouldScrollToBottomOnRefresh: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 setShouldScrollToBottomOnRefresh:NO];
+ }
+}
+- (IBAction)filterAction:(id)sender {
+ if (![[APIClient sharedClient] isAuthenticated]) {
+ [self.navigationController performSegueWithIdentifier:@"loginSegue" sender:self.navigationController];
+ return;
+ }
+ UIAlertController *filterAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
+ [filterAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
+ [filterAlert addAction:[UIAlertAction actionWithTitle:@"My feed" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+ self.path = [APIClient feedUrl];
+ self.navigationController.visibleViewController.navigationItem.title = @"My feed";
+ self.params = nil;
+ [self.messages removeAllObjects];
+ [self.tableView reloadData];
+ [self setShouldScrollToBottomOnRefresh:NO];
+ }]];
+ [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discover" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+ self.path = [APIClient messagesUrl];
+ self.navigationController.visibleViewController.navigationItem.title = @"Discover";
+ self.params = nil;
+ [self.messages removeAllObjects];
+ [self.tableView reloadData];
+ [self setShouldScrollToBottomOnRefresh:NO];
+ }]];
+ [filterAlert addAction:[UIAlertAction actionWithTitle:@"Discussions" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+ self.path = [APIClient discussionsUrl];
+ self.navigationController.visibleViewController.navigationItem.title = @"Discussions";
+ self.params = nil;
+ [self.messages removeAllObjects];
+ [self.tableView reloadData];
+ [self setShouldScrollToBottomOnRefresh:NO];
+ }]];
+ [filterAlert.view setTintColor:[ColorScheme linkColor]];
+ UIPopoverPresentationController *popover = [filterAlert popoverPresentationController];
+ if (popover) {
+ popover.sourceView = self.view;
+ popover.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds), 0, 0);
+ popover.permittedArrowDirections = UIPopoverArrowDirectionUp;
+ }
+ [self presentViewController:filterAlert animated:YES completion:nil];
+}
+
+-(void) loadMore {
+ Message *lastMsg = [self.messages lastObject];
+ if (lastMsg != nil) {
+ if ([self.path isEqualToString:[APIClient discussionsUrl]]) {
+ NSDate *msgDate = [[APIClient sharedClient].dateFormatter dateFromString:lastMsg.timestamp];
+ self.params = [@{@"to" : [NSString stringWithFormat:@"%.0f", [msgDate timeIntervalSince1970] * 1000]} mutableCopy];
+ } else if (![self.path isEqualToString:[APIClient threadUrl]]) {
+ NSNumber *lastMid = lastMsg.mid;
+ self.params = [@{@"before_mid":lastMid} mutableCopy];
+ }
+ [self setShouldScrollToBottomOnRefresh:NO];
+ }
+}
+
+@end
--
cgit v1.2.3