79 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-11-09 18:57:36 +00:00
import { View, Text, Button, Card, XStack } from "tamagui";
import React from "react";
import { MultiTapPressable } from "@/components/ui/pressable";
import Icons from "@/components/ui/icons";
import OSIcons from "@/components/ui/os-icons";
type HostItemProps = {
host: any;
2024-11-16 23:50:02 +07:00
selected?: boolean;
2024-11-09 18:57:36 +00:00
onMultiTap: () => void;
2024-11-16 23:50:02 +07:00
onTap?: () => void;
2024-11-09 18:57:36 +00:00
onEdit?: (() => void) | null;
};
2024-11-16 23:50:02 +07:00
const HostItem = ({
host,
selected,
onMultiTap,
onTap,
onEdit,
}: HostItemProps) => {
2024-11-09 18:57:36 +00:00
return (
<MultiTapPressable
cursor="pointer"
group
numberOfTaps={2}
onMultiTap={onMultiTap}
onTap={onTap}
>
2024-11-16 23:50:02 +07:00
<Card
bordered
p="$4"
borderColor={selected ? "$blue8" : "$borderColor"}
bg={selected ? "$blue3" : undefined}
>
2024-11-09 18:57:36 +00:00
<XStack>
2024-11-16 23:50:02 +07:00
{host.type === "group" ? (
<Icons name="package-variant-closed" size={18} mr="$2" mt="$1" />
) : (
<OSIcons
name={host.os}
size={18}
mr="$2"
mt="$1"
fallback="desktop-classic"
/>
)}
2024-11-09 18:57:36 +00:00
<View flex={1}>
<Text>{host.label}</Text>
<Text fontSize="$3" mt="$2">
{host.host}
</Text>
</View>
{onEdit != null && (
<Button
circular
2024-11-12 19:15:13 +07:00
opacity={0}
$sm={{ opacity: 1 }}
$group-hover={{ opacity: 1 }}
animation="quick"
animateOnly={["opacity"]}
2024-11-09 18:57:36 +00:00
onPress={(e) => {
e.stopPropagation();
onEdit();
}}
>
<Icons name="pencil" size={16} />
</Button>
)}
</XStack>
</Card>
</MultiTapPressable>
);
};
export default HostItem;