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:
@@ -17,7 +17,7 @@ import {
|
||||
} from "@expo/vector-icons";
|
||||
import { router, useLocalSearchParams } from "expo-router";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Pressable, Text, View, VirtualizedList } from "react-native";
|
||||
import { Pressable, RefreshControl, Text, View, VirtualizedList } from "react-native";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
@@ -34,11 +34,11 @@ export default function ListDivision() {
|
||||
cat?: string;
|
||||
}>();
|
||||
const [isList, setList] = useState(false);
|
||||
const entityUser = useSelector((state: any) => state.user);
|
||||
const { token, decryptToken } = useAuthSession();
|
||||
const [search, setSearch] = useState("");
|
||||
const [nameGroup, setNameGroup] = useState("");
|
||||
const [data, setData] = useState<Props[]>([]);
|
||||
const entityUser = useSelector((state: any) => state.user)
|
||||
const { token, decryptToken } = useAuthSession()
|
||||
const [search, setSearch] = useState("")
|
||||
const [nameGroup, setNameGroup] = useState("")
|
||||
const [data, setData] = useState<Props[]>([])
|
||||
const update = useSelector((state: any) => state.divisionUpdate)
|
||||
const arrSkeleton = Array.from({ length: 3 }, (_, index) => index)
|
||||
const [loading, setLoading] = useState(false)
|
||||
@@ -46,6 +46,7 @@ export default function ListDivision() {
|
||||
const [category, setCategory] = useState<'divisi-saya' | 'semua'>('divisi-saya')
|
||||
const [page, setPage] = useState(1)
|
||||
const [waiting, setWaiting] = useState(false)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
|
||||
async function handleLoad(loading: boolean, thisPage: number) {
|
||||
try {
|
||||
@@ -95,6 +96,13 @@ export default function ListDivision() {
|
||||
}, 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,
|
||||
name: data[index].name,
|
||||
@@ -235,6 +243,12 @@ export default function ListDivision() {
|
||||
onEndReached={loadMoreData}
|
||||
onEndReachedThreshold={0.5}
|
||||
showsVerticalScrollIndicator={false}
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
refreshing={refreshing}
|
||||
onRefresh={handleRefresh}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
) : (
|
||||
@@ -264,6 +278,12 @@ export default function ListDivision() {
|
||||
onEndReached={loadMoreData}
|
||||
onEndReachedThreshold={0.5}
|
||||
showsVerticalScrollIndicator={false}
|
||||
refreshControl={
|
||||
<RefreshControl
|
||||
refreshing={refreshing}
|
||||
onRefresh={handleRefresh}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user