summaryrefslogtreecommitdiff
path: root/Juick/ViewControllers
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-12-03 12:15:52 +0300
committerGravatar Vitaly Takmazov2017-12-03 12:15:52 +0300
commitdc73ee639bc902b7ef93cfa86630fa4ada758397 (patch)
tree866295247dc121f6b70673ef21ef85feeaff9b32 /Juick/ViewControllers
parent3ded167cf5bd443e98015523614624225169ee6f (diff)
Thread View
Diffstat (limited to 'Juick/ViewControllers')
-rw-r--r--Juick/ViewControllers/MessagesViewController.h3
-rw-r--r--Juick/ViewControllers/MessagesViewController.m31
-rw-r--r--Juick/ViewControllers/ThreadViewController.h5
-rw-r--r--Juick/ViewControllers/ThreadViewController.m13
4 files changed, 24 insertions, 28 deletions
diff --git a/Juick/ViewControllers/MessagesViewController.h b/Juick/ViewControllers/MessagesViewController.h
index fc3545a..33b86b6 100644
--- a/Juick/ViewControllers/MessagesViewController.h
+++ b/Juick/ViewControllers/MessagesViewController.h
@@ -7,9 +7,8 @@
//
#import <UIKit/UIKit.h>
-@import PHFComposeBarView;
-@interface MessagesViewController : UITableViewController<PHFComposeBarViewDelegate>
+@interface MessagesViewController : UITableViewController
@property(nonatomic, strong) NSString *path;
@property(nonatomic, strong) NSMutableDictionary *params;
- (void) refreshData;
diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m
index b91f056..5a1521d 100644
--- a/Juick/ViewControllers/MessagesViewController.m
+++ b/Juick/ViewControllers/MessagesViewController.m
@@ -69,16 +69,18 @@
self.dataLoading = NO;
[self.view setBackgroundColor:[ColorScheme mainBackground]];
+ [self.tableView registerNib:[UINib nibWithNibName:@"MessageCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"messageCell"];
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 500.0f;
self.messages = [NSMutableArray array];
- self.params = [NSMutableDictionary new];
self.refreshControl = [UIRefreshControl new];
[self.refreshControl addTarget:self action:@selector(refreshData) forControlEvents:UIControlEventValueChanged];
if ([User isAuthenticated]) {
[User checkIsValid:^(BOOL success) {
if (success) {
- self.path = [APIClient feedUrl];
+ if ([self.path length] == 0) {
+ self.path = [APIClient feedUrl];
+ }
[self refreshData];
} else {
[User throwUnableToLogin:self];
@@ -86,7 +88,9 @@
}];
} else {
- self.path = [APIClient messagesUrl];
+ if ([self.path length] == 0) {
+ self.path = [APIClient messagesUrl];
+ }
[self refreshData];
}
}
@@ -111,14 +115,19 @@
return cell;
}
-- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- if ([self.path isEqualToString:[APIClient threadUrl]])
- return;
- Message *msg = [self.messages objectAtIndex:indexPath.row];
- ThreadViewController *threadViewController = [[ThreadViewController alloc] init];
- [threadViewController setPath:[APIClient threadUrl]];
- [threadViewController setParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:msg.mid, @"mid", nil]];
- [self.navigationController pushViewController:threadViewController animated:NO];
+-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+ NSString * cellIdentifier = @"messageCell";
+ MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
+ [self performSegueWithIdentifier:@"threadViewSegue" sender:cell];
+}
+
+-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
+ if ([segue.identifier isEqual: @"threadViewSegue"]) {
+ Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row];
+ ThreadViewController *threadVC = (ThreadViewController *)segue.destinationViewController;
+ [threadVC setPath:[APIClient threadUrl]];
+ [threadVC setParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:msg.mid, @"mid", nil]];
+ }
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView_ {
diff --git a/Juick/ViewControllers/ThreadViewController.h b/Juick/ViewControllers/ThreadViewController.h
index 3f2b59c..484e2fb 100644
--- a/Juick/ViewControllers/ThreadViewController.h
+++ b/Juick/ViewControllers/ThreadViewController.h
@@ -7,9 +7,8 @@
//
#import <UIKit/UIKit.h>
+#include "MessagesViewController.h"
@import PHFComposeBarView;
-@interface ThreadViewController : UITableViewController<PHFComposeBarViewDelegate>
-@property(nonatomic, strong) NSString *path;
-@property(nonatomic, strong) NSMutableDictionary *params;
+@interface ThreadViewController : MessagesViewController<PHFComposeBarViewDelegate>
@end
diff --git a/Juick/ViewControllers/ThreadViewController.m b/Juick/ViewControllers/ThreadViewController.m
index 2ee4af5..893765b 100644
--- a/Juick/ViewControllers/ThreadViewController.m
+++ b/Juick/ViewControllers/ThreadViewController.m
@@ -8,6 +8,7 @@
#import "ThreadViewController.h"
#import "ColorScheme.h"
+#import "MessageCell.h"
@interface ThreadViewController ()
@@ -27,18 +28,6 @@
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
-#pragma mark - Table view data source
-
-- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
-#warning Incomplete implementation, return the number of sections
- return 0;
-}
-
-- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-#warning Incomplete implementation, return the number of rows
- return 0;
-}
-
- (BOOL) canBecomeFirstResponder {
return YES;