-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
57 additions
and
12 deletions.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
packages/mobile/src/screens/sign-on-screen/components/HandleField.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,46 @@ | ||
import { | ||
pickHandlePageMessages as messages, | ||
useIsWaitingForValidation | ||
} from '@audius/common' | ||
import { useField } from 'formik' | ||
|
||
import { Flex, IconCheck, Text } from '@audius/harmony-native' | ||
import { TextField, type TextFieldProps } from 'app/components/fields' | ||
|
||
export const HandleField = ({ | ||
name = 'handle', | ||
...other | ||
}: Partial<TextFieldProps>) => { | ||
const [{ value: handle }, { error }] = useField(name) | ||
|
||
const { isWaitingForValidation, handleChange } = useIsWaitingForValidation() | ||
|
||
const helperText = | ||
error && error !== 'handle required' && handle | ||
? error | ||
: handle && !isWaitingForValidation | ||
? messages.handleAvailable | ||
: null | ||
|
||
return ( | ||
<Flex gap='s'> | ||
{/* TODO: harmonize this component */} | ||
<TextField | ||
name={name} | ||
label={messages.handle} | ||
noGutter | ||
{...other} | ||
onChangeText={() => { | ||
handleChange() | ||
}} | ||
debouncedValidationMs={1000} | ||
Icon={ | ||
!isWaitingForValidation && handle && !error ? IconCheck : undefined | ||
} | ||
/> | ||
{helperText ? ( | ||
<Text color={error ? 'danger' : 'default'}>{helperText}</Text> | ||
) : undefined} | ||
</Flex> | ||
) | ||
} |
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
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