import { useState, useRef } from "react"; import { TouchableOpacity, View } from "react-native"; import type IDateTimeSheetProps from "./type"; import stylesheet, { useStyles } from "./stylesheet"; import { NCoreUIKitLocalize, NCoreUIKitTheme } from "../../core/hooks"; import type { IDateSelectorRef } from "../dateSelector/type"; import type { IMonthSelectorRef } from "../monthSelector/type"; import type { IYearSelectorRef } from "../yearSelector/type"; import MonthSelector from "../monthSelector"; import TimeSelector from "../timeSelector"; import YearSelector from "../yearSelector"; import DateSelector from "../dateSelector"; import BottomSheet from "../bottomSheet"; import CheckBox from "../checkBox"; import Loading from "../loading"; import Button from "../button"; import Text from "../text"; const DateTimeSheet = ({ isTimeSelectWorksWithCenterWhenTimePicker, dateCalendarType: dateCalendarTypeProp, multipleSelectMinimumRequiredDayCount, localeBasedFirstDayOfWeek = true, multipleSelectMinimumRequireMS, isShowTodayIndicator = true, isShowCalenderChangerTool, dayOfWeekLength = "short", LoadingIconComponentProp, multipleSelectMaximumMS, multipleSelectDayLimit, monthOfYearLengthType, selectMultipleObject, isWorkWithRealtime, isShowTools = true, isWorkWithSeconds, dateTimePickerKey, bottomSheetProps, bottomSheetRef, customLocalize, selectObject, customTheme, setIsActive, pickerType, dateRange, maxChoice, minChoice, isLoading, isActive, dateRule, variant, maxDate, minDate, cancel, clean, title, date, ok }: IDateTimeSheetProps) => { const { radiuses, borders, spaces, colors } = NCoreUIKitTheme.useContext(customTheme); const { localize } = NCoreUIKitLocalize.useContext(customLocalize); const [ isSheetContentReady, setIsSheetContentReady ] = useState(false); const [ dateCalendarType, setDateCalendarType ] = useState(dateCalendarTypeProp ?? "day"); const monthCalendarRef = useRef(null); const yearCalendarRef = useRef(null); const dayCalendarRef = useRef(null); const { calendarChangerToolContainer: calendarChangerToolContainerDynamicStyle, calendarChangerToolButton: calendarChangerToolButtonDynamicStyle, loadingContainer: loadingContainerDynamicStyle, contentContainer: contentContainerDynamicStyle, headerContainer: headerContainerDynamicStyle, bottomContainer: bottomContainerDynamicStyle, toolsContainer: toolsContainerDynamicStyle, cancelButton: cancelButtonDynamicStyle, headerTitle: headerTitleDynamicStyle, okButton: okButtonDynamicStyle } = useStyles({ radiuses, borders, spaces, colors }); const renderCalenderChangerTool = () => { if(!isShowCalenderChangerTool) { return null; } if(dateCalendarTypeProp) { return null; } return { setDateCalendarType("day"); }} > {localize("daily")} { setDateCalendarType("month"); }} > {localize("monthly")} { setDateCalendarType("year"); }} > {localize("yearly")} ; }; const renderDateCalendar = () => { if(pickerType === "time") { return null; } if(dateCalendarType === "month") { return ; } if(dateCalendarType === "year") { return ; } return ; }; const renderBottomSheetContent = () => { if(isLoading) { return { LoadingIconComponentProp ? : } ; } return {renderCalenderChangerTool()} {renderDateCalendar()} { pickerType === "date" ? null : } ; }; const renderTools = () => { if(!isShowTools) { return null; } if(minChoice && maxChoice !== -1) { return null; } let isAnySelected = false; if(variant === "single" && date) { isAnySelected = true; } if(variant === "range" && dateRange && (dateRange.start || dateRange.end)) { isAnySelected = true; } if(variant === "rrule" && dateRule) { isAnySelected = true; } return { !minChoice ? { clean(); }} /> : null }