import React from "react";
import {
View,
Text,
Modal,
TouchableOpacity,
Animated,
StyleSheet,
ScrollView,
useWindowDimensions,
} from "react-native";
import { Ionicons } from "@expo/vector-icons";
import type { VideoItem } from "../services/types";
import { useTheme } from "../utils/theme";
import { formatCount, formatTime } from "../utils/format";
import { useSheetTransition } from "../utils/useSheetTransition";
interface Props {
visible: boolean;
onClose: () => void;
/** Sheet 顶部对齐到屏幕的绝对 Y(一般是播放器底部) */
topOffset: number;
video: VideoItem | null;
}
export function DescriptionSheet({ visible, onClose, topOffset, video }: Props) {
const theme = useTheme();
const { height } = useWindowDimensions();
const sheetH = Math.max(120, height - topOffset);
const { rendered, slideAnim } = useSheetTransition(visible, sheetH);
if (!rendered || !video) return null;
const stat = video.stat;
return (
简介
{video.title}
{!!video.tname && (
{video.tname}
)}
{!!video.pubdate && (
发布于 {formatTime(video.pubdate)}
)}
{!!stat && (
)}
{video.desc?.trim() || "暂无简介"}
);
}
function StatCell({
label,
value,
theme,
}: {
label: string;
value: number;
theme: ReturnType;
}) {
return (
{formatCount(value ?? 0)}
{label}
);
}
const styles = StyleSheet.create({
sheet: {
position: "absolute",
left: 0,
right: 0,
bottom: 0,
borderTopLeftRadius: 12,
borderTopRightRadius: 12,
overflow: "hidden",
},
header: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
paddingHorizontal: 20,
paddingTop: 14,
paddingBottom: 10,
borderBottomWidth: StyleSheet.hairlineWidth,
},
headerTitle: { fontSize: 16, fontWeight: "700" },
closeBtn: { padding: 4 },
body: { padding: 20, paddingBottom: 40 },
title: { fontSize: 17, fontWeight: "700", lineHeight: 24, marginBottom: 10 },
tnameBadge: {
alignSelf: "flex-start",
backgroundColor: "rgba(0,174,236,0.12)",
borderRadius: 4,
paddingHorizontal: 8,
paddingVertical: 3,
marginBottom: 10,
},
tnameText: { fontSize: 12, color: "#00AEEC" },
pubdate: { fontSize: 12, marginBottom: 14 },
statGrid: {
flexDirection: "row",
flexWrap: "wrap",
marginVertical: 4,
},
statCell: { width: "33.333%", alignItems: "center", paddingVertical: 8 },
statValue: { fontSize: 15, fontWeight: "700" },
statLabel: { fontSize: 11, marginTop: 2 },
descDivider: { height: StyleSheet.hairlineWidth, marginVertical: 16 },
descText: { fontSize: 14, lineHeight: 22 },
});