diff options
author | Vitaly Takmazov | 2017-12-03 12:55:50 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-12-03 12:55:50 +0300 |
commit | 95f73b34319b62df320dcaa43e9c7925dc4868df (patch) | |
tree | a4905d9b7423817528c24a187a26c46e65f0228e | |
parent | dc73ee639bc902b7ef93cfa86630fa4ada758397 (diff) |
Refactor
-rw-r--r-- | Juick.xcodeproj/project.pbxproj | 6 | ||||
-rw-r--r-- | Juick/Main.storyboard | 4 | ||||
-rw-r--r-- | Juick/Supporting Files/Juick-Info.plist | 2 | ||||
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.h | 14 | ||||
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.m | 37 | ||||
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.h | 3 | ||||
-rw-r--r-- | Juick/ViewControllers/MessagesViewController.m | 21 |
7 files changed, 63 insertions, 24 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index aa2fdf3..f97e69d 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -32,6 +32,7 @@ 774528C51F93AC0F004D110B /* CoreDataStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 774528C41F93AC0F004D110B /* CoreDataStack.m */; }; 776C41BD1FD3EF180063B82E /* MessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 776C41BB1FD3EF180063B82E /* MessageCell.m */; }; 776C41BE1FD3EF180063B82E /* MessageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 776C41BC1FD3EF180063B82E /* MessageCell.xib */; }; + 776C41C11FD3FF6E0063B82E /* DiscoverViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 776C41C01FD3FF6E0063B82E /* DiscoverViewController.m */; }; 77975A1D182B6E9A00410C2B /* NewPostViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77975A1C182B6E9A00410C2B /* NewPostViewController.m */; }; 77975A1F182BDCE900410C2B /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77975A1E182BDCE900410C2B /* SystemConfiguration.framework */; }; 77975A21182BDCF300410C2B /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77975A20182BDCF300410C2B /* MobileCoreServices.framework */; }; @@ -95,6 +96,8 @@ 776C41BA1FD3EF180063B82E /* MessageCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageCell.h; sourceTree = "<group>"; }; 776C41BB1FD3EF180063B82E /* MessageCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageCell.m; sourceTree = "<group>"; }; 776C41BC1FD3EF180063B82E /* MessageCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MessageCell.xib; sourceTree = "<group>"; }; + 776C41BF1FD3FF6E0063B82E /* DiscoverViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DiscoverViewController.h; sourceTree = "<group>"; }; + 776C41C01FD3FF6E0063B82E /* DiscoverViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DiscoverViewController.m; sourceTree = "<group>"; }; 77975A1B182B6E9A00410C2B /* NewPostViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewPostViewController.h; sourceTree = "<group>"; }; 77975A1C182B6E9A00410C2B /* NewPostViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewPostViewController.m; sourceTree = "<group>"; }; 77975A1E182BDCE900410C2B /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; @@ -275,6 +278,8 @@ 77975A1C182B6E9A00410C2B /* NewPostViewController.m */, 77C6ADE21F7717BC000AEA8C /* ThreadViewController.h */, 77C6ADE31F7717BC000AEA8C /* ThreadViewController.m */, + 776C41BF1FD3FF6E0063B82E /* DiscoverViewController.h */, + 776C41C01FD3FF6E0063B82E /* DiscoverViewController.m */, ); path = ViewControllers; sourceTree = "<group>"; @@ -512,6 +517,7 @@ buildActionMask = 2147483647; files = ( 77317BBC181BBE8500D60005 /* AppDelegate.m in Sources */, + 776C41C11FD3FF6E0063B82E /* DiscoverViewController.m in Sources */, 77FCADDF1D6A50DA00CBA649 /* APIClient.m in Sources */, 77A0954A181F1F25002BDECD /* Message.m in Sources */, 774528C51F93AC0F004D110B /* CoreDataStack.m in Sources */, 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 @@ <!--Discover--> <scene sceneID="uvH-u9-x7X"> <objects> - <tableViewController title="Discover" id="VCH-GK-jaH" customClass="MessagesViewController" sceneMemberID="viewController"> + <tableViewController title="Discover" id="VCH-GK-jaH" customClass="DiscoverViewController" sceneMemberID="viewController"> <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" id="tbe-Zb-PfB"> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <prototypes> - <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="Orz-mD-PnE"> + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="blue" accessoryType="disclosureIndicator" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="prototypeMessage" id="Orz-mD-PnE"> <rect key="frame" x="0.0" y="28" width="375" height="44"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Orz-mD-PnE" id="WRd-ev-Osb"> 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 @@ <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>1.0.21</string> + <string>1.0.22</string> <key>ITSAppUsesNonExemptEncryption</key> <false/> <key>LSApplicationCategoryType</key> 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 <UIKit/UIKit.h> +#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; |