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"; ...@@ -6,6 +6,7 @@ import SmallButton from "../../components/button/SmallButton";
import Spacer from "../../components/Spacer/Spacer"; import Spacer from "../../components/Spacer/Spacer";
import { Text, View } from "../../components/Themed"; import { Text, View } from "../../components/Themed";
import Colors from "../../constants/Colors"; import Colors from "../../constants/Colors";
import { IEcosystem } from "../../types/firestore/ecosystems";
const BusinessEcosystemScreen = () => { const BusinessEcosystemScreen = () => {
const nav = useNavigation(); const nav = useNavigation();
...@@ -31,7 +32,9 @@ const BusinessEcosystemScreen = () => { ...@@ -31,7 +32,9 @@ const BusinessEcosystemScreen = () => {
screen: "Recommended", screen: "Recommended",
params: { params: {
headerTitle: "Ekosistem Saya", headerTitle: "Ekosistem Saya",
toFetch: "MyEcosystem", toFetch: () => {
return new Promise<IEcosystem[]>(() => {});
},
}, },
}); });
}} }}
...@@ -69,7 +72,9 @@ const BusinessEcosystemScreen = () => { ...@@ -69,7 +72,9 @@ const BusinessEcosystemScreen = () => {
screen: "Recommended", screen: "Recommended",
params: { params: {
headerTitle: "Paling Populer", headerTitle: "Paling Populer",
toFetch: "Popular", toFetch: () => {
return new Promise<IEcosystem[]>(() => {});
},
}, },
}); });
}} }}
...@@ -85,7 +90,9 @@ const BusinessEcosystemScreen = () => { ...@@ -85,7 +90,9 @@ const BusinessEcosystemScreen = () => {
screen: "Recommended", screen: "Recommended",
params: { params: {
headerTitle: "Terbaru Minggu Ini", headerTitle: "Terbaru Minggu Ini",
toFetch: "Latest", toFetch: () => {
return new Promise<IEcosystem[]>(() => {});
},
}, },
}); });
}} }}
......
import * as React from "react"; import * as React from "react";
import { Alert, StyleSheet } from "react-native"; import { StyleSheet } from "react-native";
import { Text, View } from "../../components/Themed"; import { Text, View } from "../../components/Themed";
import Colors from "../../constants/Colors"; import Colors from "../../constants/Colors";
import { EcosystemStackScreenProps } from "../../types/navigation"; import { EcosystemStackScreenProps } from "../../types/navigation";
import { LogBox } from "react-native";
const RecommendedEcosystemScreen = ({ const RecommendedEcosystemScreen = async ({
route, route,
}: EcosystemStackScreenProps<"Recommended">) => { }: EcosystemStackScreenProps<"Recommended">) => {
const { toFetch } = route.params; const { toFetch } = route.params;
await toFetch();
LogBox.ignoreLogs([
"Non-serializable values were found in the navigation state",
]);
return ( return (
<View style={styles.container}> <View style={styles.container}>
<View> <View>
<Text onPress={() => Alert.alert(toFetch)}> <Text>Layar Rekomendasi Ekosistem</Text>
Layar Rekomendasi Ekosistem
</Text>
</View> </View>
</View> </View>
); );
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* https://reactnavigation.org/docs/typescript/ * https://reactnavigation.org/docs/typescript/
*/ */
import { NativeStackScreenProps } from "@react-navigation/native-stack"; import { NativeStackScreenProps } from "@react-navigation/native-stack";
import { IEcosystem } from "../firestore/ecosystems";
export type EcosystemStackParamList = { export type EcosystemStackParamList = {
BusinessEcosystem: undefined; BusinessEcosystem: undefined;
...@@ -12,7 +13,7 @@ export type EcosystemStackParamList = { ...@@ -12,7 +13,7 @@ export type EcosystemStackParamList = {
EcosystemMap: undefined; EcosystemMap: undefined;
BusinessList: { headerTitle: string }; BusinessList: { headerTitle: string };
EcosystemDetails: { headerTitle: string }; EcosystemDetails: { headerTitle: string };
Recommended: { headerTitle: string; toFetch: string }; Recommended: { headerTitle: string; toFetch: () => Promise<IEcosystem[]> };
}; };
export type EcosystemStackScreenProps< export type EcosystemStackScreenProps<
......
Markdown is supported
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