···11-import React from 'react'
11+import React, {useLayoutEffect} from 'react'
22import {Modal, View} from 'react-native'
33+import {StatusBar} from 'expo-status-bar'
44+import * as SystemUI from 'expo-system-ui'
35import {observer} from 'mobx-react-lite'
4677+import {isIOS} from '#/platform/detection'
58import {Provider as LegacyModalProvider} from '#/state/modals'
66-import {useComposerState} from 'state/shell/composer'
99+import {useComposerState} from '#/state/shell/composer'
710import {ModalsContainer as LegacyModalsContainer} from '#/view/com/modals/Modal'
88-import {useTheme} from '#/alf'
1111+import {atoms as a, useTheme} from '#/alf'
1212+import {getBackgroundColor, useThemeName} from '#/alf/util/useColorModeTheme'
913import {
1014 Outlet as PortalOutlet,
1115 Provider as PortalProvider,
···1923 const state = useComposerState()
2024 const ref = useComposerCancelRef()
21252626+ const open = !!state
2727+2228 return (
2329 <Modal
2430 aria-modal
2531 accessibilityViewIsModal
2626- visible={!!state}
2727- presentationStyle="overFullScreen"
3232+ visible={open}
3333+ presentationStyle="formSheet"
2834 animationType="slide"
2935 onRequestClose={() => ref.current?.onPressCancel()}>
3030- <View style={[t.atoms.bg, {flex: 1}]}>
3636+ <View style={[t.atoms.bg, a.flex_1]}>
3137 <LegacyModalProvider>
3238 <PortalProvider>
3339 <ComposePost
···4349 <PortalOutlet />
4450 </PortalProvider>
4551 </LegacyModalProvider>
5252+ {isIOS && <IOSModalBackground active={open} />}
4653 </View>
4754 </Modal>
4855 )
4956})
5757+5858+// Generally, the backdrop of the app is the theme color, but when this is open
5959+// we want it to be black due to the modal being a form sheet.
6060+function IOSModalBackground({active}: {active: boolean}) {
6161+ const theme = useThemeName()
6262+6363+ useLayoutEffect(() => {
6464+ SystemUI.setBackgroundColorAsync('black')
6565+6666+ return () => {
6767+ SystemUI.setBackgroundColorAsync(getBackgroundColor(theme))
6868+ }
6969+ }, [theme])
7070+7171+ // Set the status bar to light - however, only if the modal is active
7272+ // If we rely on this component being mounted to set this,
7373+ // there'll be a delay before it switches back to default.
7474+ return active ? <StatusBar style="light" animated /> : null
7575+}