Bluesky app fork with some witchin' additions 馃挮
at main 791 B view raw
1import {useId} from 'react' 2import {useKeepAwake} from 'expo-keep-awake' 3import {useIsFocused} from '@react-navigation/native' 4 5/** 6 * Stops the screen from sleeping. Only applies to the current screen. 7 * 8 * Note: Expo keeps the screen permanently awake when in dev mode, so 9 * you'll only see this do anything when in production. 10 * 11 * @platform ios, android 12 */ 13export function KeepAwake({enabled = true}) { 14 const isFocused = useIsFocused() 15 if (enabled && isFocused) { 16 return <KeepAwakeInner /> 17 } else { 18 return null 19 } 20} 21 22function KeepAwakeInner() { 23 const id = useId() 24 // if you don't pass an explicit ID, any `useKeepAwake` hook unmounting disables them all. 25 // very strange behaviour, but easily fixed by passing a unique ID -sfn 26 useKeepAwake(id) 27 return null 28}