mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {useCallback} from 'react'
2import {SystemBars} from 'react-native-edge-to-edge'
3
4import {isIOS} from '#/platform/detection'
5
6/**
7 * If we're calling a system API like the image picker that opens a sheet
8 * wrap it in this function to make sure the status bar is the correct color.
9 */
10export function useSheetWrapper() {
11 return useCallback(async <T>(promise: Promise<T>): Promise<T> => {
12 if (isIOS) {
13 const entry = SystemBars.pushStackEntry({
14 style: {
15 statusBar: 'light',
16 },
17 })
18 const res = await promise
19 SystemBars.popStackEntry(entry)
20 return res
21 } else {
22 return await promise
23 }
24 }, [])
25}