mirror of
https://github.com/urosran/cally.git
synced 2025-07-10 07:07:16 +00:00
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import {View} from "react-native-ui-lib";
|
|
import React, {useCallback, useRef, useState} from "react";
|
|
import {LayoutChangeEvent} from "react-native";
|
|
import CalendarViewSwitch from "@/components/pages/calendar/CalendarViewSwitch";
|
|
import {AddEventDialog} from "@/components/pages/calendar/AddEventDialog";
|
|
import {ManuallyAddEventModal} from "@/components/pages/calendar/ManuallyAddEventModal";
|
|
import {EventCalendar} from "@/components/pages/calendar/EventCalendar";
|
|
|
|
export const InnerCalendar = () => {
|
|
const [calendarWidth, setCalendarWidth] = useState(0);
|
|
const calendarContainerRef = useRef(null);
|
|
const hasSetInitialSize = useRef(false);
|
|
|
|
const onLayout = useCallback((event: LayoutChangeEvent) => {
|
|
if (!hasSetInitialSize.current) {
|
|
const width = event.nativeEvent.layout.width;
|
|
setCalendarWidth(width);
|
|
hasSetInitialSize.current = true;
|
|
}
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<View
|
|
style={{flex: 1, backgroundColor: "#fff", borderRadius: 0, marginBottom: 0, overflow: "hidden"}}
|
|
ref={calendarContainerRef}
|
|
onLayout={onLayout}
|
|
paddingB-0
|
|
>
|
|
<EventCalendar
|
|
calendarWidth={calendarWidth}
|
|
/>
|
|
</View>
|
|
<CalendarViewSwitch/>
|
|
|
|
<AddEventDialog/>
|
|
<ManuallyAddEventModal/>
|
|
</>
|
|
)
|
|
} |