({ navigation }: RootStackScreenProps<Route.Login>)
| 14 | import { styles } from './Login.styles'; |
| 15 | |
| 16 | export const Login = ({ navigation }: RootStackScreenProps<Route.Login>) => { |
| 17 | const { apiKey, setApiKey, userId, setUserId, initialize, loginInProgress } = |
| 18 | useIterableApp(); |
| 19 | const loginIsEnabled = useMemo(() => apiKey && userId, [apiKey, userId]); |
| 20 | |
| 21 | return ( |
| 22 | <SafeAreaView style={styles.loginScreenContainer}> |
| 23 | {loginInProgress ? ( |
| 24 | <View style={styles.loadingContainer}> |
| 25 | <ActivityIndicator size="large" color={colors.brandPurple} /> |
| 26 | </View> |
| 27 | ) : ( |
| 28 | <> |
| 29 | <Text style={styles.appName}>Iterable</Text> |
| 30 | <Text style={styles.title}>Sign in to continue</Text> |
| 31 | <Text style={styles.subtitle}> |
| 32 | Example app for React Native developers |
| 33 | </Text> |
| 34 | <View style={styles.formContainer}> |
| 35 | <Text style={styles.label}>API key</Text> |
| 36 | <TextInput |
| 37 | style={styles.input} |
| 38 | onChangeText={setApiKey} |
| 39 | value={apiKey} |
| 40 | placeholder="eg: 1234567890abcdefg1234567890hijkl" |
| 41 | autoCapitalize="none" |
| 42 | autoCorrect={false} |
| 43 | /> |
| 44 | <Text style={styles.label}>Email address or User Id</Text> |
| 45 | <TextInput |
| 46 | style={styles.input} |
| 47 | onChangeText={setUserId} |
| 48 | value={userId ?? ''} |
| 49 | placeholder="eg: my.name@gmail.com or 1234567890" |
| 50 | autoCapitalize="none" |
| 51 | autoCorrect={false} |
| 52 | autoComplete="email" |
| 53 | /> |
| 54 | <Pressable |
| 55 | style={loginIsEnabled ? styles.button : styles.buttonDisabled} |
| 56 | disabled={!loginIsEnabled} |
| 57 | onPressOut={() => initialize(navigation)} |
| 58 | > |
| 59 | <Text |
| 60 | style={ |
| 61 | loginIsEnabled ? styles.buttonText : styles.buttonTextDisabled |
| 62 | } |
| 63 | > |
| 64 | Login |
| 65 | </Text> |
| 66 | </Pressable> |
| 67 | </View> |
| 68 | </> |
| 69 | )} |
| 70 | </SafeAreaView> |
| 71 | ); |
| 72 | }; |
| 73 |
nothing calls this directly
no test coverage detected
searching dependent graphs…