Skip to content

Commit 7018b36

Browse files
committed
a post about : textinput
1 parent e175c21 commit 7018b36

File tree

4 files changed

+699
-75
lines changed

4 files changed

+699
-75
lines changed

.idea/workspace.xml

Lines changed: 72 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BasicsDemo/index.ios.js

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,59 @@ import {
99
AppRegistry,
1010
StyleSheet,
1111
Text,
12+
TextInput,
13+
ScrollView,
14+
Image,
1215
View
1316
} from 'react-native';
1417

18+
1519
class BasicsDemo extends Component {
20+
21+
constructor(props) {
22+
super(props);
23+
this.state = {text: ''};
24+
}
25+
1626
render() {
1727
return (
18-
<View style={styles.container}>
19-
<View style={{width:50, height:50,backgroundColor:'red'}}/>
20-
<View style={{width:100, height:100,backgroundColor:'green'}}/>
21-
<View style={{width:150, height:150,backgroundColor:'skyblue'}}/>
22-
</View>
28+
// <View style={styles.container}>
29+
// <View style={{width:50, height:50,backgroundColor:'red'}}/>
30+
// <View style={{width:100, height:100,backgroundColor:'green'}}/>
31+
// <View style={{width:150, height:150,backgroundColor:'skyblue'}}/>
32+
// </View>
2333

2434
// <View style={{flex:1 , flexDirection: 'column' }}>
2535
// <View style={{flex:1,backgroundColor:'red'}}/>
2636
// <View style={{flex: 2,backgroundColor:'green'}}/>
2737
// <View style={{flex:2,backgroundColor:'skyblue'}}/>
2838
// </View>
39+
40+
41+
// <View style={styles.container}>
42+
//
43+
// <TextInput
44+
// style={styles.textInputStyle}
45+
//
46+
// placeholder={"Plase Input Text Here"}
47+
//
48+
// autoCapitalize = 'characters'
49+
//
50+
// multiline = {true}
51+
//
52+
// numberOfLines = {3}
53+
//
54+
// onChangeText = { (text) => this.setState({text})}/>
55+
//
56+
// <Text style={{padding: 10, fontSize: 42}}>
57+
// {this.state.text.split(' ').map((word) => word && '🍕').join(' ')}
58+
// </Text>
59+
//
60+
// </View>
61+
62+
63+
64+
2965
);
3066
}
3167
}
@@ -34,10 +70,24 @@ const styles = StyleSheet.create({
3470
container: {
3571
flex: 1,
3672
backgroundColor: '#f4f4f4',
37-
flexDirection: 'row',
38-
justifyContent:'space-between',
73+
flexDirection: 'column',
74+
justifyContent:'center',
3975
alignItems : 'center'
40-
}
76+
},
77+
78+
textInputStyle:{
79+
color:'red',
80+
height : 40,
81+
borderColor: 'green',
82+
borderWidth : 1,
83+
margin:10,
84+
borderRadius : 3,
85+
justifyContent: 'center',
86+
alignItems:'center',
87+
paddingLeft:10,
88+
borderBottomColor:'blue',
89+
90+
}
4191
});
4292

4393
AppRegistry.registerComponent('BasicsDemo', () => BasicsDemo);

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,27 @@ React Native Play Ground for practice。
3939
* alignItems: flex-start, center, flex-end, and stretch.
4040

4141
view在从轴的排列方式;
42+
43+
# TextInput : 允许用户输入文本的组件
44+
45+
```
46+
<TextInput
47+
style={styles.textInputStyle}
48+
49+
placeholder={"Plase Input Text Here"}
50+
51+
autoCapitalize = 'characters'
52+
53+
multiline = {true}
54+
55+
numberOfLines = {3}
56+
57+
onChangeText = { (text) => this.setState({text})}/>
58+
59+
<Text style={{padding: 10, fontSize: 42}}>
60+
{this.state.text.split(' ').map((word) => word && '🍕').join(' ')}
61+
</Text>
62+
```
63+
4264

4365

0 commit comments

Comments
 (0)