Skip to content

Commit

Permalink
INtegrate camera/photo surveys
Browse files Browse the repository at this point in the history
  • Loading branch information
brung committed Feb 25, 2015
1 parent a05385b commit 62d8f3f
Show file tree
Hide file tree
Showing 15 changed files with 500 additions and 10 deletions.
26 changes: 26 additions & 0 deletions unnamed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@
B827A9E81A9815E100AB43CE /* ProfileImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = B827A9E71A9815E100AB43CE /* ProfileImageView.m */; };
B827A9EE1A98287B00AB43CE /* GrayBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = B827A9ED1A98287B00AB43CE /* GrayBarButtonItem.m */; };
B82956B81A9B10C000D0ECFD /* HomeProfileAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = B82956B71A9B10C000D0ECFD /* HomeProfileAnimation.m */; };
B82956BC1A9C553200D0ECFD /* CameraViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B82956BA1A9C553200D0ECFD /* CameraViewController.m */; };
B82956BD1A9C553200D0ECFD /* CameraViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B82956BB1A9C553200D0ECFD /* CameraViewController.xib */; };
B82956C61A9C5AA200D0ECFD /* ComposePhotoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B82956C41A9C5AA200D0ECFD /* ComposePhotoCell.m */; };
B82956C71A9C5AA200D0ECFD /* ComposePhotoCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B82956C51A9C5AA200D0ECFD /* ComposePhotoCell.xib */; };
B862A88C1A970E25008B2310 /* DetailAnswerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B862A88A1A970E25008B2310 /* DetailAnswerCell.m */; };
B862A88D1A970E25008B2310 /* DetailAnswerCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B862A88B1A970E25008B2310 /* DetailAnswerCell.xib */; };
B87C15BC1A93113400191823 /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B87C15B71A93113400191823 /* LoginViewController.m */; };
B87C15BD1A93113400191823 /* LoginViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = B87C15B81A93113400191823 /* LoginViewController.xib */; };
B895C4A01A9C7709001DF829 /* QuestionPhotos.m in Sources */ = {isa = PBXBuildFile; fileRef = B895C49F1A9C7709001DF829 /* QuestionPhotos.m */; };
B8BA93E81A9459B5003BD476 /* User.m in Sources */ = {isa = PBXBuildFile; fileRef = B8BA93E71A9459B5003BD476 /* User.m */; };
B8BA93EB1A9464C7003BD476 /* Question.m in Sources */ = {isa = PBXBuildFile; fileRef = B8BA93EA1A9464C7003BD476 /* Question.m */; };
B8BA93F41A947718003BD476 /* Answer.m in Sources */ = {isa = PBXBuildFile; fileRef = B8BA93F31A947718003BD476 /* Answer.m */; };
Expand Down Expand Up @@ -102,12 +107,20 @@
B827A9ED1A98287B00AB43CE /* GrayBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GrayBarButtonItem.m; sourceTree = "<group>"; };
B82956B61A9B10C000D0ECFD /* HomeProfileAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeProfileAnimation.h; sourceTree = "<group>"; };
B82956B71A9B10C000D0ECFD /* HomeProfileAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeProfileAnimation.m; sourceTree = "<group>"; };
B82956B91A9C553200D0ECFD /* CameraViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CameraViewController.h; sourceTree = "<group>"; };
B82956BA1A9C553200D0ECFD /* CameraViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CameraViewController.m; sourceTree = "<group>"; };
B82956BB1A9C553200D0ECFD /* CameraViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CameraViewController.xib; sourceTree = "<group>"; };
B82956C31A9C5AA200D0ECFD /* ComposePhotoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposePhotoCell.h; sourceTree = "<group>"; };
B82956C41A9C5AA200D0ECFD /* ComposePhotoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ComposePhotoCell.m; sourceTree = "<group>"; };
B82956C51A9C5AA200D0ECFD /* ComposePhotoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ComposePhotoCell.xib; sourceTree = "<group>"; };
B862A8891A970E25008B2310 /* DetailAnswerCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailAnswerCell.h; sourceTree = "<group>"; };
B862A88A1A970E25008B2310 /* DetailAnswerCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailAnswerCell.m; sourceTree = "<group>"; };
B862A88B1A970E25008B2310 /* DetailAnswerCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DetailAnswerCell.xib; sourceTree = "<group>"; };
B87C15B61A93113400191823 /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; };
B87C15B71A93113400191823 /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = "<group>"; };
B87C15B81A93113400191823 /* LoginViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = LoginViewController.xib; sourceTree = "<group>"; };
B895C49E1A9C7709001DF829 /* QuestionPhotos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuestionPhotos.h; sourceTree = "<group>"; };
B895C49F1A9C7709001DF829 /* QuestionPhotos.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuestionPhotos.m; sourceTree = "<group>"; };
B8BA93E61A9459B5003BD476 /* User.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = User.h; sourceTree = "<group>"; };
B8BA93E71A9459B5003BD476 /* User.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = User.m; sourceTree = "<group>"; };
B8BA93E91A9464C7003BD476 /* Question.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Question.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -192,6 +205,8 @@
B8BA93F61A947817003BD476 /* Vote.m */,
B8C0DBF21A95C2D60023BC39 /* ParseClient.h */,
B8C0DBF31A95C2D60023BC39 /* ParseClient.m */,
B895C49E1A9C7709001DF829 /* QuestionPhotos.h */,
B895C49F1A9C7709001DF829 /* QuestionPhotos.m */,
);
name = Parse;
sourceTree = "<group>";
Expand Down Expand Up @@ -306,6 +321,9 @@
3E4B809E1A9C42FB004F5D78 /* CommentView.h */,
3E4B809F1A9C42FB004F5D78 /* CommentView.m */,
3E4B80A11A9C4345004F5D78 /* CommentView.xib */,
B82956C31A9C5AA200D0ECFD /* ComposePhotoCell.h */,
B82956C41A9C5AA200D0ECFD /* ComposePhotoCell.m */,
B82956C51A9C5AA200D0ECFD /* ComposePhotoCell.xib */,
);
name = View;
sourceTree = "<group>";
Expand All @@ -331,6 +349,9 @@
3E7C1D561A95AA520046FDE1 /* SurveyViewController.h */,
3E7C1D571A95AA520046FDE1 /* SurveyViewController.m */,
3E7C1D581A95AA520046FDE1 /* SurveyViewController.xib */,
B82956B91A9C553200D0ECFD /* CameraViewController.h */,
B82956BA1A9C553200D0ECFD /* CameraViewController.m */,
B82956BB1A9C553200D0ECFD /* CameraViewController.xib */,
);
name = Control;
sourceTree = "<group>";
Expand Down Expand Up @@ -435,6 +456,7 @@
buildActionMask = 2147483647;
files = (
E25DBF0C1A948D870074D48B /* ProfileViewController.xib in Resources */,
B82956BD1A9C553200D0ECFD /* CameraViewController.xib in Resources */,
B8C704AB1A97065600243C3B /* DetailQuestionCell.xib in Resources */,
3E2BB7E11A94FF0000E78B3A /* AppNavigationController.xib in Resources */,
E25DBF071A9489530074D48B /* TabBarMenuViewController.xib in Resources */,
Expand All @@ -450,6 +472,7 @@
B8C0DBCE1A94F71A0023BC39 /* ComposeViewController.xib in Resources */,
3E4B80A21A9C4345004F5D78 /* CommentView.xib in Resources */,
3E7C1D501A958BC10046FDE1 /* HomeViewController.xib in Resources */,
B82956C71A9C5AA200D0ECFD /* ComposePhotoCell.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -501,6 +524,8 @@
buildActionMask = 2147483647;
files = (
B8C0DBF41A95C2D60023BC39 /* ParseClient.m in Sources */,
B82956C61A9C5AA200D0ECFD /* ComposePhotoCell.m in Sources */,
B895C4A01A9C7709001DF829 /* QuestionPhotos.m in Sources */,
B8BA93E81A9459B5003BD476 /* User.m in Sources */,
B8C0DBF11A95C1DA0023BC39 /* Survey.m in Sources */,
B81A2F161A9AC409001F2C6D /* GraphData.m in Sources */,
Expand All @@ -527,6 +552,7 @@
B8C0DBDC1A95138C0023BC39 /* ComposeAnswerCell.m in Sources */,
B827A9E81A9815E100AB43CE /* ProfileImageView.m in Sources */,
B87C15BC1A93113400191823 /* LoginViewController.m in Sources */,
B82956BC1A9C553200D0ECFD /* CameraViewController.m in Sources */,
B862A88C1A970E25008B2310 /* DetailAnswerCell.m in Sources */,
B8BA93F71A947817003BD476 /* Vote.m in Sources */,
);
Expand Down
3 changes: 3 additions & 0 deletions unnamed/Answer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
// Copyright (c) 2015 com.yahoo. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIImage.h>

