From 3789c833993b6ab98e4eaab7b1bae1e5293290df Mon Sep 17 00:00:00 2001 From: Eddy Borja Date: Wed, 9 Apr 2014 15:19:30 -0400 Subject: [PATCH] Added "Commenting is Disabled" text when comments are not allowed for a photo to avoid confusion about why there is no textview shown. Reorganized some methods in EBCommentsView. --- EBPhotoPagesController/EBCommentsView.m | 49 ++++++++++++++++--------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/EBPhotoPagesController/EBCommentsView.m b/EBPhotoPagesController/EBCommentsView.m index 758db27..5b89dcb 100644 --- a/EBPhotoPagesController/EBCommentsView.m +++ b/EBPhotoPagesController/EBCommentsView.m @@ -88,14 +88,15 @@ - (void)loadTableView - (void)loadCommentTextView { - CGRect commentViewFrame = CGRectMake(0, - self.tableView.frame.size.height, - self.frame.size.width-72, - self.frame.size.height-self.tableView.frame.size.height); + CGPoint textViewOrigin = CGPointMake(5, self.tableView.frame.size.height); + CGRect textViewFrame = CGRectMake(textViewOrigin.x, + textViewOrigin.y, + self.frame.size.width-(72+textViewOrigin.x), + self.frame.size.height-self.tableView.frame.size.height); - UITextView *textView = [[UITextView alloc] initWithFrame:commentViewFrame]; + UITextView *textView = [[UITextView alloc] initWithFrame:textViewFrame]; [textView setBackgroundColor:[UIColor clearColor]]; [textView setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:16]]; [textView setKeyboardAppearance:UIKeyboardAppearanceAlert]; @@ -116,14 +117,11 @@ - (void)loadPlaceholderForTextView:(UITextView *)textView [label setTextColor:[UIColor colorWithWhite:0.5 alpha:1]]; [textView.superview insertSubview:label belowSubview:textView]; [label setText:[self commentInputPlaceholderText]]; - [label setFrame:CGRectOffset(label.frame, 8, -1)]; + [label setFrame:CGRectOffset(label.frame, 5, -3)]; [self setCommentTextViewPlaceholder:label]; } -- (NSString *)commentInputPlaceholderText -{ - return NSLocalizedString(@"Write a comment...", @"Appears in a textbox where a user can write a comment."); -} + - (void)loadKeyboardFillerView { @@ -169,11 +167,6 @@ - (void)loadPostButton } -- (UIColor *)postButtonColor -{ - return [UIColor colorWithRed:0 green:118/255.0 blue:1.0 alpha:1.0]; -} - - (void)setNeedsLayout { CGRect newFrame = self.bounds; @@ -228,14 +221,16 @@ - (void)didSelectPostButton:(id)sender - (void)enableCommenting { [self.commentTextView setHidden:NO]; - [self.commentTextViewPlaceholder setHidden:NO]; + //[self.commentTextViewPlaceholder setHidden:NO]; + [self.commentTextViewPlaceholder setText:[self commentInputPlaceholderText]]; [self.tableView setDrawsDividerLine:YES]; } - (void)disableCommenting { [self.commentTextView setHidden:YES]; - [self.commentTextViewPlaceholder setHidden:YES]; + //[self.commentTextViewPlaceholder setHidden:YES]; + [self.commentTextViewPlaceholder setText:[self disabledInputPlaceholderText]]; [self.tableView setDrawsDividerLine:NO]; } @@ -250,7 +245,27 @@ - (void)cancelCommenting } +#pragma mark - Colors and Text + + +- (UIColor *)postButtonColor +{ + return [UIColor colorWithRed:0 green:118/255.0 blue:1.0 alpha:1.0]; +} + +- (NSString *)commentInputPlaceholderText +{ + return NSLocalizedString(@"Write a comment...", @"Appears in a textbox where a user can write a comment."); +} + +- (NSString *)disabledInputPlaceholderText +{ + return NSLocalizedString(@"Commenting is disabled.", @"Appears in a text box to informa a user no new comments are being accepted for a photo."); +} + + +#pragma mark - //Leave this blank to prevent UITextView from scrolling the UIPageViewController when it becomes first responder. - (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated{}