Rewrite the post composer as a modal

This commit is contained in:
Paul Frazee 2022-09-05 14:16:48 -05:00
parent 41bbe2b60b
commit cb310ab1c1
12 changed files with 207 additions and 144 deletions

View file

@ -1,43 +0,0 @@
import React, {useLayoutEffect, useRef} from 'react'
// import {Text, TouchableOpacity} from 'react-native'
// import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {Composer as ComposerComponent} from '../com/composer/Composer'
import {ScreenParams} from '../routes'
export const Composer = ({params}: ScreenParams) => {
const {replyTo} = params
const ref = useRef<{publish: () => Promise<boolean>}>()
// TODO
// useLayoutEffect(() => {
// navigation.setOptions({
// headerShown: true,
// headerTitle: replyTo ? 'Reply' : 'New Post',
// headerLeft: () => (
// <TouchableOpacity onPress={() => navigation.goBack()}>
// <FontAwesomeIcon icon="x" />
// </TouchableOpacity>
// ),
// headerRight: () => (
// <TouchableOpacity
// onPress={() => {
// if (!ref.current) {
// return
// }
// ref.current.publish().then(
// posted => {
// if (posted) {
// navigation.goBack()
// }
// },
// err => console.error('Failed to create post', err),
// )
// }}>
// <Text>Post</Text>
// </TouchableOpacity>
// ),
// })
// }, [navigation, replyTo, ref])
return <ComposerComponent ref={ref} replyTo={replyTo} />
}

View file

@ -5,6 +5,7 @@ import {Feed} from '../com/feed/Feed'
import {FAB} from '../com/util/FloatingActionButton'
import {useStores} from '../../state'
import {FeedViewModel} from '../../state/models/feed-view'
import {ComposePostModel} from '../../state/models/shell'
import {ScreenParams} from '../routes'
import {s} from '../lib/styles'
@ -30,7 +31,7 @@ export const Home = observer(function Home({visible}: ScreenParams) {
}, [visible, store])
const onComposePress = () => {
store.nav.navigate('/compose')
store.shell.openModal(new ComposePostModel())
}
return (