import React from 'react'; import { StyleSheet, Text, View, TouchableOpacity } from 'react-native'; interface SleepCardProps { sleepDuration?: number | null; style?: object; onPress?: () => void; } const SleepCard: React.FC = ({ sleepDuration, style, onPress }) => { const formatSleepDuration = (duration: number): string => { const hours = Math.floor(duration / 60); const minutes = Math.floor(duration % 60); return `${hours}小时${minutes}分钟`; }; const CardContent = ( 睡眠 {sleepDuration != null ? formatSleepDuration(sleepDuration) : '——'} ); if (onPress) { return ( {CardContent} ); } return CardContent; }; const styles = StyleSheet.create({ container: { // Container styles will be inherited from parent (FloatingCard) }, cardHeaderRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', }, cardTitle: { fontSize: 14, color: '#192126', }, sleepValue: { fontSize: 16, color: '#1E40AF', fontWeight: '700', marginTop: 8, }, }); export default SleepCard;