Skip to content

Commit

Permalink
Attempts to display photos
Browse files Browse the repository at this point in the history
  • Loading branch information
brung committed Feb 25, 2015
1 parent 19918c6 commit ddcb958
Show file tree
Hide file tree
Showing 15 changed files with 483 additions and 4 deletions.
39 changes: 37 additions & 2 deletions unnamed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
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 */; };
B895C4A31A9CD9B8001DF829 /* PhotoAnswerView.m in Sources */ = {isa = PBXBuildFile; fileRef = B895C4A21A9CD9B8001DF829 /* PhotoAnswerView.m */; };
B895C4A51A9CD9D4001DF829 /* PhotoAnswerView.xib in Resources */ = {isa = PBXBuildFile; fileRef = B895C4A41A9CD9D4001DF829 /* PhotoAnswerView.xib */; };
B895C4A81A9CDE1B001DF829 /* PhotoAnswerCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = B895C4A71A9CDE1B001DF829 /* PhotoAnswerCollectionView.m */; };
B895C4AB1A9D5BC9001DF829 /* UIImageView+Parse.m in Sources */ = {isa = PBXBuildFile; fileRef = B895C4AA1A9D5BC9001DF829 /* UIImageView+Parse.m */; };
B895C4AF1A9D6516001DF829 /* PhotoAnswerCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B895C4AD1A9D6516001DF829 /* PhotoAnswerCell.m */; };
B895C4B01A9D6516001DF829 /* PhotoAnswerCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = B895C4AE1A9D6516001DF829 /* PhotoAnswerCell.xib */; };
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 @@ -121,6 +127,16 @@
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>"; };
B895C4A11A9CD9B8001DF829 /* PhotoAnswerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoAnswerView.h; sourceTree = "<group>"; };
B895C4A21A9CD9B8001DF829 /* PhotoAnswerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoAnswerView.m; sourceTree = "<group>"; };
B895C4A41A9CD9D4001DF829 /* PhotoAnswerView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PhotoAnswerView.xib; sourceTree = "<group>"; };
B895C4A61A9CDE1B001DF829 /* PhotoAnswerCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoAnswerCollectionView.h; sourceTree = "<group>"; };
B895C4A71A9CDE1B001DF829 /* PhotoAnswerCollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoAnswerCollectionView.m; sourceTree = "<group>"; };
B895C4A91A9D5BC9001DF829 /* UIImageView+Parse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+Parse.h"; sourceTree = "<group>"; };
B895C4AA1A9D5BC9001DF829 /* UIImageView+Parse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+Parse.m"; sourceTree = "<group>"; };
B895C4AC1A9D6516001DF829 /* PhotoAnswerCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhotoAnswerCell.h; sourceTree = "<group>"; };
B895C4AD1A9D6516001DF829 /* PhotoAnswerCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhotoAnswerCell.m; sourceTree = "<group>"; };
B895C4AE1A9D6516001DF829 /* PhotoAnswerCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PhotoAnswerCell.xib; 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 @@ -197,14 +213,14 @@
B8C0DBEE1A95C15B0023BC39 /* Parse */ = {
isa = PBXGroup;
children = (
B8C0DBF21A95C2D60023BC39 /* ParseClient.h */,
B8C0DBF31A95C2D60023BC39 /* ParseClient.m */,
B8BA93E91A9464C7003BD476 /* Question.h */,
B8BA93EA1A9464C7003BD476 /* Question.m */,
B8BA93F21A947718003BD476 /* Answer.h */,
B8BA93F31A947718003BD476 /* Answer.m */,
B8BA93F51A947817003BD476 /* Vote.h */,
B8BA93F61A947817003BD476 /* Vote.m */,
B8C0DBF21A95C2D60023BC39 /* ParseClient.h */,
B8C0DBF31A95C2D60023BC39 /* ParseClient.m */,
B895C49E1A9C7709001DF829 /* QuestionPhotos.h */,
B895C49F1A9C7709001DF829 /* QuestionPhotos.m */,
);
Expand Down Expand Up @@ -257,6 +273,8 @@
B827A9ED1A98287B00AB43CE /* GrayBarButtonItem.m */,
3EC3AEDF1A9AB22100E0DCCB /* UIColor+AppColor.h */,
3EC3AEE01A9AB22100E0DCCB /* UIColor+AppColor.m */,
B895C4A91A9D5BC9001DF829 /* UIImageView+Parse.h */,
B895C4AA1A9D5BC9001DF829 /* UIImageView+Parse.m */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -297,6 +315,9 @@
B8C0DBD91A95138C0023BC39 /* ComposeAnswerCell.h */,
B8C0DBDA1A95138C0023BC39 /* ComposeAnswerCell.m */,
B8C0DBDB1A95138C0023BC39 /* ComposeAnswerCell.xib */,
B82956C31A9C5AA200D0ECFD /* ComposePhotoCell.h */,
B82956C41A9C5AA200D0ECFD /* ComposePhotoCell.m */,
B82956C51A9C5AA200D0ECFD /* ComposePhotoCell.xib */,
E2C6FF1B1A96C178005AEDA9 /* ProfileCell.h */,
E2C6FF1C1A96C178005AEDA9 /* ProfileCell.m */,
E2C6FF1D1A96C178005AEDA9 /* ProfileCell.xib */,
Expand Down Expand Up @@ -324,6 +345,14 @@
B82956C31A9C5AA200D0ECFD /* ComposePhotoCell.h */,
B82956C41A9C5AA200D0ECFD /* ComposePhotoCell.m */,
B82956C51A9C5AA200D0ECFD /* ComposePhotoCell.xib */,
B895C4A61A9CDE1B001DF829 /* PhotoAnswerCollectionView.h */,
B895C4A71A9CDE1B001DF829 /* PhotoAnswerCollectionView.m */,
B895C4A11A9CD9B8001DF829 /* PhotoAnswerView.h */,
B895C4A21A9CD9B8001DF829 /* PhotoAnswerView.m */,
B895C4A41A9CD9D4001DF829 /* PhotoAnswerView.xib */,
B895C4AC1A9D6516001DF829 /* PhotoAnswerCell.h */,
B895C4AD1A9D6516001DF829 /* PhotoAnswerCell.m */,
B895C4AE1A9D6516001DF829 /* PhotoAnswerCell.xib */,
);
name = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -466,8 +495,10 @@
3E7C1D5A1A95AA520046FDE1 /* SurveyViewController.xib in Resources */,
B862A88D1A970E25008B2310 /* DetailAnswerCell.xib in Resources */,
B8C291C01A930BDD000F2143 /* Images.xcassets in Resources */,
B895C4B01A9D6516001DF829 /* PhotoAnswerCell.xib in Resources */,
B87C15BD1A93113400191823 /* LoginViewController.xib in Resources */,
B8C0DBDD1A95138C0023BC39 /* ComposeAnswerCell.xib in Resources */,
B895C4A51A9CD9D4001DF829 /* PhotoAnswerView.xib in Resources */,
3E58B4CC1A98229200AA14D4 /* SurveyViewCell.xib in Resources */,
B8C0DBCE1A94F71A0023BC39 /* ComposeViewController.xib in Resources */,
3E4B80A21A9C4345004F5D78 /* CommentView.xib in Resources */,
Expand Down Expand Up @@ -528,6 +559,7 @@
B895C4A01A9C7709001DF829 /* QuestionPhotos.m in Sources */,
B8BA93E81A9459B5003BD476 /* User.m in Sources */,
B8C0DBF11A95C1DA0023BC39 /* Survey.m in Sources */,
B895C4AB1A9D5BC9001DF829 /* UIImageView+Parse.m in Sources */,
B81A2F161A9AC409001F2C6D /* GraphData.m in Sources */,
3E58B4D41A9832BF00AA14D4 /* AnswerView.m in Sources */,
3E58B4CB1A98229200AA14D4 /* SurveyViewCell.m in Sources */,
Expand All @@ -538,7 +570,9 @@
B8C0DBCD1A94F71A0023BC39 /* ComposeViewController.m in Sources */,
B8C291B81A930BDD000F2143 /* AppDelegate.m in Sources */,
B8C291B51A930BDD000F2143 /* main.m in Sources */,
B895C4A81A9CDE1B001DF829 /* PhotoAnswerCollectionView.m in Sources */,
E2C6FF1E1A96C178005AEDA9 /* ProfileCell.m in Sources */,
B895C4A31A9CD9B8001DF829 /* PhotoAnswerView.m in Sources */,
E25DBF0B1A948D870074D48B /* ProfileViewController.m in Sources */,
3E7C1D4F1A958BC10046FDE1 /* HomeViewController.m in Sources */,
B82956B81A9B10C000D0ECFD /* HomeProfileAnimation.m in Sources */,
Expand All @@ -553,6 +587,7 @@
B827A9E81A9815E100AB43CE /* ProfileImageView.m in Sources */,
B87C15BC1A93113400191823 /* LoginViewController.m in Sources */,
B82956BC1A9C553200D0ECFD /* CameraViewController.m in Sources */,
B895C4AF1A9D6516001DF829 /* PhotoAnswerCell.m in Sources */,
B862A88C1A970E25008B2310 /* DetailAnswerCell.m in Sources */,
B8BA93F71A947817003BD476 /* Vote.m in Sources */,
);
Expand Down
2 changes: 2 additions & 0 deletions unnamed/Answer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIImage.h>
#import <Parse/Parse.h>

