File tree Expand file tree Collapse file tree 7 files changed +38
-0
lines changed Expand file tree Collapse file tree 7 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ Check out the [example project](example) for more examples.
78
78
- [ ` minimumTrackImage ` ] ( #minimumtrackimage )
79
79
- [ ` thumbImage ` ] ( #thumbimage )
80
80
- [ ` trackImage ` ] ( #trackimage )
81
+ - [ ` inverted ` ] ( #inverted )
81
82
82
83
---
83
84
@@ -251,6 +252,15 @@ Assigns a single image for the track. Only static images are supported. The cent
251
252
| ---------------------- | -------- | -------- |
252
253
| Image.propTypes.source | No | iOS |
253
254
255
+ ---
256
+
257
+ ### ` inverted `
258
+ Reverses the direction of the slider. Default value is false.
259
+
260
+ | Type | Required | Platform |
261
+ | ---- | -------- | -------- |
262
+ | bool | No | iOS |
263
+
254
264
## Maintainers
255
265
256
266
- [ Michał Chudziak] ( https://github.com/michalchudziak ) - [ Callstack] ( https://callstack.com/ )
Original file line number Diff line number Diff line change @@ -191,4 +191,11 @@ exports.examples = [
191
191
) ;
192
192
} ,
193
193
} ,
194
+ {
195
+ title : 'Inverted slider direction' ,
196
+ platform : 'ios' ,
197
+ render ( ) : React . Element < any > {
198
+ return < SliderExample value = { 0.6 } inverted /> ;
199
+ } ,
200
+ } ,
194
201
] ;
Original file line number Diff line number Diff line change @@ -84,4 +84,13 @@ - (UIImage *)thumbImage
84
84
return [self thumbImageForState: UIControlStateNormal];
85
85
}
86
86
87
+ - (void )setInverted : (BOOL )inverted
88
+ {
89
+ if (inverted) {
90
+ self.transform = CGAffineTransformMakeScale (-1 , 1 );
91
+ } else {
92
+ self.transform = CGAffineTransformMakeScale (1 , 1 );
93
+ }
94
+ }
95
+
87
96
@end
Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ - (void)sliderTouchEnd:(RNCSlider *)sender
98
98
RCT_EXPORT_VIEW_PROPERTY (onRNCSliderSlidingComplete, RCTBubblingEventBlock);
99
99
RCT_EXPORT_VIEW_PROPERTY (thumbTintColor, UIColor);
100
100
RCT_EXPORT_VIEW_PROPERTY (thumbImage, UIImage);
101
+ RCT_EXPORT_VIEW_PROPERTY (inverted, BOOL );
101
102
RCT_CUSTOM_VIEW_PROPERTY (disabled, BOOL , RNCSlider)
102
103
{
103
104
if (json) {
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ type NativeProps = $ReadOnly<{|
29
29
...ViewProps ,
30
30
disabled ?: ?boolean ,
31
31
enabled ?: ?boolean ,
32
+ inverted ?: ?boolean ,
32
33
maximumTrackImage ?: ?ImageSource ,
33
34
maximumTrackTintColor ?: ?ColorValue ,
34
35
maximumValue ?: ?number ,
Original file line number Diff line number Diff line change @@ -54,6 +54,12 @@ type IOSProps = $ReadOnly<{|
54
54
* Sets an image for the thumb. Only static images are supported.
55
55
*/
56
56
thumbImage ?: ?ImageSource ,
57
+
58
+ /**
59
+ * If true the slider will be inverted.
60
+ * Default value is false.
61
+ */
62
+ inverted ?: ?boolean ,
57
63
| } > ;
58
64
59
65
type Props = $ReadOnly < { |
@@ -270,6 +276,7 @@ SliderWithRef.defaultProps = {
270
276
minimumValue : 0 ,
271
277
maximumValue : 1 ,
272
278
step : 0 ,
279
+ inverted : false ,
273
280
} ;
274
281
275
282
let styles ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ exports[`<Slider /> renders a slider with custom props 1`] = `
4
4
<RNCSlider
5
5
disabled = { false }
6
6
enabled = { true }
7
+ inverted = { false }
7
8
maximumTrackTintColor = " red"
8
9
maximumValue = { 2 }
9
10
minimumTrackTintColor = " blue"
@@ -29,6 +30,7 @@ exports[`<Slider /> renders disabled slider 1`] = `
29
30
<RNCSlider
30
31
disabled = { true }
31
32
enabled = { false }
33
+ inverted = { false }
32
34
maximumValue = { 1 }
33
35
minimumValue = { 0 }
34
36
onChange = { null }
@@ -51,6 +53,7 @@ exports[`<Slider /> renders enabled slider 1`] = `
51
53
<RNCSlider
52
54
disabled = { false }
53
55
enabled = { true }
56
+ inverted = { false }
54
57
maximumValue = { 1 }
55
58
minimumValue = { 0 }
56
59
onChange = { null }
You can’t perform that action at this time.
0 commit comments