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

@@ -17,7 +17,7 @@ import {
} from "@expo/vector-icons";
import { router, useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { Pressable, ScrollView, Text, View, VirtualizedList } from "react-native";
import { Pressable, RefreshControl, ScrollView, Text, View, VirtualizedList } from "react-native";
import { useSelector } from "react-redux";
type Props = {
@@ -38,16 +38,17 @@ export default function ListProject() {
}>();
const [statusFix, setStatusFix] = useState<'0' | '1' | '2' | '3'>('0')
const { token, decryptToken } = useAuthSession();
const entityUser = useSelector((state: any) => state.user);
const [search, setSearch] = useState("");
const [nameGroup, setNameGroup] = useState("");
const [data, setData] = useState<Props[]>([]);
const [isList, setList] = useState(false);
const entityUser = useSelector((state: any) => state.user)
const [search, setSearch] = useState("")
const [nameGroup, setNameGroup] = useState("")
const [data, setData] = useState<Props[]>([])
const [isList, setList] = useState(false)
const update = useSelector((state: any) => state.projectUpdate)
const [loading, setLoading] = useState(true)
const arrSkeleton = Array.from({ length: 3 }, (_, index) => index)
const [page, setPage] = useState(1)
const [waiting, setWaiting] = useState(false)
const [refreshing, setRefreshing] = useState(false)
async function handleLoad(loading: boolean, thisPage: number) {
try {
@@ -96,7 +97,14 @@ export default function ListProject() {
setTimeout(() => {
handleLoad(false, page + 1)
}, 1000);
};
}
const handleRefresh = async () => {
setRefreshing(true)
handleLoad(false, 1)
await new Promise(resolve => setTimeout(resolve, 2000));
setRefreshing(false)
}
const getItem = (_data: unknown, index: number): Props => ({
id: data[index].id,
@@ -189,14 +197,14 @@ export default function ListProject() {
(entityUser.role == "supadmin" || entityUser.role == "developer") && nameGroup
}
{
(entityUser.role == 'user' || entityUser.role == 'coadmin')
(entityUser.role == 'user' || entityUser.role == 'coadmin' || entityUser.role == 'cosupadmin')
? (cat == 'null' || cat == 'undefined' || cat == undefined || cat == '' || cat == 'data-saya') ? 'Kegiatan Saya' : 'Semua Kegiatan'
: ''
}
</Text>
</View>
</View>
<View style={[{ flex: 2}]}>
<View style={[{ flex: 2 }]}>
{
loading ?
isList ?
@@ -239,6 +247,12 @@ export default function ListProject() {
onEndReached={loadMoreData}
onEndReachedThreshold={0.5}
showsVerticalScrollIndicator={false}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={handleRefresh}
/>
}
/>
{/* {
data.map((item, index) => {
@@ -311,6 +325,12 @@ export default function ListProject() {
onEndReached={loadMoreData}
onEndReachedThreshold={0.5}
showsVerticalScrollIndicator={false}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={handleRefresh}
/>
}
/>
{/* {data.map((item, index) => {
return (