-
Notifications
You must be signed in to change notification settings - Fork 112
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
Errors: Banner message for error loading data on My Store dashboard #4704
Conversation
…ding or removing error banner
…es without pull to refresh
You can trigger an installable build for these changes by visiting CircleCI here. |
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
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.
Thank you for handling this issue! Overall everything works as expected for happy cases, however I have a few nits and comments below.
/// | ||
private lazy var innerStackView: UIStackView = { | ||
let view = UIStackView() | ||
view.layoutMargins = UIEdgeInsets(top: 0, left: Constants.leadingMargin, bottom: 0, right: 0) |
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.
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.
Good catch, thanks! I added a margin for the right inset in cd48e49. I thought about using directionalLayoutMargins
to add the inset to the leading edge specifically (not left/right) but I realized it would be good to have insets on both sides anyway in case of very long store names.
}() | ||
|
||
/// A stack view for views displayed between the navigation bar and content (e.g. store name subtitle, top banner) | ||
/// | ||
private lazy var stackView: UIStackView = { |
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.
Do you think it might be necessary to update the name of this property to mainStackView
or headerStackView
to make it clearer?
}) | ||
}() | ||
|
||
private lazy var spacerView: UIView = { |
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.
I think a comment for this property can be helpful to understand its purpose - WDYT?
private lazy var stackView: UIStackView = { | ||
let view = UIStackView() | ||
view.translatesAutoresizingMaskIntoConstraints = false | ||
view.backgroundColor = .listForeground | ||
view.layoutMargins = UIEdgeInsets(top: 0, left: navigationController?.navigationBar.directionalLayoutMargins.leading ?? 0, bottom: 0, right: 0) |
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.
This line seems to have caused an issue with the margin when app is launched in landscape mode - removing this seems to have fixed the issue. Bravo 🎉
/// | ||
func hideTopBannerView() { | ||
topBannerView.removeFromSuperview() | ||
spacerView.removeFromSuperview() |
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.
I think there's no need for adding and removing topBannerView
and spacerView
when showing / hiding the banner view. The great thing about stack view is that it can collapse or expand when showing / hiding its subviews.
Therefore, I'd suggest that you add these as arranged subviews right after adding the innerStackView
, and hide them by default. When showing or hiding the banner view, all you need to do is show / hide these subviews and it should still work as expected.
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.
This is a great approach that I didn't think of, thanks! In 92e6c6c I changed how these views are configured, and it simplifies the way the constraints are set, too. Now the header stack view is configured up front with all the arranged subviews added, and as you suggested the methods to show or hide the banner just show/hide those subviews.
@@ -9,7 +9,7 @@ protocol DashboardUI: UIViewController { | |||
var scrollDelegate: DashboardUIScrollDelegate? { get set } | |||
|
|||
/// Called when the Dashboard should display syncing error | |||
var displaySyncingErrorNotice: () -> Void { get set } | |||
var displaySyncingError: () -> Void { get set } |
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.
Thanks for renaming this too! 💯
Thanks for the review and suggestions, @itsmeichigo! This is ready for another look when you have a chance. |
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.
This looks great, thanks for updating!
Resolves: #4382
Description
To improve our error states, we are introducing a top banner that can be used whenever there is a problem loading data. The banner is collapsed by default and on select, users can read our troubleshooting tips or contact support directly.
This PR sets up the banner and adds it to the top of the My Store screen. (This banner replaces the "Unable to load content" notice we displayed before.)
Changes
DashboardViewController
. A quick overview of the changes there:shouldShowStoreNameAsSubtitle
istrue
. The store name is now embedded inside another stack view, to retain its leading margin. (That margin is now defined with a constant equivalent to the margins it had before.)shouldShowStoreNameAsSubtitle
isfalse
, the stack view is added when the banner is displayed, with all necessary constraints. (Those constraints are otherwise set when the subtitle is configured and the dashboard UI is added below it).Testing
Submitter Checklist
Update release notes:
RELEASE-NOTES.txt
if necessary.