Switch to a better lightbox implementation (close #42)

This commit is contained in:
Paul Frazee 2023-01-17 19:34:12 -06:00
parent 61682d5846
commit b449ab842f
5 changed files with 46 additions and 167 deletions

View file

@ -52,55 +52,22 @@ export class ReportAccountModal {
}
}
interface LightboxModel {
canSwipeLeft: boolean
canSwipeRight: boolean
onSwipeLeft: () => void
onSwipeRight: () => void
}
interface LightboxModel {}
export class ProfileImageLightbox implements LightboxModel {
name = 'profile-image'
canSwipeLeft = false
canSwipeRight = false
constructor(public profileView: ProfileViewModel) {
makeAutoObservable(this)
}
onSwipeLeft() {}
onSwipeRight() {}
}
export class ImageLightbox implements LightboxModel {
name = 'image'
canSwipeLeft = true
canSwipeRight = true
constructor(public uri: string) {
makeAutoObservable(this)
}
onSwipeLeft() {}
onSwipeRight() {}
}
export class ImagesLightbox implements LightboxModel {
name = 'images'
get canSwipeLeft() {
return this.index > 0
}
get canSwipeRight() {
return this.index < this.uris.length - 1
}
constructor(public uris: string[], public index: number) {
makeAutoObservable(this)
}
onSwipeLeft() {
if (this.canSwipeLeft) {
this.index = this.index - 1
}
}
onSwipeRight() {
if (this.canSwipeRight) {
this.index = this.index + 1
}
setIndex(index: number) {
this.index = index
}
}
@ -187,9 +154,7 @@ export class ShellUiModel {
this.activeModal = undefined
}
openLightbox(
lightbox: ProfileImageLightbox | ImageLightbox | ImagesLightbox,
) {
openLightbox(lightbox: ProfileImageLightbox | ImagesLightbox) {
this.isLightboxActive = true
this.activeLightbox = lightbox
}