Skip to content

Commit

Permalink
Fix clicking on user profile in home view for photo surveys
Browse files Browse the repository at this point in the history
  • Loading branch information
brung committed Feb 25, 2015
1 parent 6638e92 commit ecdf107
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 66 deletions.
9 changes: 0 additions & 9 deletions unnamed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
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 */; };
Expand Down Expand Up @@ -130,8 +129,6 @@
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>"; };
Expand Down Expand Up @@ -342,11 +339,6 @@
3E4B809E1A9C42FB004F5D78 /* CommentView.h */,
3E4B809F1A9C42FB004F5D78 /* CommentView.m */,
3E4B80A11A9C4345004F5D78 /* CommentView.xib */,
B82956C31A9C5AA200D0ECFD /* ComposePhotoCell.h */,
B82956C41A9C5AA200D0ECFD /* ComposePhotoCell.m */,
B82956C51A9C5AA200D0ECFD /* ComposePhotoCell.xib */,
B895C4A61A9CDE1B001DF829 /* PhotoAnswerCollectionView.h */,
B895C4A71A9CDE1B001DF829 /* PhotoAnswerCollectionView.m */,
B895C4A11A9CD9B8001DF829 /* PhotoAnswerView.h */,
B895C4A21A9CD9B8001DF829 /* PhotoAnswerView.m */,
B895C4A41A9CD9D4001DF829 /* PhotoAnswerView.xib */,
Expand Down Expand Up @@ -570,7 +562,6 @@
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 */,
Expand Down
3 changes: 1 addition & 2 deletions unnamed/HomeProfileAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "SurveyViewCell.h"

@interface HomeProfileAnimation : NSObject <UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning, UINavigationControllerDelegate>
@property (nonatomic, strong) SurveyViewCell *selectedCell;
@property (nonatomic, strong) UITableViewCell *selectedCell;
@property (nonatomic, assign) BOOL isPresenting;
@end
11 changes: 10 additions & 1 deletion unnamed/HomeProfileAnimation.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#import "HomeProfileAnimation.h"
#import "ProfileViewController.h"
#import "HomeViewController.h"
#import "SurveyViewCell.h"
#import "PhotoAnswerCell.h"

@interface HomeProfileAnimation()
@property UINavigationController *navController;
@end
Expand Down Expand Up @@ -38,7 +41,13 @@ - (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionCo
ProfileImageView *remoteProfileImageView = [vc getMainProfileImageView];
remoteProfileImageView.hidden = YES;

UIImageView *selectedProfileImage = self.selectedCell.profileImageView;

UIImageView *selectedProfileImage;
if ([self.selectedCell isKindOfClass:[SurveyViewCell class]]) {
selectedProfileImage = ((SurveyViewCell *)self.selectedCell).profileImageView;
} else if ([self.selectedCell isKindOfClass:[PhotoAnswerCell class]]) {
selectedProfileImage = ((PhotoAnswerCell *)self.selectedCell).profileImageView;
}


CGRect frame = [selectedProfileImage convertRect:selectedProfileImage.frame toView:containerView];
Expand Down
17 changes: 16 additions & 1 deletion unnamed/HomeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
NSString * const kSurveyViewCell = @"SurveyViewCell";
NSString * const kPhotoViewCell = @"PhotoAnswerCell";

@interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, SurveyViewCellDelegate>
@interface HomeViewController () <UITableViewDelegate, UITableViewDataSource, SurveyViewCellDelegate, PhotoAnswerCellDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) UIRefreshControl *tableRefreshControl;
@property (nonatomic, strong) NSMutableArray *surveys;
Expand Down Expand Up @@ -225,6 +225,7 @@ - (void)configureCell:(UITableViewCell *)pCell forRowAtIndexPath:(NSIndexPath *)
} else if ([pCell isKindOfClass:[PhotoAnswerCell class]]) {
PhotoAnswerCell *cell = (PhotoAnswerCell *)pCell;
cell.survey = self.surveys[indexPath.row];
cell.delegate = self;
}
}

Expand All @@ -241,6 +242,20 @@ - (void)surveyViewCell:(SurveyViewCell *)cell didClickOnUser:(User *)user {
}
}

#pragma mark - PhotoAnswerCellDelegate methods
- (void)photoAnswerCell:(PhotoAnswerCell *)cell didClickOnUser:(User *)user{
if ([user.objectId isEqualToString:[User currentUser].objectId]) {
[self.tabBarController setSelectedIndex:2];
} else {
ProfileViewController *vc = [[ProfileViewController alloc] init];
vc.user = user;
vc.view.frame = self.view.frame;
self.transitionAnimation.selectedCell = cell;
[self.navigationController pushViewController:vc animated:YES];
}
}


#pragma mark - Private Methods
- (void)onNewPost:(NSNotification *)notification {
Survey *survey = notification.userInfo[@"survey"];
Expand Down
12 changes: 12 additions & 0 deletions unnamed/PhotoAnswerCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@

#import <UIKit/UIKit.h>
#import "Survey.h"
#import "User.h"
#import "ProfileImageView.h"

@class PhotoAnswerCell;
@protocol PhotoAnswerCellDelegate <NSObject>

- (void) photoAnswerCell:(PhotoAnswerCell *)cell didClickOnUser:(User *)user;

@end

@interface PhotoAnswerCell : UITableViewCell
@property (weak, nonatomic) IBOutlet ProfileImageView *profileImageView;
@property (nonatomic, strong) Survey *survey;
@property (nonatomic, strong) id<PhotoAnswerCellDelegate> delegate;

@end
8 changes: 5 additions & 3 deletions unnamed/PhotoAnswerCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@

#import "PhotoAnswerCell.h"
#import "PhotoAnswerView.h"
#import "ProfileImageView.h"
#import "UIColor+AppColor.h"
#import "NSDate+MinimalTimeAgo.h"

@interface PhotoAnswerCell()
@interface PhotoAnswerCell() <ProfileImageViewDelegate>
@property (weak, nonatomic) IBOutlet UIView *innerView;
@property (weak, nonatomic) IBOutlet ProfileImageView *profileImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *questionLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
Expand All @@ -30,6 +28,7 @@ - (void)awakeFromNib {
self.backgroundColor = [UIColor appBgColor];
self.innerView.layer.cornerRadius = 10;
self.innerView.layer.masksToBounds = YES;
self.profileImageView.delegate = self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
Expand All @@ -49,5 +48,8 @@ - (void)setSurvey:(Survey *)survey {
[self.photo2View setAnswer:self.survey.answers[1] andTotalVotes:self.survey.totalVotes];
}

- (void)profileImageView:(ProfileImageView *)view tappedUser:(User *)user {
[self.delegate photoAnswerCell:self didClickOnUser:user];
}

@end
13 changes: 0 additions & 13 deletions unnamed/PhotoAnswerCollectionView.h

This file was deleted.

37 changes: 0 additions & 37 deletions unnamed/PhotoAnswerCollectionView.m

This file was deleted.

0 comments on commit ecdf107

Please sign in to comment.