diff --git a/native/account/log-in-panel.react.js b/native/account/log-in-panel.react.js --- a/native/account/log-in-panel.react.js +++ b/native/account/log-in-panel.react.js @@ -60,8 +60,8 @@ +passwordInputText: ?string, }; type BaseProps = { - +setActiveAlert: (activeAlert: boolean) => void, - +opacityStyle: ViewStyle, + +setActiveAlert?: (activeAlert: boolean) => void, + +opacityStyle?: ViewStyle, +logInState: StateContainer, }; type Props = { @@ -230,7 +230,7 @@ }; onSubmit: () => Promise = async () => { - this.props.setActiveAlert(true); + this.props.setActiveAlert?.(true); if (this.usernameInputText.search(validEmailRegex) > -1) { Alert.alert( 'Can’t log in with email', @@ -288,7 +288,7 @@ password: this.passwordInputText, authActionSource: logInActionSources.logInFromNativeForm, }); - this.props.setActiveAlert(false); + this.props.setActiveAlert?.(false); await setNativeCredentials({ username: result.currentUserInfo.username, password: this.passwordInputText, @@ -331,7 +331,7 @@ this.usernameInputText, this.passwordInputText, ); - this.props.setActiveAlert(false); + this.props.setActiveAlert?.(false); await setNativeCredentials({ username: this.usernameInputText, password: this.passwordInputText, @@ -373,7 +373,7 @@ } onUnsuccessfulLoginAlertAckowledged: () => void = () => { - this.props.setActiveAlert(false); + this.props.setActiveAlert?.(false); this.props.logInState.setState( { usernameInputText: '', @@ -384,7 +384,7 @@ }; onUsernameAlertAcknowledged: () => void = () => { - this.props.setActiveAlert(false); + this.props.setActiveAlert?.(false); this.props.logInState.setState( { usernameInputText: '', @@ -394,7 +394,7 @@ }; onPasswordAlertAcknowledged: () => void = () => { - this.props.setActiveAlert(false); + this.props.setActiveAlert?.(false); this.props.logInState.setState( { passwordInputText: '', @@ -404,7 +404,7 @@ }; onOtherErrorAlertAcknowledged: () => void = () => { - this.props.setActiveAlert(false); + this.props.setActiveAlert?.(false); }; } diff --git a/native/account/panel-components.react.js b/native/account/panel-components.react.js --- a/native/account/panel-components.react.js +++ b/native/account/panel-components.react.js @@ -58,7 +58,7 @@ } type PanelProps = { - +opacityStyle: ViewStyle, + +opacityStyle: ?ViewStyle, +children: React.Node, +style?: ViewStyle, }; diff --git a/native/account/restore-password-account-screen.react.js b/native/account/restore-password-account-screen.react.js new file mode 100644 --- /dev/null +++ b/native/account/restore-password-account-screen.react.js @@ -0,0 +1,55 @@ +// @flow + +import * as React from 'react'; +import { Text } from 'react-native'; + +import type { LogInState } from './log-in-panel.react'; +import LogInPanel from './log-in-panel.react.js'; +import RegistrationContainer from './registration/registration-container.react.js'; +import RegistrationContentContainer from './registration/registration-content-container.react.js'; +import type { SignInNavigationProp } from './sign-in-navigator.react.js'; +import type { NavigationRoute } from '../navigation/route-names.js'; +import { useStyles } from '../themes/colors.js'; + +type Props = { + +navigation: SignInNavigationProp<'RestorePasswordAccountScreen'>, + +route: NavigationRoute<'RestorePasswordAccountScreen'>, +}; + +const initialLogInState = { + usernameInputText: null, + passwordInputText: null, +}; + +// eslint-disable-next-line no-unused-vars +function RestorePasswordAccountScreen(props: Props): React.Node { + const [logInState, setLogInState] = + React.useState(initialLogInState); + const logInStateContainer = React.useMemo( + () => ({ + state: logInState, + setState: setLogInState, + }), + [logInState, setLogInState], + ); + + const styles = useStyles(unboundStyles); + return ( + + + Restore with password + + + + ); +} + +const unboundStyles = { + header: { + fontSize: 24, + color: 'panelForegroundLabel', + paddingBottom: 16, + }, +}; + +export default RestorePasswordAccountScreen; diff --git a/native/account/restore-prompt-screen.react.js b/native/account/restore-prompt-screen.react.js --- a/native/account/restore-prompt-screen.react.js +++ b/native/account/restore-prompt-screen.react.js @@ -9,6 +9,7 @@ import RegistrationContentContainer from './registration/registration-content-container.react.js'; import type { SignInNavigationProp } from './sign-in-navigator.react'; import type { NavigationRoute } from '../navigation/route-names'; +import { RestorePasswordAccountScreenRouteName } from '../navigation/route-names.js'; import { useStyles } from '../themes/colors.js'; type Props = { @@ -16,10 +17,13 @@ +route: NavigationRoute<'RestorePromptScreen'>, }; -// eslint-disable-next-line no-unused-vars function RestorePromptScreen(props: Props): React.Node { const styles = useStyles(unboundStyles); + const openPasswordRestoreScreen = React.useCallback(() => { + props.navigation.navigate(RestorePasswordAccountScreenRouteName); + }, [props.navigation]); + return ( @@ -42,7 +46,7 @@ {}} + onPress={openPasswordRestoreScreen} variant="regular" /> diff --git a/native/account/sign-in-navigator.react.js b/native/account/sign-in-navigator.react.js --- a/native/account/sign-in-navigator.react.js +++ b/native/account/sign-in-navigator.react.js @@ -9,6 +9,7 @@ import { SafeAreaView } from 'react-native-safe-area-context'; import QRCodeScreen from './qr-code-screen.react.js'; +import RestorePasswordAccountScreen from './restore-password-account-screen.react.js'; import RestorePromptScreen from './restore-prompt-screen.react.js'; import type { RootNavigationProp } from '../navigation/root-navigator.react.js'; import { @@ -16,6 +17,7 @@ type SignInParamList, QRCodeScreenRouteName, RestorePromptScreenRouteName, + RestorePasswordAccountScreenRouteName, } from '../navigation/route-names.js'; import { useStyles, useColors } from '../themes/colors.js'; @@ -64,6 +66,10 @@ name={RestorePromptScreenRouteName} component={RestorePromptScreen} /> + ); diff --git a/native/navigation/route-names.js b/native/navigation/route-names.js --- a/native/navigation/route-names.js +++ b/native/navigation/route-names.js @@ -152,6 +152,8 @@ export const SignInNavigatorRouteName = 'SignInNavigator'; export const QRCodeScreenRouteName = 'QRCodeScreen'; export const RestorePromptScreenRouteName = 'RestorePromptScreen'; +export const RestorePasswordAccountScreenRouteName = + 'RestorePasswordAccountScreen'; export const UserProfileBottomSheetNavigatorRouteName = 'UserProfileBottomSheetNavigator'; export const UserProfileBottomSheetRouteName = 'UserProfileBottomSheet'; @@ -337,6 +339,7 @@ export type SignInParamList = { +QRCodeScreen: void, +RestorePromptScreen: void, + +RestorePasswordAccountScreen: void, }; export type UserProfileBottomSheetParamList = {