import type { ReactNode } from "react";
import { Ionicons } from "@expo/vector-icons";
import { Pressable, ScrollView, View } from "react-native";
import { Text } from "@/components/ui/Text";
import { colors, radii, space } from "@/lib/theme";
export function Chip({
label,
selected,
onPress,
onRemove,
icon,
tone = "default",
size = "md",
}: {
label: string;
selected?: boolean;
onPress?: () => void;
onRemove?: () => void;
icon?: keyof typeof Ionicons.glyphMap;
tone?: "default" | "outline";
size?: "sm" | "md";
}) {
const bg = selected ? colors.brand : tone === "outline" ? "transparent" : colors.surface;
const fg = selected ? colors.ink : colors.muted;
const border = selected ? colors.brand : colors.line;
return (
({
flexDirection: "row",
alignItems: "center",
gap: 6,
paddingVertical: size === "sm" ? 6 : 9,
paddingHorizontal: size === "sm" ? 10 : 14,
borderRadius: radii.pill,
backgroundColor: bg,
borderWidth: 1,
borderColor: border,
opacity: pressed ? 0.8 : 1,
})}
>
{icon ? : null}
{label}
{onRemove ? (
) : null}
);
}
/** Horizontally scrolling chip strip that bleeds to the screen edge. */
export function ChipRow({
children,
gutters = 20,
}: {
children: ReactNode;
gutters?: number;
}) {
return (
{children}
);
}
/** Read-only meta tag, e.g. "Tablet" or "Qty: 100". */
export function MetaTag({
label,
icon,
}: {
label: string;
icon?: keyof typeof Ionicons.glyphMap;
}) {
return (
{icon ? : null}
{label}
);
}
export function Segmented({
options,
value,
onChange,
}: {
options: { value: T; label: string }[];
value: T;
onChange: (value: T) => void;
}) {
return (
{options.map((option) => {
const active = option.value === value;
return (
onChange(option.value)}
style={{
flex: 1,
alignItems: "center",
paddingVertical: 10,
borderRadius: radii.pill,
backgroundColor: active ? colors.surface : "transparent",
}}
>
{option.label}
);
})}
);
}