Skip to content

Commit 8ecd0a1

Browse files
author
maciej.lodygowski
committed
fix: improve pr
1 parent 93fbc46 commit 8ecd0a1

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

example/src/Examples.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,20 @@ export const examples: Props[] = [
513513
);
514514
},
515515
},
516+
{
517+
title: 'Buffer value on Android',
518+
render() {
519+
return (
520+
<SliderExample
521+
step={1}
522+
minimumValue={0}
523+
maximumValue={100}
524+
bufferedValue={75}
525+
bufferedTrackTintColor="red"
526+
/>
527+
);
528+
},
529+
},
516530
{
517531
title: 'onSlidingStart',
518532
render(): React.ReactElement {

package/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private void disableStateListAnimatorIfNeeded() {
124124

125125
/* package */ void setBufferedValue(double value) {
126126
mBufferedValue = value;
127-
updateBufferedValue();
127+
updateAll();
128128
}
129129

130130
/* package */ void setStep(double step) {
@@ -238,6 +238,7 @@ private void updateAll() {
238238
updateLowerLimit();
239239
updateUpperLimit();
240240
updateValue();
241+
updateBufferedValue();
241242
}
242243

243244
/** Update limit based on props limit, max and min

package/typings/index.d.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
2-
import { FC } from 'react';
2+
import {FC} from 'react';
33
import * as ReactNative from 'react-native';
4-
import { ImageURISource } from 'react-native';
4+
import {ImageURISource} from 'react-native';
55

66
type Constructor<T> = new (...args: any[]) => T;
77

@@ -14,6 +14,21 @@ export interface SliderPropsAndroid extends ReactNative.ViewProps {
1414
* Color of the foreground switch grip.
1515
*/
1616
thumbTintColor?: string;
17+
18+
/**
19+
* Write-only property representing the bufferedValue of the slider.
20+
* Entered once at the beginning still acts as an initial value.
21+
* The value should be between minimumValue and maximumValue,
22+
* which default to 0 and 1 respectively.
23+
* Default value is 0.
24+
*/
25+
bufferedValue?: number;
26+
27+
/**
28+
* The color used for the buffered track (secondaryProgress)
29+
* Overrides the default grey gradient image.
30+
*/
31+
bufferedTrackTintColor?: string;
1732
}
1833

1934
export interface SliderRef {
@@ -108,12 +123,6 @@ export interface SliderProps
108123
*/
109124
minimumTrackTintColor?: string;
110125

111-
/**
112-
* The color used for the buffered track (secondaryProgress)
113-
* Overrides the default grey gradient image.
114-
*/
115-
bufferedTrackTintColor?: string;
116-
117126
/**
118127
* Initial minimum value of the slider. Default value is 0.
119128
*/
@@ -163,15 +172,6 @@ export interface SliderProps
163172
*/
164173
value?: number;
165174

166-
/**
167-
* Write-only property representing the bufferedValue of the slider.
168-
* Entered once at the beginning still acts as an initial value.
169-
* The value should be between minimumValue and maximumValue,
170-
* which default to 0 and 1 respectively.
171-
* Default value is 0.
172-
*/
173-
bufferedValue?: number;
174-
175175
/**
176176
* Reverses the direction of the slider.
177177
*/
@@ -183,7 +183,7 @@ export interface SliderProps
183183
StepMarker?: FC<MarkerProps>;
184184

185185
/**
186-
*
186+
*
187187
*/
188188
renderStepNumber?: boolean;
189189

0 commit comments

Comments
 (0)