use <Modal> to display composer
This commit is contained in:
@@ -139,7 +139,7 @@ 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 : isMobile && isWeb ? 15 : 0,
|
||||||
}),
|
}),
|
||||||
[insets, isKeyboardVisible, isMobile],
|
[insets, isKeyboardVisible, isMobile],
|
||||||
)
|
)
|
||||||
|
|||||||
+18
-65
@@ -1,77 +1,30 @@
|
|||||||
import React, {useEffect} from 'react'
|
import React from 'react'
|
||||||
|
import {Modal} from 'react-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 {useComposerState} from 'state/shell/composer'
|
||||||
winHeight,
|
import {ComposePost} from '../com/composer/Composer'
|
||||||
}: {
|
|
||||||
|
export const Composer = observer(function ComposerImpl({}: {
|
||||||
winHeight: number
|
winHeight: number
|
||||||
}) {
|
}) {
|
||||||
const state = useComposerState()
|
const state = useComposerState()
|
||||||
const pal = usePalette('default')
|
|
||||||
const initInterp = useAnimatedValue(0)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (state) {
|
|
||||||
Animated.timing(initInterp, {
|
|
||||||
toValue: 1,
|
|
||||||
duration: 300,
|
|
||||||
easing: Easing.out(Easing.exp),
|
|
||||||
useNativeDriver: true,
|
|
||||||
}).start()
|
|
||||||
} else {
|
|
||||||
initInterp.setValue(0)
|
|
||||||
}
|
|
||||||
}, [initInterp, state])
|
|
||||||
const wrapperAnimStyle = {
|
|
||||||
transform: [
|
|
||||||
{
|
|
||||||
translateY: initInterp.interpolate({
|
|
||||||
inputRange: [0, 1],
|
|
||||||
outputRange: [winHeight, 0],
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
// rendering
|
|
||||||
// =
|
|
||||||
|
|
||||||
if (!state) {
|
|
||||||
return <View />
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Animated.View
|
<Modal
|
||||||
style={[styles.wrapper, pal.view, wrapperAnimStyle]}
|
|
||||||
aria-modal
|
aria-modal
|
||||||
accessibilityViewIsModal>
|
accessibilityViewIsModal
|
||||||
|
visible={!!state}
|
||||||
|
presentationStyle="formSheet"
|
||||||
|
animationType="slide">
|
||||||
<ComposePost
|
<ComposePost
|
||||||
replyTo={state.replyTo}
|
replyTo={state?.replyTo}
|
||||||
onPost={state.onPost}
|
onPost={state?.onPost}
|
||||||
quote={state.quote}
|
quote={state?.quote}
|
||||||
mention={state.mention}
|
mention={state?.mention}
|
||||||
text={state.text}
|
text={state?.text}
|
||||||
imageUris={state.imageUris}
|
imageUris={state?.imageUris}
|
||||||
/>
|
/>
|
||||||
</Animated.View>
|
</Modal>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
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