Skip to content

Commit

Permalink
Add DetailPhotoAnswerCell to Survey Detail View
Browse files Browse the repository at this point in the history
  • Loading branch information
casing committed Feb 26, 2015
1 parent 3b1cdce commit 8d9a939
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 10 deletions.
10 changes: 10 additions & 0 deletions unnamed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
3E2BB7E01A94FF0000E78B3A /* AppNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E2BB7DE1A94FF0000E78B3A /* AppNavigationController.m */; };
3E2BB7E11A94FF0000E78B3A /* AppNavigationController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3E2BB7DF1A94FF0000E78B3A /* AppNavigationController.xib */; };
3E3C84C11A9DB7FD00A053CA /* DetailPhotoAnswerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E3C84BF1A9DB7FD00A053CA /* DetailPhotoAnswerCell.m */; };
3E3C84C21A9DB7FD00A053CA /* DetailPhotoAnswerCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3E3C84C01A9DB7FD00A053CA /* DetailPhotoAnswerCell.xib */; };
3E4B809D1A9C41CF004F5D78 /* CommentCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E4B809C1A9C41CF004F5D78 /* CommentCollectionView.m */; };
3E4B80A01A9C42FB004F5D78 /* CommentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E4B809F1A9C42FB004F5D78 /* CommentView.m */; };
3E4B80A21A9C4345004F5D78 /* CommentView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3E4B80A11A9C4345004F5D78 /* CommentView.xib */; };
Expand Down Expand Up @@ -79,6 +81,9 @@
3E2BB7DD1A94FF0000E78B3A /* AppNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppNavigationController.h; sourceTree = "<group>"; };
3E2BB7DE1A94FF0000E78B3A /* AppNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppNavigationController.m; sourceTree = "<group>"; };
3E2BB7DF1A94FF0000E78B3A /* AppNavigationController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AppNavigationController.xib; sourceTree = "<group>"; };
3E3C84BE1A9DB7FD00A053CA /* DetailPhotoAnswerCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailPhotoAnswerCell.h; sourceTree = "<group>"; };
3E3C84BF1A9DB7FD00A053CA /* DetailPhotoAnswerCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailPhotoAnswerCell.m; sourceTree = "<group>"; };
3E3C84C01A9DB7FD00A053CA /* DetailPhotoAnswerCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DetailPhotoAnswerCell.xib; sourceTree = "<group>"; };
3E4B809B1A9C41CF004F5D78 /* CommentCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentCollectionView.h; sourceTree = "<group>"; };
3E4B809C1A9C41CF004F5D78 /* CommentCollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CommentCollectionView.m; sourceTree = "<group>"; };
3E4B809E1A9C42FB004F5D78 /* CommentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommentView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -340,6 +345,9 @@
B895C4AC1A9D6516001DF829 /* PhotoAnswerCell.h */,
B895C4AD1A9D6516001DF829 /* PhotoAnswerCell.m */,
B895C4AE1A9D6516001DF829 /* PhotoAnswerCell.xib */,
3E3C84BE1A9DB7FD00A053CA /* DetailPhotoAnswerCell.h */,
3E3C84BF1A9DB7FD00A053CA /* DetailPhotoAnswerCell.m */,
3E3C84C01A9DB7FD00A053CA /* DetailPhotoAnswerCell.xib */,
);
name = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -482,6 +490,7 @@
B87C15BD1A93113400191823 /* LoginViewController.xib in Resources */,
B8C0DBDD1A95138C0023BC39 /* ComposeAnswerCell.xib in Resources */,
B895C4A51A9CD9D4001DF829 /* PhotoAnswerView.xib in Resources */,
3E3C84C21A9DB7FD00A053CA /* DetailPhotoAnswerCell.xib in Resources */,
3E58B4CC1A98229200AA14D4 /* SurveyViewCell.xib in Resources */,
B8C0DBCE1A94F71A0023BC39 /* ComposeViewController.xib in Resources */,
3E4B80A21A9C4345004F5D78 /* CommentView.xib in Resources */,
Expand Down Expand Up @@ -571,6 +580,7 @@
B895C4AF1A9D6516001DF829 /* PhotoAnswerCell.m in Sources */,
B862A88C1A970E25008B2310 /* DetailAnswerCell.m in Sources */,
B8BA93F71A947817003BD476 /* Vote.m in Sources */,
3E3C84C11A9DB7FD00A053CA /* DetailPhotoAnswerCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
18 changes: 18 additions & 0 deletions unnamed/DetailPhotoAnswerCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// DetailPhotoAnswerCell.h
// unnamed
//
// Created by Casing Chu on 2/24/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//

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

@interface DetailPhotoAnswerCell : UITableViewCell

@property (nonatomic, assign) BOOL isCurrentVote;
@property (weak, nonatomic) IBOutlet UIImageView *selectionImage;
- (void) initWithAnswer:(Answer *)answer totalVotes:(NSInteger)count;

@end
72 changes: 72 additions & 0 deletions unnamed/DetailPhotoAnswerCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// DetailPhotoAnswerCell.m
// unnamed
//
// Created by Casing Chu on 2/24/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//

#import "DetailPhotoAnswerCell.h"
#import "UIColor+AppColor.h"
#import "GRKBarGraphView.h"

@interface DetailPhotoAnswerCell ()

@property (weak, nonatomic) IBOutlet UIImageView *photoAnswerImageView;
@property (weak, nonatomic) IBOutlet UILabel *percentLabel;
@property (weak, nonatomic) IBOutlet UIImageView *voteImageView;
@property (weak, nonatomic) IBOutlet GRKBarGraphView *barGraphView;

@property (nonatomic, strong) Answer *answer;
@property (nonatomic, assign) NSInteger totalVotes;

- (void)displayVoteIcon;

@end

@implementation DetailPhotoAnswerCell

- (void)awakeFromNib {
// Initialization code
// Initialization code
self.barGraphView.barStyle = GRKBarStyleFromBottom;
self.barGraphView.barColor = [UIColor appTintColor];
self.barGraphView.tintColor = [UIColor appTintColor];
self.barGraphView.contentMode = UIViewContentModeCenter;
self.barGraphView.animationDuration = 1;

[self.selectionImage setImage:[UIImage imageNamed:@"answer_unselected"]];
}

- (void)layoutSubviews {
float percent = self.totalVotes > 0 ? (float)self.answer.count / (float)self.totalVotes : 0;
self.percentLabel.text = [NSString stringWithFormat:@"%.1f%%", percent * 100];
self.photoAnswerImageView.image = self.answer.photo;
self.barGraphView.percent = percent;
}

- (void) initWithAnswer:(Answer *)answer totalVotes:(NSInteger)count {
_answer = answer;
_totalVotes = count;
}

- (void)setIsCurrentVote:(BOOL)isCurrentVote {
_isCurrentVote = isCurrentVote;
[self displayVoteIcon];
}

- (void) displayVoteIcon {
if (self.isCurrentVote) {
[self.selectionImage setImage:[UIImage imageNamed:@"answer_selected"]];
} else {
[self.selectionImage setImage:[UIImage imageNamed:@"answer_unselected"]];
}
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

@end
109 changes: 109 additions & 0 deletions unnamed/DetailPhotoAnswerCell.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="233" id="KGk-i7-Jjw" customClass="DetailPhotoAnswerCell">
<rect key="frame" x="0.0" y="0.0" width="388" height="233"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="sZ1-qQ-zdP">
<rect key="frame" x="8" y="44.5" width="145" height="145"/>
<constraints>
<constraint firstAttribute="height" constant="145" id="5eE-tc-QZI"/>
<constraint firstAttribute="width" constant="145" id="WZE-BK-ceH"/>
<constraint firstAttribute="height" constant="150" id="xru-Td-8pu"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="xru-Td-8pu"/>
</mask>
</variation>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="btq-ii-Ckc">
<rect key="frame" x="311" y="85" width="64" height="64"/>
<constraints>
<constraint firstAttribute="width" constant="64" id="xBr-22-Ikl"/>
<constraint firstAttribute="height" constant="64" id="xZ7-25-vrH"/>
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yi9-IC-JZL">
<rect key="frame" x="233" y="43.5" width="70" height="145"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="100.0%" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QWp-06-bBm">
<rect key="frame" x="0.0" y="116" width="69.5" height="29"/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aN1-84-63s" customClass="GRKBarGraphView">
<rect key="frame" x="25" y="0.0" width="20" height="110"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="20" id="LQO-DI-D26"/>
<constraint firstAttribute="height" constant="150" id="eaP-0C-VeA"/>
<constraint firstAttribute="width" constant="20" id="mPr-Ge-DVq"/>
<constraint firstAttribute="height" constant="118" id="uUb-9g-BXU"/>
<constraint firstAttribute="height" constant="110" id="vf0-1N-EXh"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="eaP-0C-VeA"/>
<exclude reference="mPr-Ge-DVq"/>
<exclude reference="uUb-9g-BXU"/>
</mask>
</variation>
</view>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="QWp-06-bBm" secondAttribute="trailing" id="C9R-iC-XRv"/>
<constraint firstAttribute="height" constant="145" id="QeS-5F-oyJ"/>
<constraint firstAttribute="bottom" secondItem="QWp-06-bBm" secondAttribute="bottom" id="Sgx-RS-MZP"/>
<constraint firstItem="aN1-84-63s" firstAttribute="top" secondItem="yi9-IC-JZL" secondAttribute="top" id="fqa-8A-FgR"/>
<constraint firstAttribute="centerX" secondItem="aN1-84-63s" secondAttribute="centerX" id="h4F-Ki-Lae"/>
<constraint firstAttribute="trailing" secondItem="aN1-84-63s" secondAttribute="trailing" constant="25" id="hoy-uO-2d8"/>
<constraint firstAttribute="centerX" secondItem="QWp-06-bBm" secondAttribute="centerX" id="kcU-sN-5Lv"/>
<constraint firstAttribute="width" constant="70" id="lfM-av-UNx"/>
<constraint firstItem="QWp-06-bBm" firstAttribute="top" secondItem="aN1-84-63s" secondAttribute="bottom" constant="6" id="oYA-Nv-R7o"/>
<constraint firstItem="aN1-84-63s" firstAttribute="leading" secondItem="yi9-IC-JZL" secondAttribute="leading" constant="25" id="p2I-mx-e5V"/>
<constraint firstItem="QWp-06-bBm" firstAttribute="leading" secondItem="yi9-IC-JZL" secondAttribute="leading" id="zfE-Go-AHP"/>
</constraints>
</view>
</subviews>
<constraints>
<constraint firstItem="sZ1-qQ-zdP" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="8" id="1BR-qM-T05"/>
<constraint firstItem="yi9-IC-JZL" firstAttribute="leading" secondItem="sZ1-qQ-zdP" secondAttribute="trailing" constant="80" id="1LN-gR-f4s"/>
<constraint firstAttribute="centerY" secondItem="btq-ii-Ckc" secondAttribute="centerY" id="8S5-G8-maf"/>
<constraint firstItem="sZ1-qQ-zdP" firstAttribute="top" relation="greaterThanOrEqual" secondItem="H2p-sc-9uM" secondAttribute="top" constant="8" id="A7J-fK-yZJ"/>
<constraint firstAttribute="centerY" secondItem="sZ1-qQ-zdP" secondAttribute="centerY" id="ZVc-sW-tEy"/>
<constraint firstAttribute="centerY" secondItem="yi9-IC-JZL" secondAttribute="centerY" id="a8u-Lm-lKV"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="btq-ii-Ckc" secondAttribute="bottom" constant="8" id="bvb-Xu-ixO"/>
<constraint firstAttribute="bottom" secondItem="sZ1-qQ-zdP" secondAttribute="bottom" constant="8" id="cWg-tv-XdD"/>
<constraint firstItem="btq-ii-Ckc" firstAttribute="leading" secondItem="yi9-IC-JZL" secondAttribute="trailing" constant="8" id="iem-ai-YnM"/>
<constraint firstAttribute="trailing" secondItem="btq-ii-Ckc" secondAttribute="trailing" constant="8" id="k5C-EY-bhe"/>
<constraint firstItem="btq-ii-Ckc" firstAttribute="top" relation="greaterThanOrEqual" secondItem="H2p-sc-9uM" secondAttribute="top" constant="8" id="ku1-tn-wpm"/>
<constraint firstAttribute="bottomMargin" relation="greaterThanOrEqual" secondItem="sZ1-qQ-zdP" secondAttribute="bottom" constant="8" id="mJZ-L1-swn"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="cWg-tv-XdD"/>
</mask>
</variation>
</tableViewCellContentView>
<connections>
<outlet property="barGraphView" destination="aN1-84-63s" id="dzi-rV-IlS"/>
<outlet property="percentLabel" destination="QWp-06-bBm" id="G69-6e-yvv"/>
<outlet property="photoAnswerImageView" destination="sZ1-qQ-zdP" id="D4F-7a-pjM"/>
<outlet property="selectionImage" destination="btq-ii-Ckc" id="KZM-zc-kzw"/>
</connections>
<point key="canvasLocation" x="107" y="260.5"/>
</tableViewCell>
</objects>
</document>
2 changes: 1 addition & 1 deletion unnamed/PhotoAnswerCell.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" 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"/>
Expand Down
2 changes: 1 addition & 1 deletion unnamed/SurveyViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?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">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
Expand Down
Loading

0 comments on commit 8d9a939

Please sign in to comment.