From dc73ee639bc902b7ef93cfa86630fa4ada758397 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 3 Dec 2017 12:15:52 +0300 Subject: Thread View --- Juick.xcodeproj/project.pbxproj | 16 +-- Juick/Main.storyboard | 142 +++++++------------------ Juick/ViewControllers/MessagesViewController.h | 3 +- Juick/ViewControllers/MessagesViewController.m | 31 ++++-- Juick/ViewControllers/ThreadViewController.h | 5 +- Juick/ViewControllers/ThreadViewController.m | 13 +-- Juick/Views/MessageCell.h | 4 +- Juick/Views/MessageCell.m | 10 +- Juick/Views/MessageCell.xib | 123 +++++++++++++++++++++ 9 files changed, 200 insertions(+), 147 deletions(-) create mode 100644 Juick/Views/MessageCell.xib diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index a026387..aa2fdf3 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -30,6 +30,8 @@ 77418CBD182FB9B6004111B7 /* ImageIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77418CBC182FB9B6004111B7 /* ImageIO.framework */; }; 774528C21F930C06004D110B /* Attachment.m in Sources */ = {isa = PBXBuildFile; fileRef = 774528C11F930C06004D110B /* Attachment.m */; }; 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 */; }; 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 */; }; @@ -44,7 +46,6 @@ 77C6ADE41F7717BC000AEA8C /* ThreadViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C6ADE31F7717BC000AEA8C /* ThreadViewController.m */; }; 77E35A82189A5B5A00B2D216 /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E35A81189A5B5A00B2D216 /* LoginViewController.m */; }; 77FCADDF1D6A50DA00CBA649 /* APIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 77FCADDE1D6A50DA00CBA649 /* APIClient.m */; }; - 77FFC0191D5FD186003BD81A /* MessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 77FFC0171D5FD186003BD81A /* MessageCell.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -91,6 +92,9 @@ 774528C91F93EE83004D110B /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; }; 774528CB1F93EE9F004D110B /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; 774528CD1F96B39C004D110B /* Juick.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Juick.entitlements; sourceTree = ""; }; + 776C41BA1FD3EF180063B82E /* MessageCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageCell.h; sourceTree = ""; }; + 776C41BB1FD3EF180063B82E /* MessageCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageCell.m; sourceTree = ""; }; + 776C41BC1FD3EF180063B82E /* MessageCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MessageCell.xib; sourceTree = ""; }; 77975A1B182B6E9A00410C2B /* NewPostViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewPostViewController.h; sourceTree = ""; }; 77975A1C182B6E9A00410C2B /* NewPostViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NewPostViewController.m; sourceTree = ""; }; 77975A1E182BDCE900410C2B /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; @@ -114,8 +118,6 @@ 77E35A81189A5B5A00B2D216 /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = ""; }; 77FCADDE1D6A50DA00CBA649 /* APIClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIClient.m; sourceTree = ""; }; 77FCADE01D6A50EC00CBA649 /* APIClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APIClient.h; sourceTree = ""; }; - 77FFC0161D5FD186003BD81A /* MessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageCell.h; sourceTree = ""; }; - 77FFC0171D5FD186003BD81A /* MessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageCell.m; sourceTree = ""; }; 9FF4AA695CB46B0E7AED628D /* Pods_JuickTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_JuickTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B3271B16DFB6247972806713 /* Pods-Juick.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Juick.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Juick/Pods-Juick.debug.xcconfig"; sourceTree = ""; }; EE63D145DADD14AE17A58456 /* Pods_Juick.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Juick.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -293,8 +295,9 @@ 77FFC0151D5FD13C003BD81A /* Views */ = { isa = PBXGroup; children = ( - 77FFC0161D5FD186003BD81A /* MessageCell.h */, - 77FFC0171D5FD186003BD81A /* MessageCell.m */, + 776C41BA1FD3EF180063B82E /* MessageCell.h */, + 776C41BB1FD3EF180063B82E /* MessageCell.m */, + 776C41BC1FD3EF180063B82E /* MessageCell.xib */, ); path = Views; sourceTree = ""; @@ -401,6 +404,7 @@ 773F23391F76ED5E00B5B0DF /* Splash@3x.png in Resources */, 77C6ADDE1F770EB2000AEA8C /* Main.storyboard in Resources */, 773F23381F76ED5E00B5B0DF /* Splash@2x.png in Resources */, + 776C41BE1FD3EF180063B82E /* MessageCell.xib in Resources */, 773F23371F76ED5E00B5B0DF /* Splash.png in Resources */, 773F231C1F76DD0B00B5B0DF /* SerpentineBoldItalic.ttf in Resources */, 77317BB6181BBE8500D60005 /* InfoPlist.strings in Resources */, @@ -518,8 +522,8 @@ 77975A1D182B6E9A00410C2B /* NewPostViewController.m in Sources */, 77C67EE81828379700427098 /* ColorScheme.m in Sources */, 77C67EE51828342000427098 /* NSURL+PathParameters.m in Sources */, - 77FFC0191D5FD186003BD81A /* MessageCell.m in Sources */, 77E35A82189A5B5A00B2D216 /* LoginViewController.m in Sources */, + 776C41BD1FD3EF180063B82E /* MessageCell.m in Sources */, 77317BB8181BBE8500D60005 /* main.m in Sources */, 774528C21F930C06004D110B /* Attachment.m in Sources */, ); diff --git a/Juick/Main.storyboard b/Juick/Main.storyboard index 201ee3a..600b5ea 100644 --- a/Juick/Main.storyboard +++ b/Juick/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -31,6 +31,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -40,114 +69,15 @@ - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 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 -@import PHFComposeBarView; -@interface MessagesViewController : UITableViewController +@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 +#include "MessagesViewController.h" @import PHFComposeBarView; -@interface ThreadViewController : UITableViewController -@property(nonatomic, strong) NSString *path; -@property(nonatomic, strong) NSMutableDictionary *params; +@interface ThreadViewController : MessagesViewController @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; diff --git a/Juick/Views/MessageCell.h b/Juick/Views/MessageCell.h index 92345d6..737ec89 100644 --- a/Juick/Views/MessageCell.h +++ b/Juick/Views/MessageCell.h @@ -2,8 +2,8 @@ // MessageCell.h // Juick // -// Created by Vitaly Takmazov on 14/08/16. -// Copyright © 2016 com.juick. All rights reserved. +// Created by Vitaly Takmazov on 03/12/2017. +// Copyright © 2017 com.juick. All rights reserved. // #import diff --git a/Juick/Views/MessageCell.m b/Juick/Views/MessageCell.m index 236b4a3..ca84053 100644 --- a/Juick/Views/MessageCell.m +++ b/Juick/Views/MessageCell.m @@ -2,11 +2,10 @@ // MessageCell.m // Juick // -// Created by Vitaly Takmazov on 14/08/16. -// Copyright © 2016 com.juick. All rights reserved. +// Created by Vitaly Takmazov on 03/12/2017. +// Copyright © 2017 com.juick. All rights reserved. // - #import "MessageCell.h" #import "ColorScheme.h" #import "UIImage+Utils.h" @@ -23,11 +22,11 @@ self.text.enabledTextCheckingTypes = NSTextCheckingTypeLink; self.text.delegate = self; self.text.linkAttributes = @{ (id)kCTForegroundColorAttributeName: [ColorScheme linkColor], - (id)kCTUnderlineStyleAttributeName : [NSNumber numberWithInt:NSUnderlineStyleSingle] }; + (id)kCTUnderlineStyleAttributeName : [NSNumber numberWithInt:NSUnderlineStyleSingle] }; self.title.textColor = [ColorScheme linkColor]; self.timestamp.textColor = [UIColor grayColor]; self.summary.textColor = [UIColor grayColor]; - self.tags.textFont = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; + self.tags.textFont = [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote]; } - (void) configureWithMessage:(Message *)msg { @@ -69,4 +68,5 @@ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; } + @end diff --git a/Juick/Views/MessageCell.xib b/Juick/Views/MessageCell.xib new file mode 100644 index 0000000..7a08ca9 --- /dev/null +++ b/Juick/Views/MessageCell.xib @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3