From a1649b2d74f57c3e8e5757875f01134df8732662 Mon Sep 17 00:00:00 2001 From: Jamaal Sedayao Date: Wed, 16 Sep 2015 15:53:43 -0400 Subject: [PATCH] first commit - JS --- PartTwo/CustomView.xib | 80 ++++++++++++++++++++ PartTwo/PartTwo.xcodeproj/project.pbxproj | 15 ++++ PartTwo/PartTwo/Base.lproj/Main.storyboard | 25 +++++- PartTwo/PartTwo/SocialMediaDelegate.h | 20 +++++ PartTwo/PartTwo/ViewController.h | 2 + PartTwo/PartTwo/ViewController.m | 39 ++++++++-- PartTwo/SocialMediaView.h | 17 +++++ PartTwo/SocialMediaView.m | 27 +++++++ PickAPic/PickAPic.xcodeproj/project.pbxproj | 10 +++ PickAPic/PickAPic/Base.lproj/Main.storyboard | 50 +++++++++++- PickAPic/PickAPicViewController.h | 13 ++++ PickAPic/PickAPicViewController.m | 69 +++++++++++++++++ 12 files changed, 354 insertions(+), 13 deletions(-) create mode 100644 PartTwo/CustomView.xib create mode 100644 PartTwo/PartTwo/SocialMediaDelegate.h create mode 100644 PartTwo/SocialMediaView.h create mode 100644 PartTwo/SocialMediaView.m create mode 100644 PickAPic/PickAPicViewController.h create mode 100644 PickAPic/PickAPicViewController.m diff --git a/PartTwo/CustomView.xib b/PartTwo/CustomView.xib new file mode 100644 index 0000000..6e519ae --- /dev/null +++ b/PartTwo/CustomView.xib @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PartTwo/PartTwo.xcodeproj/project.pbxproj b/PartTwo/PartTwo.xcodeproj/project.pbxproj index 5582517..87cd4da 100644 --- a/PartTwo/PartTwo.xcodeproj/project.pbxproj +++ b/PartTwo/PartTwo.xcodeproj/project.pbxproj @@ -15,6 +15,8 @@ 8DD103571BA66E0900CE483B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8DD103551BA66E0900CE483B /* LaunchScreen.storyboard */; }; 8DD103621BA66E0900CE483B /* PartTwoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DD103611BA66E0900CE483B /* PartTwoTests.m */; }; 8DD1036D1BA66E0900CE483B /* PartTwoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DD1036C1BA66E0900CE483B /* PartTwoUITests.m */; }; + 9AD49E371BA90F4800426529 /* CustomView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9AD49E361BA90F4800426529 /* CustomView.xib */; settings = {ASSET_TAGS = (); }; }; + 9AD49E451BA91C9400426529 /* SocialMediaView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AD49E441BA91C9400426529 /* SocialMediaView.m */; settings = {ASSET_TAGS = (); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -51,6 +53,10 @@ 8DD103681BA66E0900CE483B /* PartTwoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PartTwoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 8DD1036C1BA66E0900CE483B /* PartTwoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PartTwoUITests.m; sourceTree = ""; }; 8DD1036E1BA66E0900CE483B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9AD49E361BA90F4800426529 /* CustomView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CustomView.xib; path = ../CustomView.xib; sourceTree = ""; }; + 9AD49E431BA91C9400426529 /* SocialMediaView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SocialMediaView.h; path = ../SocialMediaView.h; sourceTree = ""; }; + 9AD49E441BA91C9400426529 /* SocialMediaView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SocialMediaView.m; path = ../SocialMediaView.m; sourceTree = ""; }; + 9AEED1271BA9F797006638A4 /* SocialMediaDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SocialMediaDelegate.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -103,8 +109,12 @@ children = ( 8DD1034A1BA66E0900CE483B /* AppDelegate.h */, 8DD1034B1BA66E0900CE483B /* AppDelegate.m */, + 9AEED1271BA9F797006638A4 /* SocialMediaDelegate.h */, 8DD1034D1BA66E0900CE483B /* ViewController.h */, 8DD1034E1BA66E0900CE483B /* ViewController.m */, + 9AD49E431BA91C9400426529 /* SocialMediaView.h */, + 9AD49E441BA91C9400426529 /* SocialMediaView.m */, + 9AD49E361BA90F4800426529 /* CustomView.xib */, 8DD103501BA66E0900CE483B /* Main.storyboard */, 8DD103531BA66E0900CE483B /* Assets.xcassets */, 8DD103551BA66E0900CE483B /* LaunchScreen.storyboard */, @@ -244,6 +254,7 @@ buildActionMask = 2147483647; files = ( 8DD103571BA66E0900CE483B /* LaunchScreen.storyboard in Resources */, + 9AD49E371BA90F4800426529 /* CustomView.xib in Resources */, 8DD103541BA66E0900CE483B /* Assets.xcassets in Resources */, 8DD103521BA66E0900CE483B /* Main.storyboard in Resources */, ); @@ -272,6 +283,7 @@ files = ( 8DD1034F1BA66E0900CE483B /* ViewController.m in Sources */, 8DD1034C1BA66E0900CE483B /* AppDelegate.m in Sources */, + 9AD49E451BA91C9400426529 /* SocialMediaView.m in Sources */, 8DD103491BA66E0900CE483B /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -498,6 +510,7 @@ 8DD103731BA66E0900CE483B /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 8DD103741BA66E0900CE483B /* Build configuration list for PBXNativeTarget "PartTwoTests" */ = { isa = XCConfigurationList; @@ -506,6 +519,7 @@ 8DD103761BA66E0900CE483B /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; 8DD103771BA66E0900CE483B /* Build configuration list for PBXNativeTarget "PartTwoUITests" */ = { isa = XCConfigurationList; @@ -514,6 +528,7 @@ 8DD103791BA66E0900CE483B /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/PartTwo/PartTwo/Base.lproj/Main.storyboard b/PartTwo/PartTwo/Base.lproj/Main.storyboard index f56d2f3..d2b4b4c 100644 --- a/PartTwo/PartTwo/Base.lproj/Main.storyboard +++ b/PartTwo/PartTwo/Base.lproj/Main.storyboard @@ -1,13 +1,14 @@ - + - + + - + @@ -15,11 +16,29 @@ + + + + + + + + + + + + + + + + + + diff --git a/PartTwo/PartTwo/SocialMediaDelegate.h b/PartTwo/PartTwo/SocialMediaDelegate.h new file mode 100644 index 0000000..465f6ba --- /dev/null +++ b/PartTwo/PartTwo/SocialMediaDelegate.h @@ -0,0 +1,20 @@ +// +// SocialMediaDelegate.h +// PartTwo +// +// Created by Jamaal Sedayao on 9/16/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + + +#import + +@class SocialMediaView; + +@protocol SocialMediaDelegate + +- (void) socialMediaViewDidTapLikeButton:(SocialMediaView*)view; +- (void)socialMediaViewDidTapCommentButton:(SocialMediaView*)view; +- (void)socialMediaViewDidTapShareButton:(SocialMediaView*)view; + +@end diff --git a/PartTwo/PartTwo/ViewController.h b/PartTwo/PartTwo/ViewController.h index cb5d98b..5fdc45b 100644 --- a/PartTwo/PartTwo/ViewController.h +++ b/PartTwo/PartTwo/ViewController.h @@ -8,8 +8,10 @@ #import + @interface ViewController : UIViewController + @end diff --git a/PartTwo/PartTwo/ViewController.m b/PartTwo/PartTwo/ViewController.m index adca251..fbeaac8 100644 --- a/PartTwo/PartTwo/ViewController.m +++ b/PartTwo/PartTwo/ViewController.m @@ -7,8 +7,13 @@ // #import "ViewController.h" +#import "SocialMediaView.h" +#import "SocialMediaDelegate.h" + +@interface ViewController () + +@property (weak, nonatomic) IBOutlet UIView *customViewController; -@interface ViewController () @end @@ -16,12 +21,34 @@ @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. -} + -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. + NSArray *views = [[NSBundle mainBundle]loadNibNamed:@"CustomView" owner:self options:nil]; + + SocialMediaView *customView = [views firstObject]; + + [self.customViewController addSubview:customView]; + + customView.frame = self.customViewController.bounds; + + customView.delegate = self; + +} +- (void) socialMediaViewDidTapLikeButton:(SocialMediaView*)view{ + + self.view.backgroundColor = [UIColor blueColor]; +} +- (void)socialMediaViewDidTapCommentButton:(SocialMediaView*)view{ + + self.view.backgroundColor = [UIColor greenColor]; + } +- (void)socialMediaViewDidTapShareButton:(SocialMediaView*)view{ + + self.view.backgroundColor = [UIColor redColor]; +} + + + @end diff --git a/PartTwo/SocialMediaView.h b/PartTwo/SocialMediaView.h new file mode 100644 index 0000000..7300777 --- /dev/null +++ b/PartTwo/SocialMediaView.h @@ -0,0 +1,17 @@ +// +// SocialMediaView.h +// PartTwo +// +// Created by Jamaal Sedayao on 9/15/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import +#import "SocialMediaDelegate.h" + + +@interface SocialMediaView : UIView + +@property (nonatomic,weak) id delegate; + +@end diff --git a/PartTwo/SocialMediaView.m b/PartTwo/SocialMediaView.m new file mode 100644 index 0000000..ac72362 --- /dev/null +++ b/PartTwo/SocialMediaView.m @@ -0,0 +1,27 @@ +// +// SocialMediaView.m +// PartTwo +// +// Created by Jamaal Sedayao on 9/15/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "SocialMediaView.h" + +@implementation SocialMediaView + + +- (IBAction)likeButtonTapped:(id)sender { + [self.delegate socialMediaViewDidTapLikeButton:self]; +} + +- (IBAction)commentButtonTapped:(id)sender{ + [self.delegate socialMediaViewDidTapCommentButton:self]; +} + +- (IBAction)shareButtonTapped:(id)sender { + [self.delegate socialMediaViewDidTapShareButton:self]; +} + + +@end diff --git a/PickAPic/PickAPic.xcodeproj/project.pbxproj b/PickAPic/PickAPic.xcodeproj/project.pbxproj index 049896b..1420227 100644 --- a/PickAPic/PickAPic.xcodeproj/project.pbxproj +++ b/PickAPic/PickAPic.xcodeproj/project.pbxproj @@ -15,6 +15,8 @@ 8D1F73CF1BA66AE50040D369 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D1F73CD1BA66AE50040D369 /* LaunchScreen.storyboard */; }; 8D1F73DA1BA66AE50040D369 /* PickAPicTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F73D91BA66AE50040D369 /* PickAPicTests.m */; }; 8D1F73E51BA66AE50040D369 /* PickAPicUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D1F73E41BA66AE50040D369 /* PickAPicUITests.m */; }; + 9A5D9A771BA77F0500BCDD82 /* PickAPicViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A5D9A761BA77F0500BCDD82 /* PickAPicViewController.m */; settings = {ASSET_TAGS = (); }; }; + 9A5D9A791BA7CD4F00BCDD82 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A5D9A781BA7CD4F00BCDD82 /* MobileCoreServices.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -51,6 +53,9 @@ 8D1F73E01BA66AE50040D369 /* PickAPicUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PickAPicUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 8D1F73E41BA66AE50040D369 /* PickAPicUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PickAPicUITests.m; sourceTree = ""; }; 8D1F73E61BA66AE50040D369 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 9A5D9A751BA77F0500BCDD82 /* PickAPicViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PickAPicViewController.h; sourceTree = SOURCE_ROOT; }; + 9A5D9A761BA77F0500BCDD82 /* PickAPicViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PickAPicViewController.m; sourceTree = SOURCE_ROOT; }; + 9A5D9A781BA7CD4F00BCDD82 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -58,6 +63,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 9A5D9A791BA7CD4F00BCDD82 /* MobileCoreServices.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -81,6 +87,7 @@ 8D1F73B31BA66AE50040D369 = { isa = PBXGroup; children = ( + 9A5D9A781BA7CD4F00BCDD82 /* MobileCoreServices.framework */, 8D1F73BE1BA66AE50040D369 /* PickAPic */, 8D1F73D81BA66AE50040D369 /* PickAPicTests */, 8D1F73E31BA66AE50040D369 /* PickAPicUITests */, @@ -105,6 +112,8 @@ 8D1F73C31BA66AE50040D369 /* AppDelegate.m */, 8D1F73C51BA66AE50040D369 /* ViewController.h */, 8D1F73C61BA66AE50040D369 /* ViewController.m */, + 9A5D9A751BA77F0500BCDD82 /* PickAPicViewController.h */, + 9A5D9A761BA77F0500BCDD82 /* PickAPicViewController.m */, 8D1F73C81BA66AE50040D369 /* Main.storyboard */, 8D1F73CB1BA66AE50040D369 /* Assets.xcassets */, 8D1F73CD1BA66AE50040D369 /* LaunchScreen.storyboard */, @@ -272,6 +281,7 @@ files = ( 8D1F73C71BA66AE50040D369 /* ViewController.m in Sources */, 8D1F73C41BA66AE50040D369 /* AppDelegate.m in Sources */, + 9A5D9A771BA77F0500BCDD82 /* PickAPicViewController.m in Sources */, 8D1F73C11BA66AE50040D369 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/PickAPic/PickAPic/Base.lproj/Main.storyboard b/PickAPic/PickAPic/Base.lproj/Main.storyboard index f055f71..dc56e39 100644 --- a/PickAPic/PickAPic/Base.lproj/Main.storyboard +++ b/PickAPic/PickAPic/Base.lproj/Main.storyboard @@ -1,14 +1,30 @@ - + - + + + + + + + + + + + + + + + + + - + @@ -16,12 +32,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/PickAPic/PickAPicViewController.h b/PickAPic/PickAPicViewController.h new file mode 100644 index 0000000..c86a611 --- /dev/null +++ b/PickAPic/PickAPicViewController.h @@ -0,0 +1,13 @@ +// +// PickAPicViewController.h +// PickAPic +// +// Created by Jamaal Sedayao on 9/14/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import + +@interface PickAPicViewController : UIViewController + +@end diff --git a/PickAPic/PickAPicViewController.m b/PickAPic/PickAPicViewController.m new file mode 100644 index 0000000..cf87479 --- /dev/null +++ b/PickAPic/PickAPicViewController.m @@ -0,0 +1,69 @@ +// +// PickAPicViewController.m +// PickAPic +// +// Created by Jamaal Sedayao on 9/14/15. +// Copyright © 2015 Mike Kavouras. All rights reserved. +// + +#import "PickAPicViewController.h" +#import + + +@interface PickAPicViewController () + +@property (weak, nonatomic) IBOutlet UIImageView *imageView; + +@end + +@implementation PickAPicViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + //self.imageView.clipsToBounds = YES; + + self.imageView.backgroundColor = [UIColor lightGrayColor]; +} +-(void)viewDidAppear:(BOOL)animated{ + + self.imageView.clipsToBounds = YES; +} +- (IBAction)clickedCameraRollButton:(id)sender { + + UIImagePickerController *imagePicker = [[UIImagePickerController alloc]init]; + + imagePicker.delegate = self; + + imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; + + [self.navigationController presentViewController:imagePicker animated:YES completion:nil]; + +} +- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { + + //self.imageView.image = [UIImage imageNamed:info]; + + self.imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage]; + + [self.navigationController dismissViewControllerAnimated:YES completion:nil]; +} + +- (IBAction)clickedCameraIcon:(id)sender { + + if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { + + UIImagePickerController *imageFromCamera = [[UIImagePickerController alloc]init]; + + imageFromCamera.delegate = self; + + imageFromCamera.sourceType = UIImagePickerControllerSourceTypeCamera; + + [self.navigationController presentViewController:imageFromCamera animated:YES completion:nil]; + } +} + + + + +@end