From a19d891f386816f127ea1ee3970c6ec48adb0d74 Mon Sep 17 00:00:00 2001 From: Lionel Han <47760119+IGoByJoe@users.noreply.github.com> Date: Thu, 18 Jun 2020 22:01:02 -0700 Subject: added mobile collection to menu and added image upload to current collection --- src/mobile/ImageUpload.tsx | 9 ++++++-- src/mobile/MobileInterface.tsx | 48 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 5 deletions(-) (limited to 'src/mobile') diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx index b66f0461d..0b63c42be 100644 --- a/src/mobile/ImageUpload.tsx +++ b/src/mobile/ImageUpload.tsx @@ -29,7 +29,7 @@ export interface ImageUploadProps { const inputRef = React.createRef(); @observer -export class Uploader extends React.Component { +export class Uploader extends React.Component { @observable error: string = ""; @observable status: string = ""; @observable nm: string = "Choose files"; @@ -37,6 +37,7 @@ export class Uploader extends React.Component { onClick = async () => { try { + const col = this.props.Document; await Docs.Prototypes.initialize(); const imgPrev = document.getElementById("img_preview"); const slab1 = document.getElementById("slab1"); @@ -84,7 +85,11 @@ export class Uploader extends React.Component { const field = await DocServer.GetRefField(res); let pending: Opt; if (field instanceof Doc) { - pending = await Cast(field.rightSidebarCollection, Doc); + // if (col === Cast(Doc.UserDoc().rightSidebarCollection, Doc) as Doc) { + // pending = await Cast(field.rightSidebarCollection, Doc); + // } + pending = col; + //pending = await Cast(field.col, Doc); } if (pending) { const data = await Cast(pending.data, listSpec(Doc)); diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx index 3a81e5de1..2fde359aa 100644 --- a/src/mobile/MobileInterface.tsx +++ b/src/mobile/MobileInterface.tsx @@ -674,6 +674,15 @@ export class MobileInterface extends React.Component { @action toggleUpload = () => this.imageUploadActive = !this.imageUploadActive + @action + toggleUploadInCollection = () => { + const button = document.getElementById("imageButton") as HTMLElement; + button.style.backgroundColor = this.imageUploadActive ? "white" : "black"; + button.style.color = this.imageUploadActive ? "black" : "white"; + + this.imageUploadActive = !this.imageUploadActive; + } + // For closing the image upload pop up @action closeUpload = () => { @@ -687,12 +696,22 @@ export class MobileInterface extends React.Component { } else if (!this.imageUploadActive) { } + + let doc; + let toggle; + if (this._homeMenu === false) { + doc = this._activeDoc; + toggle = this.toggleUploadInCollection; + } else { + doc = Cast(Doc.UserDoc().rightSidebarCollection, Doc) as Doc + toggle = this.toggleUpload; + } return (
-
+
- +
); } @@ -708,8 +727,27 @@ export class MobileInterface extends React.Component { e.stopPropagation(); } - uploadToCurrentCollection = (doc: Doc) => { + uploadImageButton = () => { + if (this._activeDoc.type === "collection" && this._activeDoc !== this._homeDoc && this._activeDoc._viewType !== "docking" && this._activeDoc.title !== "WORKSPACES") { + return
+ +
+ } + } + switchToMobileUploads = () => { + if (this._activeDoc.title !== "Presentation") { + this._parents.push(this._activeDoc); + } + const mobileUpload = Cast(Doc.UserDoc().rightSidebarCollection, Doc) as Doc; + console.log(mobileUpload.title); + this._activeDoc = mobileUpload; + this.switchCurrentView((userDoc: Doc) => mobileUpload); + this._homeMenu = false; } render() { @@ -718,14 +756,17 @@ export class MobileInterface extends React.Component {
{this.uploadImage()} +
{this.switchMenuView()} {this.inkMenu()}
+ {this.uploadImageButton()} {this.pinToPresentation()} {this.downloadDocument()} {this.drawInk()} {this.uploadAudioButton()} +
{this.displayWorkspaces()} @@ -746,3 +787,4 @@ Scripting.addGlobal(function openMobileAudio() { return MobileInterface.Instance Scripting.addGlobal(function openMobileSettings() { return SettingsManager.Instance.open(); }); Scripting.addGlobal(function switchToLibrary() { return MobileInterface.Instance.switchToLibrary(); }); Scripting.addGlobal(function uploadImageMobile() { return MobileInterface.Instance.toggleUpload(); }); +Scripting.addGlobal(function switchToMobileUploads() { return MobileInterface.Instance.switchToMobileUploads(); }); -- cgit v1.2.3-70-g09d2