Skip to content

Commit 2f2f134

Browse files
authored
Fix/ renderSliderOption method (#1381)
* fix renderSliderOption * set initial value to slider
1 parent 44c2552 commit 2f2f134

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

demo/src/screens/ExampleScreenPresenter.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function renderColorOption(title,
107107
}
108108

109109
export function renderSliderOption(title, key, {min = 0, max = 10, step = 1, initial = 0, sliderText = ''}) {
110-
const value = this.state[key];
110+
const value = this.state[key] || initial;
111111
return (
112112
<View marginV-s2>
113113
<Text marginB-s1 text70M>
@@ -123,7 +123,7 @@ export function renderSliderOption(title, key, {min = 0, max = 10, step = 1, ini
123123
step={step}
124124
onValueChange={value => this.setState({[key]: value})}
125125
/>
126-
<Text marginL-s4 text70>
126+
<Text marginL-s4 text70 style={styles.text}>
127127
{sliderText}
128128
{value}
129129
</Text>
@@ -135,5 +135,8 @@ export function renderSliderOption(title, key, {min = 0, max = 10, step = 1, ini
135135
const styles = StyleSheet.create({
136136
rowWrap: {
137137
flexWrap: 'wrap'
138+
},
139+
text: {
140+
width: 30
138141
}
139142
});

demo/src/screens/componentScreens/ViewScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ViewScreen extends Component {
6969
<View height={2} bg-grey60 marginB-20/>
7070
{renderBooleanOption.call(this, 'Row (parent)', 'useRow')}
7171
{renderBooleanOption.call(this, 'Flex (child)', 'shouldFlex')}
72-
{renderSliderOption.call(this, 'BorderRadius(brXX)', 'borderRadius', {step: 10, min: 0, max: 60})}
72+
{renderSliderOption.call(this, 'BorderRadius(brXX)', 'borderRadius', {step: 10, min: 0, max: 60, initial: 20})}
7373
{renderSliderOption.call(this, 'Padding(padding-XX)', 'padding', {step: 4, min: 0, max: 40})}
7474
{renderSliderOption.call(this, 'Margin(margin-XX)', 'margin', {step: 4, min: 0, max: 40})}
7575
{renderRadioGroup.call(this, 'Alignment (parent)', 'alignment', ALIGNMENTS, {isRow: true})}

0 commit comments

Comments
 (0)