| 1 | import { SymbolView } from "../components/AppSymbol"; |
| 2 | import { Image, type ImageStyle, type StyleProp } from "react-native"; |
| 3 | |
| 4 | import { markdownFileIconSource } from "../lib/markdownFileIcons"; |
| 5 | import { resolveMarkdownFileIcon } from "../lib/markdownLinks"; |
| 6 | |
| 7 | export function PierreEntryIcon(props: { |
| 8 | readonly path: string; |
| 9 | readonly kind: "file" | "directory"; |
| 10 | readonly size?: number; |
| 11 | readonly style?: StyleProp<ImageStyle>; |
| 12 | }) { |
| 13 | const size = props.size ?? 16; |
| 14 | if (props.kind === "directory") { |
| 15 | return ( |
| 16 | <SymbolView |
| 17 | name="folder" |
| 18 | size={size} |
| 19 | tintColorClassName={"accent-icon-subtle"} |
| 20 | type="monochrome" |
| 21 | /> |
| 22 | ); |
| 23 | } |
| 24 | |
| 25 | return ( |
| 26 | <Image |
| 27 | source={markdownFileIconSource(resolveMarkdownFileIcon(props.path))} |
| 28 | resizeMode="contain" |
| 29 | style={[{ width: size, height: size }, props.style]} |
| 30 | /> |
| 31 | ); |
| 32 | } |