Fakultas Ilmu Komputer UI

Commit 91e7dd9a authored by Abraham Rudolf Brahmana's avatar Abraham Rudolf Brahmana Committed by angelin depthios
Browse files

feat: Pass function as params in ecosystem navigation

parent 66bb9b6f
......@@ -6,6 +6,7 @@ import SmallButton from "../../components/button/SmallButton";
import Spacer from "../../components/Spacer/Spacer";
import { Text, View } from "../../components/Themed";
import Colors from "../../constants/Colors";
import { IEcosystem } from "../../types/firestore/ecosystems";
const BusinessEcosystemScreen = () => {
const nav = useNavigation();
......@@ -31,7 +32,9 @@ const BusinessEcosystemScreen = () => {
screen: "Recommended",
params: {
headerTitle: "Ekosistem Saya",
toFetch: "MyEcosystem",
toFetch: () => {
return new Promise<IEcosystem[]>(() => {});
},
},
});
}}
......@@ -69,7 +72,9 @@ const BusinessEcosystemScreen = () => {
screen: "Recommended",
params: {
headerTitle: "Paling Populer",
toFetch: "Popular",
toFetch: () => {
return new Promise<IEcosystem[]>(() => {});
},
},
});
}}
......@@ -85,7 +90,9 @@ const BusinessEcosystemScreen = () => {
screen: "Recommended",
params: {
headerTitle: "Terbaru Minggu Ini",
toFetch: "Latest",
toFetch: () => {
return new Promise<IEcosystem[]>(() => {});
},
},
});
}}
......
import * as React from "react";
import { Alert, StyleSheet } from "react-native";
import { StyleSheet } from "react-native";
import { Text, View } from "../../components/Themed";
import Colors from "../../constants/Colors";
import { EcosystemStackScreenProps } from "../../types/navigation";
import { LogBox } from "react-native";
const RecommendedEcosystemScreen = ({
const RecommendedEcosystemScreen = async ({
route,
}: EcosystemStackScreenProps<"Recommended">) => {
const { toFetch } = route.params;
await toFetch();
LogBox.ignoreLogs([
"Non-serializable values were found in the navigation state",
]);
return (
<View style={styles.container}>
<View>
<Text onPress={() => Alert.alert(toFetch)}>
Layar Rekomendasi Ekosistem
</Text>
<Text>Layar Rekomendasi Ekosistem</Text>
</View>
</View>
);
......
......@@ -3,6 +3,7 @@
* https://reactnavigation.org/docs/typescript/
*/
import { NativeStackScreenProps } from "@react-navigation/native-stack";
import { IEcosystem } from "../firestore/ecosystems";
export type EcosystemStackParamList = {
BusinessEcosystem: undefined;
......@@ -12,7 +13,7 @@ export type EcosystemStackParamList = {
EcosystemMap: undefined;
BusinessList: { headerTitle: string };
EcosystemDetails: { headerTitle: string };
Recommended: { headerTitle: string; toFetch: string };
Recommended: { headerTitle: string; toFetch: () => Promise<IEcosystem[]> };
};
export type EcosystemStackScreenProps<
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment