import React from "react";
import { View } from "react-native-ui-lib";
import HeaderTemplate from "@/components/shared/HeaderTemplate";
import { InnerCalendar } from "@/components/pages/calendar/InnerCalendar";
import { useSetAtom } from "jotai";
import { refreshEnabledAtom } from "./atoms";

export default function CalendarPage() {
    const setRefreshEnabled = useSetAtom(refreshEnabledAtom);

  const disableRefreshControl = () => setRefreshEnabled(false);
  const enableRefreshControl = () => setRefreshEnabled(true);
  return (
    <View
      style={{ flex: 1, height: "100%", padding: 10 }}
      paddingH-22
      paddingT-0
    >
      <View
        onStartShouldSetResponder={() => {
          enableRefreshControl();
          console.log("yeah");
          return true;
        }}
        onResponderRelease={() => {
          disableRefreshControl();
          console.log("sure");
          console.log(refreshEnabledAtom)
        }}
      >
        <HeaderTemplate
          message={"Let's get your week started !"}
          isWelcome
          isCalendar={true}
        />
      </View>
      <InnerCalendar />
    </View>
  );
}
