mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {useCallback} from 'react'
2
3import {useDialogStateControlContext} from '#/state/dialogs'
4
5/**
6 * If we're calling a system API like the image picker that opens a sheet
7 * wrap it in this function to make sure the status bar is the correct color.
8 */
9export function useSheetWrapper() {
10 const {setFullyExpandedCount} = useDialogStateControlContext()
11 return useCallback(
12 async <T>(promise: Promise<T>): Promise<T> => {
13 setFullyExpandedCount(c => c + 1)
14 const res = await promise
15 setFullyExpandedCount(c => c - 1)
16 return res
17 },
18 [setFullyExpandedCount],
19 )
20}