@interface Answer : NSObject
@property (nonatomic, assign) NSInteger index;
@property (nonatomic, strong) NSString *text;
@property (nonatomic, strong) UIImage *photo;
@property (nonatomic, strong) PFFile *photoFile;
@property (nonatomic, assign) NSInteger count;
@end
21 changes: 19 additions & 2 deletions unnamed/HomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
#import "SurveyViewController.h"
#import "ProfileViewController.h"
#import "SurveyViewCell.h"
#import "PhotoAnswerCell.h"
#import "ParseClient.h"
#import "UIColor+AppColor.h"
#import "HomeProfileAnimation.h"

NSString * const kSurveyViewCell = @"SurveyViewCell";
NSString * const kPhotoViewCell = @"PhotoAnswerCell";

@interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, SurveyViewCellDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
Expand All @@ -24,6 +26,7 @@ @interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, Su
@property (nonatomic, assign) BOOL isUpdating;
@property (nonatomic, assign) BOOL isInsertingNewPost;
@property (nonatomic, strong) SurveyViewCell * prototypeSurveyCell;
@property (nonatomic, strong) PhotoAnswerCell *prototypePhotoCell;
@property (nonatomic, strong) HomeProfileAnimation *transitionAnimation;

@end
Expand Down Expand Up @@ -91,6 +94,7 @@ - (void)viewDidLoad {
self.tableView.dataSource = self;
self.tableView.delegate = self;
[self.tableView registerNib:[UINib nibWithNibName:kSurveyViewCell bundle:nil] forCellReuseIdentifier:kSurveyViewCell];
[self.tableView registerNib:[UINib nibWithNibName:kPhotoViewCell bundle:nil] forCellReuseIdentifier:kPhotoViewCell];
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.backgroundColor = [UIColor appBgColor];

Expand Down Expand Up @@ -153,6 +157,13 @@ - (SurveyViewCell *)prototypeSurveyCell {
return _prototypeSurveyCell;
}

- (PhotoAnswerCell *)prototypePhotoCell {
if (!_prototypePhotoCell) {
_prototypePhotoCell = [self.tableView dequeueReusableCellWithIdentifier:kPhotoViewCell];
}
return _prototypePhotoCell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.surveys.count;
}
Expand All @@ -164,11 +175,17 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[self fetchSurveys];
}
}

