-
Notifications
You must be signed in to change notification settings - Fork 211
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
[CIS-528] Add connection status banner to DemoApp #970
Conversation
Codecov Report
@@ Coverage Diff @@
## main #970 +/- ##
==========================================
+ Coverage 89.62% 89.68% +0.06%
==========================================
Files 210 211 +1
Lines 8739 8772 +33
==========================================
+ Hits 7832 7867 +35
+ Misses 907 905 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
DemoApp/DemoAppCoordinator.swift
Outdated
import UIKit | ||
|
||
final class DemoAppCoordinator { | ||
static var shared: DemoAppCoordinator! |
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.
It is this ugly for several reasons:
- Initial nav controller lives in a storyboard
- LoginViewController needs that to present Chat
- We throw out LogicViewController as soon as we present Chat
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.
If it's ugly why don't you fix it? 🤔 🤷♂️
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.
What I meant is that we don't have much choice here, so it's ugly comparing to conventional coordinators.
Or do you mean fixing the reasons I enumerated? I believe you mentioned something about storyboard being used on purpose
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.
Reworked it
63922f4
to
4a0b0a3
Compare
90c45a1
to
a870c06
Compare
4e9f08c
to
1fc3ad6
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.
Looks good 👍 I left a couple of comments and questions...
config.waitsForConnectivity = true | ||
config.waitsForConnectivity = false |
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 change should be covered by a test since it's a requirement for the system to work correctly.
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.
Added a test
WHAT? Almost all my comments disappeared 😭 |
DemoApp/BannerView.swift
Outdated
override func didMoveToSuperview() { | ||
super.didMoveToSuperview() | ||
setUpLayout() | ||
defaultAppearance() | ||
} |
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 a pattern from the SDK and I don't think we should use it here. The SDK for example takes care of the fact that this is called just once, which here doesn't happen. I think it's better to call these methods from a method which is guaranteed to be called just once.
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.
Now it's called once from init
DemoApp/BannerView.swift
Outdated
|
||
addSubview(label) | ||
|
||
translatesAutoresizingMaskIntoConstraints = false |
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.
The view's superview should decide about this, not the view itself.
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.
Reworked
func attachToTopViewIfNeeded() { | ||
guard let topView = navigationController.topViewController?.view, | ||
topView != bannerView.superview else { return } | ||
|
||
topView.addSubview(bannerView) | ||
|
||
let guide = topView.safeAreaLayoutGuide | ||
NSLayoutConstraint.activate( | ||
[ | ||
bannerView.topAnchor.constraint(equalTo: guide.topAnchor) | ||
] | ||
) | ||
} |
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.
Rather than messing up with the view, can't we just add the banner to the navbar view?
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.
Now it works like this. I was having doubts on this approach when I first considered how to implement it because it is based on an assumption that navbar has clipsToBounds == false and also that it has the highest Z position, but probably it should be fine for the DemoApp. Anyway it's easy to rework if there will be issues
DemoApp/DemoAppCoordinator.swift
Outdated
import UIKit | ||
|
||
final class DemoAppCoordinator { | ||
static var shared: DemoAppCoordinator! |
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.
If it's ugly why don't you fix it? 🤔 🤷♂️
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.
Great 🎉
…o make reconnection logic work
bfa4aca
to
bbe17ae
Compare
@dmigach please merge when you're ready 👍 |
Mostly this change is about:
internetIsOfflineError
that prevented web socket client from reconnecting