import type { ReactNode } from 'react';
import { Pressable, StyleSheet, Text, View } from 'react-native';
import { AppIcon } from './app-icon';
import { colors, fonts, m3Colors, spacing } from '../theme/proulr-theme';
export function ListItem({
avatar,
title,
subtitle,
trailing,
onPress,
showDivider,
showChevron,
}: {
avatar?: ReactNode;
title: string;
subtitle?: string;
trailing?: ReactNode;
onPress?: () => void;
showDivider?: boolean;
showChevron?: boolean;
}) {
const navChevron = onPress && showChevron !== false && !trailing;
const inner = (
<>
{avatar ? {avatar} : null}
{title}
{subtitle ? (
{subtitle}
) : null}
{navChevron ? : null}
{trailing ? {trailing} : null}
>
);
if (onPress) {
return (
{inner}
);
}
return {inner};
}
const styles = StyleSheet.create({
listItem: {
flexDirection: 'row',
alignItems: 'center',
gap: spacing.md,
paddingVertical: spacing.md,
},
listItemDivider: {
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: colors.border,
},
listAvatar: {},
listContent: { flex: 1 },
listTitle: { color: colors.textPrimary, fontSize: 15, fontFamily: fonts.semibold },
listSubtitle: { color: colors.textSecondary, fontSize: 13, marginTop: 2 },
listTrailing: { alignItems: 'flex-end' },
});