@interface Answer : NSObject
@property (nonatomic, assign) NSInteger index;
@property (nonatomic, strong) NSString *text;
@property (nonatomic, strong) UIImage *photo;
@property (nonatomic, assign) NSInteger count;
@end
21 changes: 21 additions & 0 deletions unnamed/CameraViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// CameraViewController.h
// unnamed
//
// Created by Bruce Ng on 2/23/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//

#import <UIKit/UIKit.h>

@class CameraViewController;
@protocol CameraViewControllerDelegate <NSObject>

- (void)cameraViewController:(CameraViewController *)vc didSelectPhoto:(UIImage *)photo;

@end

@interface CameraViewController : UIViewController
@property (nonatomic, assign) NSIndexPath *indexPath;
@property (nonatomic,strong) id<CameraViewControllerDelegate> delegate;
@end
90 changes: 90 additions & 0 deletions unnamed/CameraViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// CameraViewController.m
// unnamed
//
// Created by Bruce Ng on 2/23/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//

#import "CameraViewController.h"

@interface CameraViewController () <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIAlertViewDelegate>
@property (weak, nonatomic) IBOutlet UIButton *takePhotoButton;
@property (weak, nonatomic) IBOutlet UIButton *selectPhotoButton;
@property (strong, nonatomic) IBOutlet UIImageView *photoImageView;

