import React from 'react'; import { type StyleProp, StyleSheet, type TextStyle, View, type ViewStyle, } from 'react-native'; import { moderateScale } from 'react-native-size-matters'; import ATypography from '../TTypography/TTypography'; import { TypographyVariant } from '../TTypography/TTypographyEnum'; import { withTheme, useTheme } from '../../core/theming'; import type { Theme } from '../../utils/types'; import { defaultScale } from '../../utils/Common'; type Props = React.ComponentPropsWithRef & { title: React.ReactNode; titleStyle?: StyleProp; titleNumberOfLines?: number; subtitle?: React.ReactNode; subtitleStyle?: StyleProp; subtitleNumberOfLines?: number; left?: (props: { size: number }) => React.ReactNode; leftStyle?: StyleProp; right?: (props: { size: number }) => React.ReactNode; rightStyle?: StyleProp; style?: StyleProp; theme: Theme; }; const LEFT_RIGHT_SIZE = moderateScale(40, defaultScale); const CardTitle = ({ title, titleStyle, titleNumberOfLines = 1, subtitle, subtitleStyle, subtitleNumberOfLines = 1, left, leftStyle, right, rightStyle, style, }: Props): any => { const { colors } = useTheme(); const stylesWithProp = styles({ colors }); return ( {left ? ( {left({ size: LEFT_RIGHT_SIZE, })} ) : null} {title && ( {title} )} {subtitle && ( {subtitle} )} {right ? ( {right({ size: LEFT_RIGHT_SIZE, })} ) : null} ); }; CardTitle.displayName = 'Card.Title'; const styles = (props: { colors: any }) => StyleSheet.create({ container: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: moderateScale(16, defaultScale), paddingTop: moderateScale(16, defaultScale), paddingBottom: moderateScale(8, defaultScale), backgroundColor: props.colors.background, }, left: { justifyContent: 'center', marginRight: moderateScale(10, defaultScale), height: LEFT_RIGHT_SIZE, width: LEFT_RIGHT_SIZE, backgroundColor: props.colors.background, }, right: { justifyContent: 'center', marginLeft: moderateScale(10, defaultScale), height: LEFT_RIGHT_SIZE, width: LEFT_RIGHT_SIZE, backgroundColor: props.colors.background, }, titles: { flex: 1, flexDirection: 'column', justifyContent: 'center', }, title: { color: props.colors.textColor, }, subtitle: { color: props.colors.textColor, marginTop: moderateScale(8, defaultScale), }, }); export default withTheme(CardTitle);