Skip to content

Commit

Permalink
refresh pulldown
Browse files Browse the repository at this point in the history
  • Loading branch information
solderq35 committed Mar 14, 2024
1 parent f696e5c commit ce7a558
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
21 changes: 19 additions & 2 deletions app/content/drill/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Link, useNavigation } from "expo-router";
import { ScrollView, StyleSheet } from "react-native";
import { useCallback, useState } from "react";
import { RefreshControl, ScrollView, StyleSheet } from "react-native";
import { Appbar, List, PaperProvider } from "react-native-paper";
import { SafeAreaView } from "react-native-safe-area-context";

import { router } from "expo-router";
import ErrorComponent from "~/components/errorComponent";
import Loading from "~/components/loading";
import { useDrillInfo } from "~/hooks/useDrillInfo";
Expand All @@ -16,6 +18,16 @@ export default function Index() {
isLoading: drillInfoIsLoading,
} = useDrillInfo();

const [refreshing, setRefreshing] = useState(false);

const onRefresh = useCallback(() => {
setRefreshing(true);
setTimeout(() => {
router.replace("content/drill/");
setRefreshing(false);
}, 500);
}, []);

if (drillInfoIsLoading) {
return <Loading />;
}
Expand All @@ -31,7 +43,12 @@ export default function Index() {
<Appbar.Content title="Drills" />
</Appbar.Header>

<ScrollView contentContainerStyle={styles.scrollView}>
<ScrollView
contentContainerStyle={styles.scrollView}
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}
>
<List.Section>
{Object.values(drillInfo).map((drill) => (
<Link
Expand Down
21 changes: 19 additions & 2 deletions app/content/profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import {
BottomSheetModalProvider,
} from "@gorhom/bottom-sheet";
import { useQueryClient } from "@tanstack/react-query";
import { router } from "expo-router";
import {
getAuth,
signInWithEmailAndPassword,
signOut as signoutFireBase,
updatePassword,
} from "firebase/auth";
import { doc, updateDoc } from "firebase/firestore";
import { useEffect, useMemo, useRef, useState } from "react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
Image,
Pressable,
RefreshControl,
ScrollView,
StyleSheet,
Text,
Expand Down Expand Up @@ -74,6 +76,16 @@ function Index(props) {
isLoading: drillInfoIsLoading,
} = useDrillInfo();

const [refreshing, setRefreshing] = useState(false);

const onRefresh = useCallback(() => {
setRefreshing(true);
setTimeout(() => {
router.replace("content/profile/");
setRefreshing(false);
}, 500);
}, []);

// ref
const bottomSheetModalRef = useRef(null);

Expand Down Expand Up @@ -247,7 +259,12 @@ function Index(props) {
</Appbar.Header>

<BottomSheetModalProvider>
<ScrollView contentContainerStyle={styles.scrollViewContent}>
<ScrollView
contentContainerStyle={styles.scrollViewContent}
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}
>
<View style={styles.profileContainer}>
<ProfileCard user={userData} />
</View>
Expand Down
19 changes: 18 additions & 1 deletion app/content/team/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import {
BottomSheetModalProvider,
} from "@gorhom/bottom-sheet";
import { router } from "expo-router";
import React, { useCallback, useMemo, useRef } from "react";
import React, { useCallback, useMemo, useRef, useState } from "react";
import {
Image,
Keyboard,
Pressable,
RefreshControl,
TouchableWithoutFeedback,
View,
} from "react-native";
Expand Down Expand Up @@ -51,6 +52,16 @@ function Index() {
//console.log("handleSheetChanges", index);
}, []);

const [refreshing, setRefreshing] = useState(false);

const onRefresh = useCallback(() => {
setRefreshing(true);
setTimeout(() => {
router.replace("content/team/");
setRefreshing(false);
}, 500);
}, []);

if (userIsLoading) return <Loading />;

if (userError) return <ErrorComponent message={userError.message} />;
Expand Down Expand Up @@ -93,6 +104,12 @@ function Index() {
keyboardShouldPersistTaps="handled"
showsVerticalScrollIndicator={false}
stickyHeaderIndices={[3]}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={onRefresh}
/>
}
>
<View style={{ alignItems: "center" }}>
<Image
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5810,7 +5810,7 @@ has-flag@^4.0.0:
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==

has-property-descriptors@^1.0.0, has-property-descriptors@^1.0.1:
has-property-descriptors@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854"
integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==
Expand Down

0 comments on commit ce7a558

Please sign in to comment.