@end

@implementation CameraViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {

UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Device has no camera"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles: nil];

[myAlertView show];

}
}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
self.takePhotoButton.enabled = NO;
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)onTakePhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

[self presentViewController:picker animated:YES completion:NULL];
}

- (IBAction)onSelectPhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

[self presentViewController:picker animated:YES completion:NULL];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.photoImageView.image = chosenImage;

[picker dismissViewControllerAnimated:YES completion:NULL];

[self.delegate cameraViewController:self didSelectPhoto:chosenImage];


}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

[picker dismissViewControllerAnimated:YES completion:NULL];

}

/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end
59 changes: 59 additions & 0 deletions unnamed/CameraViewController.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="CameraViewController">
<connections>
<outlet property="photoImageView" destination="vXb-iN-7Vp" id="wRU-ku-g3j"/>
<outlet property="selectPhotoButton" destination="J2U-4C-9gb" id="A35-IU-PX1"/>
<outlet property="takePhotoButton" destination="3qn-rV-o56" id="3XI-hf-ws1"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="vXb-iN-7Vp">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<constraints>
<constraint firstAttribute="width" secondItem="vXb-iN-7Vp" secondAttribute="height" multiplier="1:1" id="erW-fD-vS7"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3qn-rV-o56">
<rect key="frame" x="262" y="530" width="77" height="30"/>
<state key="normal" title="Take Photo">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onTakePhoto:" destination="-1" eventType="touchUpInside" id="KQg-oJ-n6v"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="J2U-4C-9gb">
<rect key="frame" x="504" y="531" width="88" height="30"/>
<state key="normal" title="Select Photo">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onSelectPhoto:" destination="-1" eventType="touchUpInside" id="O9J-xs-i6Q"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="J2U-4C-9gb" secondAttribute="bottom" constant="39" id="08R-fW-wtk"/>
<constraint firstItem="vXb-iN-7Vp" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="2w7-FZ-TFL"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="vXb-iN-7Vp" secondAttribute="bottom" id="Akd-IX-D2n"/>
<constraint firstAttribute="trailing" secondItem="J2U-4C-9gb" secondAttribute="trailing" constant="8" id="FaO-Go-8IS"/>
<constraint firstItem="vXb-iN-7Vp" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="Frz-lF-6ZH"/>
<constraint firstAttribute="centerX" secondItem="3qn-rV-o56" secondAttribute="centerX" id="Ktd-PS-Cux"/>
<constraint firstAttribute="trailing" secondItem="vXb-iN-7Vp" secondAttribute="trailing" id="PQI-PG-V0d"/>
<constraint firstAttribute="bottom" secondItem="3qn-rV-o56" secondAttribute="bottom" constant="40" id="a8N-RB-i56"/>
</constraints>
</view>
</objects>
</document>
14 changes: 14 additions & 0 deletions unnamed/ComposePhotoCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// ComposePhotoCell.h
// unnamed
//
// Created by Bruce Ng on 2/23/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "Answer.h"

@interface ComposePhotoCell : UICollectionViewCell
@property (nonatomic, strong) Answer *answer;
@end
33 changes: 33 additions & 0 deletions unnamed/ComposePhotoCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// ComposePhotoCell.m
// unnamed
//
// Created by Bruce Ng on 2/23/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//

#import "ComposePhotoCell.h"
#import "UIColor+AppColor.h"
@interface ComposePhotoCell()
@property (weak, nonatomic) IBOutlet UILabel *addPhotoLabel;
@property (weak, nonatomic) IBOutlet UIImageView *photoView;
@end

@implementation ComposePhotoCell

- (void)awakeFromNib {
// Initialization code
}

- (void)layoutSubviews {
if (self.answer && self.answer.photo) {
[self.photoView setImage:self.answer.photo];
self.photoView.alpha = 1;
self.addPhotoLabel.alpha = 0;
} else {
self.photoView.alpha = 0;
self.addPhotoLabel.alpha = 1;
}
}

@end
Loading

0 comments on commit 62d8f3f

Please sign in to comment.