Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
fix datetimepicker ios display prop causing crash on android
Browse files Browse the repository at this point in the history
  • Loading branch information
lyqht committed Apr 25, 2022
1 parent c20d849 commit a9a50e0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/BillForm/CustomDatetimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import {Icon, Input} from '@ui-kitten/components';
import dayjs from 'dayjs';
import React, {useState} from 'react';
import {View} from 'react-native';
import {getSystemName} from 'react-native-device-info';
import DateTimePickerModal from 'react-native-modal-datetime-picker';

type IOSDisplay = 'default' | 'compact' | 'inline' | 'spinner';

interface Props {
onChange: (date: any) => void;
value: Date;
Expand All @@ -24,6 +27,12 @@ const CustomDatetimePicker: React.FC<Props> = ({value, onChange}) => {
hideDatePicker();
};

const displayProps: {display?: IOSDisplay} = {
...((getSystemName() === 'iOS' || getSystemName() === 'iPadOS') && {
display: 'spinner',
}),
};

return (
<View>
<Input
Expand All @@ -38,9 +47,9 @@ const CustomDatetimePicker: React.FC<Props> = ({value, onChange}) => {
isVisible={isDatePickerVisible}
mode="datetime"
date={value}
display={'inline'}
onConfirm={handleConfirm}
onCancel={hideDatePicker}
{...displayProps}
/>
</View>
);
Expand Down

0 comments on commit a9a50e0

Please sign in to comment.