add layout animations to gallery

This commit is contained in:
Samuel Newman
2024-09-05 14:38:30 +01:00
parent 527d777724
commit 87248ddf7f
+8 -3
View File
@@ -1,8 +1,10 @@
import {makeAutoObservable, runInAction} from 'mobx' import {LayoutAnimation} from 'react-native'
import {ImageModel} from './image'
import {Image as RNImage} from 'react-native-image-crop-picker' import {Image as RNImage} from 'react-native-image-crop-picker'
import {openPicker} from 'lib/media/picker' import {makeAutoObservable, runInAction} from 'mobx'
import {getImageDim} from 'lib/media/manip' import {getImageDim} from 'lib/media/manip'
import {openPicker} from 'lib/media/picker'
import {ImageModel} from './image'
interface InitialImageUri { interface InitialImageUri {
uri: string uri: string
@@ -63,6 +65,7 @@ export class GalleryModel {
} }
runInAction(() => { runInAction(() => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
this.add(image) this.add(image)
}) })
} }
@@ -76,6 +79,7 @@ export class GalleryModel {
} }
remove(image: ImageModel) { remove(image: ImageModel) {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
const index = this.images.findIndex(image_ => image_.path === image.path) const index = this.images.findIndex(image_ => image_.path === image.path)
this.images.splice(index, 1) this.images.splice(index, 1)
} }
@@ -90,6 +94,7 @@ export class GalleryModel {
allowsMultipleSelection: true, allowsMultipleSelection: true,
}) })
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut)
return await Promise.all( return await Promise.all(
images.map(image => { images.map(image => {
this.add(image) this.add(image)