diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-03-14 13:11:46 -0500 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2023-03-14 13:11:46 -0500 |
commit | 7ff4e91363e1d58a3d1182827f0a06858dcafb87 (patch) | |
tree | b5be0def0cc69f2dc0205dddfad129601492587e /src/state/models/shell-ui.ts | |
parent | cf30c66c3392c948234f6e8cda2eaf89f7f0bfc6 (diff) | |
download | voidsky-7ff4e91363e1d58a3d1182827f0a06858dcafb87.tar.zst |
Move the shell-ui model to the ui folder
Diffstat (limited to 'src/state/models/shell-ui.ts')
-rw-r--r-- | src/state/models/shell-ui.ts | 207 |
1 files changed, 0 insertions, 207 deletions
diff --git a/src/state/models/shell-ui.ts b/src/state/models/shell-ui.ts deleted file mode 100644 index 8e4eed6eb..000000000 --- a/src/state/models/shell-ui.ts +++ /dev/null @@ -1,207 +0,0 @@ -import {RootStoreModel} from './root-store' -import {makeAutoObservable} from 'mobx' -import {ProfileViewModel} from './profile-view' -import {isObj, hasProp} from 'lib/type-guards' -import {PickedMedia} from 'lib/media/types' - -export interface ConfirmModal { - name: 'confirm' - title: string - message: string | (() => JSX.Element) - onPressConfirm: () => void | Promise<void> -} - -export interface EditProfileModal { - name: 'edit-profile' - profileView: ProfileViewModel - onUpdate?: () => void -} - -export interface ServerInputModal { - name: 'server-input' - initialService: string - onSelect: (url: string) => void -} - -export interface ReportPostModal { - name: 'report-post' - postUri: string - postCid: string -} - -export interface ReportAccountModal { - name: 'report-account' - did: string -} - -export interface CropImageModal { - name: 'crop-image' - uri: string - onSelect: (img?: PickedMedia) => void -} - -export interface DeleteAccountModal { - name: 'delete-account' -} - -export interface RepostModal { - name: 'repost' - onRepost: () => void - onQuote: () => void - isReposted: boolean -} - -export interface ChangeHandleModal { - name: 'change-handle' - onChanged: () => void -} - -export type Modal = - | ConfirmModal - | EditProfileModal - | ServerInputModal - | ReportPostModal - | ReportAccountModal - | CropImageModal - | DeleteAccountModal - | RepostModal - | ChangeHandleModal - -interface LightboxModel {} - -export class ProfileImageLightbox implements LightboxModel { - name = 'profile-image' - constructor(public profileView: ProfileViewModel) { - makeAutoObservable(this) - } -} - -export class ImagesLightbox implements LightboxModel { - name = 'images' - constructor(public uris: string[], public index: number) { - makeAutoObservable(this) - } - setIndex(index: number) { - this.index = index - } -} - -export interface ComposerOptsPostRef { - uri: string - cid: string - text: string - author: { - handle: string - displayName?: string - avatar?: string - } -} -export interface ComposerOptsQuote { - uri: string - cid: string - text: string - indexedAt: string - author: { - handle: string - displayName?: string - avatar?: string - } -} -export interface ComposerOpts { - replyTo?: ComposerOptsPostRef - onPost?: () => void - quote?: ComposerOptsQuote -} - -export class ShellUiModel { - darkMode = false - minimalShellMode = false - isDrawerOpen = false - isModalActive = false - activeModals: Modal[] = [] - isLightboxActive = false - activeLightbox: ProfileImageLightbox | ImagesLightbox | undefined - isComposerActive = false - composerOpts: ComposerOpts | undefined - isOnboarding = false - - constructor(public rootStore: RootStoreModel) { - makeAutoObservable(this, { - serialize: false, - rootStore: false, - hydrate: false, - }) - } - - serialize(): unknown { - return { - darkMode: this.darkMode, - } - } - - hydrate(v: unknown) { - if (isObj(v)) { - if (hasProp(v, 'darkMode') && typeof v.darkMode === 'boolean') { - this.darkMode = v.darkMode - } - } - } - - setDarkMode(v: boolean) { - this.darkMode = v - } - - setMinimalShellMode(v: boolean) { - this.minimalShellMode = v - } - - openDrawer() { - this.isDrawerOpen = true - } - - closeDrawer() { - this.isDrawerOpen = false - } - - openModal(modal: Modal) { - this.rootStore.emitNavigation() - this.isModalActive = true - this.activeModals.push(modal) - } - - closeModal() { - this.activeModals.pop() - this.isModalActive = this.activeModals.length > 0 - } - - openLightbox(lightbox: ProfileImageLightbox | ImagesLightbox) { - this.rootStore.emitNavigation() - this.isLightboxActive = true - this.activeLightbox = lightbox - } - - closeLightbox() { - this.isLightboxActive = false - this.activeLightbox = undefined - } - - openComposer(opts: ComposerOpts) { - this.rootStore.emitNavigation() - this.isComposerActive = true - this.composerOpts = opts - } - - closeComposer() { - this.isComposerActive = false - this.composerOpts = undefined - } - - setOnboarding(v: boolean) { - this.isOnboarding = v - if (this.isOnboarding) { - this.rootStore.me.mainFeed.switchFeedType('suggested') - } else { - this.rootStore.me.mainFeed.switchFeedType('home') - } - } -} |