-
Notifications
You must be signed in to change notification settings - Fork 1.2k
#720 - add message explaining Jetpack to notifications tab #725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ac469a8
Fixed issue where notifications view would persistently show refresh …
tomwitkin f70db06
Added ability to add button to WPNoResultsView
tomwitkin 5ce2e53
Added ability to add button to WPTableViewController no results view
tomwitkin 46bc123
Web view controller hides tab bar when pushed
tomwitkin a8db883
Added message explaining Jetpack to notifications tab for self-hosted…
tomwitkin 430274c
Created const for inline string
tomwitkin 2e1c725
Changed WPNoResultsView delegate method name
tomwitkin 2bd1b3b
Removed unnecessary delegate code from WPNoResultsView
tomwitkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,17 +15,18 @@ @interface WPNoResultsView () | |
| @property (nonatomic, copy) UILabel *titleLabel; | ||
| @property (nonatomic, copy) UILabel *messageLabel; | ||
| @property (nonatomic, copy) UIView *accessoryView; | ||
| @property (nonatomic, copy) UIButton *button; | ||
| @end | ||
|
|
||
| @implementation WPNoResultsView | ||
|
|
||
| #pragma mark - | ||
| #pragma mark Lifecycle Methods | ||
|
|
||
| + (WPNoResultsView *)noResultsViewWithTitle:(NSString *)titleText message:(NSString *)messageText accessoryView:(UIView *)accessoryView { | ||
| + (WPNoResultsView *)noResultsViewWithTitle:(NSString *)titleText message:(NSString *)messageText accessoryView:(UIView *)accessoryView buttonTitle:(NSString *)buttonTitle { | ||
|
|
||
| WPNoResultsView *view = [[WPNoResultsView alloc] init]; | ||
| [view setupWithTitle:titleText message:messageText accessoryView:accessoryView]; | ||
| [view setupWithTitle:titleText message:messageText accessoryView:accessoryView buttonTitle:buttonTitle]; | ||
|
|
||
| return view; | ||
| } | ||
|
|
@@ -36,6 +37,7 @@ - (void)didMoveToSuperview { | |
|
|
||
| - (void)dealloc { | ||
| [[NSNotificationCenter defaultCenter] removeObserver:self]; | ||
| self.delegate = nil; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason to have these manual getters/setters instead of just a property? |
||
|
|
||
| - (void)layoutSubviews { | ||
|
|
@@ -51,9 +53,17 @@ - (void)layoutSubviews { | |
| CGSize messageSize = [_messageLabel.text boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: _messageLabel.font} context:nil].size; | ||
| _messageLabel.frame = CGRectMake(0, CGRectGetMaxY(_titleLabel.frame) + 10.0, width, messageSize.height); | ||
|
|
||
| [_button sizeToFit]; | ||
| CGSize buttonSize = _button.frame.size; | ||
| buttonSize.width += 20.0; | ||
| CGFloat buttonYOrigin = (CGRectGetHeight(_messageLabel.frame) > 0 ? CGRectGetMaxY(_messageLabel.frame) : CGRectGetMaxY(_titleLabel.frame)) + 20.0 ; | ||
| _button.frame = CGRectMake((width - buttonSize.width) / 2, buttonYOrigin, MIN(buttonSize.width, width), buttonSize.height); | ||
|
|
||
|
|
||
| CGRect bottomViewRect; | ||
| if (_messageLabel.text.length > 0) { | ||
| if (_button != nil) { | ||
| bottomViewRect = _button.frame; | ||
| } else if (_messageLabel.text.length > 0) { | ||
| bottomViewRect = _messageLabel.frame; | ||
| } else if (_titleLabel.text.length > 0) { | ||
| bottomViewRect = _titleLabel.frame; | ||
|
|
@@ -72,7 +82,7 @@ - (void)layoutSubviews { | |
|
|
||
| #pragma mark Instance Methods | ||
|
|
||
| - (void)setupWithTitle:(NSString *)titleText message:(NSString *)messageText accessoryView:(UIView *)accessoryView { | ||
| - (void)setupWithTitle:(NSString *)titleText message:(NSString *)messageText accessoryView:(UIView *)accessoryView buttonTitle:(NSString *)buttonTitle { | ||
|
|
||
| [self addSubview:accessoryView]; | ||
|
|
||
|
|
@@ -88,12 +98,39 @@ - (void)setupWithTitle:(NSString *)titleText message:(NSString *)messageText acc | |
| // Setup message text | ||
| _messageLabel = [[UILabel alloc] init]; | ||
| _messageLabel.font = [WPStyleGuide regularTextFont]; | ||
| _messageLabel.textColor = [WPStyleGuide whisperGrey]; | ||
| _messageLabel.textColor = [WPStyleGuide allTAllShadeGrey]; | ||
| [self setMessageText:messageText]; | ||
| _messageLabel.numberOfLines = 0; | ||
| _messageLabel.textAlignment = NSTextAlignmentCenter; | ||
| [self addSubview:_messageLabel]; | ||
|
|
||
| // Setup button | ||
| if (buttonTitle.length > 0) { | ||
| _button = [UIButton buttonWithType:UIButtonTypeCustom]; | ||
| [_button setTitle:buttonTitle forState:UIControlStateNormal]; | ||
| [_button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside]; | ||
| [_button setTitleColor:[WPStyleGuide allTAllShadeGrey] forState:UIControlStateNormal]; | ||
| [_button.titleLabel setFont:[WPStyleGuide regularTextFont]]; | ||
|
|
||
| // Generate button background image | ||
| CGRect fillRect = CGRectMake(0, 0, 11.0, 36.0); | ||
| UIEdgeInsets capInsets = UIEdgeInsetsMake(4, 4, 4, 4); | ||
| UIImage *mainImage; | ||
|
|
||
| UIGraphicsBeginImageContextWithOptions(fillRect.size, NO, [[UIScreen mainScreen] scale]); | ||
| CGContextRef context = UIGraphicsGetCurrentContext(); | ||
| CGContextSetStrokeColorWithColor(context, [WPStyleGuide allTAllShadeGrey].CGColor); | ||
| CGContextAddPath(context, [UIBezierPath bezierPathWithRoundedRect:CGRectInset(fillRect, 1, 1) cornerRadius:2.0].CGPath); | ||
| CGContextStrokePath(context); | ||
| mainImage = UIGraphicsGetImageFromCurrentImageContext(); | ||
| UIGraphicsEndImageContext(); | ||
|
|
||
| [_button setBackgroundImage:[mainImage resizableImageWithCapInsets:capInsets] forState:UIControlStateNormal]; | ||
|
|
||
| [self addSubview:_button]; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| // Register for orientation changes | ||
| [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChange:) name:UIDeviceOrientationDidChangeNotification object:nil]; | ||
|
|
@@ -103,7 +140,7 @@ - (void)setupWithTitle:(NSString *)titleText message:(NSString *)messageText acc | |
|
|
||
| - (void)setTitleText:(NSString *)title { | ||
| if (title.length > 0) { | ||
| _titleLabel.attributedText = [[NSAttributedString alloc] initWithString:title attributes:[WPNUXUtility titleAttributesWithColor:[WPStyleGuide whisperGrey]]]; | ||
| _titleLabel.attributedText = [[NSAttributedString alloc] initWithString:title attributes:[WPNUXUtility titleAttributesWithColor:[WPStyleGuide allTAllShadeGrey]]]; | ||
| } | ||
| [self setNeedsLayout]; | ||
| } | ||
|
|
@@ -144,4 +181,11 @@ - (void)orientationDidChange:(NSNotification *)notification { | |
| [self setNeedsLayout]; | ||
| } | ||
|
|
||
| - (void)buttonAction:(id)sender | ||
| { | ||
| if ([self.delegate respondsToSelector:@selector(didTapNoResultsView:)]) { | ||
| [self.delegate didTapNoResultsView:self]; | ||
| } | ||
| } | ||
|
|
||
| @end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stylistic comment, but for these cases I like ditching the
elseand havingreturn nilbe the punctuation at the end of the method. (Some languages/compilers will even complain about not doing it this way).