feat: add thumbSize to set size of thumb#752
Conversation
BartoszKlonowski
left a comment
There was a problem hiding this comment.
So far I have some cosmetic comments and a question before I'll dive deeper into the implementation itself.
|
Hello @bdtren, let me know please if you plan to push this forward, or should I take it from here? |
|
Hi @BartoszKlonowski , |
…thumbImage change. Remove comments via fb
|
Hi @BartoszKlonowski , |
BartoszKlonowski
left a comment
There was a problem hiding this comment.
Thank you for addressing comments! 🙏
As for the triggering the callback - let's take a look if there are some issues after, for now, even when testing this locally I don't see it needing a special attention.
I'm in the middle of rewriting the modules to Swift/Kotlin, so I really want to release this feature now, not to wait for all my work to be done.
Thank you again very much @bdtren :)
| public void setThumbSize(final double size) { | ||
| float density = getResources().getDisplayMetrics().density; | ||
| mThumbSizePx = size > 0 ? Math.round((float) size * density) : 0; |
There was a problem hiding this comment.
| public void setThumbSize(final double size) { | |
| float density = getResources().getDisplayMetrics().density; | |
| mThumbSizePx = size > 0 ? Math.round((float) size * density) : 0; | |
| public void setThumbSize(final float size) { | |
| float density = getResources().getDisplayMetrics().density; | |
| mThumbSizePx = size > 0 ? Math.round(size * density) : 0; |
| view.setThumbImage(uri); | ||
| } | ||
|
|
||
| public static void setThumbSize(ReactSlider view, double size) { |
There was a problem hiding this comment.
| public static void setThumbSize(ReactSlider view, double size) { | |
| public static void setThumbSize(ReactSlider view, float size) { |
| testID?: string; | ||
| thumbImage?: ImageSource; | ||
| thumbTintColor?: ColorValue; | ||
| thumbSize?: Double; |
There was a problem hiding this comment.
| thumbSize?: Double; | |
| thumbSize?: Float; |
|
|
||
| @Override | ||
| @ReactProp(name = "thumbSize", defaultFloat = 0f) | ||
| public void setThumbSize(ReactSlider view, double size) { |
There was a problem hiding this comment.
| public void setThumbSize(ReactSlider view, double size) { | |
| public void setThumbSize(ReactSlider view, float size) { |
Summary:
This PR adds a new thumbSize prop to control the thumb’s size for both with and without thumb image. It is a simple feature that I need and did patch-package in some of my projects but I didn't have a chance to contribute, I think some developers might also need it:
Test Plan:
Verify in the example list:
“Custom thumb size (no image)” renders a larger thumb (e.g. thumbSize={32}) tinted with thumbTintColor.
“Custom thumb size (scaled image)” renders the thumb image scaled to the configured size (e.g. thumbSize={60}).
Verify the same two examples behave equivalently on iOS (thumb resizes; image scales when provided).