-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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] Remove fixed size for Android. Fixes #3785 #4298
Conversation
cc @mkonicek |
I think this is good! cc @sahrens How have you tested it? Can you add a screenshot from the UIExplorer for example? |
@mkonicek Yea I've tested it. With change matches:
|
Can we please not have different layout behavior between iOS and android? This makes android switch stretch and right align which is super weird and does not match iOS. |
Can we just change the width? Or pass down the width from the native module if it varies by device? |
@sahrens I had originally thought about just adjusting the width but after speaking with @mkonicek he mentioned something about auto-layout with Android and that it's not necessary to define and fixed values. Adjust the width to 45 makes it not get cut off but all the switches are still aligned left. Does the switch component vary in size between different Android devices? |
Size of switch on android varies between OS versions, it can be different when some of the accessibility features are on AFAIK, not to mention custom skins/themes some vendor like to preinstall. It's always been measuring itself because of the aforementioned reasons and I personally support this change. Not sure what the benefit would be from having it send over but it will definitely introduce some limitations (e.g currently we can start initialising the bridge before activity is started and we don't yet have access to the theme at that time, to pass it down as a constant we'd need to have theme before we initialise the bridge) |
If it's not reasonable to pass the size through as a constant, there are two options to make it consistent with iOS:
The only thing I really care about is consistency. |
The current changes should keep the same layout behavior if you were to use SwitchIOS or SwitchAndroid separately since SwitchIOS is the only one that has styling pre defined and passed into the native component. |
But are they interchangeable? We should strive for interchangeable whenever it's reasonable, and this seems like a perfect case for that. |
I like what Spencer suggested:
Is that doable? I think you need to change the measure logic in Java. I agree it's a bit strange the Android Switch fills parent and is right-aligned. |
@christopherdro Would love to get this merged. Without this the Cross platform switch component is not usable. |
Let's figure out the alignment on Android separately. I agree without this PR the cross-platform switch is unusable. |
@facebook-github-bot shipit |
Thanks for importing. If you are an FB employee go to https://our.intern.facebook.com/intern/opensource/github/pull_request/179289565750654/int_phab to review. |
Summary: Fixed facebook#3785 Closes facebook#4298 Reviewed By: svcscm Differential Revision: D2807289 Pulled By: mkonicek fb-gh-sync-id: 6f161e4f8b04597726183fdcf8bc22c682557958
Fixed #3785