mirror of
https://github.com/Jellify-Music/App.git
synced 2026-02-15 15:08:30 -06:00
building out artist navigation from the main home screen
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import { ScrollView } from "tamagui";
|
||||
import Avatar from "../helpers/avatar";
|
||||
|
||||
export default function Artist({ artistId }: { artistId: string }): React.JSX.Element {
|
||||
export default function Artist({ artistId, artistName }: { artistId: string, artistName: string }): React.JSX.Element {
|
||||
return (
|
||||
<ScrollView>
|
||||
<Avatar itemId={artistId}>
|
||||
{artistName}
|
||||
</Avatar>
|
||||
</ScrollView>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ScrollView, YStack } from "tamagui";
|
||||
import _ from "lodash";
|
||||
import { H2 } from "../helpers/text";
|
||||
import { H2, Text } from "../helpers/text";
|
||||
import RecentlyPlayed from "./helpers/recently-played";
|
||||
import { useApiClientContext } from "../jellyfin-api-provider";
|
||||
import RecentArtists from "./helpers/recent-artists";
|
||||
@@ -17,8 +17,25 @@ export default function Home(): React.JSX.Element {
|
||||
return (
|
||||
<HomeProvider>
|
||||
<Stack.Navigator id="Home" initialRouteName="Home">
|
||||
<Stack.Screen name="Home" component={ProvidedHome} />
|
||||
<Stack.Screen name="Artist" component={HomeArtistScreen} />
|
||||
<Stack.Screen
|
||||
name="Home"
|
||||
component={ProvidedHome}
|
||||
options={{
|
||||
headerShown: false
|
||||
}}
|
||||
/>
|
||||
|
||||
<Stack.Screen
|
||||
name="Artist"
|
||||
component={HomeArtistScreen}
|
||||
options={({ route }) => ({
|
||||
title: route.params.artistName,
|
||||
headerLargeTitle: true,
|
||||
headerLargeTitleStyle: {
|
||||
fontFamily: 'Aileron-Black'
|
||||
}
|
||||
})}
|
||||
/>
|
||||
</Stack.Navigator>
|
||||
</HomeProvider>
|
||||
);
|
||||
|
||||
@@ -25,12 +25,12 @@ export default function RecentArtists({ navigation }: ProvidedHomeProps): React.
|
||||
<ScrollView horizontal>
|
||||
{ recentArtists && recentArtists.map((recentArtist) => {
|
||||
return (
|
||||
<Button onPress={() => navigation.navigate('Artist', { artistId: recentArtist.Id! })}>
|
||||
<Button onPress={() => navigation.navigate('Artist', { artistId: recentArtist.Id!, artistName: recentArtist.Name ?? "Unknown Artist" })}>
|
||||
<YStack
|
||||
gap="$4"
|
||||
alignContent="center"
|
||||
justifyContent="center"
|
||||
padding="$3"
|
||||
marginHorizontal="$3"
|
||||
width="$10"
|
||||
>
|
||||
<Avatar circular size="$10">
|
||||
|
||||
@@ -3,7 +3,10 @@ import { NativeStackScreenProps } from "@react-navigation/native-stack";
|
||||
|
||||
export type HomeStackParamList = {
|
||||
Home: undefined;
|
||||
Artist: { artistId: string };
|
||||
Artist: {
|
||||
artistId: string,
|
||||
artistName: string
|
||||
};
|
||||
}
|
||||
|
||||
export type ProvidedHomeProps = NativeStackScreenProps<HomeStackParamList>;
|
||||
|
||||
28
components/helpers/avatar.tsx
Normal file
28
components/helpers/avatar.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Avatar as TamaguiAvatar } from "tamagui"
|
||||
import { Label, Text } from "./text"
|
||||
import { useApiClientContext } from "../jellyfin-api-provider"
|
||||
import { Colors } from "../../enums/colors";
|
||||
|
||||
interface AvatarProps {
|
||||
circular?: boolean | undefined;
|
||||
itemId: string;
|
||||
children: string;
|
||||
}
|
||||
|
||||
export default function Avatar(props: AvatarProps): React.JSX.Element {
|
||||
|
||||
const { server } = useApiClientContext();
|
||||
|
||||
return (
|
||||
<>
|
||||
<TamaguiAvatar
|
||||
circular={props.circular}
|
||||
size="$10"
|
||||
>
|
||||
<TamaguiAvatar.Image src={`${server!.url}/Items/${props.itemId!}/Images/Primary`} />
|
||||
<TamaguiAvatar.Fallback backgroundColor={Colors.Secondary}/>
|
||||
</TamaguiAvatar>
|
||||
<Label htmlFor={""} size={"$3"}>{props.children}</Label>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user