mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at offline-detection 75 lines 2.0 kB view raw
1import React, {useState, useCallback} from 'react' 2import {StyleProp, StyleSheet, TextStyle, View, ViewStyle} from 'react-native' 3// @ts-ignore types not available -prf 4import {unstable_createElement} from 'react-native-web' 5import {usePalette} from 'lib/hooks/usePalette' 6 7interface Props { 8 testID?: string 9 value: Date 10 onChange: (date: Date) => void 11 buttonType?: string 12 buttonStyle?: StyleProp<ViewStyle> 13 buttonLabelType?: string 14 buttonLabelStyle?: StyleProp<TextStyle> 15 accessibilityLabel: string 16 accessibilityHint: string 17 accessibilityLabelledBy?: string 18} 19 20export function DateInput(props: Props) { 21 const pal = usePalette('default') 22 const [value, setValue] = useState(toDateInputValue(props.value)) 23 24 const onChangeInternal = useCallback( 25 (v: Date) => { 26 if (!v) { 27 return 28 } 29 setValue(toDateInputValue(v)) 30 props.onChange(v) 31 }, 32 [setValue, props], 33 ) 34 35 return ( 36 <View style={[pal.borderDark, styles.container]}> 37 {unstable_createElement('input', { 38 type: 'date', 39 testID: props.testID, 40 value, 41 onChange: (e: any) => onChangeInternal(e.currentTarget.valueAsDate), 42 style: [pal.text, pal.view, pal.border, styles.textInput], 43 placeholderTextColor: pal.colors.textLight, 44 accessibilityLabel: props.accessibilityLabel, 45 accessibilityHint: props.accessibilityHint, 46 accessibilityLabelledBy: props.accessibilityLabelledBy, 47 })} 48 </View> 49 ) 50} 51 52// we need the date in the form yyyy-MM-dd to pass to the input 53function toDateInputValue(d: Date): string { 54 return d.toISOString().split('T')[0] 55} 56 57const styles = StyleSheet.create({ 58 container: { 59 flexDirection: 'row', 60 paddingHorizontal: 4, 61 borderWidth: 1, 62 borderRadius: 10, 63 }, 64 textInput: { 65 flex: 1, 66 width: '100%', 67 paddingVertical: 10, 68 paddingHorizontal: 10, 69 fontSize: 17, 70 letterSpacing: 0.25, 71 fontWeight: '400', 72 borderRadius: 10, 73 borderWidth: 0, 74 }, 75})