diff options
author | dan <dan.abramov@gmail.com> | 2024-11-06 00:21:35 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-06 00:21:35 +0000 |
commit | 206df2ab801d211a412f9ce3694d90bdd053caaa (patch) | |
tree | e185c0694eba262c48bd08fc0f430dd0fb203a47 /src/state/lightbox.tsx | |
parent | 6b826fb88dd33fe594fd7bb631a90d1a1713d0df (diff) | |
download | voidsky-206df2ab801d211a412f9ce3694d90bdd053caaa.tar.zst |
Remove SCREEN from lightbox layout (#6124)
* Assign an ID to lightbox and use it as a key * Consolidate lightbox props into an object * Remove unused prop * Move SafeAreaView declaration * Keep SafeAreaView always mounted When exploring Android animation, I noticed its content jumps on the first frame. I think this should help prevent that. * Pass safe area down for measurement * Remove dependency on SCREEN in Android event handlers * Remove dependency on SCREEN in iOS event handlers * Remove dependency on SCREEN on iOS * Remove dependency on SCREEN on Android * Remove dependency on JS calc in controls * Use flex for iOS layout
Diffstat (limited to 'src/state/lightbox.tsx')
-rw-r--r-- | src/state/lightbox.tsx | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/state/lightbox.tsx b/src/state/lightbox.tsx index 1dae67932..06541106e 100644 --- a/src/state/lightbox.tsx +++ b/src/state/lightbox.tsx @@ -1,10 +1,12 @@ import React from 'react' import type {MeasuredDimensions} from 'react-native-reanimated' +import {nanoid} from 'nanoid/non-secure' import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' import {ImageSource} from '#/view/com/lightbox/ImageViewing/@types' -type Lightbox = { +export type Lightbox = { + id: string images: ImageSource[] thumbDims: MeasuredDimensions | null index: number @@ -17,7 +19,7 @@ const LightboxContext = React.createContext<{ }) const LightboxControlContext = React.createContext<{ - openLightbox: (lightbox: Lightbox) => void + openLightbox: (lightbox: Omit<Lightbox, 'id'>) => void closeLightbox: () => boolean }>({ openLightbox: () => {}, @@ -29,9 +31,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) { null, ) - const openLightbox = useNonReactiveCallback((lightbox: Lightbox) => { - setActiveLightbox(lightbox) - }) + const openLightbox = useNonReactiveCallback( + (lightbox: Omit<Lightbox, 'id'>) => { + setActiveLightbox({...lightbox, id: nanoid()}) + }, + ) const closeLightbox = useNonReactiveCallback(() => { let wasActive = !!activeLightbox |