import { HeaderCenter, HeaderLeft } from '@components/Header' import { ParseEmojis } from '@components/Parse' import { StackNavigationState, TypedNavigator } from '@react-navigation/native' import { StackScreenProps } from '@react-navigation/stack' import TabSharedAccount from '@screens/Tabs/Shared/Account' import TabSharedAttachments from '@screens/Tabs/Shared/Attachments' import TabSharedHashtag from '@screens/Tabs/Shared/Hashtag' import TabSharedRelationships from '@screens/Tabs/Shared/Relationships' import TabSharedSearch from '@screens/Tabs/Shared/Search' import TabSharedToot from '@screens/Tabs/Shared/Toot' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' import { debounce } from 'lodash' import React, { useCallback, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' import { Platform, StyleSheet, Text, View } from 'react-native' import { TextInput } from 'react-native-gesture-handler' import { NativeStackNavigationEventMap, NativeStackNavigationOptions, NativeStackNavigatorProps } from 'react-native-screens/lib/typescript/types' export type BaseScreens = | Nav.TabLocalStackParamList | Nav.TabPublicStackParamList | Nav.TabNotificationsStackParamList | Nav.TabMeStackParamList export type SharedAccountProp = StackScreenProps< BaseScreens, 'Tab-Shared-Account' > export type SharedAttachmentsProp = StackScreenProps< BaseScreens, 'Tab-Shared-Attachments' > export type SharedHashtagProp = StackScreenProps< BaseScreens, 'Tab-Shared-Hashtag' > export type SharedRelationshipsProp = StackScreenProps< BaseScreens, 'Tab-Shared-Relationships' > export type SharedSearchProp = StackScreenProps< BaseScreens, 'Tab-Shared-Search' > export type SharedTootProp = StackScreenProps const sharedScreens = ( Stack: TypedNavigator< BaseScreens, StackNavigationState>, NativeStackNavigationOptions, NativeStackNavigationEventMap, ({ initialRouteName, children, screenOptions, ...rest }: NativeStackNavigatorProps) => JSX.Element > ) => { const { theme } = useTheme() const { t } = useTranslation() const [searchTerm, setSearchTerm] = useState() const onChangeText = useCallback( debounce(text => setSearchTerm(text), 1000, { trailing: true }), [] ) return [ { return { headerTranslucent: true, headerStyle: { backgroundColor: `rgba(255, 255, 255, 0)` }, headerCenter: () => null, headerLeft: () => navigation.goBack()} /> } }} />, { return { headerLeft: () => navigation.goBack()} />, headerCenter: () => ( , ]} /> ) } }} />, ({ title: `#${decodeURIComponent(route.params.hashtag)}`, headerLeft: () => navigation.goBack()} /> })} />, ({ headerLeft: () => navigation.goBack()} /> })} />, ({ headerLeft: () => navigation.goBack()} />, // https://github.com/react-navigation/react-navigation/issues/6746#issuecomment-583897436 headerCenter: () => ( } /> setSearchTerm(text) } placeholder={t('sharedSearch:content.header.placeholder')} placeholderTextColor={theme.secondary} returnKeyType='go' /> ) })} > {() => } , ({ headerTitle: t('sharedToot:heading'), ...(Platform.OS === 'android' && { headerCenter: () => }), headerLeft: () => navigation.goBack()} /> })} /> ] } const styles = StyleSheet.create({ searchBar: { flexBasis: '80%', flexDirection: 'row', alignItems: 'center' }, textInput: { fontSize: StyleConstants.Font.Size.M } }) export default sharedScreens