Skip to content

Commit

Permalink
Merge pull request #140 from fbu-team-awesome/reviews-ui-updates
Browse files Browse the repository at this point in the history
updated review UI to look like the wireframe
  • Loading branch information
britphan committed Aug 9, 2018
2 parents 04f64a7 + 84b6c36 commit b77135e
Show file tree
Hide file tree
Showing 22 changed files with 245 additions and 64 deletions.
208 changes: 151 additions & 57 deletions Storyboards/DetailsView.storyboard

Large diffs are not rendered by default.

36 changes: 33 additions & 3 deletions View Controllers/DetailsViewController.m
Expand Up @@ -19,6 +19,7 @@
#import <NYTPhotoViewer/NYTPhotosViewController.h>
#import "HCSStarRatingView.h"
#import "ReviewCell.h"
#import "UIStylesHelper.h"

@interface DetailsViewController () <GMSMapViewDelegate, UICollectionViewDelegate, UICollectionViewDataSource, PhotoCellDelegate, NYTPhotosViewControllerDelegate, UITableViewDelegate, UITableViewDataSource>
// Outlet Definitions //
Expand All @@ -37,6 +38,11 @@ @interface DetailsViewController () <GMSMapViewDelegate, UICollectionViewDelegat
@property (weak, nonatomic) IBOutlet UITextView *reviewTextView;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UIView *overallRatingView;
@property (weak, nonatomic) IBOutlet UIView *composeRatingView;
@property (weak, nonatomic) IBOutlet UIView *submitButtonView;
@property (weak, nonatomic) IBOutlet UIButton *submitButton;
@property (weak, nonatomic) IBOutlet UILabel *overallRatingLabel;
@property (weak, nonatomic) IBOutlet UILabel *ratingsCountLabel;

