added calendar events refresh

This commit is contained in:
ivic00
2024-11-17 20:23:41 +01:00
parent a95191c890
commit d7928c799d
5 changed files with 78 additions and 28 deletions

View File

@ -1,5 +1,5 @@
import {View} from "react-native-ui-lib";
import React, {useRef, useState} from "react";
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";
@ -11,12 +11,16 @@ export const InnerCalendar = () => {
const [calendarHeight, setCalendarHeight] = useState(0);
const [calendarWidth, setCalendarWidth] = useState(0);
const calendarContainerRef = useRef(null);
const hasSetInitialSize = useRef(false);
const onLayout = (event: LayoutChangeEvent) => {
const {height, width} = event.nativeEvent.layout;
setCalendarHeight(height);
setCalendarWidth(width);
};
const onLayout = useCallback((event: LayoutChangeEvent) => {
if (!hasSetInitialSize.current) {
const {height, width} = event.nativeEvent.layout;
setCalendarHeight(height);
setCalendarWidth(width);
hasSetInitialSize.current = true;
}
}, []);
return (
<>