mg-library 1.0.331 → 1.0.332
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blocks.js +95 -1
- package/package.json +1 -1
package/blocks.js
CHANGED
@@ -1,14 +1,108 @@
|
|
1
1
|
import { useCallback, useState } from 'react';
|
2
|
+
import { useSelector } from 'react-redux';
|
3
|
+
import { useForm, Controller } from 'react-hook-form';
|
2
4
|
import { View, ActivityIndicator, Pressable, Image, FlatList } from 'react-native';
|
3
|
-
import { Text, Divider, Button, Popover, Card } from '@ui-kitten/components';
|
5
|
+
import { Text, Divider, Button, Popover, Card, Layout } from '@ui-kitten/components';
|
4
6
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
5
7
|
import * as ImageManipulator from 'expo-image-manipulator';
|
6
8
|
import { Camera } from 'expo-camera';
|
7
9
|
import axios from 'axios';
|
8
10
|
import { uploadFile } from '@uploadcare/upload-client';
|
11
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
9
12
|
|
10
13
|
import './prototypes.js';
|
11
14
|
import * as mgFunctionsLib from './functions.js';
|
15
|
+
import * as mgLoginLib from './login.js';
|
16
|
+
|
17
|
+
export default function MGLogin(props) {
|
18
|
+
|
19
|
+
let server = props.useSelector((state) => state.session.server);
|
20
|
+
let language = props.useSelector((state) => state.session.language);
|
21
|
+
|
22
|
+
const { control, handleSubmit, formState: { errors } } = useForm({
|
23
|
+
defaultValues: { userName: '', password: '' },
|
24
|
+
});
|
25
|
+
|
26
|
+
const insets = useSafeAreaInsets();
|
27
|
+
|
28
|
+
let cardHeader = (
|
29
|
+
<View style={{ flex: 1, flexGrow: 1, flexDirection: 'row' }}>
|
30
|
+
<Text category='h6' style={{ alignSelf: 'center', color: props.theme['color-primary-500'] }}>{mgFunctionsLib.i18nString('credentials', language)}</Text>
|
31
|
+
</View>
|
32
|
+
);
|
33
|
+
|
34
|
+
const loginIcon = () => (
|
35
|
+
<MaterialCommunityIcons name='logout' color='white' size={20} />
|
36
|
+
);
|
37
|
+
|
38
|
+
let cardFooter = (
|
39
|
+
<View>
|
40
|
+
<Button
|
41
|
+
accessoryRight={loginIcon}
|
42
|
+
onPress={handleSubmit((data) => {
|
43
|
+
props.setNavigator(undefined);
|
44
|
+
mgLoginLib.onPressLogin(
|
45
|
+
props.dispatch,
|
46
|
+
props.actions,
|
47
|
+
server,
|
48
|
+
props.app,
|
49
|
+
props.apiUrl,
|
50
|
+
language,
|
51
|
+
data);
|
52
|
+
})}>
|
53
|
+
{mgFunctionsLib.i18nString('login', language)}
|
54
|
+
</Button>
|
55
|
+
</View>
|
56
|
+
);
|
57
|
+
|
58
|
+
return (
|
59
|
+
<View style={{ flex: 1 }}>
|
60
|
+
<Layout style={[mgFunctionsLib.safeAreaViewStyleSheet(insets).safeAreaView, { display: 'flex', flexDirection: 'column', flexGrow: 1 }]}>
|
61
|
+
<View style={{ flexDirection: 'column', flexGrow: 1, justifyContent: 'center' }}>
|
62
|
+
<View style={{ flexDirection: 'column', alignItems: 'center', marginBottom: 100 }}>
|
63
|
+
<Image
|
64
|
+
source={require('./assets/clubonline.png')}
|
65
|
+
style={{ width: 300, height: 150 }} />
|
66
|
+
<Text category='h6'>{mgFunctionsLib.i18nString('appDescription', language)}</Text>
|
67
|
+
<Text category='p2'>{props.appVersion}</Text>
|
68
|
+
</View>
|
69
|
+
<View>
|
70
|
+
<Card style={{ flexDirection: 'column', justifyContent: 'center', alignContent: 'center', marginLeft: 30, marginRight: 30 }}
|
71
|
+
header={cardHeader}
|
72
|
+
footer={cardFooter}>
|
73
|
+
<Controller
|
74
|
+
control={control}
|
75
|
+
rules={{ maxLength: 50 }}
|
76
|
+
render={({ field: { onChange, value } }) => (
|
77
|
+
<Input
|
78
|
+
size='large'
|
79
|
+
placeholder={mgFunctionsLib.i18nString('userName', language)}
|
80
|
+
onChangeText={onChange}
|
81
|
+
value={value}
|
82
|
+
/>
|
83
|
+
)}
|
84
|
+
name="userName" />
|
85
|
+
<Controller
|
86
|
+
control={control}
|
87
|
+
rules={{ maxLength: 50 }}
|
88
|
+
render={({ field: { onChange, value } }) => (
|
89
|
+
<Input
|
90
|
+
size='large'
|
91
|
+
placeholder={mgFunctionsLib.i18nString('password', language)}
|
92
|
+
onChangeText={onChange}
|
93
|
+
secureTextEntry={true}
|
94
|
+
value={value}
|
95
|
+
/>
|
96
|
+
)}
|
97
|
+
name="password" />
|
98
|
+
</Card>
|
99
|
+
</View>
|
100
|
+
</View>
|
101
|
+
</Layout>
|
102
|
+
</View>
|
103
|
+
);
|
104
|
+
|
105
|
+
}
|
12
106
|
|
13
107
|
export function MGCurrentAccount(props) {
|
14
108
|
function cardHeader(item) {
|