@ha_tecno/live-id-sdk 2.3.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/index.js +0 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/screens/FingerAuth/FingerAuth.js +8 -10
- package/lib/commonjs/screens/FingerAuth/FingerAuth.js.map +1 -1
- package/lib/commonjs/screens/FingerRegister/FingerRegister.js +9 -11
- package/lib/commonjs/screens/FingerRegister/FingerRegister.js.map +1 -1
- package/lib/commonjs/screens/LifeCertificate/LifeCertificate.js +3 -7
- package/lib/commonjs/screens/LifeCertificate/LifeCertificate.js.map +1 -1
- package/lib/commonjs/utils/hooks/useIsForeground.js +23 -0
- package/lib/commonjs/utils/hooks/useIsForeground.js.map +1 -0
- package/lib/commonjs/utils/index.js +7 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/index.js +0 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/screens/FingerAuth/FingerAuth.js +8 -10
- package/lib/module/screens/FingerAuth/FingerAuth.js.map +1 -1
- package/lib/module/screens/FingerRegister/FingerRegister.js +9 -11
- package/lib/module/screens/FingerRegister/FingerRegister.js.map +1 -1
- package/lib/module/screens/LifeCertificate/LifeCertificate.js +3 -7
- package/lib/module/screens/LifeCertificate/LifeCertificate.js.map +1 -1
- package/lib/module/utils/hooks/useIsForeground.js +16 -0
- package/lib/module/utils/hooks/useIsForeground.js.map +1 -0
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/screens/FingerAuth/FingerAuth.d.ts +1 -2
- package/lib/typescript/src/screens/FingerAuth/FingerAuth.d.ts.map +1 -1
- package/lib/typescript/src/screens/FingerRegister/FingerRegister.d.ts +1 -2
- package/lib/typescript/src/screens/FingerRegister/FingerRegister.d.ts.map +1 -1
- package/lib/typescript/src/screens/LifeCertificate/LifeCertificate.d.ts.map +1 -1
- package/lib/typescript/src/utils/hooks/useIsForeground.d.ts +2 -0
- package/lib/typescript/src/utils/hooks/useIsForeground.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +2 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +0 -4
- package/src/screens/FingerAuth/FingerAuth.tsx +8 -10
- package/src/screens/FingerRegister/FingerRegister.tsx +9 -11
- package/src/screens/LifeCertificate/LifeCertificate.tsx +2 -6
- package/src/utils/hooks/useIsForeground.ts +18 -0
- package/src/utils/index.ts +2 -1
- package/lib/commonjs/screens/CadastroScreen/CadastroScreen.js +0 -186
- package/lib/commonjs/screens/CadastroScreen/CadastroScreen.js.map +0 -1
- package/lib/module/screens/CadastroScreen/CadastroScreen.js +0 -177
- package/lib/module/screens/CadastroScreen/CadastroScreen.js.map +0 -1
- package/lib/typescript/src/screens/CadastroScreen/CadastroScreen.d.ts +0 -12
- package/lib/typescript/src/screens/CadastroScreen/CadastroScreen.d.ts.map +0 -1
- package/src/screens/CadastroScreen/CadastroScreen.tsx +0 -195
@@ -1,177 +0,0 @@
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
-
/* eslint-disable react-native/no-inline-styles */
|
3
|
-
import React, { useEffect, useState } from "react";
|
4
|
-
import { View, Text, TextInput, TouchableOpacity, StyleSheet, Alert, Image } from "react-native";
|
5
|
-
import { cadastro } from "../../services";
|
6
|
-
import Modal from "react-native-modal";
|
7
|
-
export const CadastroScreen = ({
|
8
|
-
isVisible = false,
|
9
|
-
onCloseModal,
|
10
|
-
onError,
|
11
|
-
onSuccess,
|
12
|
-
ModalParams
|
13
|
-
}) => {
|
14
|
-
const [cpf, setCpf] = useState("");
|
15
|
-
const [nome, setNome] = useState("");
|
16
|
-
const [senha, setSenha] = useState("");
|
17
|
-
const [confirmarSenha, setConfirmarSenha] = useState("");
|
18
|
-
const generateRandomElevenDigits = () => {
|
19
|
-
let cpf = "";
|
20
|
-
for (let i = 0; i < 11; i++) {
|
21
|
-
cpf += Math.floor(Math.random() * 9);
|
22
|
-
}
|
23
|
-
return cpf;
|
24
|
-
};
|
25
|
-
const generateRandomName = () => {
|
26
|
-
// uma strin aleatória de 10 caracteres a 14 caracteres
|
27
|
-
let name = "";
|
28
|
-
const length = Math.floor(Math.random() * 5) + 10;
|
29
|
-
for (let i = 0; i < length; i++) {
|
30
|
-
name += String.fromCharCode(Math.floor(Math.random() * 26) + 97);
|
31
|
-
}
|
32
|
-
return name;
|
33
|
-
};
|
34
|
-
useEffect(() => {
|
35
|
-
generateRnadomUser();
|
36
|
-
}, []);
|
37
|
-
const generateRnadomUser = () => {
|
38
|
-
setCpf(generateRandomElevenDigits());
|
39
|
-
setNome(generateRandomName());
|
40
|
-
setSenha("123");
|
41
|
-
setConfirmarSenha("123");
|
42
|
-
};
|
43
|
-
const handleCadastro = async () => {
|
44
|
-
try {
|
45
|
-
if (senha === confirmarSenha) {
|
46
|
-
const response = await cadastro(cpf, nome, senha);
|
47
|
-
console.log(response);
|
48
|
-
var jsonString = JSON.stringify(response);
|
49
|
-
onSuccess && onSuccess(response);
|
50
|
-
onCloseModalHandler();
|
51
|
-
if (jsonString.includes("person_id")) {
|
52
|
-
if (response.finger === false) {
|
53
|
-
// openModal({
|
54
|
-
// type: 'ajuda',
|
55
|
-
// screenProps: {
|
56
|
-
// id: response.person_id,
|
57
|
-
// },
|
58
|
-
// });
|
59
|
-
} else {
|
60
|
-
// openModal({
|
61
|
-
// type: 'login',
|
62
|
-
// });
|
63
|
-
}
|
64
|
-
} else if (jsonString.includes("User exists")) {
|
65
|
-
Alert.alert("Usuário já cadastrado!");
|
66
|
-
// openModal({
|
67
|
-
// type: 'login',
|
68
|
-
// });
|
69
|
-
} else if (jsonString.includes("erro")) {
|
70
|
-
Alert.alert("Usuário não cadastrado", "Por favor, cadastre-se!");
|
71
|
-
} else {
|
72
|
-
Alert.alert("Erro", "Ocorreu um erro ao fazer o Cadastro. Por favor, tente novamente mais tarde.");
|
73
|
-
}
|
74
|
-
} else {
|
75
|
-
Alert.alert("Erro", "As senhas não coincidem. Por favor, tente novamente.");
|
76
|
-
return;
|
77
|
-
}
|
78
|
-
} catch (error) {
|
79
|
-
onError && onError(error);
|
80
|
-
console.error(error);
|
81
|
-
}
|
82
|
-
};
|
83
|
-
const onCloseModalHandler = () => {
|
84
|
-
onCloseModal && onCloseModal();
|
85
|
-
generateRnadomUser();
|
86
|
-
};
|
87
|
-
return /*#__PURE__*/React.createElement(Modal, _extends({
|
88
|
-
style: {
|
89
|
-
margin: 0
|
90
|
-
},
|
91
|
-
isVisible: isVisible,
|
92
|
-
swipeDirection: "down",
|
93
|
-
propagateSwipe: true,
|
94
|
-
onSwipeComplete: onCloseModalHandler
|
95
|
-
}, ModalParams), /*#__PURE__*/React.createElement(View, {
|
96
|
-
style: styles.container
|
97
|
-
}, /*#__PURE__*/React.createElement(Image, {
|
98
|
-
source: require("../../assets/logo.png"),
|
99
|
-
style: styles.logo
|
100
|
-
}), /*#__PURE__*/React.createElement(Text, {
|
101
|
-
style: styles.title
|
102
|
-
}, "Cadastro de usu\xE1rio"), /*#__PURE__*/React.createElement(TextInput, {
|
103
|
-
style: styles.input,
|
104
|
-
placeholder: "CPF",
|
105
|
-
placeholderTextColor: "#000",
|
106
|
-
keyboardType: "numeric",
|
107
|
-
value: cpf,
|
108
|
-
onChangeText: setCpf
|
109
|
-
}), /*#__PURE__*/React.createElement(TextInput, {
|
110
|
-
style: styles.input,
|
111
|
-
placeholder: "Nome",
|
112
|
-
placeholderTextColor: "#000",
|
113
|
-
value: nome,
|
114
|
-
onChangeText: setNome
|
115
|
-
}), /*#__PURE__*/React.createElement(TextInput, {
|
116
|
-
style: styles.input,
|
117
|
-
placeholder: "Digite a senha",
|
118
|
-
placeholderTextColor: "#000",
|
119
|
-
secureTextEntry: true,
|
120
|
-
value: senha,
|
121
|
-
onChangeText: text => setSenha(text)
|
122
|
-
}), /*#__PURE__*/React.createElement(TextInput, {
|
123
|
-
style: styles.input,
|
124
|
-
placeholderTextColor: "#000",
|
125
|
-
placeholder: "Digite a senha novamente",
|
126
|
-
secureTextEntry: true,
|
127
|
-
value: confirmarSenha,
|
128
|
-
onChangeText: text => setConfirmarSenha(text)
|
129
|
-
}), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
130
|
-
style: styles.button,
|
131
|
-
onPress: handleCadastro
|
132
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
133
|
-
style: styles.buttonText
|
134
|
-
}, "Cadastrar"))));
|
135
|
-
};
|
136
|
-
const styles = StyleSheet.create({
|
137
|
-
container: {
|
138
|
-
flex: 1,
|
139
|
-
alignItems: "center",
|
140
|
-
justifyContent: "center",
|
141
|
-
backgroundColor: "#fff"
|
142
|
-
},
|
143
|
-
title: {
|
144
|
-
fontSize: 24,
|
145
|
-
marginBottom: 16,
|
146
|
-
color: "#00bfff"
|
147
|
-
},
|
148
|
-
input: {
|
149
|
-
width: "80%",
|
150
|
-
height: 50,
|
151
|
-
padding: 10,
|
152
|
-
borderWidth: 1,
|
153
|
-
borderColor: "#ccc",
|
154
|
-
borderRadius: 4,
|
155
|
-
marginBottom: 16,
|
156
|
-
fontSize: 16,
|
157
|
-
color: "#000"
|
158
|
-
},
|
159
|
-
button: {
|
160
|
-
width: "80%",
|
161
|
-
height: 50,
|
162
|
-
backgroundColor: "#00bfff",
|
163
|
-
borderRadius: 4,
|
164
|
-
alignItems: "center",
|
165
|
-
justifyContent: "center"
|
166
|
-
},
|
167
|
-
buttonText: {
|
168
|
-
fontSize: 16,
|
169
|
-
color: "#fff"
|
170
|
-
},
|
171
|
-
logo: {
|
172
|
-
width: 500,
|
173
|
-
height: 250,
|
174
|
-
resizeMode: "contain"
|
175
|
-
}
|
176
|
-
});
|
177
|
-
//# sourceMappingURL=CadastroScreen.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["React","useEffect","useState","View","Text","TextInput","TouchableOpacity","StyleSheet","Alert","Image","cadastro","Modal","CadastroScreen","isVisible","onCloseModal","onError","onSuccess","ModalParams","cpf","setCpf","nome","setNome","senha","setSenha","confirmarSenha","setConfirmarSenha","generateRandomElevenDigits","i","Math","floor","random","generateRandomName","name","length","String","fromCharCode","generateRnadomUser","handleCadastro","response","console","log","jsonString","JSON","stringify","onCloseModalHandler","includes","finger","alert","error","createElement","_extends","style","margin","swipeDirection","propagateSwipe","onSwipeComplete","styles","container","source","require","logo","title","input","placeholder","placeholderTextColor","keyboardType","value","onChangeText","secureTextEntry","text","button","onPress","buttonText","create","flex","alignItems","justifyContent","backgroundColor","fontSize","marginBottom","color","width","height","padding","borderWidth","borderColor","borderRadius","resizeMode"],"sourceRoot":"../../../../src","sources":["screens/CadastroScreen/CadastroScreen.tsx"],"mappings":";AAAA;AACA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,IAAI,EAAEC,IAAI,EAAEC,SAAS,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,KAAK,EAAEC,KAAK,QAAQ,cAAc;AAChG,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,KAAK,MAA2B,oBAAoB;AAU3D,OAAO,MAAMC,cAA6C,GAAGA,CAAC;EAC5DC,SAAS,GAAG,KAAK;EACjBC,YAAY;EACZC,OAAO;EACPC,SAAS;EACTC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,GAAG,EAAEC,MAAM,CAAC,GAAGjB,QAAQ,CAAC,EAAE,CAAC;EAClC,MAAM,CAACkB,IAAI,EAAEC,OAAO,CAAC,GAAGnB,QAAQ,CAAC,EAAE,CAAC;EACpC,MAAM,CAACoB,KAAK,EAAEC,QAAQ,CAAC,GAAGrB,QAAQ,CAAC,EAAE,CAAC;EACtC,MAAM,CAACsB,cA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G;IACVC,MAAM,EAAE,GAAG;IACXK,UAAU,EAAE;EACd;AACF,CAAC,CAAC"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import React from "react";
|
2
|
-
import { type ModalProps } from "react-native-modal";
|
3
|
-
interface CadastroScreenProps {
|
4
|
-
isVisible: boolean;
|
5
|
-
onCloseModal?: () => void;
|
6
|
-
onError?: (response?: any) => void;
|
7
|
-
onSuccess?: (response?: any) => void;
|
8
|
-
ModalParams?: ModalProps;
|
9
|
-
}
|
10
|
-
export declare const CadastroScreen: React.FC<CadastroScreenProps>;
|
11
|
-
export {};
|
12
|
-
//# sourceMappingURL=CadastroScreen.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"CadastroScreen.d.ts","sourceRoot":"","sources":["../../../../../src/screens/CadastroScreen/CadastroScreen.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAGnD,OAAc,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE5D,UAAU,mBAAmB;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,UAAU,CAAC;CAC1B;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA0IxD,CAAC"}
|
@@ -1,195 +0,0 @@
|
|
1
|
-
/* eslint-disable react-native/no-inline-styles */
|
2
|
-
import React, { useEffect, useState } from "react";
|
3
|
-
import { View, Text, TextInput, TouchableOpacity, StyleSheet, Alert, Image } from "react-native";
|
4
|
-
import { cadastro } from "../../services";
|
5
|
-
import Modal, { type ModalProps } from "react-native-modal";
|
6
|
-
|
7
|
-
interface CadastroScreenProps {
|
8
|
-
isVisible: boolean;
|
9
|
-
onCloseModal?: () => void;
|
10
|
-
onError?: (response?: any) => void;
|
11
|
-
onSuccess?: (response?: any) => void;
|
12
|
-
ModalParams?: ModalProps;
|
13
|
-
}
|
14
|
-
|
15
|
-
export const CadastroScreen: React.FC<CadastroScreenProps> = ({
|
16
|
-
isVisible = false,
|
17
|
-
onCloseModal,
|
18
|
-
onError,
|
19
|
-
onSuccess,
|
20
|
-
ModalParams
|
21
|
-
}) => {
|
22
|
-
const [cpf, setCpf] = useState("");
|
23
|
-
const [nome, setNome] = useState("");
|
24
|
-
const [senha, setSenha] = useState("");
|
25
|
-
const [confirmarSenha, setConfirmarSenha] = useState("");
|
26
|
-
|
27
|
-
const generateRandomElevenDigits = () => {
|
28
|
-
let cpf = "";
|
29
|
-
for (let i = 0; i < 11; i++) {
|
30
|
-
cpf += Math.floor(Math.random() * 9);
|
31
|
-
}
|
32
|
-
return cpf;
|
33
|
-
};
|
34
|
-
|
35
|
-
const generateRandomName = () => {
|
36
|
-
// uma strin aleatória de 10 caracteres a 14 caracteres
|
37
|
-
let name = "";
|
38
|
-
const length = Math.floor(Math.random() * 5) + 10;
|
39
|
-
for (let i = 0; i < length; i++) {
|
40
|
-
name += String.fromCharCode(Math.floor(Math.random() * 26) + 97);
|
41
|
-
}
|
42
|
-
return name;
|
43
|
-
};
|
44
|
-
|
45
|
-
useEffect(() => {
|
46
|
-
generateRnadomUser();
|
47
|
-
}, []);
|
48
|
-
|
49
|
-
const generateRnadomUser = () => {
|
50
|
-
setCpf(generateRandomElevenDigits());
|
51
|
-
setNome(generateRandomName());
|
52
|
-
setSenha("123");
|
53
|
-
setConfirmarSenha("123");
|
54
|
-
};
|
55
|
-
|
56
|
-
const handleCadastro = async () => {
|
57
|
-
try {
|
58
|
-
if (senha === confirmarSenha) {
|
59
|
-
const response = await cadastro(cpf, nome, senha);
|
60
|
-
|
61
|
-
console.log(response);
|
62
|
-
var jsonString = JSON.stringify(response);
|
63
|
-
onSuccess && onSuccess(response);
|
64
|
-
|
65
|
-
onCloseModalHandler();
|
66
|
-
if (jsonString.includes("person_id")) {
|
67
|
-
if (response.finger === false) {
|
68
|
-
// openModal({
|
69
|
-
// type: 'ajuda',
|
70
|
-
// screenProps: {
|
71
|
-
// id: response.person_id,
|
72
|
-
// },
|
73
|
-
// });
|
74
|
-
} else {
|
75
|
-
// openModal({
|
76
|
-
// type: 'login',
|
77
|
-
// });
|
78
|
-
}
|
79
|
-
} else if (jsonString.includes("User exists")) {
|
80
|
-
Alert.alert("Usuário já cadastrado!");
|
81
|
-
// openModal({
|
82
|
-
// type: 'login',
|
83
|
-
// });
|
84
|
-
} else if (jsonString.includes("erro")) {
|
85
|
-
Alert.alert("Usuário não cadastrado", "Por favor, cadastre-se!");
|
86
|
-
} else {
|
87
|
-
Alert.alert("Erro", "Ocorreu um erro ao fazer o Cadastro. Por favor, tente novamente mais tarde.");
|
88
|
-
}
|
89
|
-
} else {
|
90
|
-
Alert.alert("Erro", "As senhas não coincidem. Por favor, tente novamente.");
|
91
|
-
return;
|
92
|
-
}
|
93
|
-
} catch (error) {
|
94
|
-
onError && onError(error);
|
95
|
-
console.error(error);
|
96
|
-
}
|
97
|
-
};
|
98
|
-
|
99
|
-
const onCloseModalHandler = () => {
|
100
|
-
onCloseModal && onCloseModal();
|
101
|
-
generateRnadomUser();
|
102
|
-
};
|
103
|
-
|
104
|
-
return (
|
105
|
-
<Modal
|
106
|
-
style={{ margin: 0 }}
|
107
|
-
isVisible={isVisible}
|
108
|
-
swipeDirection="down"
|
109
|
-
propagateSwipe={true}
|
110
|
-
onSwipeComplete={onCloseModalHandler}
|
111
|
-
{...ModalParams}
|
112
|
-
>
|
113
|
-
<View style={styles.container}>
|
114
|
-
<Image source={require("../../assets/logo.png")} style={styles.logo} />
|
115
|
-
<Text style={styles.title}>Cadastro de usuário</Text>
|
116
|
-
<TextInput
|
117
|
-
style={styles.input}
|
118
|
-
placeholder="CPF"
|
119
|
-
placeholderTextColor="#000"
|
120
|
-
keyboardType="numeric"
|
121
|
-
value={cpf}
|
122
|
-
onChangeText={setCpf}
|
123
|
-
/>
|
124
|
-
<TextInput
|
125
|
-
style={styles.input}
|
126
|
-
placeholder="Nome"
|
127
|
-
placeholderTextColor="#000"
|
128
|
-
value={nome}
|
129
|
-
onChangeText={setNome}
|
130
|
-
/>
|
131
|
-
<TextInput
|
132
|
-
style={styles.input}
|
133
|
-
placeholder="Digite a senha"
|
134
|
-
placeholderTextColor="#000"
|
135
|
-
secureTextEntry={true}
|
136
|
-
value={senha}
|
137
|
-
onChangeText={(text) => setSenha(text)}
|
138
|
-
/>
|
139
|
-
<TextInput
|
140
|
-
style={styles.input}
|
141
|
-
placeholderTextColor="#000"
|
142
|
-
placeholder="Digite a senha novamente"
|
143
|
-
secureTextEntry={true}
|
144
|
-
value={confirmarSenha}
|
145
|
-
onChangeText={(text) => setConfirmarSenha(text)}
|
146
|
-
/>
|
147
|
-
<TouchableOpacity style={styles.button} onPress={handleCadastro}>
|
148
|
-
<Text style={styles.buttonText}>Cadastrar</Text>
|
149
|
-
</TouchableOpacity>
|
150
|
-
</View>
|
151
|
-
</Modal>
|
152
|
-
);
|
153
|
-
};
|
154
|
-
|
155
|
-
const styles = StyleSheet.create({
|
156
|
-
container: {
|
157
|
-
flex: 1,
|
158
|
-
alignItems: "center",
|
159
|
-
justifyContent: "center",
|
160
|
-
backgroundColor: "#fff"
|
161
|
-
},
|
162
|
-
title: {
|
163
|
-
fontSize: 24,
|
164
|
-
marginBottom: 16,
|
165
|
-
color: "#00bfff"
|
166
|
-
},
|
167
|
-
input: {
|
168
|
-
width: "80%",
|
169
|
-
height: 50,
|
170
|
-
padding: 10,
|
171
|
-
borderWidth: 1,
|
172
|
-
borderColor: "#ccc",
|
173
|
-
borderRadius: 4,
|
174
|
-
marginBottom: 16,
|
175
|
-
fontSize: 16,
|
176
|
-
color: "#000"
|
177
|
-
},
|
178
|
-
button: {
|
179
|
-
width: "80%",
|
180
|
-
height: 50,
|
181
|
-
backgroundColor: "#00bfff",
|
182
|
-
borderRadius: 4,
|
183
|
-
alignItems: "center",
|
184
|
-
justifyContent: "center"
|
185
|
-
},
|
186
|
-
buttonText: {
|
187
|
-
fontSize: 16,
|
188
|
-
color: "#fff"
|
189
|
-
},
|
190
|
-
logo: {
|
191
|
-
width: 500,
|
192
|
-
height: 250,
|
193
|
-
resizeMode: "contain"
|
194
|
-
}
|
195
|
-
});
|