From b41363d347a21de4d0281243ff8f2608738d9a22 Mon Sep 17 00:00:00 2001
From: herrrta <@>
Date: Thu, 28 Nov 2024 22:01:11 -0500
Subject: [PATCH] # Allow option for viewing custom menu links
- Added new 'Other' setting to toggle new tab visibility
- Added new Tab to show custom links
- Added icon asset for list
---
app/(auth)/(tabs)/(custom-links)/_layout.tsx | 20 +++++
app/(auth)/(tabs)/(custom-links)/index.tsx | 73 +++++++++++++++++++
app/(auth)/(tabs)/_layout.tsx | 13 ++++
assets/icons/list.png | Bin 0 -> 2396 bytes
components/settings/SettingToggles.tsx | 20 +++++
utils/atoms/settings.ts | 4 +-
6 files changed, 129 insertions(+), 1 deletion(-)
create mode 100644 app/(auth)/(tabs)/(custom-links)/_layout.tsx
create mode 100644 app/(auth)/(tabs)/(custom-links)/index.tsx
create mode 100644 assets/icons/list.png
diff --git a/app/(auth)/(tabs)/(custom-links)/_layout.tsx b/app/(auth)/(tabs)/(custom-links)/_layout.tsx
new file mode 100644
index 00000000..ed0529d4
--- /dev/null
+++ b/app/(auth)/(tabs)/(custom-links)/_layout.tsx
@@ -0,0 +1,20 @@
+import {Stack} from "expo-router";
+import { Platform } from "react-native";
+
+export default function CustomMenuLayout() {
+ return (
+
+
+
+ );
+}
diff --git a/app/(auth)/(tabs)/(custom-links)/index.tsx b/app/(auth)/(tabs)/(custom-links)/index.tsx
new file mode 100644
index 00000000..76b10fb8
--- /dev/null
+++ b/app/(auth)/(tabs)/(custom-links)/index.tsx
@@ -0,0 +1,73 @@
+import {FlatList, TouchableOpacity, View} from "react-native";
+import {useSafeAreaInsets} from "react-native-safe-area-context";
+import React, {useCallback, useEffect, useState} from "react";
+import {useAtom} from "jotai/index";
+import {apiAtom} from "@/providers/JellyfinProvider";
+import {ListItem} from "@/components/ListItem";
+import * as WebBrowser from 'expo-web-browser';
+import Ionicons from '@expo/vector-icons/Ionicons';
+import {Text} from "@/components/common/Text";
+
+export interface MenuLink {
+ name: string,
+ url: string,
+ icon: string
+}
+
+export default function menuLinks() {
+ const [api] = useAtom(apiAtom);
+ const insets = useSafeAreaInsets()
+ const [menuLinks, setMenuLinks] = useState([])
+
+ const getMenuLinks = useCallback(async () => {
+ try {
+ const response = await api?.axiosInstance.get(api?.basePath + "/web/config.json")
+ const config = response?.data;
+
+ if (!config && !config.hasOwnProperty("menuLinks")) {
+ console.error("Menu links not found");
+ return;
+ }
+
+ setMenuLinks(config?.menuLinks as MenuLink[])
+ } catch (error) {
+ console.error("Failed to retrieve config:", error);
+ }
+ },
+ [api]
+ )
+
+ useEffect(() => { getMenuLinks() }, []);
+ return (
+ (
+ WebBrowser.openBrowserAsync(item.url) }>
+ }
+ />
+
+ )
+ }
+ ItemSeparatorComponent={() => (
+
+ )}
+ ListEmptyComponent={
+
+ No links
+
+ }
+ />
+ );
+}
\ No newline at end of file
diff --git a/app/(auth)/(tabs)/_layout.tsx b/app/(auth)/(tabs)/_layout.tsx
index e717d16d..01e7ea73 100644
--- a/app/(auth)/(tabs)/_layout.tsx
+++ b/app/(auth)/(tabs)/_layout.tsx
@@ -18,6 +18,7 @@ import type {
TabNavigationState,
} from "@react-navigation/native";
import { SystemBars } from "react-native-edge-to-edge";
+import {useSettings} from "@/utils/atoms/settings";
export const NativeTabs = withLayoutContext<
BottomTabNavigationOptions,
@@ -27,6 +28,7 @@ export const NativeTabs = withLayoutContext<
>(Navigator);
export default function TabLayout() {
+ const [settings] = useSettings();
return (
<>
@@ -71,6 +73,17 @@ export default function TabLayout() {
: () => ({ sfSymbol: "rectangle.stack" }),
}}
/>
+ require("@/assets/icons/list.png")
+ : () => ({sfSymbol: "list.dash"}),
+ tabBarButton: (p) =>
+ settings?.showCustomMenuLinks == true ? undefined : null,
+ }}
+ />
>
);
diff --git a/assets/icons/list.png b/assets/icons/list.png
new file mode 100644
index 0000000000000000000000000000000000000000..3c548bb4cddcf48aef881e03b221ad530ca596ad
GIT binary patch
literal 2396
zcmeH}Yfuwc7>3U-TV`Rn
sDEO2vl&Ti$%#j=DLt7FfTtym?=
zYZXZjXP-xu70Wum%{jK-%z6M7xJ(KvwS1v3
z!XR{|wTl6)nbf3U6+p!l)6<9p(9~(6PKgmf%`Hj+uy*Sjq}2eg)rUMXBVoNssax0p
zc}(Gz2m>IVb5ea4$|2`hZ1w=KzR(ZIBLNmgIi?yD0DCk{%@3K7U_yv>1Dt$s^9CE)
zY*V+O*F~dIDfka-xRkF?_RyR9{iELZD^lzm3l?cgw`^TEnN%@k!XWaEhWQaBxTMHF;)|fE0#aKKR}U|o5v(GB()@tX
z3qi$a2sgA)PzRK7n}1LV55OxFijHxzcZz~g6)Tcwo%iSC@y{8LjK8`;Rn
zNYx=UHa2$VMyX3-Xpe3|^=t3=+toh3&RBYS`k0REuO35N=i**D=H^OlMe`4f*s`S4
zSv~eB_KXjTO%^a3D|GIVU1=b7uGp3!$@+vS^Rz{S;zJ}w4(M!n>0%zXn6)VmH2aeF
zW = ({ ...props }) => {
)}
+
+
+
+ Show Custom Menu Links
+
+ Show custom menu links defined inside your Jellyfin web config.json file
+
+
+ Linking.openURL("https://jellyfin.org/docs/general/clients/web-config/#custom-menu-links")
+ }
+ >
+ More info
+
+
+ updateSettings({ showCustomMenuLinks: value })}
+ />
+
diff --git a/utils/atoms/settings.ts b/utils/atoms/settings.ts
index 5d47c3dd..bb1f26ab 100644
--- a/utils/atoms/settings.ts
+++ b/utils/atoms/settings.ts
@@ -73,7 +73,8 @@ export type Settings = {
rewindSkipTime: number;
optimizedVersionsServerUrl?: string | null;
downloadMethod: "optimized" | "remux";
- autoDownload: boolean;
+ autoDownload: boolean,
+ showCustomMenuLinks: boolean;
};
const loadSettings = (): Settings => {
@@ -103,6 +104,7 @@ const loadSettings = (): Settings => {
optimizedVersionsServerUrl: null,
downloadMethod: "remux",
autoDownload: false,
+ showCustomMenuLinks: false,
};
try {