Skip to content
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

adds new checkmark placeholder #125

Merged
merged 1 commit into from
May 29, 2018
Merged

adds new checkmark placeholder #125

merged 1 commit into from
May 29, 2018

Conversation

rhaining
Copy link
Contributor

We were running into an issue where if you toggled back & forth between checked/unchecked states, the content would abruptly shift back & forth for the user, on smaller screens like the 5s. (The problem didn't exhibit itself on larger screens like the X).

This allows the developer to opt-in to use a checkmarkPlaceholder, allowing Static to insert a placeholder appropriately sized blank UIView to hang out until a checkmark may appear in its place.

Before After
privacy_settings_checks - bug privacy_settings_checks - fix

@@ -23,6 +23,10 @@ public struct Row: Hashable, Equatable {
/// Checkmark
case checkmark

/// Checkmark Placeholder.
/// Allows spacing to continue to work when switching back & forth between checked states.
case checkmarkPlaceholder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this case necessary given:
https://github.com/venmo/Static/pull/125/files#diff-083b9db3d36d23083693e650c2604474R37

Allows for any view to be set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that we are probably running into this problem elsewhere in the app, and by resolving it here, we could solve it once for many places.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given:

  • disclosureIndicator
  • checkmark
  • switch
  • customView

Each having different sizes

Would we also want a placeholder for these as well should we not want text to fill the space in cells we were using those items as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if those are problematic for layout, we could certainly add those.

right now, I'm just trying to solve for the checkmark

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal of Static is:

...to separate model data from presentation. Rows and Sections are your “view models” for your cells.

If the Row is the view model, does a value used solely for presentation belong there? To be sure, presentation has already crept into Row, but we are adding to that with this addition.

I do agree that the convenience provided by this code is something that Static looks to provide. But I would like to see two things addressed:

  1. The magic number 24 (can we get that value from the image—although I know that it is nigh impossible)
  2. Providing placeholders for all cases as @dmiluski suggests, as I believe Static needs to be a complete solution for all use cases

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the point of this PR is not to reimagine what Static is or is not, but to provide an easy way for a user to mark a cell for the potential to have a checkmark, so the rest of the content view is laid out appropriately.

24 was the result of testing this across various sized iPhones. I don't know of a way to predict this otherwise.

I don't have the time right now to add placeholders for every potential scenario – if that's a requirement for Static, I can kill this PR, and do a one-off solution in the venmo codebase.

thanks y'all

dmiluski
dmiluski previously approved these changes May 22, 2018
@eliperkins
Copy link
Contributor

What do you think of handling this with a one-off .view case? This seems a little specific to this use-case and is more of an artifact of what UIKit is doing with these types of cells (changing title label widths with specific accessory views), than what Static is doing with UIKit.

@rhaining
Copy link
Contributor Author

@eliperkins I think this'll be useful for others who might want their content to not move around when showing a check or not showing a check.

@rhaining rhaining merged commit 30d5d58 into master May 29, 2018
@rhaining rhaining deleted the checkmark_placeholder branch May 29, 2018 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants