From 1a6feb447f9c4fd461ba02dc45a93e569a283be0 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Sat, 6 Jun 2020 00:04:54 -0700 Subject: initial commit --- src/mobile/ImageUpload.scss | 55 +++-- src/mobile/ImageUpload.tsx | 74 ++---- src/mobile/MobileInkOverlay.tsx | 4 +- src/mobile/MobileInterface.scss | 9 + src/mobile/MobileInterface.tsx | 526 +++++++++++++++++++++++++++++----------- src/mobile/MobileMain.tsx | 25 ++ src/mobile/MobileMenu.scss | 240 ++++++++++++++++++ src/mobile/SideBar.scss | 79 ++++++ src/mobile/SideBar.tsx | 39 +++ src/mobile/WorkSpaceButton.scss | 0 src/mobile/WorkSpaceButton.tsx | 14 ++ 11 files changed, 851 insertions(+), 214 deletions(-) create mode 100644 src/mobile/MobileMain.tsx create mode 100644 src/mobile/MobileMenu.scss create mode 100644 src/mobile/SideBar.scss create mode 100644 src/mobile/SideBar.tsx create mode 100644 src/mobile/WorkSpaceButton.scss create mode 100644 src/mobile/WorkSpaceButton.tsx (limited to 'src') diff --git a/src/mobile/ImageUpload.scss b/src/mobile/ImageUpload.scss index eea69b81c..6ebf33438 100644 --- a/src/mobile/ImageUpload.scss +++ b/src/mobile/ImageUpload.scss @@ -1,12 +1,26 @@ @import "../client/views/globalCssVariables.scss"; .imgupload_cont { - display: flex; - justify-content: center; - flex-direction: column; - align-items: center; - width: 100vw; - height: 100vh; + // display: flex; + // justify-content: center; + // flex-direction: column; + // align-items: center; + // width: 100vw; + // height: 100vh; + + .upload_label { + font-weight: normal !important; + width: 100%; + padding: 13px 12px; + border-bottom: 1px solid rgba(200, 200, 200, 0.7); + font-family: Arial, Helvetica, sans-serif; + font-style: normal; + font-weight: normal; + user-select: none; + font-size: 35px; + text-transform: uppercase; + color: black; + } .button_file { text-align: center; @@ -21,14 +35,27 @@ display: none; } - .upload_label, + // .upload_label, + // .upload_button { + // background: $dark-color; + // font-size: 500%; + // font-family: $sans-serif; + // text-align: center; + // padding: 5vh; + // margin-bottom: 20px; + // color: white; + // } + .upload_button { - background: $dark-color; - font-size: 500%; - font-family: $sans-serif; - text-align: center; - padding: 5vh; - margin-bottom: 20px; - color: white; + width: 100%; + padding: 13px 12px; + border-bottom: 1px solid rgba(200, 200, 200, 0.7); + font-family: Arial, Helvetica, sans-serif; + font-style: normal; + font-weight: normal; + user-select: none; + font-size: 35px; + text-transform: uppercase; + color: black; } } \ No newline at end of file diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx index b15042f9f..c35c4a917 100644 --- a/src/mobile/ImageUpload.tsx +++ b/src/mobile/ImageUpload.tsx @@ -4,16 +4,18 @@ import { Docs } from '../client/documents/Documents'; import "./ImageUpload.scss"; import React = require('react'); import { DocServer } from '../client/DocServer'; -import { Opt, Doc } from '../fields/Doc'; -import { Cast } from '../fields/Types'; -import { listSpec } from '../fields/Schema'; -import { List } from '../fields/List'; import { observer } from 'mobx-react'; import { observable } from 'mobx'; import { Utils } from '../Utils'; -import MobileInterface from './MobileInterface'; -import { CurrentUserUtils } from '../client/util/CurrentUserUtils'; -import { resolvedPorts } from '../client/views/Main'; +import { Networking } from '../client/Network'; +import { Doc, Opt } from '../fields/Doc'; +import { Cast } from '../fields/Types'; +import { listSpec } from '../fields/Schema'; +import { List } from '../fields/List'; + +export interface ImageUploadProps { + Document: Doc; +} // const onPointerDown = (e: React.TouchEvent) => { // let imgInput = document.getElementById("input_image_file"); @@ -24,7 +26,7 @@ import { resolvedPorts } from '../client/views/Main'; const inputRef = React.createRef(); @observer -class Uploader extends React.Component { +export class Uploader extends React.Component { @observable error: string = ""; @observable status: string = ""; @@ -39,20 +41,15 @@ class Uploader extends React.Component { if (files && files.length !== 0) { console.log(files[0]); const name = files[0].name; - const formData = new FormData(); - formData.append("file", files[0]); - - const upload = window.location.origin + "/uploadFormData"; + const res = await Networking.UploadFilesToServer(files[0]); this.status = "uploading image"; - console.log("uploading image", formData); - const res = await fetch(upload, { - method: 'POST', - body: formData - }); this.status = "upload image, getting json"; - const json = await res.json(); - json.map(async (file: any) => { - const path = window.location.origin + file; + + res.map(async ({ result }) => { + if (result instanceof Error) { + return; + } + const path = Utils.prepend(result.accessPaths.agnostic.client); const doc = Docs.Create.ImageDocument(path, { _nativeWidth: 200, _width: 200, title: name }); this.status = "getting user document"; @@ -75,12 +72,10 @@ class Uploader extends React.Component { pending.data = new List([doc]); } this.status = "finished"; + console.log("hi"); } - }); - - // console.log(window.location.origin + file[0]) - //imgPrev.setAttribute("src", window.location.origin + files[0].name) + }); } } } catch (error) { @@ -91,12 +86,12 @@ class Uploader extends React.Component { render() { return (
- + - + {/*
Upload
*/} -

{this.status}

-

{this.error}

+ {/*

{this.status}

+

{this.error}

*/}
); } @@ -104,25 +99,4 @@ class Uploader extends React.Component { } -// DocServer.init(window.location.protocol, window.location.hostname, resolvedPorts.socket, "image upload"); -(async () => { - const info = await CurrentUserUtils.loadCurrentUser(); - DocServer.init(window.location.protocol, window.location.hostname, resolvedPorts.socket, info.email + "mobile"); - await Docs.Prototypes.initialize(); - if (info.id !== "__guest__") { - // a guest will not have an id registered - await CurrentUserUtils.loadUserDocument(info); - } - document.getElementById('root')!.addEventListener('wheel', event => { - if (event.ctrlKey) { - event.preventDefault(); - } - }, true); - ReactDOM.render(( - // - - ), - document.getElementById('root') - ); -} -)(); \ No newline at end of file +// DocServer.init(window.location.protocol, window.location.hostname, 4321, "image upload"); diff --git a/src/mobile/MobileInkOverlay.tsx b/src/mobile/MobileInkOverlay.tsx index 973931615..1b3388161 100644 --- a/src/mobile/MobileInkOverlay.tsx +++ b/src/mobile/MobileInkOverlay.tsx @@ -4,11 +4,9 @@ import { MobileInkOverlayContent, GestureContent, UpdateMobileInkOverlayPosition import { observable, action } from "mobx"; import { GestureUtils } from "../pen-gestures/GestureUtils"; import "./MobileInkOverlay.scss"; -import { StrCast, Cast } from '../fields/Types'; import { DragManager } from "../client/util/DragManager"; import { DocServer } from '../client/DocServer'; -import { Doc, DocListCastAsync } from '../fields/Doc'; -import { listSpec } from '../fields/Schema'; +import { Doc } from '../fields/Doc'; @observer diff --git a/src/mobile/MobileInterface.scss b/src/mobile/MobileInterface.scss index 4d86e208f..f75e60a37 100644 --- a/src/mobile/MobileInterface.scss +++ b/src/mobile/MobileInterface.scss @@ -16,4 +16,13 @@ height: 100%; position: relative; touch-action: none; + width: 100%; +} + +.mobileInterface-background { + height: 100%; + width: 100%; + position: relative; + touch-action: none; + background-color: pink; } \ No newline at end of file diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx index 6c2e797d6..1f7244653 100644 --- a/src/mobile/MobileInterface.tsx +++ b/src/mobile/MobileInterface.tsx @@ -1,47 +1,56 @@ import React = require('react'); import { library } from '@fortawesome/fontawesome-svg-core'; -import { faEraser, faHighlighter, faLongArrowAltLeft, faMousePointer, faPenNib } from '@fortawesome/free-solid-svg-icons'; +import { faEraser, faHighlighter, faLongArrowAltLeft, faMousePointer, faPenNib, faThumbtack, faHome } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { action, computed, observable } from 'mobx'; import { observer } from 'mobx-react'; -import { DocServer } from '../client/DocServer'; +import * as rp from 'request-promise'; import { Docs } from '../client/documents/Documents'; -import { DocumentManager } from '../client/util/DocumentManager'; -import RichTextMenu from '../client/views/nodes/formattedText/RichTextMenu'; -import { Scripting } from '../client/util/Scripting'; +import { DocumentView } from '../client/views/nodes/DocumentView'; +import { emptyPath, emptyFunction, returnFalse, returnOne, returnTrue, returnZero, Utils } from '../Utils'; import { Transform } from '../client/util/Transform'; -import { DocumentDecorations } from '../client/views/DocumentDecorations'; -import GestureOverlay from '../client/views/GestureOverlay'; +import { Scripting } from '../client/util/Scripting'; import { InkingControl } from '../client/views/InkingControl'; -import { DocumentView } from '../client/views/nodes/DocumentView'; -import { RadialMenu } from '../client/views/nodes/RadialMenu'; -import { PreviewCursor } from '../client/views/PreviewCursor'; +import "./MobileInterface.scss"; +import "./MobileMenu.scss"; +import { DocServer } from '../client/DocServer'; +import { DocumentManager } from '../client/util/DocumentManager'; +import SettingsManager from '../client/util/SettingsManager'; +import { Uploader } from "./ImageUpload"; +import { DockedFrameRenderer } from '../client/views/collections/CollectionDockingView'; import { Doc, DocListCast, FieldResult } from '../fields/Doc'; -import { Id } from '../fields/FieldSymbols'; +import { FieldValue, Cast, StrCast } from '../fields/Types'; import { InkTool } from '../fields/InkField'; import { listSpec } from '../fields/Schema'; -import { Cast, FieldValue } from '../fields/Types'; -import { WebField } from "../fields/URLField"; +import { nullAudio, WebField } from '../fields/URLField'; +import { Id } from '../fields/FieldSymbols'; import { CurrentUserUtils } from '../client/util/CurrentUserUtils'; -import { emptyFunction, emptyPath, returnEmptyString, returnFalse, returnOne, returnTrue, returnZero } from '../Utils'; -import "./MobileInterface.scss"; -import { CollectionView } from '../client/views/collections/CollectionView'; library.add(faLongArrowAltLeft); +library.add(faHome); @observer -export default class MobileInterface extends React.Component { +export class MobileInterface extends React.Component { @observable static Instance: MobileInterface; @computed private get userDoc() { return Doc.UserDoc(); } @computed private get mainContainer() { return this.userDoc ? FieldValue(Cast(this.userDoc.activeMobile, Doc)) : CurrentUserUtils.GuestMobile; } + @computed private get activeContainer() { return this.userDoc ? FieldValue(Cast(this.userDoc.activeMobile, Doc)) : CurrentUserUtils.GuestMobile; } // @observable private currentView: "main" | "ink" | "upload" = "main"; - private mainDoc: any = CurrentUserUtils.setupMobileDoc(this.userDoc); + @observable private mainDoc: any = CurrentUserUtils.setupMobileDoc(this.userDoc); @observable private renderView?: () => JSX.Element; + @observable private sidebarActive = true; + + public _activeDoc: Doc = this.mainDoc; // private inkDoc?: Doc; public drawingInk: boolean = false; - // private uploadDoc?: Doc; + // private _uploadDoc: Doc = this.userDoc; + private _child: Doc | null = null; + private _parents: Array = []; + private _menu: Doc = this.mainDoc; + private _open: boolean = false; + private _library: Doc = Cast(this.userDoc.myWorkspaces, Doc) as Doc; constructor(props: Readonly<{}>) { super(props); @@ -50,7 +59,7 @@ export default class MobileInterface extends React.Component { @action componentDidMount = () => { - library.add(...[faPenNib, faHighlighter, faEraser, faMousePointer]); + library.add(...[faPenNib, faHighlighter, faEraser, faMousePointer, faThumbtack]); if (this.userDoc && !this.mainContainer) { this.userDoc.activeMobile = this.mainDoc; @@ -81,6 +90,7 @@ export default class MobileInterface extends React.Component { onSwitchUpload = async () => { let width = 300; let height = 300; + const res = await rp.get(Utils.prepend("/getUserDocumentId")); // get width and height of the collection doc if (this.mainContainer) { @@ -102,34 +112,243 @@ export default class MobileInterface extends React.Component { }); } - renderDefaultContent = () => { + back = () => { + const doc = Cast(this._parents.pop(), Doc) as Doc; + if (doc === Cast(this._menu, Doc) as Doc) { + this._child = null; + this.userDoc.activeMobile = this.mainDoc; + } else { + if (doc) { + this._child = doc; + this.switchCurrentView((userDoc: Doc) => doc); + } + } + if (doc) { + this._activeDoc = doc; + } + } + + returnHome = () => { + this._parents = []; + this._activeDoc = this._menu; + this.switchCurrentView((userDoc: Doc) => this._menu); + this._child = null; + } + + displayWorkspaces = () => { if (this.mainContainer) { - return window.screen.width} - PanelHeight={() => window.screen.height} - renderDepth={0} - focus={emptyFunction} - backgroundColor={returnEmptyString} - parentActive={returnTrue} - whenActiveChanged={emptyFunction} - bringToFront={emptyFunction} - ContainingCollectionView={undefined} - ContainingCollectionDoc={undefined} />; + const backgroundColor = () => "white"; + return ( +
+ window.screen.width} + PanelHeight={() => window.screen.height} + renderDepth={0} + focus={emptyFunction} + backgroundColor={backgroundColor} + parentActive={returnTrue} + whenActiveChanged={emptyFunction} + bringToFront={emptyFunction} + ContainingCollectionView={undefined} + ContainingCollectionDoc={undefined} + /> +
+ ); + } + } + + handleClick(doc: Doc) { + const children = DocListCast(doc.data); + if (doc.type !== "collection") { + this._parents.push(this._activeDoc); + this._activeDoc = doc; + this.switchCurrentView((userDoc: Doc) => doc); + this.toggleSidebar(); + } else if (doc.type === "collection" && children.length === 0) { + console.log("This collection has no children"); + } else { + this._parents.push(this._activeDoc); + this._activeDoc = doc; + this.switchCurrentView((userDoc: Doc) => doc); + this._child = doc; + } + + // let sidebar = document.getElementById("sidebar") as HTMLElement; + // sidebar.classList.toggle('active'); + } + + createPathname = () => { + let pathname = ""; + this._parents.map((doc: Doc, index: any) => { + if (doc === this.mainDoc) { + pathname = pathname + doc.title; + } else { + pathname = pathname + " > " + doc.title; + } + }); + if (this._activeDoc === this.mainDoc) { + pathname = pathname + this._activeDoc.title; + } else { + pathname = pathname + " > " + this._activeDoc.title; + } + return pathname; + } + + @action + toggleSidebar = () => this.sidebarActive = !this.sidebarActive + + openLibrary() { + this._activeDoc = this.mainDoc; + this.switchCurrentView(() => this.mainDoc); + this._child = this._library; + } + + renderDefaultContent = () => { + const workspaces = Cast(this.userDoc.myWorkspaces, Doc) as Doc; + const buttons = DocListCast(this._child ? this._child.data : workspaces.data).map((doc: Doc, index: any) => { + return ( +
this.handleClick(doc)}>{doc.title} +
{doc.type}
+ +
); + }); + return ( + <> +
+
{this.sidebarActive ? StrCast(this._activeDoc.title) : "Menu"}
+
+
+
+
{this.createPathname()}
+
+
+ + {this._child ? + <> +
+
{buttons}
+
Home
+ : + <> + {buttons} + {/*
+ Library +
*/} + +
Record Audio
+
Presentation
+
SettingsManager.Instance.open()}>Settings
+ + } +
+ {this._child ? null :
{this.renderView}
} + + ); + } + + pinToPresentation = () => { + // Only making button available if it is an image + if (this._activeDoc.type === "image") { + const isPinned = this._activeDoc && Doc.isDocPinned(this._activeDoc); + return
{ + if (isPinned) { + DockedFrameRenderer.UnpinDoc(this._activeDoc); + } + else { + DockedFrameRenderer.PinDoc(this._activeDoc); + } + }}> + +
; + } + } + + recordAudio = async () => { + // upload to server with known URL + this._parents.push(this._activeDoc); + const audioDoc = Cast(Docs.Create.AudioDocument(nullAudio, { _width: 200, _height: 100, title: "mobile audio" }), Doc) as Doc; + if (audioDoc) { + console.log("audioClicked: " + audioDoc.title); + this._activeDoc = audioDoc; + this.switchCurrentView((userDoc: Doc) => audioDoc); + this.toggleSidebar(); + } + const audioRightSidebar = Cast(Doc.UserDoc().rightSidebarCollection, Doc) as Doc; + if (audioRightSidebar) { + console.log(audioRightSidebar.title); + const data = Cast(audioRightSidebar.data, listSpec(Doc)); + if (data) { + data.push(audioDoc); + } + } + } + + openDefaultPresentation = () => { + this._parents.push(this._activeDoc); + const presentation = Cast(Doc.UserDoc().activePresentation, Doc) as Doc; + + if (presentation) { + console.log("presentation clicked: " + presentation.title); + this._activeDoc = presentation; + this.switchCurrentView((userDoc: Doc) => presentation); + this.toggleSidebar(); + } + } + + // mobileHome = () => { + // return ( + //
+ //
+ + //
+ //
+ + //
+ //
+ + //
+ //
+ + //
+ //
+ + //
+ //
+ // ); + // } + + renderActiveCollection = (userDoc: Doc) => { + if (this.activeContainer) { + const active = Cast(this.activeContainer.data, listSpec(Doc)); + if (active) { + return ( +
HELLO!
+ ); + } } - return "hello"; } onBack = (e: React.MouseEvent) => { @@ -164,60 +383,15 @@ export default class MobileInterface extends React.Component { panelHeight = () => window.innerHeight; panelWidth = () => window.innerWidth; - renderInkingContent = () => { - console.log("rendering inking content"); - // TODO: support panning and zooming - // TODO: handle moving of ink strokes - if (this.mainContainer) { - return ( -
-
-
- -
-
- -
-
- - -
-
- - -
- ); - } - } + //WAS 3 + + //WAS 1 upload = async (e: React.MouseEvent) => { if (this.mainContainer) { const data = Cast(this.mainContainer.data, listSpec(Doc)); if (data) { - const collectionDoc = await data[1]; // this should be the collection doc since the positions should be locked + const collectionDoc = await data[1]; //this should be the collection doc since the positions should be locked const children = DocListCast(collectionDoc.data); const uploadDoc = children.length === 1 ? children[0] : Docs.Create.StackingDocument(children, { title: "Mobile Upload Collection", backgroundColor: "white", lockedPosition: true, _width: 300, _height: 300 @@ -260,45 +434,6 @@ export default class MobileInterface extends React.Component { } } - renderUploadContent() { - if (this.mainContainer) { - return ( -
-
- - {/* */} - {/* */} - -
- window.screen.width} - PanelHeight={() => window.screen.height} - renderDepth={0} - focus={emptyFunction} - backgroundColor={returnEmptyString} - parentActive={returnTrue} - whenActiveChanged={emptyFunction} - bringToFront={emptyFunction} - ContainingCollectionView={undefined} - ContainingCollectionDoc={undefined} /> -
- ); - } - } - onDragOver = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); @@ -314,18 +449,22 @@ export default class MobileInterface extends React.Component { {this.renderView ? this.renderView() : this.renderDefaultContent()} */} - + {/* */} + + {this.displayWorkspaces()} + {this.pinToPresentation()} + {/* */} {/* */} - - - {this.renderView ? this.renderView() : this.renderDefaultContent()} - - + {/* */} +
+ {this.renderDefaultContent()} +
+ {/* */} {/* */} - - + {/* + */} {/* */} @@ -335,9 +474,102 @@ export default class MobileInterface extends React.Component { } Scripting.addGlobal(function switchMobileView(doc: (userDoc: Doc) => Doc, renderView?: () => JSX.Element, onSwitch?: () => void) { return MobileInterface.Instance.switchCurrentView(doc, renderView, onSwitch); }); -Scripting.addGlobal(function onSwitchMobileInking() { return MobileInterface.Instance.onSwitchInking(); }); -Scripting.addGlobal(function renderMobileInking() { return MobileInterface.Instance.renderInkingContent(); }); -Scripting.addGlobal(function onSwitchMobileUpload() { return MobileInterface.Instance.onSwitchUpload(); }); -Scripting.addGlobal(function renderMobileUpload() { return MobileInterface.Instance.renderUploadContent(); }); -Scripting.addGlobal(function addWebToMobileUpload() { return MobileInterface.Instance.addWebToCollection(); }); +// WAS 2 + +// 1 +// renderUploadContent() { +// if (this.mainContainer) { +// return ( +//
+//
+// +// {/* */} +// {/* */} +// +//
+// window.screen.width} +// PanelHeight={() => window.screen.height} +// renderDepth={0} +// focus={emptyFunction} +// backgroundColor={returnEmptyString} +// parentActive={returnTrue} +// whenActiveChanged={emptyFunction} +// bringToFront={emptyFunction} +// ContainingCollectionView={undefined} +// ContainingCollectionDoc={undefined} /> +//
+// ); +// } +// } + +// 2 +// Scripting.addGlobal(function onSwitchMobileInking() { return MobileInterface.Instance.onSwitchInking(); }); +// Scripting.addGlobal(function renderMobileInking() { return MobileInterface.Instance.renderInkingContent(); }); +// Scripting.addGlobal(function onSwitchMobileUpload() { return MobileInterface.Instance.onSwitchUpload(); }); +// Scripting.addGlobal(function renderMobileUpload() { return MobileInterface.Instance.renderUploadContent(); }); + // Scripting.addGlobal(function addWebToMobileUpload() { return MobileInterface.Instance.addWebToCollection(); }); + +// 3 + // renderInkingContent = () => { + // console.log("rendering inking content"); + // // TODO: support panning and zooming + // // TODO: handle moving of ink strokes + // if (this.mainContainer) { + // return ( + //
+ //
+ //
+ // + //
+ //
+ // + //
+ //
+ // + // + //
+ //
+ // + // + //
+ // ); + // } + // } diff --git a/src/mobile/MobileMain.tsx b/src/mobile/MobileMain.tsx new file mode 100644 index 000000000..34f06438f --- /dev/null +++ b/src/mobile/MobileMain.tsx @@ -0,0 +1,25 @@ +import { DocServer } from '../client/DocServer'; +import { Docs } from '../client/documents/Documents'; +import * as ReactDOM from "react-dom"; +import { MobileInterface } from './MobileInterface'; +import * as React from "react"; +import { AssignAllExtensions } from '../extensions/General/Extensions'; +import { CurrentUserUtils } from '../client/util/CurrentUserUtils'; + +AssignAllExtensions(); + +(async () => { + const info = await CurrentUserUtils.loadCurrentUser(); + DocServer.init(window.location.protocol, window.location.hostname, 4321, info.email + " (mobile)"); + await Docs.Prototypes.initialize(); + if (info.id !== "__guest__") { + // a guest will not have an id registered + await CurrentUserUtils.loadUserDocument(info); + } + document.getElementById('root')!.addEventListener('wheel', event => { + if (event.ctrlKey) { + event.preventDefault(); + } + }, true); + ReactDOM.render(, document.getElementById('root')); +})(); \ No newline at end of file diff --git a/src/mobile/MobileMenu.scss b/src/mobile/MobileMenu.scss new file mode 100644 index 000000000..250340e36 --- /dev/null +++ b/src/mobile/MobileMenu.scss @@ -0,0 +1,240 @@ +$navbar-height: 120px; +$pathbar-height: 50px; + +* { + margin: 0px; + padding: 0px; + box-sizing: border-box; + font-family: "Open Sans"; +} + +body { + overflow: hidden; +} + +.navbar { + position: fixed; + top: 0px; + left: 0px; + width: 100vw; + height: $navbar-height; + background-color: whitesmoke; + border-bottom: 5px solid black; +} + +.navbar .toggle-btn { + position: absolute; + right: 20px; + top: 30px; + height: 70px; + width: 70px; + transition: all 300ms ease-in-out 200ms; +} + +.navbar .header { + position: absolute; + top: 50%; + top: calc(9px + 50%); + right: 50%; + transform: translate(50%, -50%); + font-size: 40; + user-select: none; + text-transform: uppercase; + font-family: Arial, Helvetica, sans-serif; +} + +.navbar .toggle-btn span { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + width: 70%; + height: 4px; + background: black; + transition: all 200ms ease; +} + +.navbar .toggle-btn span:nth-child(1) { + transition: top 200ms ease-in-out; + top: 30%; +} + +.navbar .toggle-btn span:nth-child(3) { + transition: top 200ms ease-in-out; + top: 70%; +} + +.navbar .toggle-btn.active { + transition: transform 200ms ease-in-out 200ms; + transform: rotate(135deg); +} + +.navbar .toggle-btn.active span:nth-child(1) { + top: 50%; +} + +.navbar .toggle-btn.active span:nth-child(2) { + transform: translate(-50%, -50%) rotate(90deg); +} + +.navbar .toggle-btn.active span:nth-child(3) { + top: 50%; +} + +.sidebar { + position: absolute; + top: 200px; + opacity: 0; + right: -100%; + width: 100%; + height: calc(100% - (200px)); + z-index: 5; + background-color: whitesmoke; + transition: all 400ms ease 50ms; + padding: 20px; + // border-right: 5px solid black; +} + +.sidebar .item { + width: 100%; + padding: 13px 12px; + border-bottom: 1px solid rgba(200, 200, 200, 0.7); + font-family: Arial, Helvetica, sans-serif; + font-style: normal; + font-weight: normal; + user-select: none; + font-size: 35px; + text-transform: uppercase; + color: black; +} + +.sidebar .home { + position: absolute; + top: -135px; + right: calc(50% + 80px); + transform: translate(0%, -50%); + font-size: 40; + user-select: none; + text-transform: uppercase; + font-family: Arial, Helvetica, sans-serif; + z-index: 200; +} + +.type { + display: inline; + text-transform: lowercase; + margin-left: 20px; + font-size: 35px; + font-style: italic; + color: rgb(28, 28, 28); +} + +.right { + margin-left: 20px; + z-index: 200; +} + +.left { + width: 100%; + height: 100%; +} + +.sidebar .logout { + width: 100%; + padding: 13px 12px; + border-bottom: 1px solid rgba(200, 200, 200, 0.7); + font-family: Arial, Helvetica, sans-serif; + font-style: normal; + font-weight: normal; + user-select: none; + font-size: 30px; + text-transform: uppercase; + color: black; +} + +.sidebar .settings { + width: 100%; + padding: 13px 12px; + border-bottom: 1px solid rgba(200, 200, 200, 0.7); + font-family: Arial, Helvetica, sans-serif; + font-style: normal; + font-weight: normal; + user-select: none; + font-size: 30px; + text-transform: uppercase; + color: black; +} + + +.sidebar.active { + right: 0%; + opacity: 1; +} + +.back { + position: absolute; + top: -140px; + left: 50px; + transform: translate(0%, -50%); + color: black; + font-size: 60; + user-select: none; + text-transform: uppercase; + z-index: 100; + font-family: Arial, Helvetica, sans-serif; +} + + +.pathbar { + position: absolute; + top: 118px; + background: #1a1a1a; + z-index: 20; + border-radius: 0px; + width: 100%; + height: 80px; + transition: all 400ms ease 50ms; +} + +.pathname { + position: relative; + font-size: 25; + top: 50%; + width: 90%; + left: 3%; + color: whitesmoke; + transform: translate(0%, -50%); + z-index: 20; + font-family: sans-serif; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + direction: rtl; + text-align: left; + text-transform: uppercase; +} + +.homeContainer { + position: relative; + top: 200px; + height: calc(100% - 250px); + width: 90%; + overflow: scroll; + left: 5%; + background-color: lightpink; +} + +.pinButton { + position: relative; + width: 100px; + height: 100px; + font-size: 90px; + text-align: center; + left: 50%; + transform: translate(-50%, 0); + border-style: solid; + border-radius: 50px; + border-width: medium; + background-color: pink; + z-index: 100; +} \ No newline at end of file diff --git a/src/mobile/SideBar.scss b/src/mobile/SideBar.scss new file mode 100644 index 000000000..fb6d13a2b --- /dev/null +++ b/src/mobile/SideBar.scss @@ -0,0 +1,79 @@ +* { + margin:0px; + padding:0px; + box-sizing:border-box; + font-family:"Open Sans"; +} +body { + overflow:hidden; +} +.navbar { + position:fixed; + top:0px; + left:0px; + width:100vw; + height:50px; + background:rgba(0,0,0,0.95); +} +.navbar .toggle-btn { + position:absolute; + right:20px; + height:50px; + width:50px; + transition:all 300ms ease-in-out 200ms; +} +.navbar .toggle-btn span { + position:absolute; + top:50%; + left:50%; + transform:translate(-50%,-50%); + width:70%; + height:4px; + background:#eee; + transition:all 200ms ease; +} +.navbar .toggle-btn span:nth-child(1) { + transition:top 200ms ease-in-out; + top:30%; +} +.navbar .toggle-btn span:nth-child(3) { + transition:top 200ms ease-in-out; + top:70%; +} +.navbar .toggle-btn.active { + transition:transform 200ms ease-in-out 200ms; + transform:rotate(135deg); +} +.navbar .toggle-btn.active span:nth-child(1) { + top:50%; +} +.navbar .toggle-btn.active span:nth-child(2) { + transform:translate(-50%,-50%) rotate(90deg); +} +.navbar .toggle-btn.active span:nth-child(3) { + top:50%; +} +.sidebar { + position:absolute; + top:50px; + opacity:0; + right:-100%; + width:100vw; + height:calc(100vh - 45px); + z-index:5; + background:rgba(40,40,40,1); + transition:all 400ms ease 50ms; + padding:15px; +} +.sidebar .item { + width:100%; + padding:13px 6px; + border-bottom:1px solid rgba(200,200,200,0.7); + font-size:18px; + text-transform:uppercase; + color:rgba(250,250,250,0.95); +} +.sidebar.active { + right:0%; + opacity:1; +} \ No newline at end of file diff --git a/src/mobile/SideBar.tsx b/src/mobile/SideBar.tsx new file mode 100644 index 000000000..a06069ed8 --- /dev/null +++ b/src/mobile/SideBar.tsx @@ -0,0 +1,39 @@ +import React = require("react"); +import { observer } from "mobx-react"; +import "./SideBar.scss"; +import { computed } from "mobx"; +import { DocumentView } from '../client/views/nodes/DocumentView'; + +@observer +export class SideBar extends React.Component<{ views: (DocumentView | undefined)[], stack?: any }, {}>{ + + constructor(props: { views: (DocumentView | undefined)[] }) { + super(props); + } + + @computed + onClick() { + document.getElementsByClassName('sidebar') + [0].classList.toggle('active'); + } + + render() { + return ( + <> +
+
+ + + +
+
+
+
Workspace1
+
Workspace2
+
Workspace3
+
+ + ); + } + +} \ No newline at end of file diff --git a/src/mobile/WorkSpaceButton.scss b/src/mobile/WorkSpaceButton.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/mobile/WorkSpaceButton.tsx b/src/mobile/WorkSpaceButton.tsx new file mode 100644 index 000000000..70c3e6edc --- /dev/null +++ b/src/mobile/WorkSpaceButton.tsx @@ -0,0 +1,14 @@ +import React = require('react'); +import { observer } from "mobx-react"; +import { observable } from 'mobx'; + +interface IProps { + open: boolean; +} + +@observer +export class MenuButton extends React.Component { + @observable static Instance: MenuButton; + + +} \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 1f437abfeabf897887fb9e3097df06a1934ae884 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Sat, 6 Jun 2020 01:14:09 -0700 Subject: fixed import ordering --- src/client/views/webcam/WebCamLogic.js | 5 +---- src/mobile/MobileInterface.tsx | 33 ++++++++++++++++++++++----------- src/mobile/MobileMain.tsx | 14 +++++++------- 3 files changed, 30 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/client/views/webcam/WebCamLogic.js b/src/client/views/webcam/WebCamLogic.js index a8a2f5fa4..5f6202bc8 100644 --- a/src/client/views/webcam/WebCamLogic.js +++ b/src/client/views/webcam/WebCamLogic.js @@ -1,8 +1,5 @@ 'use strict'; import io from "socket.io-client"; -import { - resolvedPorts -} from "../Main"; var socket; var isChannelReady = false; @@ -32,7 +29,7 @@ export function initialize(roomName, handlerUI) { room = roomName; - socket = io.connect(`${window.location.protocol}//${window.location.hostname}:${resolvedPorts.socket}`); + socket = io.connect(`${window.location.protocol}//${window.location.hostname}:4321`); if (room !== '') { socket.emit('create or join', room); diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx index 1f7244653..052c8975a 100644 --- a/src/mobile/MobileInterface.tsx +++ b/src/mobile/MobileInterface.tsx @@ -1,33 +1,44 @@ -import React = require('react'); +import * as React from "react"; import { library } from '@fortawesome/fontawesome-svg-core'; -import { faEraser, faHighlighter, faLongArrowAltLeft, faMousePointer, faPenNib, faThumbtack, faHome } from '@fortawesome/free-solid-svg-icons'; +import { + faTasks, faEdit, faTrashAlt, faPalette, faAngleRight, faBell, faTrash, faCamera, faExpand, faCaretDown, faCaretLeft, faCaretRight, faCaretSquareDown, faCaretSquareRight, faArrowsAltH, faPlus, faMinus, + faTerminal, faToggleOn, faFile as fileSolid, faExternalLinkAlt, faLocationArrow, faSearch, faFileDownload, faStop, faCalculator, faWindowMaximize, faAddressCard, + faQuestionCircle, faArrowLeft, faArrowRight, faArrowDown, faArrowUp, faBolt, faBullseye, faCaretUp, faCat, faCheck, faChevronRight, faClipboard, faClone, faCloudUploadAlt, + faCommentAlt, faCompressArrowsAlt, faCut, faEllipsisV, faEraser, faExclamation, faFileAlt, faFileAudio, faFilePdf, faFilm, faFilter, faFont, faGlobeAsia, faHighlighter, + faLongArrowAltRight, faMicrophone, faMousePointer, faMusic, faObjectGroup, faPause, faPen, faPenNib, faPhone, faPlay, faPortrait, faRedoAlt, faStamp, faStickyNote, + faThumbtack, faTree, faTv, faUndoAlt, faVideo, faAsterisk, faBrain, faImage, faPaintBrush, faTimes, faEye, faHome, faLongArrowAltLeft +} from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { action, computed, observable } from 'mobx'; import { observer } from 'mobx-react'; import * as rp from 'request-promise'; +import { Doc, DocListCast, FieldResult } from '../fields/Doc'; +import { Id } from '../fields/FieldSymbols'; +import { FieldValue, Cast, StrCast } from '../fields/Types'; +import { CurrentUserUtils } from '../client/util/CurrentUserUtils'; +import { emptyPath, emptyFunction, returnFalse, returnOne, returnTrue, returnZero, Utils } from '../Utils'; +import { DocServer } from '../client/DocServer'; import { Docs } from '../client/documents/Documents'; +import { Scripting } from '../client/util/Scripting'; import { DocumentView } from '../client/views/nodes/DocumentView'; -import { emptyPath, emptyFunction, returnFalse, returnOne, returnTrue, returnZero, Utils } from '../Utils'; import { Transform } from '../client/util/Transform'; -import { Scripting } from '../client/util/Scripting'; import { InkingControl } from '../client/views/InkingControl'; import "./MobileInterface.scss"; import "./MobileMenu.scss"; -import { DocServer } from '../client/DocServer'; import { DocumentManager } from '../client/util/DocumentManager'; import SettingsManager from '../client/util/SettingsManager'; import { Uploader } from "./ImageUpload"; import { DockedFrameRenderer } from '../client/views/collections/CollectionDockingView'; -import { Doc, DocListCast, FieldResult } from '../fields/Doc'; -import { FieldValue, Cast, StrCast } from '../fields/Types'; import { InkTool } from '../fields/InkField'; import { listSpec } from '../fields/Schema'; import { nullAudio, WebField } from '../fields/URLField'; -import { Id } from '../fields/FieldSymbols'; -import { CurrentUserUtils } from '../client/util/CurrentUserUtils'; -library.add(faLongArrowAltLeft); -library.add(faHome); +library.add(faTasks, faEdit, faTrashAlt, faPalette, faAngleRight, faBell, faTrash, faCamera, faExpand, faCaretDown, faCaretLeft, faCaretRight, faCaretSquareDown, faCaretSquareRight, faArrowsAltH, faPlus, faMinus, + faTerminal, faToggleOn, fileSolid, faExternalLinkAlt, faLocationArrow, faSearch, faFileDownload, faStop, faCalculator, faWindowMaximize, faAddressCard, + faQuestionCircle, faArrowLeft, faArrowRight, faArrowDown, faArrowUp, faBolt, faBullseye, faCaretUp, faCat, faCheck, faChevronRight, faClipboard, faClone, faCloudUploadAlt, + faCommentAlt, faCompressArrowsAlt, faCut, faEllipsisV, faEraser, faExclamation, faFileAlt, faFileAudio, faFilePdf, faFilm, faFilter, faFont, faGlobeAsia, faHighlighter, + faLongArrowAltRight, faMicrophone, faMousePointer, faMusic, faObjectGroup, faPause, faPen, faPenNib, faPhone, faPlay, faPortrait, faRedoAlt, faStamp, faStickyNote, + faThumbtack, faTree, faTv, faUndoAlt, faVideo, faAsterisk, faBrain, faImage, faPaintBrush, faTimes, faEye, faHome, faLongArrowAltLeft); @observer export class MobileInterface extends React.Component { diff --git a/src/mobile/MobileMain.tsx b/src/mobile/MobileMain.tsx index 34f06438f..3d4680d58 100644 --- a/src/mobile/MobileMain.tsx +++ b/src/mobile/MobileMain.tsx @@ -1,10 +1,10 @@ -import { DocServer } from '../client/DocServer'; -import { Docs } from '../client/documents/Documents'; -import * as ReactDOM from "react-dom"; -import { MobileInterface } from './MobileInterface'; -import * as React from "react"; -import { AssignAllExtensions } from '../extensions/General/Extensions'; -import { CurrentUserUtils } from '../client/util/CurrentUserUtils'; +import { MobileInterface } from "./MobileInterface"; +import { Docs } from "../client/documents/Documents"; +import { CurrentUserUtils } from "../client/util/CurrentUserUtils"; +import * as ReactDOM from 'react-dom'; +import * as React from 'react'; +import { DocServer } from "../client/DocServer"; +import { AssignAllExtensions } from "../extensions/General/Extensions"; AssignAllExtensions(); -- cgit v1.2.3-70-g09d2 From 0bd7f4f85be56de4326f0671453fc5e5e917a5d0 Mon Sep 17 00:00:00 2001 From: Lionel Han <47760119+IGoByJoe@users.noreply.github.com> Date: Sun, 7 Jun 2020 21:22:25 -0700 Subject: pull current work in --- deploy/mobile/image.html | 3 +- src/client/util/CurrentUserUtils.ts | 105 +- src/client/views/GestureOverlay.tsx | 14 +- .../collectionFreeForm/CollectionFreeFormView.tsx | 2 +- src/mobile/MobileHome.scss | 101 ++ src/mobile/MobileInterface.tsx | 1819 ++++++++++++++++++-- src/mobile/MobileMenu.scss | 122 +- src/mobile/SideBar.scss | 79 - src/mobile/SideBar.tsx | 39 - src/mobile/WorkSpaceButton.scss | 0 src/mobile/WorkSpaceButton.tsx | 14 - 11 files changed, 1916 insertions(+), 382 deletions(-) create mode 100644 src/mobile/MobileHome.scss delete mode 100644 src/mobile/SideBar.scss delete mode 100644 src/mobile/SideBar.tsx delete mode 100644 src/mobile/WorkSpaceButton.scss delete mode 100644 src/mobile/WorkSpaceButton.tsx (limited to 'src') diff --git a/deploy/mobile/image.html b/deploy/mobile/image.html index beca8b68b..d30ad6ac2 100644 --- a/deploy/mobile/image.html +++ b/deploy/mobile/image.html @@ -1,13 +1,12 @@ - Test view + Dash Mobile
-

Capture Image:

diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 496099557..8ed275efc 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -386,25 +386,56 @@ export class CurrentUserUtils { return doc.myItemCreators as Doc; } - static setupMobileButtons(doc: Doc, buttons?: string[]) { + // static setupMobileButtons(doc: Doc, buttons?: string[]) { + // const docProtoData: { title: string, icon: string, drag?: string, ignoreClick?: boolean, click?: string, ischecked?: string, activePen?: Doc, backgroundColor?: string, dragFactory?: Doc }[] = [ + // { title: "record", icon: "microphone", ignoreClick: true, click: "FILL" }, + // { title: "use pen", icon: "pen-nib", click: 'activatePen(this.activePen.inkPen = sameDocs(this.activePen.inkPen, this) ? undefined : this,2, this.backgroundColor)', backgroundColor: "blue", ischecked: `sameDocs(this.activePen.inkPen, this)`, activePen: doc }, + // { title: "use highlighter", icon: "highlighter", click: 'activateBrush(this.activePen.inkPen = sameDocs(this.activePen.inkPen, this) ? undefined : this,20,this.backgroundColor)', backgroundColor: "yellow", ischecked: `sameDocs(this.activePen.inkPen, this)`, activePen: doc }, + // { title: "use eraser", icon: "eraser", click: 'activateEraser(this.activePen.inkPen = sameDocs(this.activePen.inkPen, this) ? undefined : this);', ischecked: `sameDocs(this.activePen.inkPen, this)`, backgroundColor: "pink", activePen: doc }, + // { title: "use drag", icon: "mouse-pointer", click: 'deactivateInk();this.activePen.inkPen = this;', ischecked: `sameDocs(this.activePen.inkPen, this)`, backgroundColor: "white", activePen: doc }, + // // { title: "draw", icon: "pen-nib", click: 'switchMobileView(setupMobileInkingDoc, renderMobileInking, onSwitchMobileInking);', ischecked: `sameDocs(this.activePen.inkPen, this)`, backgroundColor: "red", activePen: doc }, + // { title: "upload", icon: "upload", click: 'switchMobileView(setupMobileUploadDoc, renderMobileUpload, onSwitchMobileUpload);', backgroundColor: "orange" }, + // // { title: "upload", icon: "upload", click: 'uploadImageMobile();', backgroundColor: "cyan" }, + // ]; + // return docProtoData.filter(d => !buttons || !buttons.includes(d.title)).map(data => Docs.Create.FontIconDocument({ + // _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100, dropAction: data.click ? "copy" : undefined, title: data.title, icon: data.icon, ignoreClick: data.ignoreClick, + // onDragStart: data.drag ? ScriptField.MakeFunction(data.drag) : undefined, onClick: data.click ? ScriptField.MakeScript(data.click) : undefined, + // ischecked: data.ischecked ? ComputedField.MakeFunction(data.ischecked) : undefined, activePen: data.activePen, + // backgroundColor: data.backgroundColor, removeDropProperties: new List(["dropAction"]), dragFactory: data.dragFactory, + // })); + // } + + static setupMobileButtons(doc?: Doc, buttons?: string[]) { const docProtoData: { title: string, icon: string, drag?: string, ignoreClick?: boolean, click?: string, ischecked?: string, activePen?: Doc, backgroundColor?: string, dragFactory?: Doc }[] = [ - { title: "record", icon: "microphone", ignoreClick: true, click: "FILL" }, - { title: "use pen", icon: "pen-nib", click: 'activatePen(this.activePen.inkPen = sameDocs(this.activePen.inkPen, this) ? undefined : this,2, this.backgroundColor)', backgroundColor: "blue", ischecked: `sameDocs(this.activePen.inkPen, this)`, activePen: doc }, - { title: "use highlighter", icon: "highlighter", click: 'activateBrush(this.activePen.inkPen = sameDocs(this.activePen.inkPen, this) ? undefined : this,20,this.backgroundColor)', backgroundColor: "yellow", ischecked: `sameDocs(this.activePen.inkPen, this)`, activePen: doc }, - { title: "use eraser", icon: "eraser", click: 'activateEraser(this.activePen.inkPen = sameDocs(this.activePen.inkPen, this) ? undefined : this);', ischecked: `sameDocs(this.activePen.inkPen, this)`, backgroundColor: "pink", activePen: doc }, - { title: "use drag", icon: "mouse-pointer", click: 'deactivateInk();this.activePen.inkPen = this;', ischecked: `sameDocs(this.activePen.inkPen, this)`, backgroundColor: "white", activePen: doc }, - // { title: "draw", icon: "pen-nib", click: 'switchMobileView(setupMobileInkingDoc, renderMobileInking, onSwitchMobileInking);', ischecked: `sameDocs(this.activePen.inkPen, this)`, backgroundColor: "red", activePen: doc }, - { title: "upload", icon: "upload", click: 'switchMobileView(setupMobileUploadDoc, renderMobileUpload, onSwitchMobileUpload);', backgroundColor: "orange" }, - // { title: "upload", icon: "upload", click: 'uploadImageMobile();', backgroundColor: "cyan" }, + { title: "library", icon: "bars", click: 'switchToLibrary()', backgroundColor: "lightgrey" }, + { title: "record", icon: "microphone", click: 'openMobileAudio()', backgroundColor: "lightgrey" }, + { title: "upload", icon: "upload", click: 'uploadMobileImage()', backgroundColor: "lightgrey" }, + { title: "presentation", icon: "desktop", click: 'openMobilePresentation()', backgroundColor: "lightgrey" }, + { title: "ink", icon: "pen-nib", backgroundColor: "lightgrey" }, + { title: "settings", icon: "cog", click: 'openMobileSettings()', backgroundColor: "lightgrey" } ]; return docProtoData.filter(d => !buttons || !buttons.includes(d.title)).map(data => Docs.Create.FontIconDocument({ - _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100, dropAction: data.click ? "copy" : undefined, title: data.title, icon: data.icon, ignoreClick: data.ignoreClick, - onDragStart: data.drag ? ScriptField.MakeFunction(data.drag) : undefined, onClick: data.click ? ScriptField.MakeScript(data.click) : undefined, - ischecked: data.ischecked ? ComputedField.MakeFunction(data.ischecked) : undefined, activePen: data.activePen, - backgroundColor: data.backgroundColor, removeDropProperties: new List(["dropAction"]), dragFactory: data.dragFactory, + _nativeWidth: 150, _nativeHeight: 150, _width: 150, _height: 150, + dropAction: undefined, + title: data.title, + icon: data.icon, + ignoreClick: data.ignoreClick, + onDragStart: data.drag ? ScriptField.MakeFunction(data.drag) : undefined, + onClick: data.click ? ScriptField.MakeScript(data.click) : undefined, + ischecked: data.ischecked ? ComputedField.MakeFunction(data.ischecked) : undefined, + activePen: data.activePen, + backgroundColor: data.backgroundColor, removeDropProperties: new List(["dropAction"]), + dragFactory: data.dragFactory, })); } + static setupMobileMenu() { + const menu = Cast(Docs.Create.StackingDocument(CurrentUserUtils.setupMobileButtons(), { + _width: 980, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "home", _autoHeight: true, _yMargin: 80 + }), Doc) as Doc; + return menu; + } + static setupThumbButtons(doc: Doc) { const docProtoData: { title: string, icon: string, drag?: string, ignoreClick?: boolean, pointerDown?: string, pointerUp?: string, ischecked?: string, clipboard?: Doc, activePen?: Doc, backgroundColor?: string, dragFactory?: Doc }[] = [ { title: "use pen", icon: "pen-nib", pointerUp: "resetPen()", pointerDown: 'setPen(2, this.backgroundColor)', backgroundColor: "blue", ischecked: `sameDocs(this.activePen.inkPen, this)`, activePen: doc }, @@ -438,16 +469,20 @@ export class CurrentUserUtils { return Cast(userDoc.thumbDoc, Doc); } - static setupMobileDoc(userDoc: Doc) { - return userDoc.activeMoble ?? Docs.Create.MasonryDocument(CurrentUserUtils.setupMobileButtons(userDoc), { - columnWidth: 100, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons", _autoHeight: true, _yMargin: 5 - }); + static setupLibrary(userDoc: Doc) { + return CurrentUserUtils.setupWorkspaces(userDoc); } static setupMobileInkingDoc(userDoc: Doc) { return Docs.Create.FreeformDocument([], { title: "Mobile Inking", backgroundColor: "white" }); } + static setupMobileDoc(userDoc: Doc) { + return userDoc.activeMoble ?? Docs.Create.MasonryDocument(CurrentUserUtils.setupMobileButtons2(userDoc), { + columnWidth: 100, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons", _autoHeight: true, _yMargin: 5 + }); + } + static setupMobileUploadDoc(userDoc: Doc) { // const addButton = Docs.Create.FontIconDocument({ onDragStart: ScriptField.MakeScript('addWebToMobileUpload()'), title: "Add Web Doc to Upload Collection", icon: "plus", backgroundColor: "black" }) const webDoc = Docs.Create.WebDocument("https://www.britannica.com/biography/Miles-Davis", { @@ -608,6 +643,42 @@ export class CurrentUserUtils { dropAction: "alias", removeDropProperties: new List(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100 })) as any as Doc + static setupMobileButtons2(doc?: Doc, buttons?: string[]) { + const docProtoData: { title: string, icon: string, drag?: string, ignoreClick?: boolean, click?: string, ischecked?: string, activePen?: Doc, backgroundColor?: string, info: string, dragFactory?: Doc }[] = [ + { title: "LIBRARY", icon: "bars", click: 'switchToLibrary()', backgroundColor: "#ffd6d6", info: "Navigate and access all of your documents within their respective collections" }, + { title: "RECORD", icon: "microphone", click: 'openMobileAudio()', backgroundColor: "#ffbfbf", info: "Use your mobile to record audio and access it on Dash Web." }, + { title: "UPLOAD", icon: "upload", click: 'uploadMobileImage()', backgroundColor: "#ff9e9e", info: "Upload an image from your mobile device so it can be accessed on Dash Web" }, + { title: "PRESENTATION", icon: "desktop", click: 'openMobilePresentation()', backgroundColor: "#ff8080", info: "Use your phone as a remote for you presentation." }, + // { title: "INK", icon: "pen-nib", backgroundColor: "lightgrey", info: "Doodle and draw with ink on your mobile and have it directly available on Dash Web" }, + { title: "SETTINGS", icon: "cog", click: 'openMobileSettings()', backgroundColor: "#ff5e5e", info: "Change your password, log out, or manage your account security" } + ]; + return docProtoData.filter(d => !buttons || !buttons.includes(d.title)).map(data => this.mobileButton({ title: data.title, onClick: data.click ? ScriptField.MakeScript(data.click) : undefined, _backgroundColor: data.backgroundColor }, [this.ficon({ ignoreClick: true, icon: data.icon, backgroundColor: "rgba(0,0,0,0)" }), this.mobileTextContainer({}, [this.mobileButtonText({}, data.title), this.mobileButtonInfo({}, data.info)])])); + } + + static mobileButton = (opts: DocumentOptions, docs: Doc[]) => new PrefetchProxy(Docs.Create.MulticolumnDocument(docs, { + ...opts, + dropAction: "alias", removeDropProperties: new List(["dropAction"]), _nativeWidth: 900, _nativeHeight: 250, _width: 900, _height: 250, _yMargin: 15, + borderRounding: "0", boxShadow: "0 0", _chromeStatus: "disabled", + })) as any as Doc + + static mobileTextContainer = (opts: DocumentOptions, docs: Doc[]) => new PrefetchProxy(Docs.Create.MultirowDocument(docs, { + ...opts, + dropAction: "alias", removeDropProperties: new List(["dropAction"]), _nativeWidth: 450, _nativeHeight: 250, _width: 450, _height: 250, _yMargin: 25, + backgroundColor: "rgba(0,0,0,0)", borderRounding: "0", boxShadow: "0 0", _chromeStatus: "disabled", + })) as any as Doc + + + static mobileButtonText = (opts: DocumentOptions, buttonTitle: string) => new PrefetchProxy(Docs.Create.TextDocument(buttonTitle, { + ...opts, + title: buttonTitle, _fontSize: 37, _xMargin: 0, _yMargin: 0, ignoreClick: true, _chromeStatus: "disabled", backgroundColor: "rgba(0,0,0,0)" + })) as any as Doc + + static mobileButtonInfo = (opts: DocumentOptions, buttonInfo: string) => new PrefetchProxy(Docs.Create.TextDocument(buttonInfo, { + ...opts, + title: "info", _fontSize: 25, _xMargin: 0, _yMargin: 0, ignoreClick: true, _chromeStatus: "disabled", backgroundColor: "rgba(0,0,0,0)", _dimMagnitude: 2, + })) as any as Doc + + /// sets up the default list of buttons to be shown in the expanding button menu at the bottom of the Dash window static setupDockedButtons(doc: Doc) { if (doc["dockedBtn-pen"] === undefined) { diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx index 4352ac52c..a11c97b09 100644 --- a/src/client/views/GestureOverlay.tsx +++ b/src/client/views/GestureOverlay.tsx @@ -27,7 +27,7 @@ import { listSpec } from "../../fields/Schema"; import { List } from "../../fields/List"; import { CollectionViewType } from "./collections/CollectionView"; import TouchScrollableMenu, { TouchScrollableMenuItem } from "./TouchScrollableMenu"; -import MobileInterface from "../../mobile/MobileInterface"; +import { MobileInterface } from "../../mobile/MobileInterface"; import { MobileInkOverlayContent } from "../../server/Message"; import MobileInkOverlay from "../../mobile/MobileInkOverlay"; import { RadialMenu } from "./nodes/RadialMenu"; @@ -115,12 +115,12 @@ export default class GestureOverlay extends Touchable { onReactTouchStart = (te: React.TouchEvent) => { document.removeEventListener("touchmove", this.onReactHoldTouchMove); document.removeEventListener("touchend", this.onReactHoldTouchEnd); - if (RadialMenu.Instance._display === true) { - te.preventDefault(); - te.stopPropagation(); - RadialMenu.Instance.closeMenu(); - return; - } + // if (RadialMenu.Instance._display === true) { + // te.preventDefault(); + // te.stopPropagation(); + // RadialMenu.Instance.closeMenu(); + // return; + // } // this chunk adds new touch targets to a map of pointer events; this helps us keep track of individual fingers // so that we can know, for example, if two fingers are pinching out or in. diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 80ee2a65d..8b0c72f5e 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -597,7 +597,7 @@ export class CollectionFreeFormView extends CollectionSubView { // bcz: theres should be a better way of doing these than referencing these static instances directly MarqueeOptionsMenu.Instance?.fadeOut(true);// I think it makes sense for the marquee menu to go away when panned. -syip2 - PDFMenu.Instance.fadeOut(true); + // PDFMenu.Instance.fadeOut(true); const [dx, dy] = this.getTransform().transformDirection(e.clientX - this._lastX, e.clientY - this._lastY); this.setPan((this.Document._panX || 0) - dx, (this.Document._panY || 0) - dy, undefined, true); diff --git a/src/mobile/MobileHome.scss b/src/mobile/MobileHome.scss new file mode 100644 index 000000000..e1566b622 --- /dev/null +++ b/src/mobile/MobileHome.scss @@ -0,0 +1,101 @@ +$navbar-height: 120px; +$pathbar-height: 50px; + +* { + margin: 0px; + padding: 0px; + box-sizing: border-box; + font-family: "Open Sans"; +} + +.homeContainer { + position: relative; + top: 200px; + overflow: scroll; + width: 100%; + left: 0; + height: calc(100% - 120px); + overflow-y: scroll; +} + +.homeButton { + width: 96%; + margin-left: 2.5%; + height: 250px; + border-radius: 30px; + margin-top: 15px; + margin-bottom: 15px; +} + +.iconRight { + position: absolute; + width: 50%; + height: 80px; + transform: translate(0, 50%); + right: 0px; + text-align: center; + font-size: 80; +} + +.iconLeft { + position: absolute; + width: 50%; + height: 80px; + transform: translate(0%, 50%); + left: 0px; + text-align: center; + font-size: 80; +} + +.textLeft { + position: absolute; + width: 50%; + left: 0px; + font-size: 40px; + text-align: left; + margin-left: 110px; + margin-top: 40px; + font-family: sans-serif; + font-weight: bold; +} + +.textRight { + position: absolute; + width: 50%; + right: 0px; + font-size: 40px; + text-align: right; + margin-right: 110px; + margin-top: 40px; + font-family: sans-serif; + font-weight: bold; +} + +.menuView { + position: absolute; + top: 135px; + left: 50%; + transform: translate(-50%, 0%); + display: flex; +} + +.iconView { + height: 60px; + width: 60px; + background-color: darkgray; + border-radius: 5px; + border-style: solid; + border-width: 2px; + border-color: black; +} + +.listView { + height: 60px; + width: 60px; + margin-left: 20; + background-color: darkgray; + border-radius: 5px; + border-style: solid; + border-width: 2px; + border-color: black; +} \ No newline at end of file diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx index 052c8975a..6b75ce07d 100644 --- a/src/mobile/MobileInterface.tsx +++ b/src/mobile/MobileInterface.tsx @@ -6,7 +6,7 @@ import { faQuestionCircle, faArrowLeft, faArrowRight, faArrowDown, faArrowUp, faBolt, faBullseye, faCaretUp, faCat, faCheck, faChevronRight, faClipboard, faClone, faCloudUploadAlt, faCommentAlt, faCompressArrowsAlt, faCut, faEllipsisV, faEraser, faExclamation, faFileAlt, faFileAudio, faFilePdf, faFilm, faFilter, faFont, faGlobeAsia, faHighlighter, faLongArrowAltRight, faMicrophone, faMousePointer, faMusic, faObjectGroup, faPause, faPen, faPenNib, faPhone, faPlay, faPortrait, faRedoAlt, faStamp, faStickyNote, - faThumbtack, faTree, faTv, faUndoAlt, faVideo, faAsterisk, faBrain, faImage, faPaintBrush, faTimes, faEye, faHome, faLongArrowAltLeft + faThumbtack, faTree, faTv, faUndoAlt, faVideo, faAsterisk, faBrain, faImage, faPaintBrush, faTimes, faEye, faHome, faLongArrowAltLeft, faBars, faTh, faChevronLeft } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { action, computed, observable } from 'mobx'; @@ -25,6 +25,7 @@ import { Transform } from '../client/util/Transform'; import { InkingControl } from '../client/views/InkingControl'; import "./MobileInterface.scss"; import "./MobileMenu.scss"; +import "./MobileHome.scss"; import { DocumentManager } from '../client/util/DocumentManager'; import SettingsManager from '../client/util/SettingsManager'; import { Uploader } from "./ImageUpload"; @@ -32,26 +33,1056 @@ import { DockedFrameRenderer } from '../client/views/collections/CollectionDocki import { InkTool } from '../fields/InkField'; import { listSpec } from '../fields/Schema'; import { nullAudio, WebField } from '../fields/URLField'; +import GestureOverlay from "../client/views/GestureOverlay"; library.add(faTasks, faEdit, faTrashAlt, faPalette, faAngleRight, faBell, faTrash, faCamera, faExpand, faCaretDown, faCaretLeft, faCaretRight, faCaretSquareDown, faCaretSquareRight, faArrowsAltH, faPlus, faMinus, faTerminal, faToggleOn, fileSolid, faExternalLinkAlt, faLocationArrow, faSearch, faFileDownload, faStop, faCalculator, faWindowMaximize, faAddressCard, faQuestionCircle, faArrowLeft, faArrowRight, faArrowDown, faArrowUp, faBolt, faBullseye, faCaretUp, faCat, faCheck, faChevronRight, faClipboard, faClone, faCloudUploadAlt, faCommentAlt, faCompressArrowsAlt, faCut, faEllipsisV, faEraser, faExclamation, faFileAlt, faFileAudio, faFilePdf, faFilm, faFilter, faFont, faGlobeAsia, faHighlighter, faLongArrowAltRight, faMicrophone, faMousePointer, faMusic, faObjectGroup, faPause, faPen, faPenNib, faPhone, faPlay, faPortrait, faRedoAlt, faStamp, faStickyNote, - faThumbtack, faTree, faTv, faUndoAlt, faVideo, faAsterisk, faBrain, faImage, faPaintBrush, faTimes, faEye, faHome, faLongArrowAltLeft); + faThumbtack, faTree, faTv, faUndoAlt, faVideo, faAsterisk, faBrain, faImage, faPaintBrush, faTimes, faEye, faHome, faLongArrowAltLeft, faBars, faTh, faChevronLeft); + +// @observer +// export class MobileInterface extends React.Component { +// @observable static Instance: MobileInterface; +// @computed private get userDoc() { return Doc.UserDoc(); } +// @computed private get mainContainer() { return this.userDoc ? FieldValue(Cast(this.userDoc.activeMobile, Doc)) : CurrentUserUtils.GuestMobile; } +// @computed private get activeContainer() { return this.userDoc ? FieldValue(Cast(this.userDoc.activeMobile, Doc)) : CurrentUserUtils.GuestMobile; } +// // @observable private currentView: "main" | "ink" | "upload" = "main"; +// @observable private mainDoc: any = CurrentUserUtils.setupMobileDoc(this.userDoc); +// @observable private renderView?: () => JSX.Element; +// @observable private sidebarActive = true; + +// public _activeDoc: Doc = this.mainDoc; +// public _homeDoc: Doc = this.mainDoc; +// private _homeMenu: boolean = true; + +// // private inkDoc?: Doc; +// public drawingInk: boolean = false; +// private _ink: boolean = false; + +// // private _uploadDoc: Doc = this.userDoc; +// private _child: Doc | null = null; +// private _parents: Array = []; +// private _library: Doc = CurrentUserUtils.setupLibrary(this.userDoc); +// private _open: boolean = false; + +// constructor(props: Readonly<{}>) { +// super(props); +// MobileInterface.Instance = this; +// } + +// @action +// componentDidMount = () => { +// library.add(...[faPenNib, faHighlighter, faEraser, faMousePointer, faThumbtack]); + +// if (this.userDoc && !this.mainContainer) { +// this.userDoc.activeMobile = this._homeDoc; +// } + +// InkingControl.Instance.switchTool(InkTool.None); +// MobileInterface.Instance.drawingInk = false; +// InkingControl.Instance.updateSelectedColor("#FF0000"); +// InkingControl.Instance.switchWidth("2"); +// this.switchCurrentView((userDoc: Doc) => this._homeDoc); +// } + +// @action +// switchCurrentView = (doc: (userDoc: Doc) => Doc, renderView?: () => JSX.Element, onSwitch?: () => void) => { +// if (!this.userDoc) return; + +// this.userDoc.activeMobile = doc(this.userDoc); +// onSwitch && onSwitch(); + +// this.renderView = renderView; +// } + +// onSwitchInking = () => { +// const button = document.getElementById("inkButton") as HTMLElement; +// const color = InkingControl.Instance.selectedColor; +// button.style.backgroundColor = this._ink ? "white" : color; +// button.style.color = this._ink ? "black" : "white"; + +// if (!this._ink) { +// console.log("INK IS ACTIVE"); +// InkingControl.Instance.switchTool(InkTool.Pen); +// MobileInterface.Instance.drawingInk = true; +// this._ink = true; +// } else { +// console.log("INK IS INACTIVE"); +// InkingControl.Instance.switchTool(InkTool.None); +// MobileInterface.Instance.drawingInk = false; +// this._ink = false; +// } +// } + +// onSwitchUpload = async () => { +// let width = 300; +// let height = 300; +// const res = await rp.get(Utils.prepend("/getUserDocumentId")); + +// // get width and height of the collection doc +// if (this.mainContainer) { +// const data = Cast(this.mainContainer.data, listSpec(Doc)); +// if (data) { +// const collectionDoc = await data[1]; // this should be the collection doc since the positions should be locked +// const docView = DocumentManager.Instance.getDocumentView(collectionDoc); +// if (docView) { +// width = docView.nativeWidth ? docView.nativeWidth : 300; +// height = docView.nativeHeight ? docView.nativeHeight : 300; +// } +// } +// } +// DocServer.Mobile.dispatchOverlayTrigger({ +// enableOverlay: true, +// width: width, +// height: height, +// text: "Documents uploaded from mobile will show here", +// }); +// } + +// back = () => { +// let header = document.getElementById("header") as HTMLElement; +// let doc = Cast(this._parents.pop(), Doc) as Doc; +// if (doc === Cast(this._library, Doc) as Doc) { +// this._child = null; +// this.userDoc.activeMobile = this._library; +// } else if (doc === Cast(this._homeDoc, Doc) as Doc) { +// this._homeMenu = true; +// this._parents = []; +// this._activeDoc = this._homeDoc; +// this._child = null; +// this.switchCurrentView((userDoc: Doc) => this._homeDoc); +// } else { +// if (doc) { +// this._child = doc; +// this.switchCurrentView((userDoc: Doc) => doc); +// this._homeMenu = false; +// header.textContent = String(doc.title); +// } +// } +// if (doc) { +// this._activeDoc = doc; +// } +// this._ink = false; +// } + +// returnHome = () => { +// if (this._homeMenu === false || this._open === true) { +// this._homeMenu = true; +// this._parents = []; +// this._activeDoc = this._homeDoc; +// this._child = null; +// this.switchCurrentView((userDoc: Doc) => this._homeDoc); +// } +// if (this._open) { +// this.toggleSidebar(); +// } +// } + +// returnMain = () => { +// this._parents = []; +// // this.toggleSidebar(); +// this._activeDoc = this._library; +// this.switchCurrentView((userDoc: Doc) => this._library); +// this._homeMenu = false; +// this._child = null; +// } + +// displayWorkspaces = () => { +// if (this.mainContainer) { +// const backgroundColor = () => "white"; +// if (this._activeDoc.title === "mobile audio") { +// return ( +//
+// window.screen.width} +// PanelHeight={() => window.screen.height} +// renderDepth={0} +// focus={emptyFunction} +// backgroundColor={backgroundColor} +// parentActive={returnTrue} +// whenActiveChanged={emptyFunction} +// bringToFront={emptyFunction} +// ContainingCollectionView={undefined} +// ContainingCollectionDoc={undefined} +// /> +//
+// ); +// } else { +// return ( +//
+// +//
+// ); +// } +// } +// } + +// returnWidth = () => 2000; +// returnHeight = () => 2000; + +// handleClick(doc: Doc) { +// let children = DocListCast(doc.data); +// if (doc.type !== "collection") { +// this._parents.push(this._activeDoc); +// this._activeDoc = doc; +// this.switchCurrentView((userDoc: Doc) => doc); +// this._homeMenu = false; +// this.toggleSidebar(); +// } else if (doc.type === "collection" && children.length === 0) { +// console.log("This collection has no children"); +// } else { +// this._parents.push(this._activeDoc); +// this._activeDoc = doc; +// this.switchCurrentView((userDoc: Doc) => doc); +// this._homeMenu = false; +// this._child = doc; +// } + +// // let sidebar = document.getElementById("sidebar") as HTMLElement; +// // sidebar.classList.toggle('active'); +// } + +// createPathname = () => { +// let docArray = []; +// this._parents.map((doc: Doc, index: any) => { +// // if (doc === this.mainDoc) { +// // pathname = pathname; +// // } else if (doc.type === "audio" || doc.type === "presentation") { +// // pathname = pathname; +// // } else if (doc.type !== "collection") { +// // pathname = pathname; +// // } else { +// // pathname = pathname + " > " + doc.title; +// // titleArray.push(doc.title); +// // docArray.push(doc); +// // } +// docArray.push(doc); +// }); +// docArray.push(this._activeDoc); +// // if (this._activeDoc.title === "mobile audio") { +// // pathname = this._activeDoc.title; +// // } else if (this._activeDoc.title === "Presentation") { +// // pathname = this._activeDoc.title; +// // } else if (this._activeDoc === this.mainDoc) { +// // pathname = pathname; +// // } else { +// // pathname = pathname + " > " + this._activeDoc.title; +// // docArray.push(this._activeDoc); +// // titleArray.push(this._activeDoc.title); +// // } + +// return docArray; +// } + +// renderPathbar = () => { +// // if (this._homeMenu == false) { +// let docArray = this.createPathname(); +// let items = docArray.map((doc: Doc, index: any) => { +// if (index == 0) { +// return ( +//
+//
this.handlePathClick(doc, index)}>{doc.title} +//
+//
); +// } else if (doc === this._activeDoc) { +// return ( +//
+// +//
this.handlePathClick(doc, index)}>{doc.title} +//
+//
); +// } else { +// return ( +//
+// +//
this.handlePathClick(doc, index)}>{doc.title} +//
+//
); +// } + +// }); +// if (this._parents.length !== 0) { +// return (
+//
+// {items} +//
+//
+// +//
+//
+//
); +// } else { +// return (
+//
+// {items} +//
+//
+//
); +// } +// // } +// // } else { + +// // return ( +// //
+// //
+// //
+// //
this.returnHome()}>Home +// //
+// //
+// //
+// //
+// //
+// // ); +// // } + +// // } +// } + +// handlePathClick = (doc: Doc, index: number) => { +// if (doc === this._library) { +// this._activeDoc = doc; +// this._child = null; +// this.switchCurrentView((userDoc: Doc) => doc); +// this._parents.length = index; +// } else if (doc === this._homeDoc) { +// this.returnHome(); +// } else { +// console.log(index); +// this._activeDoc = doc; +// this._child = doc; +// this.switchCurrentView((userDoc: Doc) => doc); +// this._parents.length = index; +// } +// } + +// @action +// toggleSidebar = () => this.sidebarActive = !this.sidebarActive + +// switchToLibrary = () => { +// this._parents.push(this._activeDoc); +// this.switchCurrentView((userDoc: Doc) => this._library); +// this._activeDoc = this._library; +// this._homeMenu = false; +// this.toggleSidebar(); +// } + +// // renderDefaultContent = () => { +// // let menuButtons = DocListCast(this._homeDoc.data).map((doc: Doc, index: any) => { +// // if (doc.type !== "ink") { +// // return ( +// //
doc.click}>{doc.title} +// //
); +// // } +// // }); + +// // if (this._homeMenu === true) { +// // return ( +// //
+// //
+// // +// // +// // +// //
+// // {this.renderPathbar()} +// // +// //
+// // ); +// // } + +// // const workspaces = Cast(this.userDoc.myWorkspaces, Doc) as Doc; +// // const buttons = DocListCast(this._child ? this._child.data : workspaces.data).map((doc: Doc, index: any) => { +// // return ( +// //
this.handleClick(doc)}>{doc.title} +// //
{doc.type}
+// // +// //
); +// // }); +// // return ( +// // <> +// //
+// //
{this.sidebarActive ? StrCast(this._activeDoc.title) : "Menu"}
+// //
+// //
+// //
+// //
{this.createPathname()}
+// //
+// //
+// // +// // {this._child ? +// // <> +// //
+// //
{buttons}
+// //
Home
+// // : +// // <> +// // {buttons} +// // {/*
+// // Library +// //
*/} +// // +// //
Record Audio
+// //
Presentation
+// //
SettingsManager.Instance.open()}>Settings
+// // +// // } +// //
+// // {this._child ? null :
{this.renderView}
} +// // +// // ); +// // } + +// renderDefaultContent = () => { +// let menuButtons = DocListCast(this._homeDoc.data).map((doc: Doc, index: any) => { +// if (doc.type !== "ink") { +// return ( +//
doc.click}>{doc.title} +//
); +// } +// }); + +// if (this._homeMenu === true) { +// return ( +//
+//
+// +// +// +//
+// {this.renderPathbar()} +// +//
+// ); +// } +// const workspaces = Cast(this.userDoc.myWorkspaces, Doc) as Doc; +// let buttons = DocListCast(workspaces.data).map((doc: Doc, index: any) => { +// if (doc.type !== "ink") { +// return ( +//
this.handleClick(doc)}>{doc.title} +//
{doc.type}
+// +//
); +// } +// }); + +// if (this._child) { +// buttons = DocListCast(this._child.data).map((doc: Doc, index: any) => { +// if (doc.type !== "ink") { +// return ( +//
this.handleClick(doc)}>{doc.title} +//
{doc.type}
+// +//
); +// } +// }); +// } + +// if (!this._child) { +// return ( +//
+//
+// +// +// +//
+// {this.renderPathbar()} +// +// {/*
+// {this.renderView} +//
*/} +//
+// ); +// } +// else { +// return ( +//
+//
+// +// +// +//
+// {this.renderPathbar()} +// +//
+// ); +// } +// } + +// recordAudio = async () => { +// // upload to server with known URL +// if (this._activeDoc.title !== "mobile audio") { +// this._parents.push(this._activeDoc); +// } +// const audioDoc = Cast(Docs.Create.AudioDocument(nullAudio, { _width: 200, _height: 100, title: "mobile audio" }), Doc) as Doc; +// console.log(audioDoc); +// if (audioDoc) { +// console.log("audioClicked: " + audioDoc.title); +// this._activeDoc = audioDoc; +// this.switchCurrentView((userDoc: Doc) => audioDoc); +// this._homeMenu = false; +// // this.toggleSidebar(); +// } +// // const audioRightSidebar = Cast(Doc.UserDoc().rightSidebarCollection, Doc) as Doc; +// // this.audioState = await audioDoc.getProto; +// // if (this.audioState) { +// // console.log(this.audioState); +// // const data = Cast(audioRightSidebar.data, listSpec(Doc)); +// // if (data) { +// // data.push(audioDoc); +// // } +// // } +// } + +// uploadAudio = () => { +// const audioRightSidebar = Cast(Doc.UserDoc().rightSidebarCollection, Doc) as Doc; +// const audioDoc = this._activeDoc; +// const data = Cast(audioRightSidebar.data, listSpec(Doc)); +// console.log(audioDoc.proto); +// if (data) { +// data.push(audioDoc); +// } +// // this.recordAudio(); +// } + +// uploadAudioButton = () => { +// if (this._activeDoc.type === "audio") { +// return
+// +//
; +// } +// } + +// toggleSelector = () => { +// console.log("toggle selector!"); +// let toolbar = document.getElementById("toolbar") as HTMLElement; +// toolbar.classList.toggle('active'); +// } + +// colorTool = () => { +// if (this._activeDoc._viewType === "docking") { +// const color = InkingControl.Instance.selectedColor; +// console.log(color); +// return ( +//
+//
+//
+//
{ +// InkingControl.Instance.updateSelectedColor("rgb(255,0,0)"); +// Doc.UserDoc().inkColor = "rgb(255,0,0)"; +// console.log(InkingControl.Instance.selectedColor); +// }}> +//
+//
{ +// InkingControl.Instance.updateSelectedColor("rgb(0,128,0)"); +// Doc.UserDoc().inkColor = "rgb(0,128,0)"; +// console.log(InkingControl.Instance.selectedColor); +// }}> +//
+//
{ +// InkingControl.Instance.updateSelectedColor("rgb(0,0,255)"); +// Doc.UserDoc().inkColor = "rgb(0,0,255)"; +// console.log(InkingControl.Instance.selectedColor); +// }}> +//
+//
+//
+// ) => InkingControl.Instance.switchWidth(e.target.value)} /> +//
+//
+//
+// ); +// } +// } + +// drawInk = () => { +// if (this._activeDoc._viewType === "docking") { +// const inkIsOn = this._ink; +// return
+// +//
; +// } +// } + +// downloadDocument = () => { +// if (this._activeDoc.type === "image") { +// const url = this._activeDoc["data-path"]?.toString(); +// return
{ +// window.open(url); +// console.log(url); +// }}> +// +//
; +// } +// } + +// pinToPresentation = () => { +// // Only making button available if it is an image +// if (this._activeDoc.type === "image") { +// const isPinned = this._activeDoc && Doc.isDocPinned(this._activeDoc); +// return
{ +// if (isPinned) { +// DockedFrameRenderer.UnpinDoc(this._activeDoc); +// } +// else { +// DockedFrameRenderer.PinDoc(this._activeDoc); +// } +// }}> +// +//
; +// } +// } + +// setupDefaultPresentation = () => { +// if (this._activeDoc.title !== "Presentation") { +// this._parents.push(this._activeDoc); +// } + +// const presentation = Cast(Doc.UserDoc().activePresentation, Doc) as Doc; + +// if (presentation) { +// console.log(this._activeDoc.mobile); +// console.log("presentation clicked: " + presentation.title); +// this._activeDoc = presentation; +// this.switchCurrentView((userDoc: Doc) => presentation); +// this._homeMenu = false; +// // this.toggleSidebar(); +// } +// } + +// // mobileHome = () => { +// // return ( +// //
+// //
+ +// //
+// //
+ +// //
+// //
+ +// //
+// //
+ +// //
+// //
+ +// //
+// //
+// // ); +// // } + +// renderActiveCollection = (userDoc: Doc) => { +// if (this.activeContainer) { +// const active = Cast(this.activeContainer.data, listSpec(Doc)); +// if (active) { +// return ( +//
HELLO!
+// ); +// } +// } +// } + +// onBack = (e: React.MouseEvent) => { +// this.switchCurrentView((userDoc: Doc) => this.mainDoc); +// InkingControl.Instance.switchTool(InkTool.None); // TODO: switch to previous tool + +// DocServer.Mobile.dispatchOverlayTrigger({ +// enableOverlay: false, +// width: window.innerWidth, +// height: window.innerHeight +// }); + +// // this.inkDoc = undefined; +// this.drawingInk = false; +// } + +// shiftLeft = (e: React.MouseEvent) => { +// DocServer.Mobile.dispatchOverlayPositionUpdate({ +// dx: -10 +// }); +// e.preventDefault(); +// e.stopPropagation(); +// } + +// shiftRight = (e: React.MouseEvent) => { +// DocServer.Mobile.dispatchOverlayPositionUpdate({ +// dx: 10 +// }); +// e.preventDefault(); +// e.stopPropagation(); +// } + +// panelHeight = () => window.innerHeight; +// panelWidth = () => window.innerWidth; +// //WAS 3 + +// //WAS 1 + +// upload = async (e: React.MouseEvent) => { +// if (this.mainContainer) { +// const data = Cast(this.mainContainer.data, listSpec(Doc)); +// if (data) { +// const collectionDoc = await data[1]; //this should be the collection doc since the positions should be locked +// const children = DocListCast(collectionDoc.data); +// const uploadDoc = children.length === 1 ? children[0] : Docs.Create.StackingDocument(children, { +// title: "Mobile Upload Collection", backgroundColor: "white", lockedPosition: true, _width: 300, _height: 300 +// }); +// if (uploadDoc) { +// DocServer.Mobile.dispatchMobileDocumentUpload({ +// docId: uploadDoc[Id], +// }); +// } +// } +// } +// e.stopPropagation(); +// e.preventDefault(); +// } + +// addWebToCollection = async () => { +// let url = "https://en.wikipedia.org/wiki/Hedgehog"; +// if (this.mainContainer) { +// const data = Cast(this.mainContainer.data, listSpec(Doc)); +// if (data) { +// const webDoc = await data[0]; +// const urlField: FieldResult = Cast(webDoc.data, WebField); +// url = urlField ? urlField.url.toString() : "https://en.wikipedia.org/wiki/Hedgehog"; + +// } +// } +// Docs.Create.WebDocument(url, { _width: 300, _height: 300, title: "Mobile Upload Web Doc" }); +// } + +// clearUpload = async () => { +// if (this.mainContainer) { +// const data = Cast(this.mainContainer.data, listSpec(Doc)); +// if (data) { +// const collectionDoc = await data[1]; +// const children = DocListCast(collectionDoc.data); +// children.forEach(doc => { +// }); +// // collectionDoc[data] = new List(); +// } +// } +// } + +// onDragOver = (e: React.DragEvent) => { +// e.preventDefault(); +// e.stopPropagation(); +// } + +// render() { +// // const content = this.currentView === "main" ? this.mainContent : +// // this.currentView === "ink" ? this.inkContent : +// // this.currentView === "upload" ? this.uploadContent : <>; +// return ( +//
+// {/* +// +// {this.renderView ? this.renderView() : this.renderDefaultContent()} +// */} +// {/* */} +// +// {/* {this.menuOptions()} */} +// {/* {this.displayHome()} */} +//
+// {this.pinToPresentation()} +// {this.downloadDocument()} +// {this.drawInk()} +// {this.uploadAudioButton()} +// {this.colorTool()} +//
+// + +// +// {this.renderDefaultContent()} +// {this.displayWorkspaces()} +// {/*
*/} +// {/* +// +// */} +// {/* */} +// {/*
+// {this.renderDefaultContent()} +//
*/} +// {/* */} +// {/* */} +// {/* +// */} +// {/* +// +// */} +//
+// ); +// } +// } + +// Scripting.addGlobal(function switchMobileView(doc: (userDoc: Doc) => Doc, renderView?: () => JSX.Element, onSwitch?: () => void) { return MobileInterface.Instance.switchCurrentView(doc, renderView, onSwitch); }); +// Scripting.addGlobal(function openMobilePresentation() { return MobileInterface.Instance.setupDefaultPresentation(); }); +// Scripting.addGlobal(function toggleMobileSidebar() { return MobileInterface.Instance.toggleSidebar(); }); +// Scripting.addGlobal(function openMobileAudio() { return MobileInterface.Instance.recordAudio(); }); +// Scripting.addGlobal(function openMobileSettings() { return SettingsManager.Instance.open(); }); +// Scripting.addGlobal(function switchToLibrary() { return MobileInterface.Instance.switchToLibrary(); }); +// // WAS 2 + +// // 1 +// // renderUploadContent() { +// // if (this.mainContainer) { +// // return ( +// //
+// //
+// // +// // {/* */} +// // {/* */} +// // +// //
+// // window.screen.width} +// // PanelHeight={() => window.screen.height} +// // renderDepth={0} +// // focus={emptyFunction} +// // backgroundColor={returnEmptyString} +// // parentActive={returnTrue} +// // whenActiveChanged={emptyFunction} +// // bringToFront={emptyFunction} +// // ContainingCollectionView={undefined} +// // ContainingCollectionDoc={undefined} /> +// //
+// // ); +// // } +// // } + +// // 2 +// // Scripting.addGlobal(function onSwitchMobileInking() { return MobileInterface.Instance.onSwitchInking(); }); +// // Scripting.addGlobal(function renderMobileInking() { return MobileInterface.Instance.renderInkingContent(); }); +// // Scripting.addGlobal(function onSwitchMobileUpload() { return MobileInterface.Instance.onSwitchUpload(); }); +// // Scripting.addGlobal(function renderMobileUpload() { return MobileInterface.Instance.renderUploadContent(); }); +// // Scripting.addGlobal(function addWebToMobileUpload() { return MobileInterface.Instance.addWebToCollection(); }); + + +// // 3 +// // renderInkingContent = () => { +// // console.log("rendering inking content"); +// // // TODO: support panning and zooming +// // // TODO: handle moving of ink strokes +// // if (this.mainContainer) { +// // return ( +// //
+// //
+// //
+// // +// //
+// //
+// // +// //
+// //
+// // +// // +// //
+// //
+// // +// // +// //
+// // ); +// // } +// // } @observer export class MobileInterface extends React.Component { @observable static Instance: MobileInterface; @computed private get userDoc() { return Doc.UserDoc(); } @computed private get mainContainer() { return this.userDoc ? FieldValue(Cast(this.userDoc.activeMobile, Doc)) : CurrentUserUtils.GuestMobile; } - @computed private get activeContainer() { return this.userDoc ? FieldValue(Cast(this.userDoc.activeMobile, Doc)) : CurrentUserUtils.GuestMobile; } - // @observable private currentView: "main" | "ink" | "upload" = "main"; - @observable private mainDoc: any = CurrentUserUtils.setupMobileDoc(this.userDoc); + // @computed private get activeContainer() { return this.userDoc ? FieldValue(Cast(this.userDoc.activeMobile, Doc)) : CurrentUserUtils.GuestMobile; } + @observable private mainDoc: any = CurrentUserUtils.setupMobileMenu(); @observable private renderView?: () => JSX.Element; - @observable private sidebarActive = true; + @observable private audioState: any; public _activeDoc: Doc = this.mainDoc; + public _homeDoc: Doc = this.mainDoc; + private _homeMenu: boolean = true; // private inkDoc?: Doc; public drawingInk: boolean = false; @@ -59,9 +1090,11 @@ export class MobileInterface extends React.Component { // private _uploadDoc: Doc = this.userDoc; private _child: Doc | null = null; private _parents: Array = []; - private _menu: Doc = this.mainDoc; + private _library: Doc = CurrentUserUtils.setupLibrary(this.userDoc); private _open: boolean = false; - private _library: Doc = Cast(this.userDoc.myWorkspaces, Doc) as Doc; + + // private _library: Doc = Cast(this.userDoc.myWorkspaces, Doc) as Doc; + private _ink: boolean = false; constructor(props: Readonly<{}>) { super(props); @@ -71,33 +1104,31 @@ export class MobileInterface extends React.Component { @action componentDidMount = () => { library.add(...[faPenNib, faHighlighter, faEraser, faMousePointer, faThumbtack]); - + if (this.userDoc.activeMobile) { + console.log(Doc.UserDoc().activeMobile) + } if (this.userDoc && !this.mainContainer) { - this.userDoc.activeMobile = this.mainDoc; + this.userDoc.activeMobile = this._homeDoc; } + InkingControl.Instance.switchTool(InkTool.None); + MobileInterface.Instance.drawingInk = false; + InkingControl.Instance.updateSelectedColor("#FF0000"); + console.log(this.userDoc.inkColor); + console.log(InkingControl.Instance.selectedColor); + InkingControl.Instance.switchWidth("2"); + this.switchCurrentView((userDoc: Doc) => this._homeDoc); } @action switchCurrentView = (doc: (userDoc: Doc) => Doc, renderView?: () => JSX.Element, onSwitch?: () => void) => { if (!this.userDoc) return; - this.userDoc.activeMobile = doc(this.userDoc); + Doc.UserDoc().activeMobile = doc(this.userDoc); onSwitch && onSwitch(); this.renderView = renderView; } - onSwitchInking = () => { - InkingControl.Instance.switchTool(InkTool.Pen); - MobileInterface.Instance.drawingInk = true; - - DocServer.Mobile.dispatchOverlayTrigger({ - enableOverlay: true, - width: window.innerWidth, - height: window.innerHeight - }); - } - onSwitchUpload = async () => { let width = 300; let height = 300; @@ -123,70 +1154,167 @@ export class MobileInterface extends React.Component { }); } + toggleSidebar = () => { + if (this._open === false) { + this._open = true; + } else { + this._open = false; + } + console.log("clicked"); + let menuButton = document.getElementById("menuButton") as HTMLElement; + menuButton.classList.toggle('active'); + + let sidebar = document.getElementById("sidebar") as HTMLElement; + sidebar.classList.toggle('active'); + + let header = document.getElementById("header") as HTMLElement; + + if (!sidebar.classList.contains('active')) { + header.textContent = String(this._activeDoc.title); + } else { + header.textContent = "library"; + } + } + + switchToLibrary = () => { + this._parents.push(this._activeDoc); + this.switchCurrentView((userDoc: Doc) => this._library); + this._activeDoc = this._library; + this._homeMenu = false; + this.toggleSidebar(); + } + back = () => { - const doc = Cast(this._parents.pop(), Doc) as Doc; - if (doc === Cast(this._menu, Doc) as Doc) { + let header = document.getElementById("header") as HTMLElement; + let doc = Cast(this._parents.pop(), Doc) as Doc; + if (doc === Cast(this._library, Doc) as Doc) { + this._child = null; + this.userDoc.activeMobile = this._library; + } else if (doc === Cast(this._homeDoc, Doc) as Doc) { + this._homeMenu = true; + this._parents = []; + this._activeDoc = this._homeDoc; this._child = null; - this.userDoc.activeMobile = this.mainDoc; + this.switchCurrentView((userDoc: Doc) => this._homeDoc); } else { if (doc) { this._child = doc; this.switchCurrentView((userDoc: Doc) => doc); + this._homeMenu = false; + header.textContent = String(doc.title); } } if (doc) { this._activeDoc = doc; } + this._ink = false; } returnHome = () => { + if (this._homeMenu === false || this._open === true) { + this._homeMenu = true; + this._parents = []; + this._activeDoc = this._homeDoc; + this._child = null; + this.switchCurrentView((userDoc: Doc) => this._homeDoc); + } + if (this._open) { + this.toggleSidebar(); + } + } + + returnMain = () => { + console.log("home"); this._parents = []; - this._activeDoc = this._menu; - this.switchCurrentView((userDoc: Doc) => this._menu); + // this.toggleSidebar(); + this._activeDoc = this._library; + this.switchCurrentView((userDoc: Doc) => this._library); + this._homeMenu = false; this._child = null; } + // @computed get onChildClickHandler() { return ScriptCast(Doc.UserDoc.onClick); } + displayWorkspaces = () => { if (this.mainContainer) { const backgroundColor = () => "white"; - return ( -
- window.screen.width} - PanelHeight={() => window.screen.height} - renderDepth={0} - focus={emptyFunction} - backgroundColor={backgroundColor} - parentActive={returnTrue} - whenActiveChanged={emptyFunction} - bringToFront={emptyFunction} - ContainingCollectionView={undefined} - ContainingCollectionDoc={undefined} - /> -
- ); + if (this._activeDoc.title === "mobile audio") { + return ( +
+ window.screen.width} + PanelHeight={() => window.screen.height} + renderDepth={0} + focus={emptyFunction} + backgroundColor={backgroundColor} + parentActive={returnTrue} + whenActiveChanged={emptyFunction} + bringToFront={emptyFunction} + ContainingCollectionView={undefined} + ContainingCollectionDoc={undefined} + /> +
+ ); + } else { + return ( +
+ +
+ ); + } } } + returnWidth = () => 2000; + returnHeight = () => 2000; + handleClick(doc: Doc) { - const children = DocListCast(doc.data); + console.log(screen.height) + console.log(screen.width) + let children = DocListCast(doc.data); if (doc.type !== "collection") { this._parents.push(this._activeDoc); this._activeDoc = doc; this.switchCurrentView((userDoc: Doc) => doc); + this._homeMenu = false; this.toggleSidebar(); } else if (doc.type === "collection" && children.length === 0) { console.log("This collection has no children"); @@ -194,6 +1322,7 @@ export class MobileInterface extends React.Component { this._parents.push(this._activeDoc); this._activeDoc = doc; this.switchCurrentView((userDoc: Doc) => doc); + this._homeMenu = false; this._child = doc; } @@ -201,167 +1330,426 @@ export class MobileInterface extends React.Component { // sidebar.classList.toggle('active'); } + /** + * Handles creation of array which is then rendered in renderPathbar() + */ createPathname = () => { - let pathname = ""; + // let pathname = 'workspaces'; + // let titleArray = []; + let docArray = []; this._parents.map((doc: Doc, index: any) => { - if (doc === this.mainDoc) { - pathname = pathname + doc.title; + // if (doc === this.mainDoc) { + // pathname = pathname; + // } else if (doc.type === "audio" || doc.type === "presentation") { + // pathname = pathname; + // } else if (doc.type !== "collection") { + // pathname = pathname; + // } else { + // pathname = pathname + " > " + doc.title; + // titleArray.push(doc.title); + // docArray.push(doc); + // } + docArray.push(doc); + }); + docArray.push(this._activeDoc); + // if (this._activeDoc.title === "mobile audio") { + // pathname = this._activeDoc.title; + // } else if (this._activeDoc.title === "Presentation") { + // pathname = this._activeDoc.title; + // } else if (this._activeDoc === this.mainDoc) { + // pathname = pathname; + // } else { + // pathname = pathname + " > " + this._activeDoc.title; + // docArray.push(this._activeDoc); + // titleArray.push(this._activeDoc.title); + // } + + return docArray; + } + + // Renders the graphical pathbar + renderPathbar = () => { + // if (this._homeMenu == false) { + let docArray = this.createPathname(); + let items = docArray.map((doc: Doc, index: any) => { + if (index == 0) { + return ( +
+
this.handlePathClick(doc, index)}>{doc.title} +
+
); + } else if (doc === this._activeDoc) { + return ( +
+ +
this.handlePathClick(doc, index)}>{doc.title} +
+
); } else { - pathname = pathname + " > " + doc.title; + return ( +
+ +
this.handlePathClick(doc, index)}>{doc.title} +
+
); } + }); - if (this._activeDoc === this.mainDoc) { - pathname = pathname + this._activeDoc.title; + if (this._parents.length !== 0) { + return (
+
+ {items} +
+
+ +
+
+
); } else { - pathname = pathname + " > " + this._activeDoc.title; + return (
+
+ {items} +
+
+
); } - return pathname; - } + // } + // } else { - @action - toggleSidebar = () => this.sidebarActive = !this.sidebarActive + // return ( + //
+ //
+ //
+ //
this.returnHome()}>Home + //
+ //
+ //
+ //
+ //
+ // ); + // } - openLibrary() { - this._activeDoc = this.mainDoc; - this.switchCurrentView(() => this.mainDoc); - this._child = this._library; + // } + } + + handlePathClick = (doc: Doc, index: number) => { + if (doc === this._library) { + this._activeDoc = doc; + this._child = null; + this.switchCurrentView((userDoc: Doc) => doc); + this._parents.length = index; + } else if (doc === this._homeDoc) { + this.returnHome(); + } else { + console.log(index); + this._activeDoc = doc; + this._child = doc; + this.switchCurrentView((userDoc: Doc) => doc); + this._parents.length = index; + } } renderDefaultContent = () => { - const workspaces = Cast(this.userDoc.myWorkspaces, Doc) as Doc; - const buttons = DocListCast(this._child ? this._child.data : workspaces.data).map((doc: Doc, index: any) => { - return ( -
this.handleClick(doc)}>{doc.title} -
{doc.type}
- -
); - }); - return ( - <> -
-
{this.sidebarActive ? StrCast(this._activeDoc.title) : "Menu"}
+ let menuButtons = DocListCast(this._homeDoc.data).map((doc: Doc, index: any) => { + if (doc.type !== "ink") { + return (
-
-
-
{this.createPathname()}
+ className="item" + key={index} + onClick={() => doc.click}>{doc.title} +
); + } + }); + + if (this._homeMenu === true) { + return ( +
+
+ + + +
+ {this.renderPathbar()} +
-
- - {this._child ? - <> -
-
{buttons}
-
Home
- : - <> + ); + } + const workspaces = Cast(this.userDoc.myWorkspaces, Doc) as Doc; + let buttons = DocListCast(workspaces.data).map((doc: Doc, index: any) => { + if (doc.type !== "ink") { + return ( +
this.handleClick(doc)}>{doc.title} +
{doc.type}
+ +
); + } + }); + + if (this._child) { + buttons = DocListCast(this._child.data).map((doc: Doc, index: any) => { + if (doc.type !== "ink") { + return ( +
this.handleClick(doc)}>{doc.title} +
{doc.type}
+ +
); + } + }); + } + + if (!this._child) { + return ( +
+
+ + + +
+ {this.renderPathbar()} + +
+ {/*
+ {this.renderView} +
*/}
- {this._child ? null :
{this.renderView}
} - - ); + ); + } + else { + return ( +
+
+ + + +
+ {this.renderPathbar()} + +
+ ); + } } - pinToPresentation = () => { - // Only making button available if it is an image + uploadAudioButton = () => { + if (this._activeDoc.type === "audio") { + return
+ +
; + } + } + + toggleSelector = () => { + console.log("toggle selector!"); + let toolbar = document.getElementById("toolbar") as HTMLElement; + toolbar.classList.toggle('active'); + } + + colorTool = () => { + if (this._activeDoc._viewType === "docking") { + const color = InkingControl.Instance.selectedColor; + console.log(color); + return ( +
+
+
+
{ + InkingControl.Instance.updateSelectedColor("rgb(255,0,0)"); + Doc.UserDoc().inkColor = "rgb(255,0,0)"; + console.log(InkingControl.Instance.selectedColor); + }}> +
+
{ + InkingControl.Instance.updateSelectedColor("rgb(0,128,0)"); + Doc.UserDoc().inkColor = "rgb(0,128,0)"; + console.log(InkingControl.Instance.selectedColor); + }}> +
+
{ + InkingControl.Instance.updateSelectedColor("rgb(0,0,255)"); + Doc.UserDoc().inkColor = "rgb(0,0,255)"; + console.log(InkingControl.Instance.selectedColor); + }}> +
+
+
+ ) => InkingControl.Instance.switchWidth(e.target.value)} /> +
+
+
+ ); + } + } + + onSwitchInking = () => { + const button = document.getElementById("inkButton") as HTMLElement; + const color = InkingControl.Instance.selectedColor; + button.style.backgroundColor = this._ink ? "white" : color; + button.style.color = this._ink ? "black" : "white"; + + if (!this._ink) { + console.log("INK IS ACTIVE"); + InkingControl.Instance.switchTool(InkTool.Pen); + MobileInterface.Instance.drawingInk = true; + this._ink = true; + } else { + console.log("INK IS INACTIVE"); + InkingControl.Instance.switchTool(InkTool.None); + MobileInterface.Instance.drawingInk = false; + this._ink = false; + } + } + + drawInk = () => { + if (this._activeDoc._viewType === "docking") { + const inkIsOn = this._ink; + return
+ +
; + } + } + + downloadDocument = () => { if (this._activeDoc.type === "image") { - const isPinned = this._activeDoc && Doc.isDocPinned(this._activeDoc); - return
{ - if (isPinned) { - DockedFrameRenderer.UnpinDoc(this._activeDoc); - } - else { - DockedFrameRenderer.PinDoc(this._activeDoc); - } + window.open(url); + console.log(url); }}> -
; } } recordAudio = async () => { - // upload to server with known URL - this._parents.push(this._activeDoc); + // upload to server with known URL + if (this._activeDoc.title !== "mobile audio") { + this._parents.push(this._activeDoc); + } const audioDoc = Cast(Docs.Create.AudioDocument(nullAudio, { _width: 200, _height: 100, title: "mobile audio" }), Doc) as Doc; + console.log(audioDoc); if (audioDoc) { console.log("audioClicked: " + audioDoc.title); this._activeDoc = audioDoc; this.switchCurrentView((userDoc: Doc) => audioDoc); - this.toggleSidebar(); - } - const audioRightSidebar = Cast(Doc.UserDoc().rightSidebarCollection, Doc) as Doc; - if (audioRightSidebar) { - console.log(audioRightSidebar.title); - const data = Cast(audioRightSidebar.data, listSpec(Doc)); - if (data) { - data.push(audioDoc); - } + this._homeMenu = false; + // this.toggleSidebar(); } + // const audioRightSidebar = Cast(Doc.UserDoc().rightSidebarCollection, Doc) as Doc; + // this.audioState = await audioDoc.getProto; + // if (this.audioState) { + // console.log(this.audioState); + // const data = Cast(audioRightSidebar.data, listSpec(Doc)); + // if (data) { + // data.push(audioDoc); + // } + // } } - openDefaultPresentation = () => { - this._parents.push(this._activeDoc); - const presentation = Cast(Doc.UserDoc().activePresentation, Doc) as Doc; - - if (presentation) { - console.log("presentation clicked: " + presentation.title); - this._activeDoc = presentation; - this.switchCurrentView((userDoc: Doc) => presentation); - this.toggleSidebar(); + uploadAudio = () => { + const audioRightSidebar = Cast(Doc.UserDoc().rightSidebarCollection, Doc) as Doc; + const audioDoc = this._activeDoc; + const data = Cast(audioRightSidebar.data, listSpec(Doc)); + console.log(audioDoc.proto); + if (data) { + data.push(audioDoc); } + // this.recordAudio(); } - // mobileHome = () => { - // return ( - //
- //
- - //
- //
- - //
- //
- - //
- //
- - //
- //
- - //
- //
- // ); + // renderActiveCollection = (userDoc: Doc) => { + // if (this.activeContainer) { + // const active = Cast(this.activeContainer.data, listSpec(Doc)); + // if (active) { + // return ( + //
HELLO!
+ // ); + // } + // } // } - renderActiveCollection = (userDoc: Doc) => { - if (this.activeContainer) { - const active = Cast(this.activeContainer.data, listSpec(Doc)); - if (active) { - return ( -
HELLO!
- ); - } - } - } - onBack = (e: React.MouseEvent) => { this.switchCurrentView((userDoc: Doc) => this.mainDoc); InkingControl.Instance.switchTool(InkTool.None); // TODO: switch to previous tool @@ -445,6 +1833,44 @@ export class MobileInterface extends React.Component { } } + pinToPresentation = () => { + // Only making button available if it is an image + if (this._activeDoc.type === "image") { + const isPinned = this._activeDoc && Doc.isDocPinned(this._activeDoc); + return
{ + if (isPinned) { + DockedFrameRenderer.UnpinDoc(this._activeDoc); + } + else { + DockedFrameRenderer.PinDoc(this._activeDoc); + } + }}> + +
; + } + } + + setupDefaultPresentation = () => { + if (this._activeDoc.title !== "Presentation") { + this._parents.push(this._activeDoc); + } + + const presentation = Cast(Doc.UserDoc().activePresentation, Doc) as Doc; + + if (presentation) { + console.log(this._activeDoc.mobile); + console.log("presentation clicked: " + presentation.title); + this._activeDoc = presentation; + this.switchCurrentView((userDoc: Doc) => presentation); + this._homeMenu = false; + // this.toggleSidebar(); + } + } + onDragOver = (e: React.DragEvent) => { e.preventDefault(); e.stopPropagation(); @@ -453,7 +1879,7 @@ export class MobileInterface extends React.Component { render() { // const content = this.currentView === "main" ? this.mainContent : // this.currentView === "ink" ? this.inkContent : - // this.currentView === "upload" ? this.uploadContent : <>; + // this.currentView === "upload" ? this.uploadContent : <>;onDragOver={this.onDragOver} return (
{/* @@ -462,16 +1888,28 @@ export class MobileInterface extends React.Component { */} {/* */} - {this.displayWorkspaces()} - {this.pinToPresentation()} + {/* {this.menuOptions()} */} + {/* {this.displayHome()} */} +
+ {this.pinToPresentation()} + {this.downloadDocument()} + {this.drawInk()} + {this.uploadAudioButton()} + {this.colorTool()} +
+ + {this.displayWorkspaces()} + {this.renderDefaultContent()} + + {/*
*/} {/* */} {/* */} -
+ {/*
{this.renderDefaultContent()} -
+
*/} {/* */} {/* */} {/* @@ -485,6 +1923,13 @@ export class MobileInterface extends React.Component { } Scripting.addGlobal(function switchMobileView(doc: (userDoc: Doc) => Doc, renderView?: () => JSX.Element, onSwitch?: () => void) { return MobileInterface.Instance.switchCurrentView(doc, renderView, onSwitch); }); +Scripting.addGlobal(function openMobilePresentation() { return MobileInterface.Instance.setupDefaultPresentation(); }); +Scripting.addGlobal(function toggleMobileSidebar() { return MobileInterface.Instance.toggleSidebar(); }); +Scripting.addGlobal(function openMobileAudio() { return MobileInterface.Instance.recordAudio(); }); +Scripting.addGlobal(function openMobileSettings() { return SettingsManager.Instance.open(); }); +Scripting.addGlobal(function switchToLibrary() { return MobileInterface.Instance.switchToLibrary(); }); + + // WAS 2 // 1 @@ -527,15 +1972,7 @@ Scripting.addGlobal(function switchMobileView(doc: (userDoc: Doc) => Doc, render // } // } -// 2 -// Scripting.addGlobal(function onSwitchMobileInking() { return MobileInterface.Instance.onSwitchInking(); }); -// Scripting.addGlobal(function renderMobileInking() { return MobileInterface.Instance.renderInkingContent(); }); -// Scripting.addGlobal(function onSwitchMobileUpload() { return MobileInterface.Instance.onSwitchUpload(); }); -// Scripting.addGlobal(function renderMobileUpload() { return MobileInterface.Instance.renderUploadContent(); }); - // Scripting.addGlobal(function addWebToMobileUpload() { return MobileInterface.Instance.addWebToCollection(); }); - - -// 3 +// 3 // renderInkingContent = () => { // console.log("rendering inking content"); // // TODO: support panning and zooming @@ -583,4 +2020,4 @@ Scripting.addGlobal(function switchMobileView(doc: (userDoc: Doc) => Doc, render //
// ); // } - // } + // } \ No newline at end of file diff --git a/src/mobile/MobileMenu.scss b/src/mobile/MobileMenu.scss index 250340e36..f600ff637 100644 --- a/src/mobile/MobileMenu.scss +++ b/src/mobile/MobileMenu.scss @@ -83,15 +83,17 @@ body { .sidebar { position: absolute; - top: 200px; + top: 120px; opacity: 0; right: -100%; width: 100%; - height: calc(100% - (200px)); - z-index: 5; + height: calc(100% - (120px)); + z-index: 101; background-color: whitesmoke; transition: all 400ms ease 50ms; padding: 20px; + // overflow-y: auto; + // -webkit-overflow-scrolling: touch; // border-right: 5px solid black; } @@ -106,14 +108,23 @@ body { font-size: 35px; text-transform: uppercase; color: black; + } -.sidebar .home { +.sidebar .ink:focus { + outline: 1px solid blue; +} + +.sidebarButtons { + top: 80px; + position: relative; +} + +.home { position: absolute; - top: -135px; - right: calc(50% + 80px); - transform: translate(0%, -50%); - font-size: 40; + top: 30px; + left: 30px; + font-size: 60; user-select: none; text-transform: uppercase; font-family: Arial, Helvetica, sans-serif; @@ -173,23 +184,26 @@ body { .back { position: absolute; - top: -140px; - left: 50px; - transform: translate(0%, -50%); - color: black; - font-size: 60; + top: 44%; + left: 42px; + background-color: black; + width: 50px; + height: 50px; + text-align: center; + border-radius: 10px; + transform: translate(0, -50%); + font-size: 25px; user-select: none; - text-transform: uppercase; z-index: 100; - font-family: Arial, Helvetica, sans-serif; } .pathbar { position: absolute; top: 118px; + left: 0px; background: #1a1a1a; - z-index: 20; + z-index: 120; border-radius: 0px; width: 100%; height: 80px; @@ -200,8 +214,8 @@ body { position: relative; font-size: 25; top: 50%; - width: 90%; - left: 3%; + width: 86%; + left: 12%; color: whitesmoke; transform: translate(0%, -50%); z-index: 20; @@ -214,27 +228,71 @@ body { text-transform: uppercase; } -.homeContainer { - position: relative; - top: 200px; - height: calc(100% - 250px); - width: 90%; - overflow: scroll; - left: 5%; - background-color: lightpink; -} - -.pinButton { +.docButton { position: relative; width: 100px; height: 100px; font-size: 90px; text-align: center; - left: 50%; - transform: translate(-50%, 0); border-style: solid; border-radius: 50px; border-width: medium; - background-color: pink; + margin: 10px; z-index: 100; +} + +.docButtonContainer { + top: 90%; + position: absolute; + display: flex; + transform: translate(-50%, 0); + left: 50%; + z-index: 100; +} + +.scrollmenu { + overflow: auto; + white-space: nowrap; +} + +.pathbarItem { + position: relative; + display: inline-flex; + color: whitesmoke; + text-align: center; + transform: translate(100px, 0px); + font-size: 30px; + padding: 10px; + text-transform: uppercase; +} + +.pathbarText { + font-family: sans-serif; + text-align: center; + height: 50px; + padding: 10px; + background-color: rgb(48, 40, 40); + font-size: 30px; + border-radius: 10px; + text-transform: uppercase; + margin-left: 20px; + position: relative; +} + + +.pathIcon { + transform: translate(0px, 8px); + position: relative; +} + +.hidePath { + position: absolute; + height: 100%; + width: 200px; + left: 0px; + top: 0px; + background-image: linear-gradient(to right, #1a1a1a, rgba(255, 0, 0, 0)); + text-align: center; + user-select: none; + z-index: 99; } \ No newline at end of file diff --git a/src/mobile/SideBar.scss b/src/mobile/SideBar.scss deleted file mode 100644 index fb6d13a2b..000000000 --- a/src/mobile/SideBar.scss +++ /dev/null @@ -1,79 +0,0 @@ -* { - margin:0px; - padding:0px; - box-sizing:border-box; - font-family:"Open Sans"; -} -body { - overflow:hidden; -} -.navbar { - position:fixed; - top:0px; - left:0px; - width:100vw; - height:50px; - background:rgba(0,0,0,0.95); -} -.navbar .toggle-btn { - position:absolute; - right:20px; - height:50px; - width:50px; - transition:all 300ms ease-in-out 200ms; -} -.navbar .toggle-btn span { - position:absolute; - top:50%; - left:50%; - transform:translate(-50%,-50%); - width:70%; - height:4px; - background:#eee; - transition:all 200ms ease; -} -.navbar .toggle-btn span:nth-child(1) { - transition:top 200ms ease-in-out; - top:30%; -} -.navbar .toggle-btn span:nth-child(3) { - transition:top 200ms ease-in-out; - top:70%; -} -.navbar .toggle-btn.active { - transition:transform 200ms ease-in-out 200ms; - transform:rotate(135deg); -} -.navbar .toggle-btn.active span:nth-child(1) { - top:50%; -} -.navbar .toggle-btn.active span:nth-child(2) { - transform:translate(-50%,-50%) rotate(90deg); -} -.navbar .toggle-btn.active span:nth-child(3) { - top:50%; -} -.sidebar { - position:absolute; - top:50px; - opacity:0; - right:-100%; - width:100vw; - height:calc(100vh - 45px); - z-index:5; - background:rgba(40,40,40,1); - transition:all 400ms ease 50ms; - padding:15px; -} -.sidebar .item { - width:100%; - padding:13px 6px; - border-bottom:1px solid rgba(200,200,200,0.7); - font-size:18px; - text-transform:uppercase; - color:rgba(250,250,250,0.95); -} -.sidebar.active { - right:0%; - opacity:1; -} \ No newline at end of file diff --git a/src/mobile/SideBar.tsx b/src/mobile/SideBar.tsx deleted file mode 100644 index a06069ed8..000000000 --- a/src/mobile/SideBar.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import React = require("react"); -import { observer } from "mobx-react"; -import "./SideBar.scss"; -import { computed } from "mobx"; -import { DocumentView } from '../client/views/nodes/DocumentView'; - -@observer -export class SideBar extends React.Component<{ views: (DocumentView | undefined)[], stack?: any }, {}>{ - - constructor(props: { views: (DocumentView | undefined)[] }) { - super(props); - } - - @computed - onClick() { - document.getElementsByClassName('sidebar') - [0].classList.toggle('active'); - } - - render() { - return ( - <> -
-
- - - -
-
-
-
Workspace1
-
Workspace2
-
Workspace3
-
- - ); - } - -} \ No newline at end of file diff --git a/src/mobile/WorkSpaceButton.scss b/src/mobile/WorkSpaceButton.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/mobile/WorkSpaceButton.tsx b/src/mobile/WorkSpaceButton.tsx deleted file mode 100644 index 70c3e6edc..000000000 --- a/src/mobile/WorkSpaceButton.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import React = require('react'); -import { observer } from "mobx-react"; -import { observable } from 'mobx'; - -interface IProps { - open: boolean; -} - -@observer -export class MenuButton extends React.Component { - @observable static Instance: MenuButton; - - -} \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 673be18526a5591b9021993fe4e9421e6373017c Mon Sep 17 00:00:00 2001 From: geireann <60007097+geireann@users.noreply.github.com> Date: Mon, 8 Jun 2020 14:06:02 +0800 Subject: updated window height --- src/mobile/MobileInterface.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx index 6b75ce07d..f3fa7de30 100644 --- a/src/mobile/MobileInterface.tsx +++ b/src/mobile/MobileInterface.tsx @@ -1250,7 +1250,6 @@ export class MobileInterface extends React.Component { pinToPres={emptyFunction} rootSelected={returnFalse} removeDocument={undefined} - onClick={undefined} ScreenToLocalTransform={Transform.Identity} ContentScaling={returnOne} NativeHeight={returnZero} @@ -1295,7 +1294,6 @@ export class MobileInterface extends React.Component { bringToFront={emptyFunction} ContainingCollectionView={undefined} ContainingCollectionDoc={undefined} - // mobile={true} />
); @@ -1303,12 +1301,10 @@ export class MobileInterface extends React.Component { } } - returnWidth = () => 2000; - returnHeight = () => 2000; + returnWidth = () => window.innerWidth; + returnHeight = () => (window.innerHeight - 300); handleClick(doc: Doc) { - console.log(screen.height) - console.log(screen.width) let children = DocListCast(doc.data); if (doc.type !== "collection") { this._parents.push(this._activeDoc); -- cgit v1.2.3-70-g09d2 From 4bcefa13f3e2d48cd6a7ca77af32ae4f3917fbfb Mon Sep 17 00:00:00 2001 From: Lionel Han <47760119+IGoByJoe@users.noreply.github.com> Date: Sun, 7 Jun 2020 23:45:45 -0700 Subject: added color picker (bit buggy) --- src/mobile/MobileInterface.tsx | 177 ++++------------------------------------- src/mobile/MobileMenu.scss | 61 +++++++++++++- 2 files changed, 74 insertions(+), 164 deletions(-) (limited to 'src') diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx index 6b75ce07d..8a0432d06 100644 --- a/src/mobile/MobileInterface.tsx +++ b/src/mobile/MobileInterface.tsx @@ -34,6 +34,9 @@ import { InkTool } from '../fields/InkField'; import { listSpec } from '../fields/Schema'; import { nullAudio, WebField } from '../fields/URLField'; import GestureOverlay from "../client/views/GestureOverlay"; +import { SelectionManager } from "../client/util/SelectionManager"; +import { SketchPicker } from "react-color"; +import { ScriptField } from "../fields/ScriptField"; library.add(faTasks, faEdit, faTrashAlt, faPalette, faAngleRight, faBell, faTrash, faCamera, faExpand, faCaretDown, faCaretLeft, faCaretRight, faCaretSquareDown, faCaretSquareRight, faArrowsAltH, faPlus, faMinus, faTerminal, faToggleOn, fileSolid, faExternalLinkAlt, faLocationArrow, faSearch, faFileDownload, faStop, faCalculator, faWindowMaximize, faAddressCard, @@ -498,137 +501,6 @@ library.add(faTasks, faEdit, faTrashAlt, faPalette, faAngleRight, faBell, faTras // // ); // // } -// renderDefaultContent = () => { -// let menuButtons = DocListCast(this._homeDoc.data).map((doc: Doc, index: any) => { -// if (doc.type !== "ink") { -// return ( -//
doc.click}>{doc.title} -//
); -// } -// }); - -// if (this._homeMenu === true) { -// return ( -//
-//
-// -// -// -//
-// {this.renderPathbar()} -// -//
-// ); -// } -// const workspaces = Cast(this.userDoc.myWorkspaces, Doc) as Doc; -// let buttons = DocListCast(workspaces.data).map((doc: Doc, index: any) => { -// if (doc.type !== "ink") { -// return ( -//
this.handleClick(doc)}>{doc.title} -//
{doc.type}
-// -//
); -// } -// }); - -// if (this._child) { -// buttons = DocListCast(this._child.data).map((doc: Doc, index: any) => { -// if (doc.type !== "ink") { -// return ( -//
this.handleClick(doc)}>{doc.title} -//
{doc.type}
-// -//
); -// } -// }); -// } - -// if (!this._child) { -// return ( -//
-//
-// -// -// -//
-// {this.renderPathbar()} -// -// {/*
-// {this.renderView} -//
*/} -//
-// ); -// } -// else { -// return ( -//
-//
-// -// -// -//
-// {this.renderPathbar()} -// -//
-// ); -// } -// } - // recordAudio = async () => { // // upload to server with known URL // if (this._activeDoc.title !== "mobile audio") { @@ -1079,6 +951,7 @@ export class MobileInterface extends React.Component { @observable private mainDoc: any = CurrentUserUtils.setupMobileMenu(); @observable private renderView?: () => JSX.Element; @observable private audioState: any; + @observable private activeToolbar: boolean = false; public _activeDoc: Doc = this.mainDoc; public _homeDoc: Doc = this.mainDoc; @@ -1466,7 +1339,7 @@ export class MobileInterface extends React.Component {
doc.click}>{doc.title} + onClick={() => doc.proto?.onClick}>{doc.title}
); } }); @@ -1603,48 +1476,26 @@ export class MobileInterface extends React.Component { } } - toggleSelector = () => { - console.log("toggle selector!"); - let toolbar = document.getElementById("toolbar") as HTMLElement; - toolbar.classList.toggle('active'); - } + + @action + toggleSelector = () => this.activeToolbar = !this.activeToolbar + colorTool = () => { if (this._activeDoc._viewType === "docking") { const color = InkingControl.Instance.selectedColor; - console.log(color); + const selDoc = SelectionManager.SelectedDocuments()?.[0]?.rootDoc; return (
-
+
-
{ - InkingControl.Instance.updateSelectedColor("rgb(255,0,0)"); - Doc.UserDoc().inkColor = "rgb(255,0,0)"; - console.log(InkingControl.Instance.selectedColor); - }}> -
-
{ - InkingControl.Instance.updateSelectedColor("rgb(0,128,0)"); - Doc.UserDoc().inkColor = "rgb(0,128,0)"; - console.log(InkingControl.Instance.selectedColor); - }}> -
-
{ - InkingControl.Instance.updateSelectedColor("rgb(0,0,255)"); - Doc.UserDoc().inkColor = "rgb(0,0,255)"; - console.log(InkingControl.Instance.selectedColor); - }}> -
+
) => InkingControl.Instance.switchWidth(e.target.value)} /> diff --git a/src/mobile/MobileMenu.scss b/src/mobile/MobileMenu.scss index f600ff637..2641cdfd2 100644 --- a/src/mobile/MobileMenu.scss +++ b/src/mobile/MobileMenu.scss @@ -237,7 +237,7 @@ body { border-style: solid; border-radius: 50px; border-width: medium; - margin: 10px; + margin: 20px; z-index: 100; } @@ -295,4 +295,63 @@ body { text-align: center; user-select: none; z-index: 99; +} + +.toolbar { + left: 50%; + transform: translate(-50%); + position: absolute; + height: max-content; + top: 0px; + border-radius: 20px; + background-color: lightgrey; + opacity: 0; + transition: all 400ms ease 50ms; +} + +.toolbar.active { + display: inline-block; + width: fit-content; + padding: 5px; + opacity: 1; + height: max-content; + top: -450px; +} + +.toolbar .colorSelector { + display: inline-flex; + width: fit-content; + padding: 5px; + height: max-content; + pointer-events: all; +} + +.widthSelector { + display: inline-flex; + width: 90%; + height: 100px; + padding: 5px; +} + +.slider { + -webkit-appearance: none; + /* Override default CSS styles */ + appearance: none; + width: 100%; + /* Full-width */ + height: 25px; + /* Specified height */ + background: #d3d3d3; + /* Grey background */ + outline: none; + /* Remove outline */ +} + +.colorButton { + width: 70px; + margin: 10px; + height: 70px; + border-style: solid; + border-width: 3px; + border-radius: 100%; } \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 520200a2a63a4189d5c6cac2b2ff48f009bb6f72 Mon Sep 17 00:00:00 2001 From: Lionel Han <47760119+IGoByJoe@users.noreply.github.com> Date: Tue, 9 Jun 2020 00:21:50 -0700 Subject: cleaned code --- src/client/util/CurrentUserUtils.ts | 4 +- src/mobile/ImageUpload.tsx | 1 + src/mobile/MobileInterface.tsx | 190 ++++++++++++------------------------ src/mobile/MobileMenu.scss | 22 ++++- 4 files changed, 82 insertions(+), 135 deletions(-) (limited to 'src') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index 8ed275efc..f2278bf3d 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -409,7 +409,7 @@ export class CurrentUserUtils { const docProtoData: { title: string, icon: string, drag?: string, ignoreClick?: boolean, click?: string, ischecked?: string, activePen?: Doc, backgroundColor?: string, dragFactory?: Doc }[] = [ { title: "library", icon: "bars", click: 'switchToLibrary()', backgroundColor: "lightgrey" }, { title: "record", icon: "microphone", click: 'openMobileAudio()', backgroundColor: "lightgrey" }, - { title: "upload", icon: "upload", click: 'uploadMobileImage()', backgroundColor: "lightgrey" }, + { title: "upload", icon: "upload", click: 'console.log("hi")', backgroundColor: "lightgrey" }, { title: "presentation", icon: "desktop", click: 'openMobilePresentation()', backgroundColor: "lightgrey" }, { title: "ink", icon: "pen-nib", backgroundColor: "lightgrey" }, { title: "settings", icon: "cog", click: 'openMobileSettings()', backgroundColor: "lightgrey" } @@ -647,7 +647,7 @@ export class CurrentUserUtils { const docProtoData: { title: string, icon: string, drag?: string, ignoreClick?: boolean, click?: string, ischecked?: string, activePen?: Doc, backgroundColor?: string, info: string, dragFactory?: Doc }[] = [ { title: "LIBRARY", icon: "bars", click: 'switchToLibrary()', backgroundColor: "#ffd6d6", info: "Navigate and access all of your documents within their respective collections" }, { title: "RECORD", icon: "microphone", click: 'openMobileAudio()', backgroundColor: "#ffbfbf", info: "Use your mobile to record audio and access it on Dash Web." }, - { title: "UPLOAD", icon: "upload", click: 'uploadMobileImage()', backgroundColor: "#ff9e9e", info: "Upload an image from your mobile device so it can be accessed on Dash Web" }, + { title: "UPLOAD", icon: "upload", click: 'console.log("hi")', backgroundColor: "#ff9e9e", info: "Upload an image from your mobile device so it can be accessed on Dash Web" }, { title: "PRESENTATION", icon: "desktop", click: 'openMobilePresentation()', backgroundColor: "#ff8080", info: "Use your phone as a remote for you presentation." }, // { title: "INK", icon: "pen-nib", backgroundColor: "lightgrey", info: "Doodle and draw with ink on your mobile and have it directly available on Dash Web" }, { title: "SETTINGS", icon: "cog", click: 'openMobileSettings()', backgroundColor: "#ff5e5e", info: "Change your password, log out, or manage your account security" } diff --git a/src/mobile/ImageUpload.tsx b/src/mobile/ImageUpload.tsx index c35c4a917..8d7ccf450 100644 --- a/src/mobile/ImageUpload.tsx +++ b/src/mobile/ImageUpload.tsx @@ -12,6 +12,7 @@ import { Doc, Opt } from '../fields/Doc'; import { Cast } from '../fields/Types'; import { listSpec } from '../fields/Schema'; import { List } from '../fields/List'; +import { Scripting } from '../client/util/Scripting'; export interface ImageUploadProps { Document: Doc; diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx index c51b5b654..e9d35096d 100644 --- a/src/mobile/MobileInterface.tsx +++ b/src/mobile/MobileInterface.tsx @@ -952,6 +952,7 @@ export class MobileInterface extends React.Component { @observable private renderView?: () => JSX.Element; @observable private audioState: any; @observable private activeToolbar: boolean = false; + @observable private sidebarActive: boolean = false; public _activeDoc: Doc = this.mainDoc; public _homeDoc: Doc = this.mainDoc; @@ -986,8 +987,6 @@ export class MobileInterface extends React.Component { InkingControl.Instance.switchTool(InkTool.None); MobileInterface.Instance.drawingInk = false; InkingControl.Instance.updateSelectedColor("#FF0000"); - console.log(this.userDoc.inkColor); - console.log(InkingControl.Instance.selectedColor); InkingControl.Instance.switchWidth("2"); this.switchCurrentView((userDoc: Doc) => this._homeDoc); } @@ -1027,34 +1026,37 @@ export class MobileInterface extends React.Component { }); } - toggleSidebar = () => { - if (this._open === false) { - this._open = true; - } else { - this._open = false; - } - console.log("clicked"); - let menuButton = document.getElementById("menuButton") as HTMLElement; - menuButton.classList.toggle('active'); + @action + toggleSidebar = () => this.sidebarActive = !this.sidebarActive - let sidebar = document.getElementById("sidebar") as HTMLElement; - sidebar.classList.toggle('active'); + // toggleSidebar = () => { + // if (this._open === false) { + // this._open = true; + // } else { + // this._open = false; + // } + // console.log("clicked"); + // let menuButton = document.getElementById("menuButton") as HTMLElement; + // //menuButton.classList.toggle('active'); - let header = document.getElementById("header") as HTMLElement; + // let sidebar = document.getElementById("sidebar") as HTMLElement; + // //sidebar.classList.toggle('active'); - if (!sidebar.classList.contains('active')) { - header.textContent = String(this._activeDoc.title); - } else { - header.textContent = "library"; - } - } + // let header = document.getElementById("header") as HTMLElement; + + // if (!sidebar.classList.contains('active')) { + // header.textContent = String(this._activeDoc.title); + // } else { + // header.textContent = "library"; + // } + // } switchToLibrary = () => { this._parents.push(this._activeDoc); this.switchCurrentView((userDoc: Doc) => this._library); this._activeDoc = this._library; this._homeMenu = false; - this.toggleSidebar(); + this.sidebarActive = true; } back = () => { @@ -1084,14 +1086,14 @@ export class MobileInterface extends React.Component { } returnHome = () => { - if (this._homeMenu === false || this._open === true) { + if (this._homeMenu === false || this.sidebarActive === true) { this._homeMenu = true; this._parents = []; this._activeDoc = this._homeDoc; this._child = null; this.switchCurrentView((userDoc: Doc) => this._homeDoc); } - if (this._open) { + if (this.sidebarActive) { this.toggleSidebar(); } } @@ -1207,32 +1209,9 @@ export class MobileInterface extends React.Component { // let titleArray = []; let docArray = []; this._parents.map((doc: Doc, index: any) => { - // if (doc === this.mainDoc) { - // pathname = pathname; - // } else if (doc.type === "audio" || doc.type === "presentation") { - // pathname = pathname; - // } else if (doc.type !== "collection") { - // pathname = pathname; - // } else { - // pathname = pathname + " > " + doc.title; - // titleArray.push(doc.title); - // docArray.push(doc); - // } docArray.push(doc); }); docArray.push(this._activeDoc); - // if (this._activeDoc.title === "mobile audio") { - // pathname = this._activeDoc.title; - // } else if (this._activeDoc.title === "Presentation") { - // pathname = this._activeDoc.title; - // } else if (this._activeDoc === this.mainDoc) { - // pathname = pathname; - // } else { - // pathname = pathname + " > " + this._activeDoc.title; - // docArray.push(this._activeDoc); - // titleArray.push(this._activeDoc.title); - // } - return docArray; } @@ -1320,7 +1299,6 @@ export class MobileInterface extends React.Component { } else if (doc === this._homeDoc) { this.returnHome(); } else { - console.log(index); this._activeDoc = doc; this._child = doc; this.switchCurrentView((userDoc: Doc) => doc); @@ -1335,7 +1313,7 @@ export class MobileInterface extends React.Component {
doc.proto?.onClick}>{doc.title} + onClick={() => doc.onClick}>{doc.title}
); } }); @@ -1346,6 +1324,7 @@ export class MobileInterface extends React.Component {
+
this.stop(e)}>
); } - const workspaces = Cast(this.userDoc.myWorkspaces, Doc) as Doc; + + let workspaces = Cast(this.userDoc.myWorkspaces, Doc) as Doc; + if (this._child) { + workspaces = this._child + } + let buttons = DocListCast(workspaces.data).map((doc: Doc, index: any) => { if (doc.type !== "ink") { return ( @@ -1375,88 +1359,39 @@ export class MobileInterface extends React.Component { } }); - if (this._child) { - buttons = DocListCast(this._child.data).map((doc: Doc, index: any) => { - if (doc.type !== "ink") { - return ( -
this.handleClick(doc)}>{doc.title} -
{doc.type}
- -
); - } - }); - } - - if (!this._child) { - return ( -
-
- - - -
- {this.renderPathbar()} -