fix internal routing, and remove softlocking

This commit is contained in:
Boof2015
2026-07-25 11:12:02 -04:00
parent 098992639d
commit 0f34ca2e8d
33 changed files with 904 additions and 157 deletions
+14 -2
View File
@@ -126,6 +126,7 @@ export function CollapsingHeader({
heroExtra,
disabled,
onBack,
backLabel,
onMore,
onPlay,
onShuffle,
@@ -145,6 +146,8 @@ export function CollapsingHeader({
heroExtra?: ReactNode;
disabled?: boolean;
onBack: () => void;
/** Names the screen `onBack` returns to; must track the real action. */
backLabel: string;
onMore?: () => void;
onPlay: () => void;
onShuffle: () => void;
@@ -282,8 +285,17 @@ export function CollapsingHeader({
>
<Ionicons name="chevron-back" size={24} color={colors.textPrimary} />
</Pressable>
<Animated.Text style={[styles.label, { top: barCenterY - 10, left: spacing.md + 26 }, labelStyle]}>
Library
<Animated.Text
numberOfLines={1}
style={[
styles.label,
// Bounded so a long artist name ellipsizes instead of running off the
// edge; clears the overflow button when the screen has one.
{ top: barCenterY - 10, left: spacing.md + 26, right: onMore ? 56 : spacing.md },
labelStyle,
]}
>
{backLabel}
</Animated.Text>
<Animated.Text
+25 -14
View File
@@ -1,5 +1,6 @@
import { useState } from 'react';
import { useRouter } from 'expo-router';
import { usePathname } from 'expo-router';
import { useReturnToTabs } from '@/navigation/returnToTabs';
import {
AppSheet,
AppSheetItem,
@@ -42,13 +43,19 @@ function TrackActionsSheetInner({
initialStep = 'menu',
extraItems = [],
}: TrackActionsSheetProps & { track: DbTrack }) {
const router = useRouter();
// This sheet also renders from `recently-played` and from inside the
// now-playing overlay, i.e. while a root-stack sibling of `(tabs)` is focused,
// where a bare push would mint a second copy of the whole tab tree.
const returnToTabs = useReturnToTabs();
const pathname = usePathname();
const [step, setStep] = useState<'menu' | 'pickPlaylist'>(initialStep);
const groupingMode = useSettingsStore((s) => s.artistGroupingMode);
const isFavorite = usePlaylistStore((s) => s.favoritePaths.has(track.path));
const toggleFavorite = usePlaylistStore((s) => s.toggleFavorite);
const artistName = resolveNavigationArtist(track, groupingMode);
const albumHref = `/library/album/${encodeURIComponent(track.album_identity_key)}`;
const artistHref = `/library/artist/${encodeURIComponent(artistName)}`;
const closeAndRun = (run: () => void) => {
onClose();
@@ -79,24 +86,28 @@ function TrackActionsSheetInner({
label: 'View album',
icon: 'albums-outline',
onPress: () =>
closeAndRun(() =>
router.push({
pathname: '/library/album/[key]',
params: { key: track.album_identity_key },
})
),
closeAndRun(() => {
// Already here (this sheet also opens from the album screen itself):
// pushing would stack a duplicate of the current screen.
if (pathname === albumHref) return;
returnToTabs(
{ pathname: '/library/album/[key]', params: { key: track.album_identity_key } },
'push'
);
}),
},
{
key: 'view-artist',
label: 'View artist',
icon: 'person-outline',
onPress: () =>
closeAndRun(() =>
router.push({
pathname: '/library/artist/[name]',
params: { name: artistName },
})
),
closeAndRun(() => {
if (pathname === artistHref) return;
returnToTabs(
{ pathname: '/library/artist/[name]', params: { name: artistName } },
'push'
);
}),
},
{
key: 'favorite',