Rework modals to support multiple active

This commit is contained in:
Paul Frazee 2023-02-23 17:22:03 -06:00
parent b4f2a6979a
commit 154c34e915
13 changed files with 147 additions and 187 deletions

View file

@ -1,6 +1,5 @@
/// <reference lib="dom" />
import {CropImageModal} from 'state/models/shell-ui'
import {PickerOpts, CameraOpts, CropperOpts, PickedMedia} from './types'
export type {PickedMedia} from './types'
import {RootStoreModel} from 'state/index'
@ -51,15 +50,17 @@ export async function openCropper(
): Promise<PickedMedia> {
// TODO handle more opts
return new Promise((resolve, reject) => {
store.shell.openModal(
new CropImageModal(opts.path, (img?: PickedMedia) => {
store.shell.openModal({
name: 'crop-image',
uri: opts.path,
onSelect: (img?: PickedMedia) => {
if (img) {
resolve(img)
} else {
reject(new Error('Canceled'))
}
}),
)
},
})
})
}