Skip to content

Commit 9f6df5f

Browse files
committed
textInput 提供更多参数,以方便修改
1 parent 6659436 commit 9f6df5f

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

src/forms/LoginForm/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const formFieldsObject = {
2020
password: {
2121
label: 'password',
2222
type: 'textInput',
23+
secureTextEntry: true,
2324
placeholder: 'placeholderPassword',
2425
},
2526
};

src/forms/formFields/TextInput/index.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,28 @@ import styles from '../styles';
1515

1616
export default function TextInput(props) {
1717
const {
18-
input, placeholder, label, layout,
18+
input, placeholder, label, layout, itemSettings, secureTextEntry,
19+
itemstyle, labelStyle,
1920
} = props;
2021

21-
const labelText = label || input.name;
22-
const itemLayout = [];
22+
const itemLayout = [itemstyle];
23+
const labelVertical = [labelStyle];
2324
if (layout === 'vertical') {
2425
itemLayout.push(styles.fieldVertical);
26+
labelVertical.push(styles.labelVertical);
2527
}
2628

29+
const labelText = label || input.name;
30+
const placeholderText = (itemSettings && itemSettings.floatingLabel === true)
31+
? null : placeholder;
32+
2733
return (
28-
<Item>
29-
<Label>{labelText}</Label>
34+
<Item {...itemSettings} style={itemLayout}>
35+
<Label style={labelVertical}>{labelText}</Label>
3036
<Input
31-
placeholder={placeholder}
37+
placeholder={placeholderText}
3238
onChangeText={input.onChange}
39+
secureTextEntry={secureTextEntry}
3340
/>
3441
</Item>
3542
);
@@ -40,11 +47,19 @@ TextInput.defaultProps = {
4047
placeholder: '',
4148
label: '',
4249
layout: '',
50+
itemSettings: {},
51+
secureTextEntry: false,
52+
itemstyle: {},
53+
labelStyle: {},
4354
};
4455

4556
TextInput.propTypes = {
4657
input: PropTypes.object,
4758
placeholder: PropTypes.string,
4859
label: PropTypes.string,
4960
layout: PropTypes.string,
61+
itemSettings: PropTypes.object,
62+
secureTextEntry: PropTypes.bool,
63+
itemstyle: PropTypes.object,
64+
labelStyle: PropTypes.object,
5065
};

src/forms/formFields/styles.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
export default {
44
fieldVertical: {
5-
// flexDirection: 'column',
6-
// alignItems: 'stretch',
5+
flexDirection: 'column',
6+
alignItems: 'stretch',
7+
height: 80,
8+
},
9+
labelVertical: {
10+
paddingHorizontal: 5,
711
},
812
};

0 commit comments

Comments
 (0)