Skip to content

Commit

Permalink
refactor: slider #154
Browse files Browse the repository at this point in the history
  • Loading branch information
BANG88 committed Dec 8, 2018
1 parent 2a74fd9 commit a75806e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 40 deletions.
12 changes: 0 additions & 12 deletions components/slider/PropsType.tsx

This file was deleted.

50 changes: 32 additions & 18 deletions components/slider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import React from 'react';
import { Slider, View } from 'react-native';
import { SliderPropsType } from './PropsType';
import SliderStyle from './style/index';
import { WithTheme } from '../style';

export interface SliderProps extends SliderPropsType {
export interface SliderProps {
maximumTrackTintColor?: string;
minimumTrackTintColor?: string;
onChange?: (value?: number) => void;
onAfterChange?: (value?: number) => void;
defaultValue?: number;
tipFormatter?: (value?: string) => React.ReactNode;
value?: number;
min?: number;
max?: number;
step?: number;
disabled?: boolean;
}

export default class SliderAntm extends React.Component<SliderProps, any> {
Expand All @@ -14,8 +22,6 @@ export default class SliderAntm extends React.Component<SliderProps, any> {
onAfterChange() {},
defaultValue: 0,
disabled: false,
maximumTrackTintColor: SliderStyle.maximum.color,
minimumTrackTintColor: SliderStyle.minimum.color,
};

render() {
Expand All @@ -32,19 +38,27 @@ export default class SliderAntm extends React.Component<SliderProps, any> {
minimumTrackTintColor,
} = this.props;
return (
<View>
<Slider
value={defaultValue || value}
minimumValue={min}
maximumValue={max}
step={step}
minimumTrackTintColor={minimumTrackTintColor}
maximumTrackTintColor={maximumTrackTintColor}
disabled={disabled}
onValueChange={onChange}
onSlidingComplete={onAfterChange}
/>
</View>
<WithTheme>
{(_, theme) => (
<View>
<Slider
value={defaultValue || value}
minimumValue={min}
maximumValue={max}
step={step}
minimumTrackTintColor={
minimumTrackTintColor || theme.brand_primary
}
maximumTrackTintColor={
maximumTrackTintColor || theme.border_color_base
}
disabled={disabled}
onValueChange={onChange}
onSlidingComplete={onAfterChange}
/>
</View>
)}
</WithTheme>
);
}
}
10 changes: 0 additions & 10 deletions components/slider/style/index.tsx

This file was deleted.

0 comments on commit a75806e

Please sign in to comment.