// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React, {useMemo} from 'react'; import {Text} from 'react-native'; import Animated, {useAnimatedStyle} from 'react-native-reanimated'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {typography} from '@utils/typography'; type Props = { defaultHeight: number; hasSearch: boolean; largeHeight: number; scrollValue?: Animated.SharedValue; subtitle?: string; theme: Theme; title: string; top: number; } const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ container: { backgroundColor: theme.sidebarBg, paddingHorizontal: 20, }, heading: { ...typography('Heading', 800), color: theme.sidebarHeaderTextColor, }, subHeading: { ...typography('Heading', 200, 'Regular'), color: changeOpacity(theme.sidebarHeaderTextColor, 0.8), }, })); const NavigationHeaderLargeTitle = ({ defaultHeight, largeHeight, hasSearch, scrollValue, subtitle, theme, title, top, }: Props) => { const styles = getStyleSheet(theme); const transform = useAnimatedStyle(() => { return { transform: [{translateY: -(top + (scrollValue?.value || 0))}], }; }, [top]); const containerStyle = useMemo(() => { return [{height: largeHeight - defaultHeight}, styles.container]; }, [defaultHeight, largeHeight, theme]); return ( {title} {!hasSearch && Boolean(subtitle) && {subtitle} } ); }; export default NavigationHeaderLargeTitle;