Switch date picker libraries (#3126)
* Revert other base PR changes, switch date picker library rm expo-linear-gradient Revert "remove unused packages, switch to `expo-linear-gradient`" This reverts commit20a0ffcfRevert "upgrade expo deps" This reverts commita43dca92ca. Revert other library changes This reverts commit5219f66eRevert "re-add normalize-url" This reverts commit654019c4ba. Revert "add `expo-haptics`" This reverts commitff3a0399b1. Revert "add `expo-clipboard`" This reverts commit440ae91632. Revert "add `expo-file-system`" This reverts commitc0fe0c9453. fix android alf use modal on android migrate to `react-native-date-picker` rm `@reactnativecommunity/datetimepicker` add `react-native-date-picker` add `expo-file-system` add `expo-clipboard` add `expo-haptics` re-add normalize-url rm blur view upgrade expo deps remove unused packages, switch to `expo-linear-gradient` * rm old library * Use UTC for dates --------- Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import React, {useState, useCallback} from 'react'
|
||||
import {StyleProp, StyleSheet, TextStyle, View, ViewStyle} from 'react-native'
|
||||
import DateTimePicker, {
|
||||
DateTimePickerEvent,
|
||||
} from '@react-native-community/datetimepicker'
|
||||
import {
|
||||
FontAwesomeIcon,
|
||||
FontAwesomeIconStyle,
|
||||
@@ -14,6 +11,7 @@ import {TypographyVariant} from 'lib/ThemeContext'
|
||||
import {useTheme} from 'lib/ThemeContext'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
import {getLocales} from 'expo-localization'
|
||||
import DatePicker from 'react-native-date-picker'
|
||||
|
||||
const LOCALE = getLocales()[0]
|
||||
|
||||
@@ -43,11 +41,9 @@ export function DateInput(props: Props) {
|
||||
}, [props.handleAsUTC])
|
||||
|
||||
const onChangeInternal = useCallback(
|
||||
(event: DateTimePickerEvent, date: Date | undefined) => {
|
||||
(date: Date) => {
|
||||
setShow(false)
|
||||
if (date) {
|
||||
props.onChange(date)
|
||||
}
|
||||
props.onChange(date)
|
||||
},
|
||||
[setShow, props],
|
||||
)
|
||||
@@ -56,6 +52,10 @@ export function DateInput(props: Props) {
|
||||
setShow(true)
|
||||
}, [setShow])
|
||||
|
||||
const onCancel = useCallback(() => {
|
||||
setShow(false)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<View>
|
||||
{isAndroid && (
|
||||
@@ -80,15 +80,17 @@ export function DateInput(props: Props) {
|
||||
</Button>
|
||||
)}
|
||||
{(isIOS || show) && (
|
||||
<DateTimePicker
|
||||
testID={props.testID ? `${props.testID}-datepicker` : undefined}
|
||||
<DatePicker
|
||||
timeZoneOffsetInMinutes={0}
|
||||
modal={isAndroid}
|
||||
open={isAndroid}
|
||||
theme={theme.colorScheme}
|
||||
date={props.value}
|
||||
onDateChange={onChangeInternal}
|
||||
onConfirm={onChangeInternal}
|
||||
onCancel={onCancel}
|
||||
mode="date"
|
||||
timeZoneName={props.handleAsUTC ? 'Etc/UTC' : undefined}
|
||||
display="spinner"
|
||||
// @ts-ignore applies in iOS only -prf
|
||||
themeVariant={theme.colorScheme}
|
||||
value={props.value}
|
||||
onChange={onChangeInternal}
|
||||
testID={props.testID ? `${props.testID}-datepicker` : undefined}
|
||||
accessibilityLabel={props.accessibilityLabel}
|
||||
accessibilityHint={props.accessibilityHint}
|
||||
accessibilityLabelledBy={props.accessibilityLabelledBy}
|
||||
|
||||
Reference in New Issue
Block a user