import { StyleSheet, View } from 'react-native'; import React, { ComponentProps } from 'react'; import { Icon, IconName, Typo } from '../../foundation'; import { SCREEN_HEADER_HEIGHT } from './utils'; import { PressableThrottled } from '../utils/PressableThrottled'; import { ContainerBottomDivider } from '../utils/ContainerBottomDivider'; interface Props { /** 'modal 기본값 'card' */ type: 'card' | 'modal'; title?: string; onPressClose: () => void; TitleSlotComponent?: React.ReactNode; /** 전달하지 않으면 닫기버튼 렌더 */ LeftSlotComponent?: React.ReactNode; /** 전달하지 않으면 닫기버튼 렌더 */ RightSlotComponent?: React.ReactNode; color?: ComponentProps['color']; showDivider: boolean; /** @deprecated 디자인 스펙에 없는 옵션 */ hideCloseButton?: boolean; } // 시각적 보정을 위해 좌우 여백이 다른 값을 갖도록 디자인 됨 const MARGIN_LEFT = 12; const MARGIN_RIGHT = 16; /** * ScreenHeader 컴포넌트의 기본 틀 * * 좌우 패딩은 본래 16이 되어야 하나, Icon 리소스가 여백을 포함하으로 시각적 조정을 위해 12로 디자인됨. * 텍스트 버튼처럼 여백이 포함되지 않은 요소에는 추가 여백을 부여하도록 디자인 될 수 있음 */ export function ScreenHeaderBase(props: Props): React.JSX.Element { return ( {/* 좌측 뷰 */} {props.LeftSlotComponent ? ( props.LeftSlotComponent ) : ( )} {/* 중앙 타이틀*/} {props.TitleSlotComponent ? ( props.TitleSlotComponent ) : ( {props.title ?? ''} )} {/* 우측 뷰 */} {props.RightSlotComponent ? ( props.RightSlotComponent ) : ( )} {props.showDivider && } ); } // 닫기/뒤로가기 버튼 function CloseIconButton( props: Pick, ): React.JSX.Element | null { if (props.hideCloseButton) { return null; } const closeIconName: IconName = props.type === 'card' ? 'chevron_left_outlined' : 'x_outlined'; return ( ); } const styles = StyleSheet.create({ container: { height: SCREEN_HEADER_HEIGHT, flexDirection: 'row', gap: 8, }, titleView: { flex: 1, alignItems: 'center', justifyContent: 'center', }, sideView: { width: 68, flexDirection: 'row', alignItems: 'center', }, });