Bluesky app fork with some witchin' additions 💫

Keep the screen awake on the video feed (#9146)

authored by samuel.fm and committed by GitHub c928d6b1 0dd71fb0

Changed files
+35 -1
src
components
screens
VideoFeed
+1
package.json
··· 145 145 "expo-image-manipulator": "~14.0.7", 146 146 "expo-image-picker": "~17.0.8", 147 147 "expo-intent-launcher": "~13.0.7", 148 + "expo-keep-awake": "^15.0.7", 148 149 "expo-linear-gradient": "~15.0.7", 149 150 "expo-linking": "~8.0.8", 150 151 "expo-localization": "~17.0.7",
+28
src/components/KeepAwake.tsx
··· 1 + import {useId} from 'react' 2 + import {useKeepAwake} from 'expo-keep-awake' 3 + import {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 + */ 13 + export function KeepAwake({enabled = true}) { 14 + const isFocused = useIsFocused() 15 + if (enabled && isFocused) { 16 + return <KeepAwakeInner /> 17 + } else { 18 + return null 19 + } 20 + } 21 + 22 + function 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 + }
+3
src/components/KeepAwake.web.tsx
··· 1 + export function KeepAwake() { 2 + return null 3 + }
+2
src/screens/VideoFeed/index.tsx
··· 93 93 import {Check_Stroke2_Corner0_Rounded as CheckIcon} from '#/components/icons/Check' 94 94 import {EyeSlash_Stroke2_Corner0_Rounded as Eye} from '#/components/icons/EyeSlash' 95 95 import {Leaf_Stroke2_Corner0_Rounded as LeafIcon} from '#/components/icons/Leaf' 96 + import {KeepAwake} from '#/components/KeepAwake' 96 97 import * as Layout from '#/components/Layout' 97 98 import {Link} from '#/components/Link' 98 99 import {ListFooter} from '#/components/Lists' ··· 150 151 return ( 151 152 <ThemeProvider theme="dark"> 152 153 <Layout.Screen noInsetTop style={{backgroundColor: 'black'}}> 154 + <KeepAwake /> 153 155 <SystemBars style={{statusBar: 'light', navigationBar: 'light'}} /> 154 156 <View 155 157 style={[
+1 -1
yarn.lock
··· 11297 11297 resolved "https://registry.yarnpkg.com/expo-json-utils/-/expo-json-utils-0.15.0.tgz#6723574814b9e6b0a90e4e23662be76123ab6ae9" 11298 11298 integrity sha512-duRT6oGl80IDzH2LD2yEFWNwGIC2WkozsB6HF3cDYNoNNdUvFk6uN3YiwsTsqVM/D0z6LEAQ01/SlYvN+Fw0JQ== 11299 11299 11300 - expo-keep-awake@~15.0.7: 11300 + expo-keep-awake@^15.0.7, expo-keep-awake@~15.0.7: 11301 11301 version "15.0.7" 11302 11302 resolved "https://registry.yarnpkg.com/expo-keep-awake/-/expo-keep-awake-15.0.7.tgz#4eada556e1cca6c9c2e5aa39478fd01816cd0bc9" 11303 11303 integrity sha512-CgBNcWVPnrIVII5G54QDqoE125l+zmqR4HR8q+MQaCfHet+dYpS5vX5zii/RMayzGN4jPgA4XYIQ28ePKFjHoA==