// Instance Properties //
@property (strong, nonatomic) GMSPlace *place;
Expand Down Expand Up @@ -314,11 +320,21 @@ - (void)didTapPhoto:(Photo *)photo {
#pragma mark - Reviews

- (void) initWriteReview {
HCSStarRatingView *ratingView = [[HCSStarRatingView alloc] initWithFrame:CGRectMake(72, 32, 100, 25)];
HCSStarRatingView *ratingView = [[HCSStarRatingView alloc] initWithFrame:CGRectMake(0, 0, 95, 13)];
ratingView.minimumValue = 0;
ratingView.maximumValue = 5;
ratingView.starBorderWidth= 0;
ratingView.filledStarImage = [UIImage imageNamed:@"star_filled"] ;
ratingView.emptyStarImage = [UIImage imageNamed:@"star_unfilled"];
[ratingView addTarget:self action:@selector(didChangeRating:) forControlEvents:UIControlEventValueChanged];
[self.composeView addSubview:ratingView];
[self.composeRatingView addSubview:ratingView];

self.reviewTextView.layer.cornerRadius = 8;
self.reviewTextView.layer.borderColor = [UIColor colorNamed:@"VTR_Borders"].CGColor;
self.reviewTextView.layer.borderWidth = 1;

[UIStylesHelper addRoundedCornersToView:self.submitButton];
[UIStylesHelper addShadowToView:self.submitButton withOffset:CGSizeMake(0, 1) withRadius:2 withOpacity:0.16];
}

- (void) initShowReviews {
Expand Down Expand Up @@ -354,6 +370,7 @@ - (void) fetchReviews {
[Relationships retrieveFollowingWithId:relationships.objectId WithCompletion:^(NSArray * _Nullable following) {
NSLog(@"Fetched all following");
[self.parsePlace retrieveReviewsFromFollowing:following withCompletion:^(NSArray<Review *> *reviews) {
NSLog(@"Fetched all reviews");
self.reviews = reviews;
[self reloadAndUpdateRating];
}];
Expand Down Expand Up @@ -387,11 +404,24 @@ - (void) updatePlaceRating {
{
[view removeFromSuperview];
}
HCSStarRatingView *ratingView = [[HCSStarRatingView alloc] initWithFrame:CGRectMake(0, 0, 80, 20)];
HCSStarRatingView *ratingView = [[HCSStarRatingView alloc] initWithFrame:CGRectMake(0, 0, 95, 13)];
ratingView.minimumValue = 0;
ratingView.maximumValue = 5;
ratingView.starBorderWidth= 0;
ratingView.filledStarImage = [UIImage imageNamed:@"star_filled"] ;
ratingView.emptyStarImage = [UIImage imageNamed:@"star_unfilled"];
ratingView.value = (CGFloat) self.overallRating;
ratingView.allowsHalfStars = YES;
[ratingView setEnabled:NO];
[self.overallRatingView addSubview:ratingView];
NSNumber *ratingNumber = [NSNumber numberWithDouble:self.overallRating];

NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
formatter.roundingIncrement = [NSNumber numberWithDouble:0.01];
formatter.numberStyle = NSNumberFormatterDecimalStyle;
[self.overallRatingLabel setText:[NSString stringWithFormat:@"%@ stars",[formatter stringFromNumber:ratingNumber]]];

[self.ratingsCountLabel setText:[NSString stringWithFormat:@"%lu ratings",self.reviews.count]];
}

@end
5 changes: 2 additions & 3 deletions Views/HCSStarRatingView.m
Expand Up @@ -208,7 +208,6 @@ - (void)setEnabled:(BOOL)enabled

- (void)_updateAppearanceForState:(BOOL)enabled
{
self.alpha = enabled ? 1.f : .5f;
}

#pragma mark - Image Drawing
Expand Down Expand Up @@ -302,7 +301,7 @@ - (void)drawRect:(CGRect)rect {

CGFloat availableWidth = rect.size.width - (_spacing * (_maximumValue - 1)) - 2;
CGFloat cellWidth = (availableWidth / _maximumValue);
CGFloat starSide = (cellWidth <= rect.size.height) ? cellWidth : rect.size.height;
CGFloat starSide = (cellWidth <= rect.size.height) ? cellWidth : rect.size.height+1;
starSide = (self.shouldUseImages) ? starSide : (starSide - _starBorderWidth);

for (int idx = 0; idx < _maximumValue; idx++) {
Expand Down Expand Up @@ -425,7 +424,7 @@ - (BOOL)canBecomeFirstResponder {

- (CGSize)intrinsicContentSize {
CGFloat height = 44.f;
return CGSizeMake(_maximumValue * height + (_maximumValue-1) * _spacing, height);
return CGSizeMake(_maximumValue * (height) + (_maximumValue-1) * _spacing, height+1);
}

#pragma mark - Accessibility
Expand Down
1 change: 1 addition & 0 deletions Views/ReviewCell.h
Expand Up @@ -14,6 +14,7 @@
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UIView *rateView;
@property (weak, nonatomic) IBOutlet UILabel *content;
@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (strong, nonatomic) Review *review;

- (void)configureCell;
Expand Down
13 changes: 12 additions & 1 deletion Views/ReviewCell.m
Expand Up @@ -10,6 +10,8 @@
#import "ParseImageHelper.h"
#import "PFUser+ExtendedUser.h"
#import "HCSStarRatingView.h"
#import "UIStylesHelper.h"
#import "DateTools.h"

@implementation ReviewCell

Expand All @@ -26,10 +28,19 @@ - (void) configureCell {
{
[view removeFromSuperview];
}
HCSStarRatingView *ratingView = [[HCSStarRatingView alloc] initWithFrame:CGRectMake(0, 0, 80, 20)];
HCSStarRatingView *ratingView = [[HCSStarRatingView alloc] initWithFrame:CGRectMake(0, 0, 95, 13)];
ratingView.minimumValue = 0;
ratingView.maximumValue = 5;
ratingView.starBorderWidth= 0;
ratingView.filledStarImage = [UIImage imageNamed:@"star_filled"] ;
ratingView.emptyStarImage = [UIImage imageNamed:@"star_unfilled"];
ratingView.value = (CGFloat) self.review.rating;
[ratingView setEnabled:NO];
[self.rateView addSubview:ratingView];

[UIStylesHelper addRoundedCornersToView:self.profilePicture];

self.dateLabel.text = self.review.createdAt.timeAgoSinceNow;
}
}

Expand Down
Binary file added assets/Group 7.pdf
Binary file not shown.
Binary file added assets/Group 7@2x.pdf
Binary file not shown.
Binary file added assets/Group 7@3x.pdf
Binary file not shown.
Binary file added assets/star_filled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/star_filled@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/star_filled@3x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/star_unfilled.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/star_unfilled@2x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/star_unfilled@3x.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions social-maps/Assets.xcassets/star_filled.imageset/Contents.json
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "star_filled.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "star_filled@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "star_filled@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions social-maps/Assets.xcassets/star_unfilled.imageset/Contents.json
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "star_unfilled.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "star_unfilled@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "star_unfilled@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b77135e

Please sign in to comment.