- Replace mobile placeholder with Expo Router app (tabs, playback, auth, library) - Move Convex backend to @otunes/convex for web and mobile reuse - Update web app imports and API routes to use shared package
112 lines
3.1 KiB
TypeScript
112 lines
3.1 KiB
TypeScript
import { Ionicons } from "@expo/vector-icons"
|
|
import { Modal, Pressable, StyleSheet, Text, View } from "react-native"
|
|
|
|
import { useThemeColors, spacing, radius } from "@/lib/theme"
|
|
|
|
export type MediaAction =
|
|
| "playlist"
|
|
| "play-next"
|
|
| "play-last"
|
|
| "shuffle"
|
|
| "favorite"
|
|
| "go-artist"
|
|
| "go-album"
|
|
|
|
export function MediaActionsSheet({
|
|
visible,
|
|
title,
|
|
selectedCount = 1,
|
|
favorited,
|
|
showFavorite = true,
|
|
showNavigation = false,
|
|
onClose,
|
|
onAction,
|
|
}: {
|
|
visible: boolean
|
|
title: string
|
|
selectedCount?: number
|
|
favorited?: boolean
|
|
showFavorite?: boolean
|
|
showNavigation?: boolean
|
|
onClose: () => void
|
|
onAction: (action: MediaAction) => void
|
|
}) {
|
|
const colors = useThemeColors()
|
|
|
|
const items: { action: MediaAction; label: string; icon: keyof typeof Ionicons.glyphMap }[] = [
|
|
{ action: "playlist", label: `Add to Playlist${selectedCount > 1 ? ` (${selectedCount})` : ""}`, icon: "list" },
|
|
{ action: "play-next", label: `Play Next${selectedCount > 1 ? ` (${selectedCount})` : ""}`, icon: "arrow-down-circle-outline" },
|
|
{ action: "play-last", label: `Play Last${selectedCount > 1 ? ` (${selectedCount})` : ""}`, icon: "arrow-up-circle-outline" },
|
|
{ action: "shuffle", label: `Shuffle${selectedCount > 1 ? ` (${selectedCount})` : ""}`, icon: "shuffle" },
|
|
]
|
|
|
|
if (showFavorite) {
|
|
items.push({
|
|
action: "favorite",
|
|
label: favorited ? "Remove from Favorites" : "Add to Favorites",
|
|
icon: favorited ? "star" : "star-outline",
|
|
})
|
|
}
|
|
|
|
if (showNavigation) {
|
|
items.push(
|
|
{ action: "go-artist", label: "Go to Artist", icon: "person" },
|
|
{ action: "go-album", label: "Go to Album", icon: "disc" }
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Modal visible={visible} transparent animationType="fade" onRequestClose={onClose}>
|
|
<Pressable style={styles.overlay} onPress={onClose}>
|
|
<Pressable
|
|
style={[styles.sheet, { backgroundColor: colors.card, borderColor: colors.border }]}
|
|
onPress={(event) => event.stopPropagation()}
|
|
>
|
|
<Text style={[styles.title, { color: colors.foreground }]} numberOfLines={2}>
|
|
{title}
|
|
</Text>
|
|
{items.map((item) => (
|
|
<Pressable
|
|
key={item.action}
|
|
style={styles.row}
|
|
onPress={() => {
|
|
onAction(item.action)
|
|
onClose()
|
|
}}
|
|
>
|
|
<Ionicons name={item.icon} size={20} color={colors.foreground} />
|
|
<Text style={{ color: colors.foreground, fontSize: 16 }}>{item.label}</Text>
|
|
</Pressable>
|
|
))}
|
|
</Pressable>
|
|
</Pressable>
|
|
</Modal>
|
|
)
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
overlay: {
|
|
flex: 1,
|
|
backgroundColor: "rgba(0,0,0,0.45)",
|
|
justifyContent: "flex-end",
|
|
},
|
|
sheet: {
|
|
borderTopLeftRadius: radius.lg,
|
|
borderTopRightRadius: radius.lg,
|
|
borderWidth: 1,
|
|
padding: spacing.lg,
|
|
gap: spacing.xs,
|
|
},
|
|
title: {
|
|
fontSize: 16,
|
|
fontWeight: "700",
|
|
marginBottom: spacing.sm,
|
|
},
|
|
row: {
|
|
flexDirection: "row",
|
|
alignItems: "center",
|
|
gap: spacing.md,
|
|
paddingVertical: spacing.md,
|
|
},
|
|
})
|