import { StyleProp, StyleSheet, View, ViewStyle } from "react-native"; import * as Progress from 'react-native-progress'; import { ThemedText } from "../ThemedText"; import { formatBytes } from "../utils/bytes"; interface Data { all: number; used: number; } interface ResourceProps { title: string; subtitle?: string; data: Data icon: any; style?: StyleProp; // 是否要转化单位 isFormatBytes?: boolean; } const ResourceComponent = (props: ResourceProps) => { return ( {props.title} {props.subtitle || " "} {props.icon} {props.isFormatBytes ? formatBytes(props.data.used) : props.data.used}/{props.isFormatBytes ? formatBytes(props.data.all) : props.data.all} ); }; const styles = StyleSheet.create({ container: { width: "100%", backgroundColor: "#FAF9F6", padding: 16, borderRadius: 18, }, header: { flexDirection: "row", justifyContent: "space-between", alignItems: "center", }, title: { fontSize: 12, fontWeight: "700", }, subtitle: { fontSize: 10, fontWeight: "400", }, dataContainer: { flexDirection: "column", }, dataText: { fontSize: 12, width: "100%", color: "#AC7E35", textAlign: "right", }, }) export default ResourceComponent;