-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(ErrorBanner): offline banner #478
Conversation
835415e
to
8723045
Compare
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.
Nothing major, but I have a couple points on the layout. All the logic changes look great.
@@ -46,6 +46,12 @@ struct ErrorBanner: View { | |||
} | |||
.frame(minHeight: minHeight) | |||
} | |||
case .networkError: | |||
ErrorCard { HStack { |
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.
Is the default alignment in this HStack not center? It looks kinda like the image is below the centerline of the text.
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.
Okay yeah, I think it's just a matter of the icon being slightly bottom heavy. Thanks for checking!
@@ -14,6 +14,6 @@ internal fun createDataStore(context: Context): DataStore<Preferences> = | |||
fun initKoin(appVariant: AppVariant, nativeModule: Module, context: Context) { | |||
startKoin { | |||
androidContext(context) | |||
modules(appModule(appVariant) + platformModule() + nativeModule) | |||
modules(platformModule() + appModule(appVariant) + nativeModule) |
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.
Just curious, but why were these swapped?
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.
Oh this isn't actually necessary. At first I tried having ErrorBannerStateRepo call subscribeToNetworkStatusChanges
on init, but that was causing dependency injection issues with BeanNotFound
errors. I thought maybe the platformModule needed to be called first here since appModule depends on it, but that didn't end up fixing the issue, and I just opted to call subscribeToNetworkStatusChanges
from the ViewModel instead.
case .networkError: | ||
ErrorCard { HStack { | ||
Image(systemName: "wifi.slash") | ||
Text("Unable to connect") |
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.
Because this has no reload button like the other two banners, it also has no Spacer()
, so we're getting the awkward squished banner. If you toss a Spacer()
at the end here, I think that'll get it to take up the full width.
Image(systemName: "wifi.slash") | ||
Text("Unable to connect") | ||
} | ||
} |
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.
nitpick: I'd put these braces on the same line 😛
import shared | ||
import XCTest | ||
|
||
final class ErrorBannerViewModelTests: XCTestCase { |
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 adding this!
This reverts commit 10d2bad.
Summary
Ticket: Offline error banner
What is this PR for?
This PR adds an error banner that appears when a user is offline.
I used the following resources as a basis for this implementation:
I drifted from the Blog post's approach in a few ways:
Testing
What testing have you done?
I included the android implementation from the blog post but did not test it.