diff options
Diffstat (limited to 'src/state/models/media/gallery.ts')
-rw-r--r-- | src/state/models/media/gallery.ts | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/state/models/media/gallery.ts b/src/state/models/media/gallery.ts index 97b1ac1d8..86bf8a314 100644 --- a/src/state/models/media/gallery.ts +++ b/src/state/models/media/gallery.ts @@ -5,6 +5,7 @@ import {Image as RNImage} from 'react-native-image-crop-picker' import {openPicker} from 'lib/media/picker' import {getImageDim} from 'lib/media/manip' import {getDataUriSize} from 'lib/media/util' +import {isNative} from 'platform/detection' export class GalleryModel { images: ImageModel[] = [] @@ -37,7 +38,12 @@ export class GalleryModel { // Temporarily enforce uniqueness but can eventually also use index if (!this.images.some(i => i.path === image_.path)) { const image = new ImageModel(this.rootStore, image_) - await image.compress() + + if (!isNative) { + await image.manipulate({}) + } else { + await image.compress() + } runInAction(() => { this.images.push(image) @@ -45,6 +51,20 @@ export class GalleryModel { } } + async edit(image: ImageModel) { + if (!isNative) { + this.rootStore.shell.openModal({ + name: 'edit-image', + image, + gallery: this, + }) + + return + } else { + this.crop(image) + } + } + async paste(uri: string) { if (this.size >= 4) { return @@ -65,8 +85,8 @@ export class GalleryModel { }) } - setAltText(image: ImageModel) { - image.setAltText() + setAltText(image: ImageModel, altText: string) { + image.setAltText(altText) } crop(image: ImageModel) { @@ -78,6 +98,10 @@ export class GalleryModel { this.images.splice(index, 1) } + async previous(image: ImageModel) { + image.previous() + } + async pick() { const images = await openPicker(this.rootStore, { multiple: true, |