Skip to content

Commit

Permalink
Fix survey detail screen for better bar graph visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
brung committed Feb 23, 2015
1 parent 40641f7 commit c2a94a1
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 176 deletions.
10 changes: 0 additions & 10 deletions unnamed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
3E7C1D591A95AA520046FDE1 /* SurveyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E7C1D571A95AA520046FDE1 /* SurveyViewController.m */; };
3E7C1D5A1A95AA520046FDE1 /* SurveyViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3E7C1D581A95AA520046FDE1 /* SurveyViewController.xib */; };
3EC3AEE11A9AB22100E0DCCB /* UIColor+AppColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EC3AEE01A9AB22100E0DCCB /* UIColor+AppColor.m */; };
B81A2F121A9AC237001F2C6D /* DetailGraphCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B81A2F101A9AC237001F2C6D /* DetailGraphCell.m */; };
B81A2F131A9AC237001F2C6D /* DetailGraphCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B81A2F111A9AC237001F2C6D /* DetailGraphCell.xib */; };
B81A2F161A9AC409001F2C6D /* GraphData.m in Sources */ = {isa = PBXBuildFile; fileRef = B81A2F151A9AC409001F2C6D /* GraphData.m */; };
B827A9E81A9815E100AB43CE /* ProfileImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = B827A9E71A9815E100AB43CE /* ProfileImageView.m */; };
B827A9EE1A98287B00AB43CE /* GrayBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = B827A9ED1A98287B00AB43CE /* GrayBarButtonItem.m */; };
Expand Down Expand Up @@ -87,9 +85,6 @@
3EC3AEE01A9AB22100E0DCCB /* UIColor+AppColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+AppColor.m"; sourceTree = "<group>"; };
4AEAEEA448EAC175BD0FED56 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
5BA90E0F57CF5978BEB02DE4 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
B81A2F0F1A9AC237001F2C6D /* DetailGraphCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DetailGraphCell.h; sourceTree = "<group>"; };
B81A2F101A9AC237001F2C6D /* DetailGraphCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DetailGraphCell.m; sourceTree = "<group>"; };
B81A2F111A9AC237001F2C6D /* DetailGraphCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DetailGraphCell.xib; sourceTree = "<group>"; };
B81A2F141A9AC409001F2C6D /* GraphData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphData.h; sourceTree = "<group>"; };
B81A2F151A9AC409001F2C6D /* GraphData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GraphData.m; sourceTree = "<group>"; };
B827A9E61A9815E100AB43CE /* ProfileImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfileImageView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -293,9 +288,6 @@
3E58B4D21A9832BF00AA14D4 /* AnswerView.h */,
3E58B4D31A9832BF00AA14D4 /* AnswerView.m */,
3E58B4D51A984C3900AA14D4 /* AnswerView.xib */,
B81A2F0F1A9AC237001F2C6D /* DetailGraphCell.h */,
B81A2F101A9AC237001F2C6D /* DetailGraphCell.m */,
B81A2F111A9AC237001F2C6D /* DetailGraphCell.xib */,
);
name = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -433,7 +425,6 @@
3E58B4D61A984C3900AA14D4 /* AnswerView.xib in Resources */,
3E7C1D5A1A95AA520046FDE1 /* SurveyViewController.xib in Resources */,
B862A88D1A970E25008B2310 /* DetailAnswerCell.xib in Resources */,
B81A2F131A9AC237001F2C6D /* DetailGraphCell.xib in Resources */,
B8C291C01A930BDD000F2143 /* Images.xcassets in Resources */,
B87C15BD1A93113400191823 /* LoginViewController.xib in Resources */,
B8C0DBDD1A95138C0023BC39 /* ComposeAnswerCell.xib in Resources */,
Expand Down Expand Up @@ -498,7 +489,6 @@
3E58B4CB1A98229200AA14D4 /* SurveyViewCell.m in Sources */,
B8C704AA1A97065600243C3B /* DetailQuestionCell.m in Sources */,
3E2BB7E01A94FF0000E78B3A /* AppNavigationController.m in Sources */,
B81A2F121A9AC237001F2C6D /* DetailGraphCell.m in Sources */,
B8BA93F41A947718003BD476 /* Answer.m in Sources */,
B8C0DBCD1A94F71A0023BC39 /* ComposeViewController.m in Sources */,
B8C291B81A930BDD000F2143 /* AppDelegate.m in Sources */,
Expand Down
4 changes: 1 addition & 3 deletions unnamed/DetailAnswerCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#import "Answer.h"

