Skip to content

Commit 2a8ed59

Browse files
authored
fix:解决在安卓手机上表单输入框占位过多的问题 #625 (#626)
'
1 parent 47e7ee9 commit 2a8ed59

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

packages/core/src/Form/comps/input.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import React from 'react';
2-
import { TextInput, TextInputProps } from 'react-native';
3-
import { useTheme } from "@shopify/restyle"
4-
import { Theme } from '../../theme'
2+
import { Platform, TextInput, TextInputProps } from 'react-native';
3+
import { useTheme } from '@shopify/restyle';
4+
import { Theme } from '../../theme';
55

66
const Input = ({ value, onChange, ...others }: TextInputProps & { onChange?: (value: string) => void }) => {
7-
const theme = useTheme<Theme>()
7+
const theme = useTheme<Theme>();
8+
const isIOS = Platform.OS === 'ios';
89
return (
910
<TextInput
1011
value={value}
1112
onChangeText={(value) => {
1213
onChange?.(value);
1314
}}
14-
style={{ color: theme.colors.text }}
15+
style={{ paddingVertical: isIOS ? 5 : -5, color: theme.colors.text }}
1516
{...others}
1617
/>
1718
);

packages/core/src/Form/comps/label.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const styles = StyleSheet.create({
2020
width: 'auto',
2121
fontSize: 16,
2222
fontWeight: '500',
23-
marginBottom: 10,
23+
marginBottom: 5,
2424
},
2525
});
2626

packages/core/src/Form/comps/tip.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useContext } from 'react';
22
import { Context } from '../hooks/context';
33
import { FormItemsProps } from '../types';
4-
import { Text } from 'react-native';
4+
import { View, Text } from 'react-native';
55

66
const Tip = ({ v }: { v: Partial<FormItemsProps> & { field: string } }) => {
77
const {
@@ -11,7 +11,11 @@ const Tip = ({ v }: { v: Partial<FormItemsProps> & { field: string } }) => {
1111
const content = validator.message(v.field, store[v.field], {
1212
validate: v?.validate,
1313
});
14-
return <Text style={{ color: 'red', marginBottom: content && 10, marginTop: content && 10 }}>{content}</Text>;
14+
return (
15+
<View style={{ marginTop: 5 }}>
16+
{content && <Text style={{ color: 'red', marginBottom: content && 5 }}>{content}</Text>}
17+
</View>
18+
);
1519
};
1620

1721
export default Tip;

packages/core/src/Form/styles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const styles = StyleSheet.create({
99
},
1010
form_items: {
1111
textAlign: 'center',
12-
margin: 10,
12+
margin: 5,
1313
borderBottomWidth: 0.5,
1414
borderBottomColor: '#ccc',
1515
},

0 commit comments

Comments
 (0)