Skip to content

Commit 618ab6c

Browse files
committed
Merge branch 'dev' of github.com:uiwjs/react-native-uiw into dev
2 parents f8805f0 + 692d305 commit 618ab6c

File tree

8 files changed

+77
-72
lines changed

8 files changed

+77
-72
lines changed

example/examples/src/routes/LoginPage/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, {Component} from 'react';
22
import Layout, {Container} from '../../Layout';
33
import {LoginPage} from '@uiw/react-native';
44
import {ComProps} from '../../routes';
5+
import {View} from 'react-native';
56
const {Header, Body, Card, Footer} = Layout;
67

78
export interface LoginPageProps extends ComProps {}
@@ -16,7 +17,7 @@ export default class LoginPageView extends Component<LoginPageProps> {
1617
<Layout>
1718
<Header title={title} description={description} />
1819
<Body>
19-
<LoginPage showPassword={true} />
20+
<LoginPage />
2021
</Body>
2122
<Footer />
2223
</Layout>
Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,21 @@
1-
MaskLayer 遮罩层
1+
LoginPage 登录页
22
---
33

4-
用于模态对话框,中的遮罩层。
5-
6-
<!-- ![](https://user-images.githubusercontent.com/66067296/139398306-d038225d-0fee-4009-a4f7-a06c7beabf45.gif) -->
7-
<!--rehype:style=zoom: 33%;float: right; margin-left: 15px;-->
8-
4+
用于项目的登录页面
95
### 基础示例
106

117
<!--DemoStart-->
128
```jsx mdx:preview&background=#bebebe29
13-
import React, { Fragment, useState } from 'react';
14-
import { Text, SafeAreaView } from 'react-native';
15-
import { Button, MaskLayer,Grid,Icon } from '@uiw/react-native';
9+
import React,{Fragment} from 'react';
10+
import { View} from 'react-native';
11+
import { LoginPage } from '@uiw/react-native';
1612

1713
const Demo = () => {
18-
const [visible, setVisible] = useState(false);
19-
const data = Array.from(new Array(24)).map((_val, i) => {
20-
return { icon: <Icon name="heart-on" color="red" />, text: `${i}`}
21-
});
2214
return (
2315
<Fragment>
24-
<MaskLayer
25-
visible={visible}
26-
onDismiss={() => {
27-
setVisible(!visible);
28-
}}>
29-
<SafeAreaView style={{alignItems:'center'}}>
30-
<Grid style={{width:500,heigth:500,}} data={data} columns='6' hasLine={false}/>
31-
</SafeAreaView>
32-
</MaskLayer>
33-
<Button
34-
onPress={() => {
35-
setVisible(true);
36-
}}>
37-
{visible ? '隐藏模态框' : '显示模态框'}
38-
</Button>
16+
<View>
17+
<LoginPage />
18+
</View>
3919
</Fragment>
4020
);
4121
}
@@ -45,14 +25,15 @@ export default Demo
4525

4626
### Props
4727

48-
继承原生 Modal 属性 [`ModalProps`](https://facebook.github.io/react-native/docs/modal.html#props)
49-
5028
| 参数 | 说明 | 类型 | 默认值 |
5129
|------|------|-----|------|
52-
| `maskClosable` | 遮罩层是否禁止点击 | `Boolean` | `true` |
53-
| `visible` | 遮罩层是否隐藏 |`Boolean` | - |
54-
| `opacity` | 遮罩层透明度 | - | 0.6 |
55-
| `onDismiss` | 隐藏消除回调事件 | () => void | - |
56-
| `children` | 子元素 | JSX.Element | |
30+
| `usernamePlaceholder` | 自定义账号输入框为空时显示的文字 | `string` | - |
31+
| `inputContainerStyle` | 自定义账号,密码,验证码输入框样式 |`Boolean` | - |
32+
| `buttonStyle` | 登录按钮自定义样式 | `Object` | - |
33+
| `containerStyle` | 登录页自定义最外层样式 | `object` | - |
34+
| `buttonText` | 登录按钮自定义文字 | `string` | - |
35+
| `customContent` | 自定义忘记密码,切换登录方式 | `React.ReactNode` | - |
36+
| `onLogin` | 登录按钮事件 | `(username: string, password: string) => void` | - |
37+
| `onForgetPassword` | 忘记密码按钮事件 | `() => void` | - |
5738

5839

packages/core/src/LoginPage/index.tsx

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,38 @@ import { useTheme } from '@shopify/restyle';
77
import { logSvg, cEyes, oEyes } from './svg';
88

99
interface LoginPageProps {
10-
showPassword?: boolean;
10+
/** 自定义账号输入框为空时显示的文字 */
1111
usernamePlaceholder?: string;
12+
/** 自定义账号,密码,验证码输入框样式 */
1213
inputContainerStyle?: object;
14+
/** 登录按钮自定义样式 */
1315
buttonStyle?: object;
16+
/** 登录页自定义最外层样式 */
1417
containerStyle?: object;
18+
/** 登录按钮自定义文字 */
1519
buttonText?: string;
20+
/** 自定义忘记密码,切换登录方式 */
21+
customContent?: React.ReactNode;
22+
/** 登录按钮事件 */
1623
onLogin?: (username: string, password: string) => void;
24+
/** 忘记密码按钮事件 */
25+
onForgetPassword?: () => void;
1726
}
1827

1928
const LoginPage: React.FC<LoginPageProps> = ({
20-
showPassword = true,
21-
usernamePlaceholder = '请输入用户名',
29+
usernamePlaceholder,
2230
inputContainerStyle = {},
2331
containerStyle = {},
2432
buttonStyle = {},
2533
buttonText = 'Login',
34+
customContent,
2635
onLogin,
36+
onForgetPassword,
2737
}) => {
28-
const [isShowPassword, setIsShowPassword] = useState(false);
38+
const [showPsd, setShowPsd] = useState(false);
39+
const [showCode, setShowCode] = useState(false); // added state
40+
console.log('showCode', showCode);
41+
2942
const theme = useTheme<Theme>();
3043
const styles = createStyles({
3144
border: theme.colors.border || '#CCC',
@@ -57,43 +70,50 @@ const LoginPage: React.FC<LoginPageProps> = ({
5770
<Icon xml={logSvg(theme)} size={30} />
5871
<Text style={styles.title}>Login</Text>
5972
</View>
60-
<View style={[styles.inputContainer, inputContainerStyle]}>
73+
<View style={[styles.inputContainer, { paddingHorizontal: 15 }, inputContainerStyle]}>
6174
<TextInput
62-
placeholder={usernamePlaceholder}
63-
placeholderTextColor={theme.colors.icon}
75+
placeholder={usernamePlaceholder ? usernamePlaceholder : `请输入${showCode ? '手机号码' : '用户名'}`}
76+
placeholderTextColor={theme.colors.border}
6477
style={styles.input}
78+
keyboardType={showCode ? 'numeric' : 'default'}
6579
onChangeText={onChangeUsername}
6680
/>
6781
</View>
68-
{showPassword ? (
69-
<View style={[styles.inputContainers, inputContainerStyle]}>
82+
{!showCode ? (
83+
<View style={[styles.inputContainer, styles.inputC, { paddingHorizontal: 15 }, inputContainerStyle]}>
7084
<TextInput
7185
placeholder="请输入密码"
72-
placeholderTextColor={theme.colors.icon}
73-
secureTextEntry={!isShowPassword}
86+
placeholderTextColor={theme.colors.border}
87+
secureTextEntry={!showPsd}
7488
style={[styles.input, { width: '92%' }]}
7589
onChangeText={onChangePassword}
7690
/>
77-
<TouchableOpacity onPress={() => setIsShowPassword(!isShowPassword)}>
78-
<Icon xml={isShowPassword ? cEyes : oEyes} size={20} />
91+
<TouchableOpacity onPress={() => setShowPsd(!showPsd)}>
92+
<Icon xml={showPsd ? cEyes : oEyes} size={20} />
7993
</TouchableOpacity>
8094
</View>
8195
) : (
8296
<VerificationCode
8397
value={password}
8498
count={60}
8599
onChange={onChangePassword}
86-
outerStyle={[styles.inputContainer, inputContainerStyle]}
100+
outerStyle={[styles.inputContainer, styles.inputC, inputContainerStyle]}
87101
/>
88102
)}
89-
<View style={styles.textSty1}>
90-
<TouchableOpacity>
91-
<Text style={styles.textSty}>忘记密码</Text>
92-
</TouchableOpacity>
93-
<TouchableOpacity>
94-
<Text style={styles.textSty}>验证码登录</Text>
95-
</TouchableOpacity>
103+
104+
<View>
105+
{customContent || (
106+
<View style={styles.textSty1}>
107+
<TouchableOpacity onPress={onForgetPassword}>
108+
<Text style={styles.textSty}>忘记密码</Text>
109+
</TouchableOpacity>
110+
<TouchableOpacity onPress={() => setShowCode(!showCode)}>
111+
<Text style={styles.textSty}>{`${showCode ? '用户名' : '验证码'}登录`}</Text>
112+
</TouchableOpacity>
113+
</View>
114+
)}
96115
</View>
116+
97117
<TouchableOpacity style={[styles.button, buttonStyle]} onPress={handleLogin}>
98118
<Text style={[styles.buttonText, styles.buttonTextStyle]}>{buttonText}</Text>
99119
</TouchableOpacity>
@@ -126,30 +146,22 @@ function createStyles({ border, putCol }: CreStyle) {
126146
title: {
127147
fontSize: 24,
128148
fontWeight: 'bold',
129-
marginLeft: 20,
149+
marginLeft: 15,
130150
color: putCol,
131151
},
132152
inputContainer: {
133153
height: 40,
134-
marginBottom: 20,
135154
borderColor: border,
136155
borderWidth: 1,
137156
borderRadius: 5,
138157
justifyContent: 'center',
139-
paddingHorizontal: 15,
140158
flexDirection: 'row',
141159
alignItems: 'center',
142160
},
143-
inputContainers: {
144-
height: 40,
161+
inputC: {
162+
paddingHorizontal: 10,
163+
marginTop: 20,
145164
marginBottom: 5,
146-
borderColor: border,
147-
borderWidth: 1,
148-
borderRadius: 5,
149-
justifyContent: 'center',
150-
paddingHorizontal: 15,
151-
flexDirection: 'row',
152-
alignItems: 'center',
153165
},
154166
input: {
155167
flex: 1,
@@ -158,6 +170,7 @@ function createStyles({ border, putCol }: CreStyle) {
158170
button: {
159171
backgroundColor: '#1890ff',
160172
height: 40,
173+
marginTop: 5,
161174
borderRadius: 5,
162175
justifyContent: 'center',
163176
alignItems: 'center',
@@ -176,7 +189,6 @@ function createStyles({ border, putCol }: CreStyle) {
176189
flexDirection: 'row',
177190
alignItems: 'center',
178191
justifyContent: 'space-between',
179-
marginBottom: 30,
180192
},
181193
});
182194
}

packages/core/src/VerificationCode/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ const VerificationCode: FC<VerificationCodeProps> = ({
7878
border={null}
7979
containerStyle={[{ height: 40 }, outerStyle]}
8080
placeholder={placeholder}
81+
placeholderTextColor={theme.colors.border}
8182
value={value}
8283
onChangeText={(text) => onChange(text)}
8384
extraEnd={
@@ -86,7 +87,7 @@ const VerificationCode: FC<VerificationCodeProps> = ({
8687
disabled={disabled}
8788
onPress={handleClick}
8889
color={theme.colors.background || '#fff'}
89-
style={buttonStyle}
90+
style={[buttonStyle]}
9091
>
9192
<Text color={disabled ? 'disabled' : 'text'}>{disabled ? `${resendLabel}(${timer}s)` : label}</Text>
9293
</Button>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Preview from 'src/component/Preview';
2+
import md from '@uiw/react-native/lib/LoginPage/README.md';
3+
4+
const DEMO = () => <Preview {...md} path="/packages/core/src/LoginPage/README.md" />;
5+
export default DEMO;

website/src/pages/docs/environment-setup/ios/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ $ yarn install # 安装node依赖
157157
**🚧🚧 如果你要运行 `react-native@0.70.0` or 或更高版本**
158158
[help](https://github.com/facebook/react-native/issues/34608#)
159159
#### 请保证你的ruby版本为2.7.5或更高版本
160-
你可以使用 [ruby](https://github.com/rbenv/rbenv#readme) 来管理你的ruby版本
160+
你可以使用 [rbenv](https://github.com/rbenv/rbenv#readme) 来管理你的ruby版本
161161

162162
```
163163
bundle install

website/src/routes/menus.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const componentMenus: MenuData[] = [
4242
{ path: '/components/timeLine', name: 'Timeline 时间轴' },
4343
{ path: '/components/transitionImage', name: 'TransitionImage 图片过渡' },
4444
{ path: '/components/verificationCode', name: 'VerificationCode 验证码倒计时组件' },
45+
{ path: '/components/loginPage', name: 'LoginPage 登录页组件' },
4546

4647
{ divider: true, name: 'Data Display 信息录入' },
4748
{ path: '/components/checkbox', name: 'CheckBox 复选框' },

website/src/routes/router.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ export const routeData = [
305305
path: '/components/verificationCode',
306306
component: lazy(() => import('../pages/components/verificationCode')),
307307
},
308+
{
309+
path: '/components/loginPage',
310+
component: lazy(() => import('../pages/components/loginPage')),
311+
},
308312
{
309313
path: '/components/actionSheet',
310314
component: lazy(() => import('../pages/components/actionSheet')),

0 commit comments

Comments
 (0)