Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WALLET-577: Back to homeScreen after upload file successful in file detail screen #70

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
//

import { Tabs } from "expo-router";
import { router, Tabs } from "expo-router";
import type { MutableRefObject } from "react";
import React, { useRef, useState } from "react";
import HouseOutLine from "@/assets/images/house-outline.svg";
Expand All @@ -34,8 +34,6 @@ import {
} from "react-native";
import PopupMenu from "@/components/PopupMenu";
import { ThemedText } from "@/components/ThemedText";
import { fetchFiles } from "@/api/files";
import { useQueryClient } from "@tanstack/react-query";

const { width, height } = Dimensions.get("window");

Expand All @@ -45,7 +43,6 @@ export default function TabLayout() {
const [positionType, setPositionType] = useState<
"topMiddle" | "bottomLeft" | "bottomMiddle"
>("bottomMiddle");
const queryClient = useQueryClient();
const tabBarAddButtonRef = useRef(null);
const rightHeaderAddButtonRef = useRef(null);
const toggleMenu = (
Expand Down Expand Up @@ -109,6 +106,7 @@ export default function TabLayout() {
name="home"
options={{
title: "Home",
href: "/home",
tabBarIcon: ({ color, focused }) =>
focused ? (
<FontAwesome6 size={24} name="house" color={color} />
Expand Down Expand Up @@ -195,12 +193,14 @@ export default function TabLayout() {
</Tabs>
<PopupMenu
visible={menuVisible}
onClose={() => toggleMenu("topMiddle", rightHeaderAddButtonRef)}
onUploadSuccess={async () => {
await queryClient.fetchQuery({
queryKey: ["files"],
queryFn: fetchFiles,
});
onClose={() => {
toggleMenu(
"topMiddle",
tabBarAddButtonRef || rightHeaderAddButtonRef
);
}}
onUploadSuccess={() => {
router.replace("/home");
}}
position={menuPosition}
positionType={positionType}
Expand Down
8 changes: 6 additions & 2 deletions app/(tabs)/home/[fileName].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//
import React, { useEffect, useLayoutEffect, useRef, useState } from "react";
import { View, StyleSheet, TouchableOpacity, Image } from "react-native";
import { useQuery } from "@tanstack/react-query";
import { useIsMutating, useQuery } from "@tanstack/react-query";
import { getFile } from "@/api/files";
import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome";
import { faEllipsis } from "@fortawesome/free-solid-svg-icons/faEllipsis";
Expand All @@ -27,6 +27,7 @@ import { Colors } from "@/constants/Colors";
import VcCard from "@/components/files/VcCard";
import BottomModal from "@/components/files/BottomModal";
import type { WalletFile } from "@/types/WalletFile";
import Loading from "@/components/LoadingButton";

interface FileDetailProps {
file: WalletFile;
Expand All @@ -46,6 +47,8 @@ const blobToBase64 = (blob: Blob): Promise<string> => {
};

const Page: React.FC<FileDetailProps> = () => {
const isMutatingFiles = useIsMutating({ mutationKey: ["filesMutation"] });

const { fileName, isRDFResourceStr, identifier } = useLocalSearchParams();
const isRDFResource: boolean = isRDFResourceStr === "true";
const [imageUri, setImageUri] = useState<string | null>(null);
Expand Down Expand Up @@ -114,6 +117,7 @@ const Page: React.FC<FileDetailProps> = () => {
/>
)}
{isRDFResource && data && <VcCard data={data} />}
<Loading isLoading={!!isMutatingFiles} />
<BottomSheetModal
enableDismissOnClose
ref={bottomSheetModalRef}
Expand All @@ -135,7 +139,7 @@ const Page: React.FC<FileDetailProps> = () => {
isRDFResource,
}}
onCloseModal={() => bottomSheetModalRef.current?.close()}
onDeleteSuccessfully={() => goBack()}
onDeleteSuccessfully={goBack}
onChangeSnapPoint={(snapHeight: number) =>
bottomSheetModalRef.current?.snapToPosition(snapHeight)
}
Expand Down