From 9201deb24b782cb9806eb6bd6573018c3db2f6f5 Mon Sep 17 00:00:00 2001 From: Violet Caulfield Date: Fri, 24 Jan 2025 05:39:07 -0600 Subject: [PATCH] itemdetail stuff --- components/Global/components/track.tsx | 4 +-- components/ItemDetail/component.tsx | 30 +++++++++++-------- .../ItemDetail/helpers/TrackOptions.tsx | 20 +++++-------- components/ItemDetail/screen.tsx | 2 +- components/Player/screens/index.tsx | 2 +- components/types.tsx | 2 +- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/components/Global/components/track.tsx b/components/Global/components/track.tsx index 044534b9..48f71cd1 100644 --- a/components/Global/components/track.tsx +++ b/components/Global/components/track.tsx @@ -67,7 +67,7 @@ export default function Track({ onLongPress={() => { navigation.push("Details", { item: track, - isModal: false + isNested: false }) }} paddingVertical={"$2"} @@ -150,7 +150,7 @@ export default function Track({ { navigation.push("Details", { item: track, - isModal: false + isNested: false }); }} /> diff --git a/components/ItemDetail/component.tsx b/components/ItemDetail/component.tsx index f7bf83cf..cb6fa9ce 100644 --- a/components/ItemDetail/component.tsx +++ b/components/ItemDetail/component.tsx @@ -8,24 +8,32 @@ import BlurhashedImage from "../Global/helpers/blurhashed-image"; import { Text } from "../Global/helpers/text"; import { Colors } from "../../enums/colors"; import FavoriteButton from "../Global/components/favorite-button"; +import { useEffect } from "react"; +import { trigger } from "react-native-haptic-feedback"; export default function ItemDetail({ item, navigation, - isModal = false + isNested } : { item: BaseItemDto, navigation: NativeStackNavigationProp, - isModal: boolean + isNested?: boolean | undefined }) : React.JSX.Element { let options: React.JSX.Element | undefined = undefined; + useEffect(() => { + trigger("impactMedium"); + }, [ + item + ]); + const { width } = useSafeAreaFrame(); switch (item.Type) { case "Audio": { - options = TrackOptions({ item, navigation, isModal }); + options = TrackOptions({ item, navigation, isNested }); break; } @@ -72,17 +80,13 @@ export default function ItemDetail({ onPress={() => { if (item.ArtistItems) { - if (isModal) - navigation.navigate("Artist", { - artist: item.ArtistItems[0] - }) - - else { + if (isNested) navigation.goBack(); - navigation.push("Artist", { - artist: item.ArtistItems[0] - }); - } + + navigation.goBack(); + navigation.push("Artist", { + artist: item.ArtistItems[0] + }); } }}> { item.Artists?.join(", ") ?? "Unknown Artist"} diff --git a/components/ItemDetail/helpers/TrackOptions.tsx b/components/ItemDetail/helpers/TrackOptions.tsx index 6d2030a9..24eccab1 100644 --- a/components/ItemDetail/helpers/TrackOptions.tsx +++ b/components/ItemDetail/helpers/TrackOptions.tsx @@ -8,11 +8,11 @@ import { XStack } from "tamagui"; export default function TrackOptions({ item, navigation, - isModal = false, + isNested } : { item: BaseItemDto, navigation: NativeStackNavigationProp, - isModal: boolean + isNested: boolean | undefined// Whether this is nested in the player modal }) : React.JSX.Element { const { data: album, isSuccess } = useItem(item.AlbumId ?? "") @@ -24,17 +24,13 @@ export default function TrackOptions({ name="music-box" onPress={() => { - if (isModal) { - navigation.navigate("Album", { - album - }); - } else { - + if (isNested) navigation.goBack(); - navigation.push("Album", { - album - }); - } + + navigation.goBack(); + navigation.push("Album", { + album + }); }} /> )} diff --git a/components/ItemDetail/screen.tsx b/components/ItemDetail/screen.tsx index a63f3d4e..76ff7428 100644 --- a/components/ItemDetail/screen.tsx +++ b/components/ItemDetail/screen.tsx @@ -15,7 +15,7 @@ export default function DetailsScreen({ ) } \ No newline at end of file diff --git a/components/Player/screens/index.tsx b/components/Player/screens/index.tsx index d440a488..ea85d4d1 100644 --- a/components/Player/screens/index.tsx +++ b/components/Player/screens/index.tsx @@ -132,7 +132,7 @@ export default function PlayerScreen({ navigation }: { navigation: NativeStackNa onPress={() => { navigation.navigate("Details", { item: nowPlaying!.item, - isModal: true + isNested: true }); }} /> diff --git a/components/types.tsx b/components/types.tsx index 6aaf58a2..7e5d35bd 100644 --- a/components/types.tsx +++ b/components/types.tsx @@ -35,7 +35,7 @@ export type StackParamList = { }; Details: { item: BaseItemDto, - isModal: boolean + isNested: boolean | undefined } }