[jank] add composer route with presentation formSheet
This commit is contained in:
@@ -54,6 +54,7 @@ import {
|
|||||||
shouldRequestEmailConfirmation,
|
shouldRequestEmailConfirmation,
|
||||||
} from './state/shell/reminders'
|
} from './state/shell/reminders'
|
||||||
import {CommunityGuidelinesScreen} from './view/screens/CommunityGuidelines'
|
import {CommunityGuidelinesScreen} from './view/screens/CommunityGuidelines'
|
||||||
|
import {ComposerScreen} from './view/screens/Composer'
|
||||||
import {CopyrightPolicyScreen} from './view/screens/CopyrightPolicy'
|
import {CopyrightPolicyScreen} from './view/screens/CopyrightPolicy'
|
||||||
import {DebugModScreen} from './view/screens/DebugMod'
|
import {DebugModScreen} from './view/screens/DebugMod'
|
||||||
import {FeedsScreen} from './view/screens/Feeds'
|
import {FeedsScreen} from './view/screens/Feeds'
|
||||||
@@ -103,6 +104,16 @@ function commonScreens(Stack: typeof HomeTab, unreadCountLabel?: string) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<Stack.Screen
|
||||||
|
name="Composer"
|
||||||
|
getComponent={() => ComposerScreen}
|
||||||
|
options={{
|
||||||
|
title: title(msg`Compose`),
|
||||||
|
requireAuth: true,
|
||||||
|
presentation: 'formSheet',
|
||||||
|
headerShown: false,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="NotFound"
|
name="NotFound"
|
||||||
getComponent={() => NotFoundScreen}
|
getComponent={() => NotFoundScreen}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type {NativeStackNavigationProp} from '@react-navigation/native-stack'
|
|||||||
export type {NativeStackScreenProps} from '@react-navigation/native-stack'
|
export type {NativeStackScreenProps} from '@react-navigation/native-stack'
|
||||||
|
|
||||||
export type CommonNavigatorParams = {
|
export type CommonNavigatorParams = {
|
||||||
|
Composer: undefined
|
||||||
NotFound: undefined
|
NotFound: undefined
|
||||||
Lists: undefined
|
Lists: undefined
|
||||||
Moderation: undefined
|
Moderation: undefined
|
||||||
|
|||||||
@@ -133,9 +133,9 @@ export const ComposePost = observer(function ComposePost({
|
|||||||
() => ({
|
() => ({
|
||||||
paddingBottom:
|
paddingBottom:
|
||||||
isAndroid || (isIOS && !isKeyboardVisible) ? insets.bottom : 0,
|
isAndroid || (isIOS && !isKeyboardVisible) ? insets.bottom : 0,
|
||||||
paddingTop: isAndroid ? insets.top : isMobile ? 15 : 0,
|
paddingTop: isAndroid ? insets.top : 0,
|
||||||
}),
|
}),
|
||||||
[insets, isKeyboardVisible, isMobile],
|
[insets, isKeyboardVisible],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onPressCancel = useCallback(() => {
|
const onPressCancel = useCallback(() => {
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {useNavigation} from '@react-navigation/native'
|
||||||
|
|
||||||
|
import {NavigationProp} from '#/lib/routes/types'
|
||||||
|
import {useComposerState} from '#/state/shell/composer'
|
||||||
|
import {ComposePost} from '../com/composer/Composer'
|
||||||
|
|
||||||
|
export function ComposerScreen() {
|
||||||
|
const state = useComposerState()
|
||||||
|
const navigation = useNavigation<NavigationProp>()
|
||||||
|
|
||||||
|
if (!state) {
|
||||||
|
navigation.goBack()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ComposePost
|
||||||
|
replyTo={state.replyTo}
|
||||||
|
quote={state.quote}
|
||||||
|
onPost={state.onPost}
|
||||||
|
mention={state.mention}
|
||||||
|
text={state.text}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
+10
-68
@@ -1,77 +1,19 @@
|
|||||||
import React, {useEffect} from 'react'
|
import {useEffect} from 'react'
|
||||||
|
import {useNavigation} from '@react-navigation/native'
|
||||||
import {observer} from 'mobx-react-lite'
|
import {observer} from 'mobx-react-lite'
|
||||||
import {Animated, Easing, Platform, StyleSheet, View} from 'react-native'
|
|
||||||
import {ComposePost} from '../com/composer/Composer'
|
|
||||||
import {useComposerState} from 'state/shell/composer'
|
|
||||||
import {useAnimatedValue} from 'lib/hooks/useAnimatedValue'
|
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
|
||||||
|
|
||||||
export const Composer = observer(function ComposerImpl({
|
import {NavigationProp} from '#/lib/routes/types'
|
||||||
winHeight,
|
import {useComposerState} from 'state/shell/composer'
|
||||||
}: {
|
|
||||||
winHeight: number
|
export const Composer = observer(function ComposerImpl() {
|
||||||
}) {
|
|
||||||
const state = useComposerState()
|
const state = useComposerState()
|
||||||
const pal = usePalette('default')
|
const navigation = useNavigation<NavigationProp>()
|
||||||
const initInterp = useAnimatedValue(0)
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (state) {
|
if (state) {
|
||||||
Animated.timing(initInterp, {
|
navigation.navigate('Composer')
|
||||||
toValue: 1,
|
|
||||||
duration: 300,
|
|
||||||
easing: Easing.out(Easing.exp),
|
|
||||||
useNativeDriver: true,
|
|
||||||
}).start()
|
|
||||||
} else {
|
|
||||||
initInterp.setValue(0)
|
|
||||||
}
|
}
|
||||||
}, [initInterp, state])
|
}, [state, navigation])
|
||||||
const wrapperAnimStyle = {
|
|
||||||
transform: [
|
|
||||||
{
|
|
||||||
translateY: initInterp.interpolate({
|
|
||||||
inputRange: [0, 1],
|
|
||||||
outputRange: [winHeight, 0],
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
// rendering
|
return null
|
||||||
// =
|
|
||||||
|
|
||||||
if (!state) {
|
|
||||||
return <View />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Animated.View
|
|
||||||
style={[styles.wrapper, pal.view, wrapperAnimStyle]}
|
|
||||||
aria-modal
|
|
||||||
accessibilityViewIsModal>
|
|
||||||
<ComposePost
|
|
||||||
replyTo={state.replyTo}
|
|
||||||
onPost={state.onPost}
|
|
||||||
quote={state.quote}
|
|
||||||
mention={state.mention}
|
|
||||||
text={state.text}
|
|
||||||
imageUris={state.imageUris}
|
|
||||||
/>
|
|
||||||
</Animated.View>
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
wrapper: {
|
|
||||||
position: 'absolute',
|
|
||||||
top: 0,
|
|
||||||
bottom: 0,
|
|
||||||
width: '100%',
|
|
||||||
...Platform.select({
|
|
||||||
ios: {
|
|
||||||
paddingTop: 24,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user