Skip to content

Adjust row height by font size in PickerIOS#13513

Closed
alin23 wants to merge 1 commit into
react:masterfrom
alin23:fix/picker-font-size
Closed

Adjust row height by font size in PickerIOS#13513
alin23 wants to merge 1 commit into
react:masterfrom
alin23:fix/picker-font-size

Conversation

@alin23

@alin23 alin23 commented Apr 14, 2017

Copy link
Copy Markdown
Contributor
  • Explain the motivation for making this change.
  • Provide a test plan demonstrating that the code is solid.
  • Match the code formatting of the rest of the codebase.
  • Target the master branch, NOT a "stable" branch.

Motivation (required)

There is a problem where setting a bigger fontSize in PickerItem style
clips the top and bottom of the text.
This solves that problem by computing the row height using the font
size.

Test Plan (required)

Create a PickerIOS component and set a larger font size (e.g. 50). The row height will grow accordingly.

Example with fontSize=50: Screenshot

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. GH Review: review-needed labels Apr 14, 2017

@shergin shergin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How do you choose 8 as a compound padding?

Comment thread React/Views/RCTPicker.m Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please fix code style.

@alin23 alin23 force-pushed the fix/picker-font-size branch from 424c2ce to 58fdd38 Compare May 29, 2017 09:07
@alin23

alin23 commented May 29, 2017

Copy link
Copy Markdown
Contributor Author

@shergin I chose it by trial and error. This value made the view look the most natural.
I tried to find out which is the default margin in UIPickerView but it's not documented and stepping through the disassembled UIKit doesn't show any obvious constant for margin/padding.

@shergin shergin added the Platform: iOS iOS applications. label May 29, 2017
@shergin

shergin commented May 29, 2017

Copy link
Copy Markdown
Contributor

Okay, but... Default row height is 40 (Right?), the default font size is 21 (Right?), so 21 + 8 = 21 != 40, so it means we change/break default styling. 🤔
Was it intentional?
Should we use 19 instead of 8?

@alin23 alin23 force-pushed the fix/picker-font-size branch from 58fdd38 to 9f19716 Compare May 29, 2017 18:45
@alin23

alin23 commented May 29, 2017

Copy link
Copy Markdown
Contributor Author

@shergin you're right, it makes sense. It actually looks way better with a 19 offset

Screenshot

@shergin shergin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@alin23 I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

@alin23 alin23 closed this Aug 23, 2017
@shergin

shergin commented Aug 23, 2017

Copy link
Copy Markdown
Contributor

@alin23 I am sorry for the delay, should we still merge this? Have tried to test how this change affects default usage?

@alin23 alin23 reopened this Aug 23, 2017
There is a problem where setting a bigger fontSize in PickerItem style
clips the top and bottom of the text.
This solves that problem by computing the row height using the font
size.
@alin23 alin23 force-pushed the fix/picker-font-size branch from 9f19716 to b309410 Compare August 23, 2017 20:08
@alin23 alin23 requested a review from javache as a code owner August 23, 2017 20:08
@alin23

alin23 commented Aug 23, 2017

Copy link
Copy Markdown
Contributor Author

@shergin Sorry for closing this, I just took for granted what the bot said and thought that the file was removed/refactored somehow.

Yes, I still think this needs to be merged. I got a request from another react-native user to merge this into master so I guess it would be a good idea to do this.

Default usage didn't seem to be affected or changed in any way in my previous tests. As long as I didn't change the default font size, everything looked the same.

@pull-bot

Copy link
Copy Markdown

Attention: @shergin, @javache

Generated by 🚫 dangerJS

@facebook-github-bot facebook-github-bot added GH Review: accepted Import Started This pull request has been imported. This does not imply the PR has been approved. and removed GH Review: review-needed labels Aug 23, 2017
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ldhios

ldhios commented Nov 15, 2018

Copy link
Copy Markdown

@alin23 why auto row height with font size? it is correct? If i use a few PickerIOS , fontSize is different, row height is catastrophic。 like this image
image

@alin23

alin23 commented Nov 15, 2018

Copy link
Copy Markdown
Contributor Author

@ldhios indeed, I didn't take into consideration that the columns could have different font sizes, thus breaking the alignment. It might not be correct, but it is better than clipping the text.

@ldhios

ldhios commented Nov 16, 2018

Copy link
Copy Markdown

@alin23 Thanks for you reply in time。 Can you help me fix my issues?

@alin23

alin23 commented Nov 16, 2018

Copy link
Copy Markdown
Contributor Author

@ldhios I'm sorry but I haven't developed in Obj-C or React Native in a while. A workaround would be to hide those separators by setting the separatorColor to transparent or same as the background color.

@ldhios

ldhios commented Nov 19, 2018

Copy link
Copy Markdown

@alin23 Thanks。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved. Platform: iOS iOS applications.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants