diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-03-20 23:29:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-20 23:29:24 +0000 |
commit | c649ee1afa80f71f108187df5671ae85eeaeed99 (patch) | |
tree | adb5227f58811d0fe4af023184f9ffd71f66f463 /src/components/forms/DateField/index.android.tsx | |
parent | 8ad813cd86c74a987cb81f5278c2eabbe8193db8 (diff) | |
parent | d2d4d3a09206b52fe78018b89f82471c3dd91c8a (diff) | |
download | voidsky-c649ee1afa80f71f108187df5671ae85eeaeed99.tar.zst |
Merge pull request #3217 from bluesky-social/samuel/alf-login
Use ALF for login & signup flow
Diffstat (limited to 'src/components/forms/DateField/index.android.tsx')
-rw-r--r-- | src/components/forms/DateField/index.android.tsx | 83 |
1 files changed, 23 insertions, 60 deletions
diff --git a/src/components/forms/DateField/index.android.tsx b/src/components/forms/DateField/index.android.tsx index 451810a5e..700d15e6d 100644 --- a/src/components/forms/DateField/index.android.tsx +++ b/src/components/forms/DateField/index.android.tsx @@ -1,19 +1,11 @@ import React from 'react' -import {View, Pressable} from 'react-native' - -import {useTheme, atoms} from '#/alf' -import {Text} from '#/components/Typography' -import {useInteractionState} from '#/components/hooks/useInteractionState' -import * as TextField from '#/components/forms/TextField' -import {CalendarDays_Stroke2_Corner0_Rounded as CalendarDays} from '#/components/icons/CalendarDays' +import DatePicker from 'react-native-date-picker' +import {useTheme} from '#/alf' import {DateFieldProps} from '#/components/forms/DateField/types' -import { - localizeDate, - toSimpleDateString, -} from '#/components/forms/DateField/utils' -import DatePicker from 'react-native-date-picker' -import {isAndroid} from 'platform/detection' +import {toSimpleDateString} from '#/components/forms/DateField/utils' +import * as TextField from '#/components/forms/TextField' +import {DateFieldButton} from './index.shared' export * as utils from '#/components/forms/DateField/utils' export const Label = TextField.Label @@ -24,18 +16,10 @@ export function DateField({ label, isInvalid, testID, + accessibilityHint, }: DateFieldProps) { const t = useTheme() const [open, setOpen] = React.useState(false) - const { - state: pressed, - onIn: onPressIn, - onOut: onPressOut, - } = useInteractionState() - const {state: focused, onIn: onFocus, onOut: onBlur} = useInteractionState() - - const {chromeFocus, chromeError, chromeErrorHover} = - TextField.useSharedInputStyles() const onChangeInternal = React.useCallback( (date: Date) => { @@ -47,50 +31,29 @@ export function DateField({ [onChangeDate, setOpen], ) + const onPress = React.useCallback(() => { + setOpen(true) + }, []) + const onCancel = React.useCallback(() => { setOpen(false) }, []) return ( - <View style={[atoms.relative, atoms.w_full]}> - <Pressable - aria-label={label} - accessibilityLabel={label} - accessibilityHint={undefined} - onPress={() => setOpen(true)} - onPressIn={onPressIn} - onPressOut={onPressOut} - onFocus={onFocus} - onBlur={onBlur} - style={[ - { - paddingTop: 16, - paddingBottom: 16, - borderColor: 'transparent', - borderWidth: 2, - }, - atoms.flex_row, - atoms.flex_1, - atoms.w_full, - atoms.px_lg, - atoms.rounded_sm, - t.atoms.bg_contrast_50, - focused || pressed ? chromeFocus : {}, - isInvalid ? chromeError : {}, - isInvalid && (focused || pressed) ? chromeErrorHover : {}, - ]}> - <TextField.Icon icon={CalendarDays} /> - - <Text - style={[atoms.text_md, atoms.pl_xs, t.atoms.text, {paddingTop: 3}]}> - {localizeDate(value)} - </Text> - </Pressable> + <> + <DateFieldButton + label={label} + value={value} + onPress={onPress} + isInvalid={isInvalid} + accessibilityHint={accessibilityHint} + /> {open && ( <DatePicker - modal={isAndroid} - open={isAndroid} + modal + open + timeZoneOffsetInMinutes={0} theme={t.name === 'light' ? 'light' : 'dark'} date={new Date(value)} onConfirm={onChangeInternal} @@ -99,9 +62,9 @@ export function DateField({ testID={`${testID}-datepicker`} aria-label={label} accessibilityLabel={label} - accessibilityHint={undefined} + accessibilityHint={accessibilityHint} /> )} - </View> + </> ) } |