import { Post , RootStackParamList , User } from '../types' ; import { errorHandlerAlert } from './errorHandler' ; import { imagePickerHandler } from './imagePickerHandler' ; export function bottomMenu ( isKeyboardShow , user , navigate , prevScreen , extensions ? , title ? , topicId ? , post ? ) { const onInsertImage = async ( ) => { if ( ! isKeyboardShow ) { return ; } try { const result = await imagePickerHandler ( extensions ) ; if ( ! user || ! result || ! result . uri ) { return ; } const imageUri = result . uri ; navigate ( 'PostImagePreview' , { imageUri , prevScreen , } ) ; } catch ( error ) { errorHandlerAlert ( error ) ; } return ; } ; const onInsertLink = ( ) => { if ( ! isKeyboardShow ) { return ; } navigate ( 'HyperLink' , { title , id : topicId , post , prevScreen } ) ; } ; return { onInsertImage , onInsertLink } ; }