@interface DetailAnswerCell : UITableViewCell
@property (nonatomic, strong) Answer *answer;
@property (nonatomic, assign) NSInteger index;
@property (nonatomic, assign) BOOL isCurrentVote;
@property (weak, nonatomic) IBOutlet UIImageView *selectionImage;

- (void) initWithAnswer:(Answer *)answer totalVotes:(NSInteger)count;
@end
29 changes: 21 additions & 8 deletions unnamed/DetailAnswerCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,44 @@
//

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

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

@property (weak, nonatomic) IBOutlet UILabel *answerIndexLabel;
@property (weak, nonatomic) IBOutlet UILabel *answerLabel;
@property (weak, nonatomic) IBOutlet GRKBarGraphView *barGraph;
@property (weak, nonatomic) IBOutlet UILabel *percentLabel;

@end

@implementation DetailAnswerCell

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

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

- (void)layoutSubviews {

self.answerIndexLabel.text = [NSString stringWithFormat:@"%ld.", (long)self.answer.index +1];
self.answerLabel.text = self.answer.text;
float percent = (float)self.answer.count / (float)self.totalVotes;
self.percentLabel.text = [NSString stringWithFormat:@"%.1f%%", percent * 100];
self.barGraph.percent = percent;
}

- (void)setAnswer:(Answer *)answer {
- (void) initWithAnswer:(Answer *)answer totalVotes:(NSInteger)count {
_answer = answer;
self.answerLabel.text = [NSString stringWithFormat:@"%ld. %@", (long)self.answer.index+1, self.answer.text];
}

- (void)setIndex:(NSInteger)index {
_index = index;
self.answerLabel.text = [NSString stringWithFormat:@"%ld. %@", (long)self.answer.index+1, self.answer.text];
_totalVotes = count;
}

- (void)setIsCurrentVote:(BOOL)isCurrentVote {
Expand Down
47 changes: 41 additions & 6 deletions unnamed/DetailAnswerCell.xib
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1Xh-Ul-rC5">
<rect key="frame" x="8" y="26" width="31" height="15"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1." lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1Xh-Ul-rC5">
<rect key="frame" x="8" y="26" width="11" height="15"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="Some answer" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mLX-L2-SWI">
<rect key="frame" x="27" y="25" width="209" height="15"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
Expand All @@ -28,32 +34,61 @@
<constraint firstAttribute="height" constant="32" id="doC-qN-PGf"/>
</constraints>
</imageView>
<view alpha="0.29999999999999999" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4ZA-wD-E7p" customClass="GRKBarGraphView">
<rect key="frame" x="23" y="17" width="249" height="33"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="33" id="0c6-Wz-Dor"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="32%" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="diZ-94-6g0">
<rect key="frame" x="244" y="26" width="26" height="15"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="1Xh-Ul-rC5" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="8" id="5te-vN-Yzl"/>
<constraint firstItem="xwf-pX-8Wb" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="1Xh-Ul-rC5" secondAttribute="trailing" constant="8" id="62C-bf-ugZ"/>
<constraint firstItem="xwf-pX-8Wb" firstAttribute="leading" secondItem="1Xh-Ul-rC5" secondAttribute="trailing" constant="8" id="62C-bf-ugZ"/>
<constraint firstAttribute="centerY" secondItem="mLX-L2-SWI" secondAttribute="centerY" id="8zP-8l-AbE"/>
<constraint firstItem="xwf-pX-8Wb" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="8" id="Ah3-Cz-EwZ"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="1Xh-Ul-rC5" secondAttribute="bottom" constant="8" id="BKo-kS-9tO"/>
<constraint firstItem="xwf-pX-8Wb" firstAttribute="top" relation="greaterThanOrEqual" secondItem="H2p-sc-9uM" secondAttribute="top" constant="4" id="CQ8-cC-v1W"/>
<constraint firstAttribute="centerY" secondItem="xwf-pX-8Wb" secondAttribute="centerY" id="FJA-UK-3J9"/>
<constraint firstAttribute="centerY" secondItem="diZ-94-6g0" secondAttribute="centerY" id="IJB-Zv-cmh"/>
<constraint firstItem="xwf-pX-8Wb" firstAttribute="leading" secondItem="4ZA-wD-E7p" secondAttribute="trailing" constant="8" id="IWm-Pc-nU9"/>
<constraint firstItem="diZ-94-6g0" firstAttribute="leading" secondItem="mLX-L2-SWI" secondAttribute="trailing" constant="8" id="Lmf-wU-qH5"/>
<constraint firstItem="4ZA-wD-E7p" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="14" id="PgD-Ge-KyA"/>
<constraint firstItem="4ZA-wD-E7p" firstAttribute="leading" secondItem="mLX-L2-SWI" secondAttribute="leading" id="Uud-v2-Sqb"/>
<constraint firstAttribute="bottomMargin" secondItem="xwf-pX-8Wb" secondAttribute="bottom" constant="8" id="WRA-yx-9Ea"/>
<constraint firstAttribute="centerY" secondItem="4ZA-wD-E7p" secondAttribute="centerY" id="bKU-98-gDw"/>
<constraint firstItem="4ZA-wD-E7p" firstAttribute="leading" secondItem="1Xh-Ul-rC5" secondAttribute="trailing" constant="4" id="c5l-NG-lpM"/>
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="xwf-pX-8Wb" secondAttribute="bottom" constant="4" id="d94-Bf-tTx"/>
<constraint firstItem="mLX-L2-SWI" firstAttribute="leading" secondItem="1Xh-Ul-rC5" secondAttribute="trailing" constant="8" id="h6s-fE-vvC"/>
<constraint firstAttribute="centerY" secondItem="1Xh-Ul-rC5" secondAttribute="centerY" id="jOP-LW-StK"/>
<constraint firstAttribute="trailing" secondItem="xwf-pX-8Wb" secondAttribute="trailing" constant="8" id="sSw-UB-2aH"/>
<constraint firstItem="xwf-pX-8Wb" firstAttribute="leading" secondItem="diZ-94-6g0" secondAttribute="trailing" constant="10" id="tlj-pm-1Vi"/>
<constraint firstItem="1Xh-Ul-rC5" firstAttribute="top" relation="greaterThanOrEqual" secondItem="H2p-sc-9uM" secondAttribute="top" constant="8" id="yv0-89-TJV"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="PgD-Ge-KyA"/>
<exclude reference="Uud-v2-Sqb"/>
<exclude reference="62C-bf-ugZ"/>
<exclude reference="Ah3-Cz-EwZ"/>
<exclude reference="WRA-yx-9Ea"/>
</mask>
</variation>
</tableViewCellContentView>
<connections>
<outlet property="answerLabel" destination="1Xh-Ul-rC5" id="3VB-PQ-E6B"/>
<outlet property="answerIndexLabel" destination="1Xh-Ul-rC5" id="fmA-Jr-8Fh"/>
<outlet property="answerLabel" destination="mLX-L2-SWI" id="YbB-Wm-kGB"/>
<outlet property="barGraph" destination="4ZA-wD-E7p" id="6rK-8Y-Y2C"/>
<outlet property="percentLabel" destination="diZ-94-6g0" id="wUY-yF-KUh"/>
<outlet property="selectionImage" destination="xwf-pX-8Wb" id="uVj-MO-gWS"/>
</connections>
<point key="canvasLocation" x="140" y="163.5"/>
<point key="canvasLocation" x="140" y="159.5"/>
</tableViewCell>
</objects>
</document>
15 changes: 0 additions & 15 deletions unnamed/DetailGraphCell.h

This file was deleted.

47 changes: 0 additions & 47 deletions unnamed/DetailGraphCell.m

This file was deleted.

47 changes: 0 additions & 47 deletions unnamed/DetailGraphCell.xib

This file was deleted.

Loading

0 comments on commit c2a94a1

Please sign in to comment.