From 566f122683240ea47f391033ec4e11ef424e7a5c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 30 Oct 2013 00:50:34 +0400 Subject: Working main feed --- .gitignore | 2 + Juick.xcodeproj/project.pbxproj | 91 +++++++++++++---- Juick.xcworkspace/contents.xcworkspacedata | 1 + Juick/AppDelegate.m | 2 +- Juick/Base.lproj/Main.storyboard | 104 -------------------- Juick/DetailViewController.h | 16 --- Juick/DetailViewController.m | 51 ---------- Juick/Juick-Info.plist | 2 + Juick/Main.storyboard | 81 +++++++++++++++ Juick/MasterViewController.h | 1 - Juick/MasterViewController.m | 152 +++++++++++++++++------------ Juick/Message.h | 20 ++++ Juick/Message.m | 30 ++++++ Juick/MessageCell.h | 21 ++++ Juick/MessageCell.m | 134 +++++++++++++++++++++++++ Podfile | 11 +++ Podfile.lock | 21 ++++ 17 files changed, 486 insertions(+), 254 deletions(-) create mode 100644 .gitignore create mode 100644 Juick.xcworkspace/contents.xcworkspacedata delete mode 100644 Juick/Base.lproj/Main.storyboard delete mode 100644 Juick/DetailViewController.h delete mode 100644 Juick/DetailViewController.m create mode 100644 Juick/Main.storyboard create mode 100644 Juick/Message.h create mode 100644 Juick/Message.m create mode 100644 Juick/MessageCell.h create mode 100644 Juick/MessageCell.m create mode 100644 Podfile create mode 100644 Podfile.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1f9ae16 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +xcuserdata +Pods/* diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index 75185cc..978e6d5 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -7,21 +7,23 @@ objects = { /* Begin PBXBuildFile section */ + 023DFC884FC1455E9522E9BF /* libPods-Juick.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E1A04338EB0146778B4503DC /* libPods-Juick.a */; }; 77317BAC181BBE8500D60005 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAB181BBE8500D60005 /* Foundation.framework */; }; 77317BAE181BBE8500D60005 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAD181BBE8500D60005 /* CoreGraphics.framework */; }; 77317BB0181BBE8500D60005 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAF181BBE8500D60005 /* UIKit.framework */; }; 77317BB6181BBE8500D60005 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 77317BB4181BBE8500D60005 /* InfoPlist.strings */; }; 77317BB8181BBE8500D60005 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 77317BB7181BBE8500D60005 /* main.m */; }; 77317BBC181BBE8500D60005 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 77317BBB181BBE8500D60005 /* AppDelegate.m */; }; - 77317BBF181BBE8500D60005 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 77317BBD181BBE8500D60005 /* Main.storyboard */; }; 77317BC2181BBE8500D60005 /* MasterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77317BC1181BBE8500D60005 /* MasterViewController.m */; }; - 77317BC5181BBE8500D60005 /* DetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77317BC4181BBE8500D60005 /* DetailViewController.m */; }; 77317BC7181BBE8500D60005 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 77317BC6181BBE8500D60005 /* Images.xcassets */; }; 77317BCE181BBE8500D60005 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BCD181BBE8500D60005 /* XCTest.framework */; }; 77317BCF181BBE8500D60005 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAB181BBE8500D60005 /* Foundation.framework */; }; 77317BD0181BBE8500D60005 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77317BAF181BBE8500D60005 /* UIKit.framework */; }; 77317BD8181BBE8500D60005 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 77317BD6181BBE8500D60005 /* InfoPlist.strings */; }; 77317BDA181BBE8500D60005 /* JuickTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 77317BD9181BBE8500D60005 /* JuickTests.m */; }; + 77A0954A181F1F25002BDECD /* Message.m in Sources */ = {isa = PBXBuildFile; fileRef = 77A09549181F1F25002BDECD /* Message.m */; }; + 77A09569181F98D0002BDECD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 77A09568181F98D0002BDECD /* Main.storyboard */; }; + 77D163C2181F048F00401EF0 /* MessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 77D163C1181F048F00401EF0 /* MessageCell.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -45,17 +47,21 @@ 77317BB9181BBE8500D60005 /* Juick-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Juick-Prefix.pch"; sourceTree = ""; }; 77317BBA181BBE8500D60005 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 77317BBB181BBE8500D60005 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 77317BBE181BBE8500D60005 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 77317BC0181BBE8500D60005 /* MasterViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MasterViewController.h; sourceTree = ""; }; 77317BC1181BBE8500D60005 /* MasterViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MasterViewController.m; sourceTree = ""; }; - 77317BC3181BBE8500D60005 /* DetailViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DetailViewController.h; sourceTree = ""; }; - 77317BC4181BBE8500D60005 /* DetailViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DetailViewController.m; sourceTree = ""; }; 77317BC6181BBE8500D60005 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 77317BCC181BBE8500D60005 /* JuickTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = JuickTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 77317BCD181BBE8500D60005 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 77317BD5181BBE8500D60005 /* JuickTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "JuickTests-Info.plist"; sourceTree = ""; }; 77317BD7181BBE8500D60005 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 77317BD9181BBE8500D60005 /* JuickTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JuickTests.m; sourceTree = ""; }; + 77A09548181F1F25002BDECD /* Message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Message.h; sourceTree = ""; }; + 77A09549181F1F25002BDECD /* Message.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Message.m; sourceTree = ""; }; + 77A09568181F98D0002BDECD /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; + 77D163C0181F048F00401EF0 /* MessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageCell.h; sourceTree = ""; }; + 77D163C1181F048F00401EF0 /* MessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MessageCell.m; sourceTree = ""; }; + AD52EBAFFD6B4395B342F246 /* Pods-Juick.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Juick.xcconfig"; path = "Pods/Pods-Juick.xcconfig"; sourceTree = ""; }; + E1A04338EB0146778B4503DC /* libPods-Juick.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Juick.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -66,6 +72,7 @@ 77317BAE181BBE8500D60005 /* CoreGraphics.framework in Frameworks */, 77317BB0181BBE8500D60005 /* UIKit.framework in Frameworks */, 77317BAC181BBE8500D60005 /* Foundation.framework in Frameworks */, + 023DFC884FC1455E9522E9BF /* libPods-Juick.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -89,6 +96,7 @@ 77317BD3181BBE8500D60005 /* JuickTests */, 77317BAA181BBE8500D60005 /* Frameworks */, 77317BA9181BBE8500D60005 /* Products */, + AD52EBAFFD6B4395B342F246 /* Pods-Juick.xcconfig */, ); sourceTree = ""; }; @@ -108,6 +116,7 @@ 77317BAD181BBE8500D60005 /* CoreGraphics.framework */, 77317BAF181BBE8500D60005 /* UIKit.framework */, 77317BCD181BBE8500D60005 /* XCTest.framework */, + E1A04338EB0146778B4503DC /* libPods-Juick.a */, ); name = Frameworks; sourceTree = ""; @@ -117,13 +126,15 @@ children = ( 77317BBA181BBE8500D60005 /* AppDelegate.h */, 77317BBB181BBE8500D60005 /* AppDelegate.m */, - 77317BBD181BBE8500D60005 /* Main.storyboard */, 77317BC0181BBE8500D60005 /* MasterViewController.h */, 77317BC1181BBE8500D60005 /* MasterViewController.m */, - 77317BC3181BBE8500D60005 /* DetailViewController.h */, - 77317BC4181BBE8500D60005 /* DetailViewController.m */, 77317BC6181BBE8500D60005 /* Images.xcassets */, 77317BB2181BBE8500D60005 /* Supporting Files */, + 77D163C0181F048F00401EF0 /* MessageCell.h */, + 77D163C1181F048F00401EF0 /* MessageCell.m */, + 77A09548181F1F25002BDECD /* Message.h */, + 77A09549181F1F25002BDECD /* Message.m */, + 77A09568181F98D0002BDECD /* Main.storyboard */, ); path = Juick; sourceTree = ""; @@ -164,9 +175,11 @@ isa = PBXNativeTarget; buildConfigurationList = 77317BDD181BBE8500D60005 /* Build configuration list for PBXNativeTarget "Juick" */; buildPhases = ( + 8C368BB4728E4484A53015A0 /* Check Pods Manifest.lock */, 77317BA4181BBE8500D60005 /* Sources */, 77317BA5181BBE8500D60005 /* Frameworks */, 77317BA6181BBE8500D60005 /* Resources */, + B3224023A642464D96AA14E2 /* Copy Pods Resources */, ); buildRules = ( ); @@ -233,9 +246,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 77A09569181F98D0002BDECD /* Main.storyboard in Resources */, 77317BC7181BBE8500D60005 /* Images.xcassets in Resources */, 77317BB6181BBE8500D60005 /* InfoPlist.strings in Resources */, - 77317BBF181BBE8500D60005 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -249,15 +262,49 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 8C368BB4728E4484A53015A0 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + B3224023A642464D96AA14E2 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Pods-Juick-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 77317BA4181BBE8500D60005 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 77D163C2181F048F00401EF0 /* MessageCell.m in Sources */, 77317BBC181BBE8500D60005 /* AppDelegate.m in Sources */, + 77A0954A181F1F25002BDECD /* Message.m in Sources */, 77317BC2181BBE8500D60005 /* MasterViewController.m in Sources */, 77317BB8181BBE8500D60005 /* main.m in Sources */, - 77317BC5181BBE8500D60005 /* DetailViewController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -288,14 +335,6 @@ name = InfoPlist.strings; sourceTree = ""; }; - 77317BBD181BBE8500D60005 /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 77317BBE181BBE8500D60005 /* Base */, - ); - name = Main.storyboard; - sourceTree = ""; - }; 77317BD6181BBE8500D60005 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( @@ -381,26 +420,40 @@ }; 77317BDE181BBE8500D60005 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = AD52EBAFFD6B4395B342F246 /* Pods-Juick.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "/Users/vt/Downloads/STV\\ 3.3.0\\ Lite/Static\\ Frameworks", + ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Juick/Juick-Prefix.pch"; INFOPLIST_FILE = "Juick/Juick-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 1; WRAPPER_EXTENSION = app; }; name = Debug; }; 77317BDF181BBE8500D60005 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = AD52EBAFFD6B4395B342F246 /* Pods-Juick.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "/Users/vt/Downloads/STV\\ 3.3.0\\ Lite/Static\\ Frameworks", + ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Juick/Juick-Prefix.pch"; INFOPLIST_FILE = "Juick/Juick-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = 1; WRAPPER_EXTENSION = app; }; name = Release; @@ -466,6 +519,7 @@ 77317BDF181BBE8500D60005 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 77317BE0181BBE8500D60005 /* Build configuration list for PBXNativeTarget "JuickTests" */ = { isa = XCConfigurationList; @@ -474,6 +528,7 @@ 77317BE2181BBE8500D60005 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/Juick.xcworkspace/contents.xcworkspacedata b/Juick.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..353d19d --- /dev/null +++ b/Juick.xcworkspace/contents.xcworkspacedata @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index 40b5fae..23cef5e 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -7,12 +7,12 @@ // #import "AppDelegate.h" +#import "MasterViewController.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - // Override point for customization after application launch. return YES; } diff --git a/Juick/Base.lproj/Main.storyboard b/Juick/Base.lproj/Main.storyboard deleted file mode 100644 index 3d5f90c..0000000 --- a/Juick/Base.lproj/Main.storyboard +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Juick/DetailViewController.h b/Juick/DetailViewController.h deleted file mode 100644 index 1246805..0000000 --- a/Juick/DetailViewController.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// DetailViewController.h -// Juick -// -// Created by Vitaly Takmazov on 26.10.13. -// Copyright (c) 2013 com.juick. All rights reserved. -// - -#import - -@interface DetailViewController : UIViewController - -@property (strong, nonatomic) id detailItem; - -@property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel; -@end diff --git a/Juick/DetailViewController.m b/Juick/DetailViewController.m deleted file mode 100644 index 4d510c9..0000000 --- a/Juick/DetailViewController.m +++ /dev/null @@ -1,51 +0,0 @@ -// -// DetailViewController.m -// Juick -// -// Created by Vitaly Takmazov on 26.10.13. -// Copyright (c) 2013 com.juick. All rights reserved. -// - -#import "DetailViewController.h" - -@interface DetailViewController () -- (void)configureView; -@end - -@implementation DetailViewController - -#pragma mark - Managing the detail item - -- (void)setDetailItem:(id)newDetailItem -{ - if (_detailItem != newDetailItem) { - _detailItem = newDetailItem; - - // Update the view. - [self configureView]; - } -} - -- (void)configureView -{ - // Update the user interface for the detail item. - - if (self.detailItem) { - self.detailDescriptionLabel.text = [self.detailItem description]; - } -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. - [self configureView]; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -@end diff --git a/Juick/Juick-Info.plist b/Juick/Juick-Info.plist index 846633e..f23f598 100644 --- a/Juick/Juick-Info.plist +++ b/Juick/Juick-Info.plist @@ -24,6 +24,8 @@ 1.0 LSRequiresIPhoneOS + NSMainNibFile~ipad + Main-iPad UIMainStoryboardFile Main UIRequiredDeviceCapabilities diff --git a/Juick/Main.storyboard b/Juick/Main.storyboard new file mode 100644 index 0000000..cac2c7f --- /dev/null +++ b/Juick/Main.storyboard @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Juick/MasterViewController.h b/Juick/MasterViewController.h index be49967..a79b5c7 100644 --- a/Juick/MasterViewController.h +++ b/Juick/MasterViewController.h @@ -9,5 +9,4 @@ #import @interface MasterViewController : UITableViewController - @end diff --git a/Juick/MasterViewController.m b/Juick/MasterViewController.m index 41b2ef5..bd75f82 100644 --- a/Juick/MasterViewController.m +++ b/Juick/MasterViewController.m @@ -6,108 +6,134 @@ // Copyright (c) 2013 com.juick. All rights reserved. // +#import "SWRevealViewController.h" + #import "MasterViewController.h" -#import "DetailViewController.h" +#import "MessageCell.h" + +#import "Message.h" + +static NSString *CellIdentifier = @"MessageCell"; @interface MasterViewController () { - NSMutableArray *_objects; + NSMutableArray *messages; } @end @implementation MasterViewController -- (void)awakeFromNib -{ - [super awakeFromNib]; -} - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. - self.navigationItem.leftBarButtonItem = self.editButtonItem; - - UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject:)]; - self.navigationItem.rightBarButtonItem = addButton; + self.title = @"Messages"; + // Change button color + + // Set the gesture + messages = [[NSMutableArray alloc] init]; + NSError *error; + NSURL *url = [NSURL URLWithString:@"http://api.juick.com/messages"]; + NSString *data = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error]; + if (data == nil) { + NSLog(@"Download Error: %@", error); + return; + } + NSArray *resultObject = [NSJSONSerialization JSONObjectWithData:[data dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error]; + if (resultObject == nil) { + NSLog(@"JSON Error: %@", error); + return; + } + + for (NSDictionary *message in resultObject) { + Message *msg = [[Message alloc] initWithDictionary:message]; + [messages addObject:msg]; + } + //UINib *cellNib = [UINib nibWithNibName:@"MessageCell" bundle:nil]; + //[self.tableView registerNib:cellNib forCellReuseIdentifier:@"MessageCell"]; + [self.tableView registerClass:[MessageCell class] forCellReuseIdentifier:CellIdentifier]; + } -- (void)didReceiveMemoryWarning +- (void)viewDidAppear:(BOOL)animated { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. + [super viewDidAppear:animated]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(contentSizeCategoryChanged:) + name:UIContentSizeCategoryDidChangeNotification + object:nil]; } -- (void)insertNewObject:(id)sender +- (void)viewDidDisappear:(BOOL)animated { - if (!_objects) { - _objects = [[NSMutableArray alloc] init]; - } - [_objects insertObject:[NSDate date] atIndex:0]; - NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; - [self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; + [super viewDidDisappear:animated]; + + [[NSNotificationCenter defaultCenter] removeObserver:self + name:UIContentSizeCategoryDidChangeNotification + object:nil]; } -#pragma mark - Table View - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +- (void)didReceiveMemoryWarning { - return 1; + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. } -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +- (void)contentSizeCategoryChanged:(NSNotification *)notification { - return _objects.count; + [self.tableView reloadData]; } -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; - - NSDate *object = _objects[indexPath.row]; - cell.textLabel.text = [object description]; - return cell; +-(void) parserDidEndDocument:(NSXMLParser *)parser { + [self.tableView reloadData]; } -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Return NO if you do not want the specified item to be editable. - return YES; +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; } -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath -{ - if (editingStyle == UITableViewCellEditingStyleDelete) { - [_objects removeObjectAtIndex:indexPath.row]; - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. - } +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return messages.count; } -/* -// Override to support rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath -{ +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; + [cell updateFonts]; + Message *msg = [messages objectAtIndex:indexPath.row]; + cell.titleLabel.text = msg.user; + cell.bodyLabel.text = msg.text; + [cell setNeedsUpdateConstraints]; + return cell; } -*/ -/* -// Override to support conditional rearranging of the table view. -- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - // Return NO if you do not want the item to be re-orderable. - return YES; + + MessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + + [cell updateFonts]; + + Message *msg = [messages objectAtIndex:indexPath.row]; + cell.titleLabel.text = msg.user; + cell.bodyLabel.text = msg.text; + + cell.bodyLabel.preferredMaxLayoutWidth = tableView.bounds.size.width - (kLabelHorizontalInsets * 2.0f); + + [cell setNeedsUpdateConstraints]; + [cell updateConstraintsIfNeeded]; + [cell.contentView setNeedsLayout]; + [cell.contentView layoutIfNeeded]; + + CGFloat height = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; + + return height; } -*/ -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath { - if ([[segue identifier] isEqualToString:@"showDetail"]) { - NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; - NSDate *object = _objects[indexPath.row]; - [[segue destinationViewController] setDetailItem:object]; - } + return 500.0f; } + @end diff --git a/Juick/Message.h b/Juick/Message.h new file mode 100644 index 0000000..4ec31e6 --- /dev/null +++ b/Juick/Message.h @@ -0,0 +1,20 @@ +// +// Message.h +// Juick +// +// Created by Vitaly Takmazov on 29.10.13. +// Copyright (c) 2013 com.juick. All rights reserved. +// + +#import +#import "NSString+HTML.h" + +@interface Message : NSObject + +@property(nonatomic, copy) NSDecimalNumber *MID; +@property(nonatomic, copy) NSDecimalNumber *RID; +@property(nonatomic, copy) NSString *user; +@property(nonatomic, copy) NSString *text; + +-(id) initWithDictionary:(NSDictionary *)dictionary; +@end diff --git a/Juick/Message.m b/Juick/Message.m new file mode 100644 index 0000000..e87834b --- /dev/null +++ b/Juick/Message.m @@ -0,0 +1,30 @@ +// +// Message.m +// Juick +// +// Created by Vitaly Takmazov on 29.10.13. +// Copyright (c) 2013 com.juick. All rights reserved. +// + +#import "Message.h" + +@implementation Message + +-(id)initWithDictionary:(NSDictionary *)dictionary +{ + Message *result = [[Message alloc] init]; + result.MID = [dictionary objectForKey:@"mid"]; + result.RID = [dictionary objectForKey:@"rid"]; + NSString *text = [[dictionary objectForKey:@"body"] stringByDecodingHTMLEntities]; + NSDictionary *userDict = [dictionary objectForKey:@"user"]; + result.user = [userDict objectForKey:@"uname"]; + NSArray *tagsArray = [dictionary objectForKey:@"tags"]; + if ([tagsArray count] > 0) { + result.text = [[NSString alloc] initWithFormat:@"%@\n%@", [tagsArray componentsJoinedByString:@", "], text]; + } else { + result.text = text; + } + return result; +} + +@end diff --git a/Juick/MessageCell.h b/Juick/MessageCell.h new file mode 100644 index 0000000..6f93048 --- /dev/null +++ b/Juick/MessageCell.h @@ -0,0 +1,21 @@ +// +// MessageCell.h +// Juick +// +// Created by Vitaly Takmazov on 29.10.13. +// Copyright (c) 2013 com.juick. All rights reserved. +// + +#import + + +#define kLabelHorizontalInsets 20.0f + +@interface MessageCell : UITableViewCell + +@property (strong, nonatomic) IBOutlet UILabel *titleLabel; +@property (strong, nonatomic) IBOutlet UILabel *bodyLabel; + +- (void)updateFonts; + +@end diff --git a/Juick/MessageCell.m b/Juick/MessageCell.m new file mode 100644 index 0000000..a8b2522 --- /dev/null +++ b/Juick/MessageCell.m @@ -0,0 +1,134 @@ +// +// MessageCell.m +// Juick +// +// Created by Vitaly Takmazov on 29.10.13. +// Copyright (c) 2013 com.juick. All rights reserved. +// + +#import "MessageCell.h" + +@interface MessageCell () + +@property (nonatomic, assign) BOOL didSetupConstraints; + +@end + +@implementation MessageCell + +- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier +{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if (self) { + self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + [self.titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; + [self.titleLabel setLineBreakMode:NSLineBreakByTruncatingTail]; + [self.titleLabel setNumberOfLines:1]; + [self.titleLabel setTextAlignment:NSTextAlignmentLeft]; + [self.titleLabel setTextColor:[UIColor blackColor]]; + [self.titleLabel setBackgroundColor:[UIColor clearColor]]; + + self.bodyLabel = [[UILabel alloc] initWithFrame:CGRectZero]; + [self.bodyLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; + [self.bodyLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical]; + [self.bodyLabel setLineBreakMode:NSLineBreakByTruncatingTail]; + [self.bodyLabel setNumberOfLines:0]; + [self.bodyLabel setTextAlignment:NSTextAlignmentLeft]; + [self.bodyLabel setTextColor:[UIColor darkGrayColor]]; + [self.bodyLabel setBackgroundColor:[UIColor clearColor]]; + [self.contentView addSubview:self.titleLabel]; + [self.contentView addSubview:self.bodyLabel]; + + [self updateFonts]; + } + return self; +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated +{ + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +- (void)updateConstraints { + [super updateConstraints]; + + if (self.didSetupConstraints) return; + + [self.contentView addConstraint:[NSLayoutConstraint + constraintWithItem:self.titleLabel + attribute:NSLayoutAttributeLeading + relatedBy:NSLayoutRelationEqual + toItem:self.contentView + attribute:NSLayoutAttributeLeading + multiplier:1.0f + constant:kLabelHorizontalInsets]]; + + [self.contentView addConstraint:[NSLayoutConstraint + constraintWithItem:self.titleLabel + attribute:NSLayoutAttributeTop + relatedBy:NSLayoutRelationEqual + toItem:self.contentView + attribute:NSLayoutAttributeTop + multiplier:1.0f + constant:(kLabelHorizontalInsets / 2)]]; + + [self.contentView addConstraint:[NSLayoutConstraint + constraintWithItem:self.titleLabel + attribute:NSLayoutAttributeTrailing + relatedBy:NSLayoutRelationEqual + toItem:self.contentView + attribute:NSLayoutAttributeTrailing + multiplier:1.0f + constant:-kLabelHorizontalInsets]]; + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + [self.contentView addConstraint:[NSLayoutConstraint + constraintWithItem:self.bodyLabel + attribute:NSLayoutAttributeLeading + relatedBy:NSLayoutRelationEqual + toItem:self.contentView + attribute:NSLayoutAttributeLeading + multiplier:1.0f + constant:kLabelHorizontalInsets]]; + + [self.contentView addConstraint:[NSLayoutConstraint + constraintWithItem:self.bodyLabel + attribute:NSLayoutAttributeTop + relatedBy:NSLayoutRelationEqual + toItem:self.titleLabel + attribute:NSLayoutAttributeBottom + multiplier:1.0f + constant:(kLabelHorizontalInsets / 4)]]; + + [self.contentView addConstraint:[NSLayoutConstraint + constraintWithItem:self.bodyLabel + attribute:NSLayoutAttributeTrailing + relatedBy:NSLayoutRelationEqual + toItem:self.contentView + attribute:NSLayoutAttributeTrailing + multiplier:1.0f + constant:-kLabelHorizontalInsets]]; + + [self.contentView addConstraint:[NSLayoutConstraint + constraintWithItem:self.bodyLabel + attribute:NSLayoutAttributeBottom + relatedBy:NSLayoutRelationEqual + toItem:self.contentView + attribute:NSLayoutAttributeBottom + multiplier:1.0f + constant:-(kLabelHorizontalInsets / 2)]]; + + self.didSetupConstraints = YES; +} + + +- (void)updateFonts +{ + self.titleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline]; + self.bodyLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody]; +} + +@end diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..d67c54c --- /dev/null +++ b/Podfile @@ -0,0 +1,11 @@ +# Uncomment this line to define a global platform for your project +platform :ios, "6.0" + +target "Juick" do +pod 'MWFeedParser' +end + +target "JuickTests" do + +end + diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 0000000..5a89ae6 --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,21 @@ +PODS: + - MWFeedParser (0.0.1): + - MWFeedParser/Feed + - MWFeedParser/NSDate+InternetDateTime + - MWFeedParser/NSString+HTML + - MWFeedParser/NSString+XMLEntities + - MWFeedParser/Feed (0.0.1) + - MWFeedParser/NSDate+InternetDateTime (0.0.1) + - MWFeedParser/NSString+HTML (0.0.1) + - MWFeedParser/NSString+XMLEntities (0.0.1) + - PKRevealController (2.0.5) + +DEPENDENCIES: + - MWFeedParser + - PKRevealController + +SPEC CHECKSUMS: + MWFeedParser: 2ca0852fac352f8333d5f46fdd4b583b921e0c4e + PKRevealController: 50a737bde432e51b68596d46b33617ec8bcb3a6a + +COCOAPODS: 0.27.1 -- cgit v1.2.3