Skip to content

Commit befdc8e

Browse files
committed
fix(Example): improve example
1 parent fffdcf6 commit befdc8e

File tree

2 files changed

+22
-82
lines changed

2 files changed

+22
-82
lines changed

Example/App.js

Lines changed: 20 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import React, {Component} from "react";
2-
import {
3-
Text,
4-
View,
5-
ScrollView,
6-
Image,
7-
FlatList,
8-
SafeAreaView,
9-
Button,
10-
} from "react-native";
2+
import {Text, View, ScrollView, Image, SafeAreaView} from "react-native";
113
import InputSpinner from "react-native-input-spinner";
124
import Styles from "./Styles";
135

@@ -30,47 +22,6 @@ export default class App extends Component {
3022
};
3123
}
3224

33-
renderItem({item}) {
34-
return (
35-
<View style={Styles.item}>
36-
<Text style={{marginRight: 20}}>
37-
Key: {item.key}
38-
{"\n"}Value: {item.value}
39-
</Text>
40-
<View style={{marginRight: 20}}>
41-
<Button
42-
style={{marginRight: 20}}
43-
onPress={() => {
44-
var data = this.state.data;
45-
data[item.key].value = data[item.key].value - 5;
46-
this.setState({data: data});
47-
}}
48-
title="- 5"
49-
/>
50-
</View>
51-
<View style={{marginRight: 20}}>
52-
<Button
53-
onPress={() => {
54-
var data = this.state.data;
55-
data[item.key].value = data[item.key].value + 5;
56-
this.setState({data: data});
57-
}}
58-
title="+ 5"
59-
/>
60-
</View>
61-
<InputSpinner
62-
value={item.value}
63-
style={Styles.spinner}
64-
onChange={(num) => {
65-
var data = this.state.data;
66-
data[item.key].value = num;
67-
this.setState({data: data});
68-
}}
69-
/>
70-
</View>
71-
);
72-
}
73-
7425
getRandomColor() {
7526
var letters = "0123456789ABCDEF";
7627
var color = "#";
@@ -201,9 +152,7 @@ export default class App extends Component {
201152
precision={2}
202153
/>
203154
</View>
204-
<Text style={Styles.title}>
205-
Skins
206-
</Text>
155+
<Text style={Styles.title}>Skins</Text>
207156
<View style={Styles.col}>
208157
<Text style={Styles.text}>Skin Default</Text>
209158
<InputSpinner
@@ -263,18 +212,21 @@ export default class App extends Component {
263212
<Text style={Styles.text}>Skin Modern</Text>
264213
<InputSpinner
265214
value={this.state.value}
266-
style={Styles.spinner}
215+
style={[
216+
Styles.spinner,
217+
{minWidth: 150} /*reset minWidth set on Style.spinner*/,
218+
]}
267219
skin="modern"
268220
max={10}
269221
colorMax={"#f04048"}
270222
colorMin={"#82cc62"}
271223
/>
272224
</View>
273-
<Text style={Styles.title}>
274-
Customization
275-
</Text>
225+
<Text style={Styles.title}>Customization</Text>
276226
<View style={Styles.col}>
277-
<Text style={Styles.text}>color, background, rounded false, showBorder false and textColor</Text>
227+
<Text style={Styles.text}>
228+
color, background, rounded false, showBorder false and textColor
229+
</Text>
278230
<InputSpinner
279231
value={this.state.value}
280232
style={Styles.spinner}
@@ -347,16 +299,6 @@ export default class App extends Component {
347299
<Text style={Styles.simbol}>$</Text>
348300
</InputSpinner>
349301
</View>
350-
<View style={Styles.col}>
351-
<Text style={Styles.text}>Prepend and append</Text>
352-
<InputSpinner
353-
value={this.state.value}
354-
style={Styles.spinner}
355-
append={<Text style={Styles.simbol}>Append</Text>}
356-
prepend={<Text style={Styles.simbol}>Prepend</Text>}>
357-
<Text style={Styles.simbol}>$</Text>
358-
</InputSpinner>
359-
</View>
360302
<View style={Styles.col}>
361303
<Text style={Styles.text}>Placeholder</Text>
362304
<InputSpinner style={Styles.spinner} placeholder={"Placeholder"} />
@@ -377,13 +319,16 @@ export default class App extends Component {
377319
}}
378320
/>
379321
</View>
380-
<Text style={Styles.title}>List</Text>
381-
<FlatList
382-
style={{height: 500}}
383-
data={this.state.data}
384-
renderItem={this.renderItem.bind(this)}
385-
keyExtractor={(item) => item.key}
386-
/>
322+
<Text style={Styles.title}>Append/Prepend</Text>
323+
<View style={Styles.col}>
324+
<InputSpinner
325+
value={this.state.value}
326+
style={[Styles.spinner, {minWidth: 300}]}
327+
append={<Text style={Styles.simbol}>Append</Text>}
328+
prepend={<Text style={Styles.simbol}>Prepend</Text>}>
329+
<Text style={Styles.simbol}>$</Text>
330+
</InputSpinner>
331+
</View>
387332
</ScrollView>
388333
</SafeAreaView>
389334
);

Example/Styles.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Platform, StatusBar, StyleSheet} from "react-native";
1+
import {StatusBar, StyleSheet} from "react-native";
22

33
export default StyleSheet.create({
44
mainContainer: {
@@ -40,12 +40,7 @@ export default StyleSheet.create({
4040
spinner: {
4141
flex: 1,
4242
marginRight: 10,
43-
...Platform.select({
44-
web: {},
45-
default: {
46-
minWidth: 150,
47-
},
48-
}),
43+
minWidth: 150,
4944
},
5045
simbol: {
5146
marginLeft: 10,

0 commit comments

Comments
 (0)