diff options
author | Paul Frazee <pfrazee@gmail.com> | 2022-11-09 15:57:49 -0600 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2022-11-09 15:57:49 -0600 |
commit | e7536289cbb4380dc82dcd70737e165727cbbb92 (patch) | |
tree | 867a226b444eb0f04f00af33131088c9f3427f7c /src/state/models/shell-ui.ts | |
parent | 93b64cf474574b315bfe48594ed7170b9bd8261e (diff) | |
download | voidsky-e7536289cbb4380dc82dcd70737e165727cbbb92.tar.zst |
Add scene creator
Diffstat (limited to 'src/state/models/shell-ui.ts')
-rw-r--r-- | src/state/models/shell-ui.ts | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/state/models/shell-ui.ts b/src/state/models/shell-ui.ts new file mode 100644 index 000000000..345a6b4a9 --- /dev/null +++ b/src/state/models/shell-ui.ts @@ -0,0 +1,91 @@ +import {makeAutoObservable} from 'mobx' +import {ProfileViewModel} from './profile-view' +import * as Post from '../../third-party/api/src/client/types/app/bsky/feed/post' + +export interface LinkActionsModelOpts { + newTab?: boolean +} +export class LinkActionsModel { + name = 'link-actions' + newTab: boolean + + constructor( + public href: string, + public title: string, + opts?: LinkActionsModelOpts, + ) { + makeAutoObservable(this) + this.newTab = typeof opts?.newTab === 'boolean' ? opts.newTab : true + } +} + +export class SharePostModel { + name = 'share-post' + + constructor(public href: string) { + makeAutoObservable(this) + } +} + +export class EditProfileModel { + name = 'edit-profile' + + constructor(public profileView: ProfileViewModel) { + makeAutoObservable(this) + } +} + +export class CreateSceneModel { + name = 'create-scene' + + constructor() { + makeAutoObservable(this) + } +} + +export interface ComposerOpts { + replyTo?: Post.PostRef + onPost?: () => void +} + +export class ShellUiModel { + isModalActive = false + activeModal: + | LinkActionsModel + | SharePostModel + | EditProfileModel + | CreateSceneModel + | undefined + isComposerActive = false + composerOpts: ComposerOpts | undefined + + constructor() { + makeAutoObservable(this) + } + + openModal( + modal: + | LinkActionsModel + | SharePostModel + | EditProfileModel + | CreateSceneModel, + ) { + this.isModalActive = true + this.activeModal = modal + } + + closeModal() { + this.isModalActive = false + this.activeModal = undefined + } + + openComposer(opts: ComposerOpts) { + this.isComposerActive = true + this.composerOpts = opts + } + + closeComposer() { + this.isComposerActive = false + this.composerOpts = undefined + } +} |