Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion example-web/src/Examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@ export interface Props {
platform?: string;
}

const StepMarker = ({
stepMarked,
currentValue,
index,
}: {
stepMarked: boolean;
currentValue: number;
index: number;
}) => (
<View
style={{
marginTop: '24px',
height: '16px',
width: '3px',
backgroundColor:
currentValue < index ? 'rgb(147, 147, 147)' : 'rgb(0, 150, 136)',
}}
/>
)

const SliderExample = (props: SliderProps) => {
const [value, setValue] = useState(0);
return (
Expand Down Expand Up @@ -232,4 +252,17 @@ export const examples: Props[] = [
);
},
},
];
{
title: 'Slider with StepMarker',
render() {
return (
<SliderExample
StepMarker={StepMarker}
step={1}
minimumValue={0}
maximumValue={10}
/>
);
},
}
];
1 change: 1 addition & 0 deletions package/src/components/StepsIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const StepsIndicator = ({
<View style={styles.stepIndicatorElement}>
<SliderTrackMark
key={`${index}-SliderTrackMark`}
index={index}
isTrue={currentValue === i}
thumbImage={thumbImage}
StepMarker={StepMarker}
Expand Down
9 changes: 8 additions & 1 deletion package/src/components/TrackMark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,32 @@ import {styles} from '../utils/styles';
export type MarkerProps = {
stepMarked: boolean;
currentValue?: number;
index: number;
};

export type TrackMarksProps = {
isTrue: boolean;
thumbImage?: ImageURISource;
StepMarker?: FC<MarkerProps>;
currentValue?: number;
index: number;
};

export const SliderTrackMark = ({
isTrue,
thumbImage,
StepMarker,
currentValue,
index,
}: TrackMarksProps) => {
return (
<View style={styles.trackMarkContainer}>
{StepMarker ? (
<StepMarker stepMarked={isTrue} currentValue={currentValue} />
<StepMarker
index={index}
stepMarked={isTrue}
currentValue={currentValue}
/>
) : null}
{thumbImage && isTrue ? (
<View style={styles.thumbImageContainer}>
Expand Down