blob: 4bc9b665a4f8d9c60cf5dfc5c90d6d87751b4469 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import {useCallback, useMemo, useState} from 'react'
import * as DynamicAppIcon from '@mozzius/expo-dynamic-app-icon'
import {useFocusEffect} from '@react-navigation/native'
import {useAppIconSets} from '#/screens/Settings/AppIconSettings/useAppIconSets'
export function useCurrentAppIcon() {
const appIconSets = useAppIconSets()
const [currentAppIcon, setCurrentAppIcon] = useState(() =>
DynamicAppIcon.getAppIcon(),
)
// refresh current icon when screen is focused
useFocusEffect(
useCallback(() => {
setCurrentAppIcon(DynamicAppIcon.getAppIcon())
}, []),
)
return useMemo(() => {
return (
appIconSets.defaults.find(i => i.id === currentAppIcon) ??
appIconSets.core.find(i => i.id === currentAppIcon) ??
appIconSets.defaults[0]
)
}, [appIconSets, currentAppIcon])
}
|