From 972764ffe8d793c06d65fd711458b36e49b25a01 Mon Sep 17 00:00:00 2001 From: krollins-mdb Date: Fri, 29 Sep 2023 21:10:26 -0500 Subject: [PATCH 01/33] Establish component bases --- examples/react-native/v12/TestApp/App.tsx | 2 + .../components/authentication/login/Login.tsx | 119 ++++++++++++++++++ .../authentication/login/LoginWithApiKey.tsx | 44 +++++++ .../authentication/login/LoginWithEmail.tsx | 75 +++++++++++ .../authentication/login/Realm.Wrapper.tsx | 40 ++++++ .../components/utility-components/Button.tsx | 31 +++++ .../v12/TestApp/src/navigation/types.tsx | 9 ++ .../src/screens/AuthenticationScreen.tsx | 71 +++++++++++ 8 files changed, 391 insertions(+) create mode 100644 examples/react-native/v12/TestApp/src/components/authentication/login/Login.tsx create mode 100644 examples/react-native/v12/TestApp/src/components/authentication/login/LoginWithApiKey.tsx create mode 100644 examples/react-native/v12/TestApp/src/components/authentication/login/LoginWithEmail.tsx create mode 100644 examples/react-native/v12/TestApp/src/components/authentication/login/Realm.Wrapper.tsx create mode 100644 examples/react-native/v12/TestApp/src/components/utility-components/Button.tsx create mode 100644 examples/react-native/v12/TestApp/src/screens/AuthenticationScreen.tsx diff --git a/examples/react-native/v12/TestApp/App.tsx b/examples/react-native/v12/TestApp/App.tsx index 73a7c05874..b0b6229330 100644 --- a/examples/react-native/v12/TestApp/App.tsx +++ b/examples/react-native/v12/TestApp/App.tsx @@ -14,6 +14,7 @@ import {CompensatingWriteErrorHandling} from './src/components/errors/Compensati // Screens import {SubscriptionScreen} from './src/screens/SubscriptionScreen'; +import {AuthenticationScreen} from './src/screens/AuthenticationScreen'; // Types import {RootStackParamList} from './src/navigation/types'; @@ -46,6 +47,7 @@ function App(): JSX.Element { name="Errors" component={CompensatingWriteErrorHandling} /> + ); diff --git a/examples/react-native/v12/TestApp/src/components/authentication/login/Login.tsx b/examples/react-native/v12/TestApp/src/components/authentication/login/Login.tsx new file mode 100644 index 0000000000..d83055e3cc --- /dev/null +++ b/examples/react-native/v12/TestApp/src/components/authentication/login/Login.tsx @@ -0,0 +1,119 @@ +import React, {useState} from 'react'; +import { + ActivityIndicator, + View, + Text, + Pressable, + StyleSheet, + ScrollView, +} from 'react-native'; +import {useAuth} from '@realm/react'; + +import {LoginWithApiKey} from './LoginWithApiKey'; +import {LoginWithEmail} from './LoginWithEmail'; + +export const LogIn = () => { + const {logIn, logInWithAnonymous, result} = useAuth(); + + const loginWithbadAuth = () => { + logIn('bad auth'); + }; + + // Log in with a `Realm.Credentials` instance. This allows login with any + // authentication mechanism supported by Realm. + // If this is called when a user is currently logged in, it will switch the user. + // Typically the other methods from `useAuth` would be used. + // If this is rendered in the fallback of the `UserProvider`, + // then it's children will be rendered as soon as this succeeds. + // useEffect(() => logIn(Realm.Credentials.anonymous()), []); + + return ( + + + To get to the rest of the app, you need to log in. + + {result.pending && } + {result.error && } + {result.success && } + + + + + Try these log in methods: + +