From 95f73b34319b62df320dcaa43e9c7925dc4868df Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 3 Dec 2017 12:55:50 +0300 Subject: Refactor --- Juick/Main.storyboard | 4 +-- Juick/Supporting Files/Juick-Info.plist | 2 +- Juick/ViewControllers/DiscoverViewController.h | 14 ++++++++++ Juick/ViewControllers/DiscoverViewController.m | 37 ++++++++++++++++++++++++++ Juick/ViewControllers/MessagesViewController.h | 3 +++ Juick/ViewControllers/MessagesViewController.m | 21 --------------- 6 files changed, 57 insertions(+), 24 deletions(-) create mode 100644 Juick/ViewControllers/DiscoverViewController.h create mode 100644 Juick/ViewControllers/DiscoverViewController.m (limited to 'Juick') diff --git a/Juick/Main.storyboard b/Juick/Main.storyboard index 600b5ea..20bd3eb 100644 --- a/Juick/Main.storyboard +++ b/Juick/Main.storyboard @@ -63,13 +63,13 @@ - + - + diff --git a/Juick/Supporting Files/Juick-Info.plist b/Juick/Supporting Files/Juick-Info.plist index d9325fa..c6816d5 100644 --- a/Juick/Supporting Files/Juick-Info.plist +++ b/Juick/Supporting Files/Juick-Info.plist @@ -21,7 +21,7 @@ CFBundleSignature ???? CFBundleVersion - 1.0.21 + 1.0.22 ITSAppUsesNonExemptEncryption LSApplicationCategoryType diff --git a/Juick/ViewControllers/DiscoverViewController.h b/Juick/ViewControllers/DiscoverViewController.h new file mode 100644 index 0000000..6bec23d --- /dev/null +++ b/Juick/ViewControllers/DiscoverViewController.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 DiscoverViewController : MessagesViewController + +@end diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m new file mode 100644 index 0000000..4b22979 --- /dev/null +++ b/Juick/ViewControllers/DiscoverViewController.m @@ -0,0 +1,37 @@ +// +// 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 "MessageCell.h" +#import "APIClient.h" + +@interface DiscoverViewController () + +@end + +@implementation DiscoverViewController + + + +-(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]]; + } +} + +@end diff --git a/Juick/ViewControllers/MessagesViewController.h b/Juick/ViewControllers/MessagesViewController.h index 33b86b6..7f5f274 100644 --- a/Juick/ViewControllers/MessagesViewController.h +++ b/Juick/ViewControllers/MessagesViewController.h @@ -12,4 +12,7 @@ @property(nonatomic, strong) NSString *path; @property(nonatomic, strong) NSMutableDictionary *params; - (void) refreshData; + +@property(nonatomic, strong) NSMutableArray *messages; +@property(nonatomic, assign) Boolean dataLoading; @end diff --git a/Juick/ViewControllers/MessagesViewController.m b/Juick/ViewControllers/MessagesViewController.m index 5a1521d..5a5a794 100644 --- a/Juick/ViewControllers/MessagesViewController.m +++ b/Juick/ViewControllers/MessagesViewController.m @@ -21,12 +21,6 @@ #import "NSURL+PathParameters.h" -@interface MessagesViewController () - -@property(nonatomic, strong) NSMutableArray *messages; -@property(nonatomic, assign) Boolean dataLoading; -@end - @implementation MessagesViewController - (void) refreshData { @@ -115,21 +109,6 @@ return cell; } --(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_ { CGFloat actualPosition = scrollView_.contentOffset.y; CGFloat contentHeight = scrollView_.contentSize.height - scrollView_.contentSize.height / 2; -- cgit v1.2.3