import { DateTimePicker } from "@expo/ui/community/datetime-picker"; import { useState } from "react"; import { Modal, Platform, Pressable, Text, View } from "react-native"; import { autopilotTimeOfDay } from "../lib/autopilot"; import { useI18n } from "../lib/i18n"; import { useMobileTokens, useResolvedAppearance } from "../lib/native"; /** * The native time picker for "Until a time". Android opens its clock dialog; iOS shows the wheel in * a sheet with Start. Either way the caller gets "HH:MM" and unmounts the picker. */ export function AutopilotTimePicker({ onPick, onClose, }: { onPick: (time: string) => void; onClose: () => void; }) { const tokens = useMobileTokens(); const colorScheme = useResolvedAppearance(); const { t } = useI18n(); const [value, setValue] = useState(() => { const morning = new Date(); morning.setHours(8, 0, 0, 0); return morning; }); if (Platform.OS === "android") { return ( onPick(autopilotTimeOfDay(date))} onDismiss={onClose} /> ); } return ( {t("Cancel")} {t("Until when?")} onPick(autopilotTimeOfDay(value))} hitSlop={12} > {t("Start")} setValue(date)} /> ); }