Survey *survey = self.surveys[indexPath.row];
if (survey.question.isTextSurvey) {
SurveyViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:kSurveyViewCell];
cell.survey = self.surveys[indexPath.row];
cell.survey = survey;
cell.delegate = self;
return cell;
} else {
PhotoAnswerCell *cell = [self.tableView dequeueReusableCellWithIdentifier:kPhotoViewCell];
cell.survey = survey;
return cell;
}
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
Expand Down
2 changes: 2 additions & 0 deletions unnamed/ParseClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ + (void)getUser:(User *)user surveysComplete:(BOOL)complete onPage:(NSInteger)pa
[query orderByDescending:@"createdAt"];
[query whereKey:@"user" matchesQuery:userQuery];
[query includeKey:@"user"];
[query includeKey:@"questionPhotos"];
[query whereKey:@"complete" equalTo:@(complete)];
query.skip = page * ResultCount;
query.limit = ResultCount;
Expand All @@ -62,6 +63,7 @@ + (void)getHomeSurveysOnPage:(NSInteger)page withCompletion:(void(^)(NSArray *su
PFQuery *query = [Question query];
[query orderByDescending:@"createdAt"];
[query includeKey:@"user"];
[query includeKey:@"questionPhotos"];
query.skip = page * ResultCount;
query.limit = ResultCount;

Expand Down
14 changes: 14 additions & 0 deletions unnamed/PhotoAnswerCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// PhotoAnswerCell.h
// unnamed
//
// Created by Bruce Ng on 2/24/15.
// Copyright (c) 2015 com.yahoo. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "Survey.h"
@interface PhotoAnswerCell : UITableViewCell
@property (nonatomic, strong) Survey *survey;

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

#import "PhotoAnswerCell.h"
#import "PhotoAnswerView.h"
#import "ProfileImageView.h"

@interface PhotoAnswerCell()
@property (weak, nonatomic) IBOutlet ProfileImageView *profileImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *questionLabel;
@property (weak, nonatomic) IBOutlet PhotoAnswerView *photo1View;
@property (weak, nonatomic) IBOutlet PhotoAnswerView *photo2View;

@end

@implementation PhotoAnswerCell

- (void)awakeFromNib {
// Initialization code
}

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

// Configure the view for the selected state
}

- (void)setSurvey:(Survey *)survey {
_survey = survey;
self.profileImageView.user = self.survey.user;
self.nameLabel.text = self.survey.user.name;
self.questionLabel.text = self.survey.question.text;

[self.photo1View setAnswer:self.survey.answers[0] andTotalVotes:self.survey.totalVotes];
[self.photo2View setAnswer:self.survey.answers[1] andTotalVotes:self.survey.totalVotes];
}


@end
Loading

0 comments on commit ddcb958

Please sign in to comment.