diff --git a/apps/android/src/ui/components.tsx b/apps/android/src/ui/components.tsx index 4e590cb..d0e2b2c 100644 --- a/apps/android/src/ui/components.tsx +++ b/apps/android/src/ui/components.tsx @@ -14,7 +14,7 @@ import { } from 'react-native' import { BlurTargetView, BlurView } from 'expo-blur' import Svg, { Defs, LinearGradient, Rect, Stop } from 'react-native-svg' -import { AlertCircle, ArrowLeft, ChevronRight, CircleCheck, RefreshCw, WifiOff, type LucideIcon } from 'lucide-react-native' +import { AlertCircle, ArrowLeft, ChevronDown, ChevronRight, CircleCheck, RefreshCw, WifiOff, type LucideIcon } from 'lucide-react-native' import { floatingShadow, radius, spacing, type } from './theme' import { useSafeAreaInsets } from 'react-native-safe-area-context' import { useTheme, type ThemeColors } from './theme-context' @@ -127,6 +127,8 @@ function VerticalFade({ from, to, style }: { from: number; to: number; style: St export function TopBar({ title, subtitle, + subtitleLabel, + subtitleAccessory, onSubtitlePress, onTitlePress, onBack, @@ -135,12 +137,16 @@ export function TopBar({ action, titleLines = 1, titleAccessory, + titleAlign = 'center', centered = false, }: { title: string titleAccessory?: ReactNode + titleAlign?: 'center' | 'left' | 'between' centered?: boolean | number subtitle?: string + subtitleLabel?: string + subtitleAccessory?: ReactNode onSubtitlePress?: () => void onTitlePress?: () => void onBack?: () => void @@ -156,7 +162,14 @@ export function TopBar({ const blurTarget = useContext(HeaderBlurTargetContext) const styles = useThemedStyles(createStyles) const hasSubtitle = subtitle !== undefined && subtitle.length > 0 - const tallerBar = hasSubtitle || titleLines > 1 + const leftAligned = titleAlign === 'left' + const betweenAligned = titleAlign === 'between' + const compactHeader = leftAligned || betweenAligned + const tallerBar = (!compactHeader && hasSubtitle) || titleLines > 1 + const showLeadingSide = !compactHeader || onBack !== undefined + const showTrailingSide = !compactHeader || (action !== undefined && action !== null) + const titleRowHitSlop = compactHeader && hasSubtitle ? { top: 10, bottom: 2, left: 6, right: 6 } : 4 + const subtitleRowHitSlop = compactHeader ? { top: 2, bottom: 10, left: 6, right: 6 } : 4 return ( )} - - {onBack !== undefined && ( - - - - - - )} - - + {showLeadingSide && ( + + {onBack !== undefined && ( + + + + + + )} + + )} + {onTitlePress === undefined - ? {title} + ? {title} : ( [styles.topBarTitleRow, pressed && styles.iconButtonPressed]} + hitSlop={titleRowHitSlop} + style={({ pressed }) => [ + compactHeader ? styles.topBarTitleRowCompact : styles.topBarTitleRow, + betweenAligned && styles.topBarTitleRowBetween, + compactHeader && !hasSubtitle && styles.topBarTitleRowCompactSingle, + pressed && styles.iconButtonPressed, + ]} > - {title} + {title} {titleAccessory} )} {hasSubtitle && ( onSubtitlePress === undefined - ? {subtitle} + ? {subtitle} : ( [styles.topBarSubtitleRow, pressed && styles.iconButtonPressed]} + hitSlop={subtitleRowHitSlop} + style={({ pressed }) => [ + compactHeader ? styles.topBarSubtitleRowCompact : styles.topBarSubtitleRow, + betweenAligned && styles.topBarSubtitleRowBetween, + pressed && styles.iconButtonPressed, + ]} > - {subtitle} - + {subtitle} + {subtitleAccessory ?? (compactHeader ? : )} ) )} - - {action !== undefined && action !== null && ( - - {action} - - )} - + {showTrailingSide && ( + + {action !== undefined && action !== null && ( + + {action} + + )} + + )} ) } @@ -585,6 +619,9 @@ function createStyles(colors: ThemeColors) { topBarTrailing: { justifyContent: 'flex-end' }, topBarActions: { paddingHorizontal: 2, gap: 0 }, topBarTitles: { flex: 1, minWidth: 0, alignItems: 'center', justifyContent: 'center', paddingHorizontal: spacing.xs, gap: 1 }, + topBarTitlesCompact: { gap: 2 }, + topBarTitlesLeft: { alignItems: 'flex-start', paddingLeft: spacing.sm, paddingRight: spacing.xs }, + topBarTitlesBetween: { alignItems: 'center', paddingHorizontal: spacing.sm }, topBarTitle: { ...type.heading, fontSize: 17, @@ -594,10 +631,19 @@ function createStyles(colors: ThemeColors) { fontWeight: '700', letterSpacing: -0.2, }, + topBarTitleCompact: { fontSize: 15.5, lineHeight: 20 }, + topBarTitleLeft: { textAlign: 'left' }, topBarTitleLink: { flexShrink: 1 }, topBarTitleRow: { alignSelf: 'stretch', minHeight: 48, maxWidth: '100%', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', paddingHorizontal: spacing.xs, borderRadius: radius.pill }, + topBarTitleRowCompact: { alignSelf: 'flex-start', maxWidth: '100%', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', borderRadius: radius.sm }, + topBarTitleRowBetween: { alignSelf: 'center', justifyContent: 'center' }, + topBarTitleRowCompactSingle: { minHeight: 40 }, topBarSubtitleRow: { maxWidth: '100%', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 1, paddingHorizontal: spacing.xs, borderRadius: radius.pill }, + topBarSubtitleRowCompact: { alignSelf: 'flex-start', maxWidth: '100%', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-start', gap: 3, borderRadius: radius.sm }, + topBarSubtitleRowBetween: { alignSelf: 'center', justifyContent: 'center', paddingLeft: 13 }, topBarSubtitle: { ...type.caption, color: colors.muted, textAlign: 'center', flexShrink: 1 }, + topBarSubtitleCompact: { fontSize: 12, lineHeight: 16 }, + topBarSubtitleLeft: { textAlign: 'left' }, iconButton: { width: 48, height: 48, borderRadius: radius.pill, alignItems: 'center', justifyContent: 'center' }, iconButtonDense: { width: 40, height: 40 }, iconButtonInChip: { width: 40, height: 40 },