-
Notifications
You must be signed in to change notification settings - Fork 7
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
Switch the gallery view to use a StackView instead of manual layout #542
base: master
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Yes Please! More UIStackView and less SnapKit. On our way toward SwiftUI. Two more things for the list of known issues:
|
and in the meantime, #545 |
var stackView = UIStackView() | ||
var collectionContainer = 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.
var stackView = UIStackView() | |
var collectionContainer = UIView() | |
let stackView = UIStackView() | |
let collectionContainer = UIView() |
@@ -56,15 +69,12 @@ class GalleryViewController: UIViewController, UICollectionViewDelegateFlowLayou | |||
let item = UIBarButtonItem(image: UIImage(systemName: "gearshape.fill"), style: UIBarButtonItem.Style.plain, target: self, action: #selector(self.settingsButtonPressed)) | |||
self.navigationItem.rightBarButtonItem = item | |||
|
|||
self.view.addSubview(self.lastUpdatedView) | |||
stackView.addArrangedSubview(self.lastUpdatedView) |
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.
How about configuring each individual view up here and then afterwards, toward the bottom of this method, setting the arranged subviews all at once? I think it would increase readability by decreasing the scope needed to see which views are in the stackView and in which order.
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.
Open to it, seems like a candidate for a follow up change.
beafc5e
to
c54b049
Compare
Summary
Previously we used SnapKit and lots of constraints in order to control the layout of the gallery view. This was a bunch of code, and cause constraint violation warnings due to margins being impossible in conjunction with hiding elements by setting their height to 0.
Here we migrate to use UIStackView which automatically handles constraints, sizing, and removing hidden views. This lets us delete a lot of code, and also fixes a bug where there would be a rendering glitch if returning to the gallery view from a goal view where the keyboard was hidden - previously the area the keyboard had occupied would appear blank.
Known issues to fix before merging: The background for last updated, deadbeat, etc, do not use the full width of the screen.
Validation
Loaded the app on iPhone and iPad