From da9f520fb7e690982924e04f6d53c2380fcf4648 Mon Sep 17 00:00:00 2001 From: iAmir Date: Fri, 28 Jun 2024 06:57:55 +0330 Subject: [PATCH] show logo and banner in join prompt --- src/containers/JoinServerPrompt/index.tsx | 133 +++++++++++++++++++--- src/utils/query.ts | 2 + src/utils/types.ts | 14 +-- 3 files changed, 122 insertions(+), 27 deletions(-) diff --git a/src/containers/JoinServerPrompt/index.tsx b/src/containers/JoinServerPrompt/index.tsx index 6e421511..9b0eaaa1 100644 --- a/src/containers/JoinServerPrompt/index.tsx +++ b/src/containers/JoinServerPrompt/index.tsx @@ -1,6 +1,7 @@ import { t } from "i18next"; import { useEffect, useMemo, useState } from "react"; import { + Image, TextInput, TouchableOpacity, View, @@ -35,7 +36,7 @@ const JoinServerPrompt = () => { } = usePersistentServers(); const { updateServer } = useServers(); const { height, width } = useWindowDimensions(); - const { theme } = useTheme(); + const { theme, themeType } = useTheme(); const [password, setPassword] = useState(""); const [perServerVersion, setPerServerVersion] = useState< SAMPDLLVersions | undefined @@ -69,11 +70,32 @@ const JoinServerPrompt = () => { setPassword(server && server.password ? server.password : ""); }, [server]); + const bannerUrl = useMemo(() => { + if (server && server.omp) { + if (themeType === "dark") { + if (server.omp.bannerDark && server.omp.bannerDark.length) + return server.omp.bannerDark; + } else { + if (server.omp.bannerLight && server.omp.bannerLight.length) + return server.omp.bannerLight; + } + } + return ""; + }, [server]); + + const logoUrl = useMemo(() => { + if (server && server.omp) { + if (server.omp.logo && server.omp.logo.length) return server.omp.logo; + } + return ""; + }, [server]); + if (!visible) { return null; } - const HEIGHT = server?.hasPassword ? 316 : 248; + const HEIGHT = + (server?.hasPassword ? 316 : 248) + (bannerUrl.length ? 77 : 0); const WIDTH = 320; return ( @@ -96,14 +118,89 @@ const JoinServerPrompt = () => { shadowRadius: 10, alignItems: "center", paddingVertical: sc(11), + paddingTop: bannerUrl.length ? sc(0) : undefined, }} > - + {bannerUrl.length ? ( + + + + ) : null} + + {logoUrl.length ? ( + + + + + + + ) : ( + + )} + { showPrompt(false)} > diff --git a/src/utils/query.ts b/src/utils/query.ts index bb9ee132..e79c7e7e 100644 --- a/src/utils/query.ts +++ b/src/utils/query.ts @@ -189,6 +189,8 @@ const getServerOmpExtraInfo = async ( data.discord_link && data.discord_link.length ? data.discord_link : undefined, + logo: + data.logo_url && data.logo_url.length ? data.logo_url : undefined, }, }; updateServerEveryWhere(server); diff --git a/src/utils/types.ts b/src/utils/types.ts index f41c8e21..64063e08 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -29,19 +29,7 @@ export interface Server { bannerLight?: string; bannerDark?: string; discordInvite?: string; - discordStatus?: { - appId: string; - largeImage: { - asset: string; - text: string; - }; - smallImage: { - asset: string; - text: string; - }; - title: string; - description: string; - }; + logo?: string; }; rules: { artwork: string;