Edge to edge support (#7497)
This commit is contained in:
committed by
GitHub
parent
6e80b340c8
commit
a770f5635b
@@ -1,20 +1,25 @@
|
||||
import {useCallback} from 'react'
|
||||
import {SystemBars} from 'react-native-edge-to-edge'
|
||||
|
||||
import {useDialogStateControlContext} from '#/state/dialogs'
|
||||
import {isIOS} from '#/platform/detection'
|
||||
|
||||
/**
|
||||
* If we're calling a system API like the image picker that opens a sheet
|
||||
* wrap it in this function to make sure the status bar is the correct color.
|
||||
*/
|
||||
export function useSheetWrapper() {
|
||||
const {setFullyExpandedCount} = useDialogStateControlContext()
|
||||
return useCallback(
|
||||
async <T>(promise: Promise<T>): Promise<T> => {
|
||||
setFullyExpandedCount(c => c + 1)
|
||||
return useCallback(async <T>(promise: Promise<T>): Promise<T> => {
|
||||
if (isIOS) {
|
||||
const entry = SystemBars.pushStackEntry({
|
||||
style: {
|
||||
statusBar: 'light',
|
||||
},
|
||||
})
|
||||
const res = await promise
|
||||
setFullyExpandedCount(c => c - 1)
|
||||
SystemBars.popStackEntry(entry)
|
||||
return res
|
||||
},
|
||||
[setFullyExpandedCount],
|
||||
)
|
||||
} else {
|
||||
return await promise
|
||||
}
|
||||
}, [])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user