-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DIA-898): use shared password field for sign-up and login [WIP] (#…
…10904) * feat: use shared password field for sign-up and login * used forwardRef to pass an input ref
- Loading branch information
Showing
3 changed files
with
61 additions
and
99 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/app/Scenes/Onboarding/Auth2/components/PasswordInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Input, useTheme } from "@artsy/palette-mobile" | ||
import { LoginPasswordStepFormValues } from "app/Scenes/Onboarding/Auth2/scenes/LoginPasswordStep" | ||
import { SignUpPasswordStepFormValues } from "app/Scenes/Onboarding/Auth2/scenes/SignUpPasswordStep" | ||
import { FormikContextType, useFormikContext } from "formik" | ||
import { forwardRef } from "react" | ||
|
||
export const PasswordInput = forwardRef<Input>((_props, ref) => { | ||
const { | ||
dirty, | ||
errors, | ||
handleChange, | ||
handleSubmit, | ||
validateForm, | ||
values, | ||
}: FormikContextType<LoginPasswordStepFormValues | SignUpPasswordStepFormValues> = | ||
useFormikContext<LoginPasswordStepFormValues | SignUpPasswordStepFormValues>() | ||
|
||
const { color } = useTheme() | ||
|
||
return ( | ||
<Input | ||
autoCapitalize="none" | ||
autoComplete="password" | ||
autoCorrect={false} | ||
blurOnSubmit={false} | ||
error={errors.password} | ||
placeholderTextColor={color("black30")} | ||
ref={ref} | ||
returnKeyType="done" | ||
secureTextEntry | ||
// textContentType="oneTimeCode" | ||
// We need to to set textContentType to password here | ||
// enable autofill of login details from the device keychain. | ||
textContentType="password" | ||
testID="password" | ||
title="Password" | ||
value={values.password} | ||
onChangeText={(text) => { | ||
handleChange("password")(text) | ||
}} | ||
onSubmitEditing={() => { | ||
if (dirty && !!values.password) { | ||
handleSubmit() | ||
} | ||
}} | ||
onBlur={validateForm} | ||
/> | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters