import React from "react"; import { Pressable, StyleSheet, Text, View, type StyleProp, type TextStyle, type ViewStyle, } from "react-native"; type Props = { activeOpacity?: number; title?: string | Element; subtitle?: string | Element; titleNumberOfLines?: number; containerStyle?: StyleProp; contentStyle?: StyleProp; titleStyle?: StyleProp; subtitleStyle?: StyleProp; rightStyle?: StyleProp; /** * If true, disable all interactions for this component. */ touchDisabled?: boolean; onPress?(): void; onLongPress?(): void; right?(): JSX.Element | undefined; }; export const SimpleItem = (props: Props) => { const activeOpacity = props.activeOpacity ?? 0.4; const titleNumberOfLines = props.titleNumberOfLines ?? 1; const touchDisabled = props.touchDisabled ?? false; const renderContent = () => ( <> {props.title} {!!props.subtitle && ( {props.subtitle} )} {!!props.right && ( {props.right()} )} ); return ( [ styles.container, props.containerStyle, { opacity: pressed ? activeOpacity : 1 }, ]} > {renderContent()} ); }; const styles = StyleSheet.create({ container: { backgroundColor: "white", justifyContent: "center", height: 56, }, content: { flexDirection: "row", }, flexContent: { flex: 1, paddingHorizontal: 16, }, title: { color: "rgba(0, 0, 0, .87)", fontSize: 16, }, subtitle: { color: "rgba(0, 0, 0, .54)", fontSize: 14, }, right: { alignItems: "center", justifyContent: "center", width: 48, }, }); export default SimpleItem;