-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# 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
- Loading branch information
herrrta
committed
Nov 29, 2024
1 parent
5292d89
commit 3797a2a
Showing
6 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {Stack} from "expo-router"; | ||
import { Platform } from "react-native"; | ||
|
||
export default function CustomMenuLayout() { | ||
return ( | ||
<Stack> | ||
<Stack.Screen | ||
name="index" | ||
options={{ | ||
headerShown: true, | ||
headerLargeTitle: true, | ||
headerTitle: "Custom Links", | ||
headerBlurEffect: "prominent", | ||
headerTransparent: Platform.OS === "ios", | ||
headerShadowVisible: false, | ||
}} | ||
/> | ||
</Stack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MenuLink[]>([]) | ||
|
||
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 ( | ||
<FlatList | ||
contentInsetAdjustmentBehavior="automatic" | ||
contentContainerStyle={{ | ||
paddingTop: 10, | ||
paddingLeft: insets.left, | ||
paddingRight: insets.right, | ||
}} | ||
data={menuLinks} | ||
renderItem={({item}) => ( | ||
<TouchableOpacity onPress={() => WebBrowser.openBrowserAsync(item.url) }> | ||
<ListItem | ||
title={item.name} | ||
iconAfter={<Ionicons name="link" size={24} color="white"/>} | ||
/> | ||
</TouchableOpacity> | ||
) | ||
} | ||
ItemSeparatorComponent={() => ( | ||
<View | ||
style={{ | ||
width: 10, | ||
height: 10, | ||
}}/> | ||
)} | ||
ListEmptyComponent={ | ||
<View className="flex flex-col items-center justify-center h-full"> | ||
<Text className="font-bold text-xl text-neutral-500">No links</Text> | ||
</View> | ||
} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters