Skip to content

Commit

Permalink
Added "Commenting is Disabled" text when comments are not allowed for…
Browse files Browse the repository at this point in the history
… a photo to avoid confusion about why there is no textview shown. Reorganized some methods in EBCommentsView.
  • Loading branch information
EddyBorja committed Apr 9, 2014
1 parent 1ce5d1a commit 3789c83
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions EBPhotoPagesController/EBCommentsView.m
Expand Up @@ -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];
Expand All @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}

Expand All @@ -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{}

Expand Down

0 comments on commit 3789c83

Please sign in to comment.