-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathLogin.tsx
More file actions
74 lines (70 loc) · 2.36 KB
/
Copy pathLogin.tsx
File metadata and controls
74 lines (70 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { useMemo } from 'react';
import {
ActivityIndicator,
Pressable,
Text,
TextInput,
View,
} from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { colors, type Route } from '../../constants';
import { useIterableApp } from '../../hooks';
import type { RootStackScreenProps } from '../../types';
import { styles } from './Login.styles';
export const Login = ({ navigation }: RootStackScreenProps<Route.Login>) => {
const { apiKey, setApiKey, userId, setUserId, initialize, loginInProgress } =
useIterableApp();
const loginIsEnabled = useMemo(() => apiKey && userId, [apiKey, userId]);
return (
<SafeAreaView style={styles.loginScreenContainer}>
{loginInProgress ? (
<View style={styles.loadingContainer}>
<ActivityIndicator size="large" color={colors.brandPurple} />
</View>
) : (
<>
<Text style={styles.appName}>Iterable</Text>
<Text style={styles.title}>Sign in to continue</Text>
<Text style={styles.subtitle}>
Example app for React Native developers
</Text>
<View style={styles.formContainer}>
<Text style={styles.label}>API key</Text>
<TextInput
style={styles.input}
onChangeText={setApiKey}
value={apiKey}
placeholder="eg: 1234567890abcdefg1234567890hijkl"
autoCapitalize="none"
autoCorrect={false}
/>
<Text style={styles.label}>Email address or User Id</Text>
<TextInput
style={styles.input}
onChangeText={setUserId}
value={userId ?? ''}
placeholder="eg: my.name@gmail.com or 1234567890"
autoCapitalize="none"
autoCorrect={false}
autoComplete="email"
/>
<Pressable
style={loginIsEnabled ? styles.button : styles.buttonDisabled}
disabled={!loginIsEnabled}
onPressOut={() => initialize(navigation)}
>
<Text
style={
loginIsEnabled ? styles.buttonText : styles.buttonTextDisabled
}
>
Login
</Text>
</Pressable>
</View>
</>
)}
</SafeAreaView>
);
};
export default Login;