Skip to content

Commit 1d5f246

Browse files
committed
fix(LoginPage):优化迭代LoginPage登录组件
1 parent 63ee587 commit 1d5f246

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

packages/core/src/LoginPage/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ LoginPage 登录页
55
### 基础示例
66

77
<!--DemoStart-->
8-
```jsx
8+
9+
```jsx mdx:preview&background=#bebebe29
910
import React,{Fragment} from 'react';
1011
import { View} from 'react-native';
1112
import { LoginPage } from '@uiw/react-native';
1213

1314
const Demo = () => {
1415
return (
1516
<Fragment>
16-
<View>
17-
<LoginPage />
18-
</View>
17+
<LoginPage />
1918
</Fragment>
2019
);
2120
}

packages/core/src/LoginPage/index.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Icon from '../Icon';
44
import VerificationCode from '../VerificationCode';
55
import { Theme } from '../theme';
66
import { useTheme } from '@shopify/restyle';
7-
import { logSvg, cEyes, oEyes } from './svg';
7+
// import { logSvg, cEyes, oEyes } from './svg';
88

99
interface LoginPageProps {
1010
/** 自定义账号输入框为空时显示的文字 */
@@ -19,6 +19,8 @@ interface LoginPageProps {
1919
buttonText?: string;
2020
/** 自定义忘记密码,切换登录方式 */
2121
customContent?: React.ReactNode;
22+
/** 自定义登录logo和login文字 */
23+
titleContent?: React.ReactNode;
2224
/** 登录按钮事件 */
2325
onLogin?: (username: string, password: string) => void;
2426
/** 忘记密码按钮事件 */
@@ -32,12 +34,12 @@ const LoginPage: React.FC<LoginPageProps> = ({
3234
buttonStyle = {},
3335
buttonText = 'Login',
3436
customContent,
37+
titleContent,
3538
onLogin,
3639
onForgetPassword,
3740
}) => {
3841
const [showPsd, setShowPsd] = useState(false);
39-
const [showCode, setShowCode] = useState(false); // added state
40-
console.log('showCode', showCode);
42+
const [showCode, setShowCode] = useState(false);
4143

4244
const theme = useTheme<Theme>();
4345
const styles = createStyles({
@@ -48,12 +50,10 @@ const LoginPage: React.FC<LoginPageProps> = ({
4850
const [password, setPassword] = useState('');
4951

5052
const onChangeUsername = (val: string) => {
51-
console.log('onChange--> 输入改变事件 ', val);
5253
setUsername(val);
5354
};
5455

5556
const onChangePassword = (val: string) => {
56-
console.log('onChange--> 输入改变事件 ', val);
5757
setPassword(val);
5858
};
5959

@@ -66,10 +66,12 @@ const LoginPage: React.FC<LoginPageProps> = ({
6666
return (
6767
<View style={[styles.container, { backgroundColor: theme.colors.background }, containerStyle]}>
6868
<View style={styles.content}>
69-
<View style={styles.center}>
70-
<Icon xml={logSvg(theme)} size={30} />
71-
<Text style={styles.title}>Login</Text>
72-
</View>
69+
{titleContent || (
70+
<View style={styles.center}>
71+
<Icon name="uiw" size={35} />
72+
<Text style={styles.title}>Login</Text>
73+
</View>
74+
)}
7375
<View style={[styles.inputContainer, { paddingHorizontal: 15 }, inputContainerStyle]}>
7476
<TextInput
7577
placeholder={usernamePlaceholder ? usernamePlaceholder : `请输入${showCode ? '手机号码' : '用户名'}`}
@@ -80,7 +82,9 @@ const LoginPage: React.FC<LoginPageProps> = ({
8082
/>
8183
</View>
8284
{!showCode ? (
83-
<View style={[styles.inputContainer, styles.inputC, { paddingHorizontal: 15 }, inputContainerStyle]}>
85+
<View
86+
style={[styles.inputContainer, styles.inputC, { paddingLeft: 15, paddingRight: 15 }, inputContainerStyle]}
87+
>
8488
<TextInput
8589
placeholder="请输入密码"
8690
placeholderTextColor={theme.colors.border}
@@ -89,18 +93,18 @@ const LoginPage: React.FC<LoginPageProps> = ({
8993
onChangeText={onChangePassword}
9094
/>
9195
<TouchableOpacity onPress={() => setShowPsd(!showPsd)}>
92-
<Icon xml={showPsd ? cEyes : oEyes} size={20} />
96+
<Icon name={showPsd ? 'eye' : 'eye-o'} size={20} color="#8a8a8a" />
9397
</TouchableOpacity>
9498
</View>
9599
) : (
96100
<VerificationCode
97101
value={password}
98102
count={60}
99103
onChange={onChangePassword}
104+
inputBorder={false}
100105
outerStyle={[styles.inputContainer, styles.inputC, inputContainerStyle]}
101106
/>
102107
)}
103-
104108
<View>
105109
{customContent || (
106110
<View style={styles.textSty1}>
@@ -113,7 +117,6 @@ const LoginPage: React.FC<LoginPageProps> = ({
113117
</View>
114118
)}
115119
</View>
116-
117120
<TouchableOpacity style={[styles.button, buttonStyle]} onPress={handleLogin}>
118121
<Text style={[styles.buttonText, styles.buttonTextStyle]}>{buttonText}</Text>
119122
</TouchableOpacity>
@@ -159,7 +162,7 @@ function createStyles({ border, putCol }: CreStyle) {
159162
alignItems: 'center',
160163
},
161164
inputC: {
162-
paddingHorizontal: 10,
165+
paddingLeft: 10,
163166
marginTop: 20,
164167
marginBottom: 5,
165168
},

0 commit comments

Comments
 (0)