upd: pull to refresh

Deskripsi:
- list banner
- lit grouop
- list position
- list member
- list diskusi umum
- list pengumuman
- list project
- list divisi
- list tugas divisi
- list diskusi divisi
- list kalender divisi
- list dokumen divisi

No Issues
This commit is contained in:
2025-07-15 12:08:55 +08:00
parent ae420ec560
commit 4a10655582
12 changed files with 249 additions and 63 deletions

View File

@@ -11,7 +11,7 @@ import dayjs from "dayjs";
import { router, Stack, useLocalSearchParams } from "expo-router";
import moment from "moment";
import { useEffect, useState } from "react";
import { Pressable, SafeAreaView, ScrollView, Text, View } from "react-native";
import { Pressable, RefreshControl, SafeAreaView, ScrollView, Text, View } from "react-native";
import Datepicker, {
CalendarComponents,
CalendarDay
@@ -32,15 +32,16 @@ type Props = {
};
export default function CalendarDivision() {
const [selected, setSelected] = useState<any>(new Date());
const [data, setData] = useState<Props[]>([]);
const { token, decryptToken } = useAuthSession();
const { id } = useLocalSearchParams<{ id: string }>();
const [dataIndicator, setDataIndicator] = useState<any>([]);
const [month, setMonth] = useState<number>(new Date().getMonth());
const [selected, setSelected] = useState<any>(new Date())
const [data, setData] = useState<Props[]>([])
const { token, decryptToken } = useAuthSession()
const { id } = useLocalSearchParams<{ id: string }>()
const [dataIndicator, setDataIndicator] = useState<any>([])
const [month, setMonth] = useState<number>(new Date().getMonth())
const update = useSelector((state: any) => state.calendarUpdate)
const [loading, setLoading] = useState(true)
const [loadingBtn, setLoadingBtn] = useState(false)
const [refreshing, setRefreshing] = useState(false)
async function handleLoad(loading: boolean) {
@@ -90,6 +91,13 @@ export default function CalendarDivision() {
handleLoadIndicator();
}, [month, update.data]);
const handleRefresh = async () => {
setRefreshing(true)
handleLoad(false)
await new Promise(resolve => setTimeout(resolve, 2000));
setRefreshing(false)
};
const components: CalendarComponents = {
Day: (day: CalendarDay) => {
const now = String(day.date);
@@ -127,7 +135,13 @@ export default function CalendarDivision() {
headerRight: () => <HeaderRightCalendarList />,
}}
/>
<ScrollView>
<ScrollView
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={handleRefresh}
/>
}>
<View style={[Styles.p15]}>
<View style={[Styles.wrapPaper, Styles.p10]}>
<Datepicker