/** * ShareTrackModal — share + QR co-listening (no backend) */ import { useState } from 'react'; import { View, Text, StyleSheet, Pressable, Modal, Alert, Share, Platform } from 'react-native'; import * as Clipboard from 'expo-clipboard'; import * as Haptics from 'expo-haptics'; import { BlurView } from 'expo-blur'; import { Image } from 'expo-image'; import Svg, { Path } from 'react-native-svg'; import { Colors, Font, Radius } from '../constants/theme'; import { Track, coverUrl } from '../services/api'; interface Props { track: Track; progress: number; visible: boolean; onClose: () => void; } function buildDeepLink(trackId: number, position: number) { return `burmalda://listen?tid=${trackId}&ts=${Math.floor(position)}`; } export default function ShareTrackModal({ track, progress, visible, onClose }: Props) { const [showQR, setShowQR] = useState(false); const cover = coverUrl(track.cover_url); const deepLink = buildDeepLink(track.id, progress); const shareText = `${track.artist} — ${track.title}\n${deepLink}`; const handleShare = async () => { Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light).catch(() => {}); try { await Share.share({ message: shareText, title: `${track.artist} — ${track.title}` }); } catch {} }; const handleCopy = async () => { Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light).catch(() => {}); try { await Clipboard.setStringAsync(deepLink); Alert.alert('Скопировано', 'Ссылка скопирована'); } catch {} }; return ( {cover ? : } {track.title} {track.artist} Поделиться Копировать Ссылка: {deepLink} Закрыть ); } const s = StyleSheet.create({ backdrop: { flex: 1 }, sheet: { borderTopLeftRadius: 24, borderTopRightRadius: 24, padding: 24, paddingBottom: 40, overflow: 'hidden', borderTopWidth: 1, borderColor: 'rgba(255,255,255,0.08)' }, handle: { width: 36, height: 4, borderRadius: 2, backgroundColor: 'rgba(255,255,255,0.3)', alignSelf: 'center', marginBottom: 20 }, trackRow: { flexDirection: 'row', alignItems: 'center', gap: 14, marginBottom: 24 }, cover: { width: 52, height: 52, borderRadius: Radius.sm }, title: { color: Colors.text, fontSize: Font.md, fontWeight: '700' }, artist: { color: 'rgba(255,255,255,0.55)', fontSize: Font.sm, marginTop: 2 }, actions: { flexDirection: 'row', gap: 10, marginBottom: 16 }, actionBtn: { flex: 1, alignItems: 'center', gap: 8, backgroundColor: 'rgba(255,255,255,0.08)', borderRadius: 14, paddingVertical: 16 }, actionLabel: { color: Colors.text, fontSize: 12, fontWeight: '600' }, hint: { color: 'rgba(255,255,255,0.3)', fontSize: 10, textAlign: 'center', marginBottom: 20 }, closeBtn: { paddingVertical: 14, alignItems: 'center', backgroundColor: 'rgba(255,255,255,0.08)', borderRadius: 14 }, closeTxt: { color: Colors.text, fontSize: Font.md, fontWeight: '600' }, });