aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFawn <fangrui_tong@brown.edu>2020-01-14 14:47:44 -0500
committerFawn <fangrui_tong@brown.edu>2020-01-14 14:47:44 -0500
commitb4c2d2add2b863060ce559e49b3953f24050f162 (patch)
tree7261c8d43e99ef76ca17933a07ad112f7563d18f /src
parentc78409b7cb6c4ab828bce0eef1525032958219f7 (diff)
can add strokes to mobile ink
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionSubView.tsx3
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx1
-rw-r--r--src/mobile/MobileInterface.tsx108
-rw-r--r--src/server/authentication/models/current_user_utils.ts4
4 files changed, 87 insertions, 29 deletions
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 73dc7edc6..d8b575092 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -53,7 +53,9 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
protected createDropAndGestureTarget = (ele: HTMLDivElement) => { //used for stacking and masonry view
this.dropDisposer && this.dropDisposer();
this.gestureDisposer && this.gestureDisposer();
+ console.log("create drop", ele);
if (ele) {
+ console.log("create drop 2", ele);
this.dropDisposer = DragManager.MakeDropTarget(ele, this.drop.bind(this));
this.gestureDisposer = GestureUtils.MakeGestureTarget(ele, this.onGesture.bind(this));
}
@@ -135,7 +137,6 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
@undoBatch
protected onGesture(e: Event, ge: GestureUtils.GestureEvent) {
-
}
@undoBatch
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 84945c6e6..c3e131184 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -356,6 +356,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
@undoBatch
onGesture = (e: Event, ge: GestureUtils.GestureEvent) => {
+ console.log("on gesture");
switch (ge.gesture) {
case GestureUtils.Gestures.Stroke:
const points = ge.points;
diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx
index 1e0920686..8d342d749 100644
--- a/src/mobile/MobileInterface.tsx
+++ b/src/mobile/MobileInterface.tsx
@@ -10,8 +10,10 @@ import { DocumentView } from '../client/views/nodes/DocumentView';
import { emptyPath, emptyFunction, returnFalse, returnOne, returnEmptyString, returnTrue } from '../Utils';
import { Transform } from '../client/util/Transform';
import { library } from '@fortawesome/fontawesome-svg-core';
-import { faPenNib, faHighlighter, faEraser, faMousePointer } from '@fortawesome/free-solid-svg-icons';
+import { faPenNib, faHighlighter, faEraser, faMousePointer, faBreadSlice } from '@fortawesome/free-solid-svg-icons';
import { Scripting } from '../client/util/Scripting';
+import { CollectionFreeFormView } from '../client/views/collections/collectionFreeForm/CollectionFreeFormView';
+import GestureOverlay from '../client/views/GestureOverlay';
@observer
export default class MobileInterface extends React.Component {
@@ -35,52 +37,102 @@ export default class MobileInterface extends React.Component {
}
}
- @action switchCurrentView = (view: "main" | "ink" | "library") => { this.currentView = view; }
+ @action
+ switchCurrentView = (view: "main" | "ink" | "library") => {
+ this.currentView = view;
+
+ if (this.userDoc) {
+ switch (view) {
+ case "main": {
+ const doc = CurrentUserUtils.setupMobileDoc(this.userDoc);
+ this.userDoc.activeMobile = doc;
+ break;
+ }
+ case "ink": {
+ const doc = CurrentUserUtils.setupMobileInkingDoc(this.userDoc);
+ this.userDoc.activeMobile = doc;
+ break;
+ }
+ }
+ }
+ }
@computed
get mainContent() {
if (this.mainContainer) {
- switch (this.currentView) {
- case "main":
- return <DocumentView
+ return <DocumentView
+ Document={this.mainContainer}
+ DataDoc={undefined}
+ LibraryPath={emptyPath}
+ addDocument={undefined}
+ addDocTab={returnFalse}
+ pinToPres={emptyFunction}
+ removeDocument={undefined}
+ ruleProvider={undefined}
+ onClick={undefined}
+ ScreenToLocalTransform={Transform.Identity}
+ ContentScaling={returnOne}
+ PanelWidth={() => window.screen.width}
+ PanelHeight={() => window.screen.height}
+ renderDepth={0}
+ focus={emptyFunction}
+ backgroundColor={returnEmptyString}
+ parentActive={returnTrue}
+ whenActiveChanged={emptyFunction}
+ bringToFront={emptyFunction}
+ ContainingCollectionView={undefined}
+ ContainingCollectionDoc={undefined}
+ zoomToScale={emptyFunction}
+ getScale={returnOne}>
+ </DocumentView>;
+ }
+ return "hello";
+ }
+
+ @computed
+ get inkContent() {
+ // return <div>INK</div>;
+ if (this.mainContainer) {
+ return (
+ <GestureOverlay>
+ <CollectionFreeFormView
Document={this.mainContainer}
DataDoc={undefined}
LibraryPath={emptyPath}
- addDocument={undefined}
+ fieldKey={""}
+ addDocument={returnFalse}
+ removeDocument={returnFalse}
+ moveDocument={returnFalse}
addDocTab={returnFalse}
pinToPres={emptyFunction}
- removeDocument={undefined}
- ruleProvider={undefined}
- onClick={undefined}
- ScreenToLocalTransform={Transform.Identity}
- ContentScaling={returnOne}
- PanelWidth={() => window.screen.width}
PanelHeight={() => window.screen.height}
- renderDepth={0}
+ PanelWidth={() => window.screen.width}
+ annotationsKey={""}
+ isAnnotationOverlay={false}
focus={emptyFunction}
- backgroundColor={returnEmptyString}
- parentActive={returnTrue}
- whenActiveChanged={emptyFunction}
- bringToFront={emptyFunction}
+ isSelected={returnTrue} //
+ select={emptyFunction}
+ active={returnTrue} //
+ ContentScaling={returnOne}
+ whenActiveChanged={returnFalse}
+ CollectionView={undefined}
+ ScreenToLocalTransform={Transform.Identity}
+ ruleProvider={undefined}
+ renderDepth={0}
ContainingCollectionView={undefined}
ContainingCollectionDoc={undefined}
- zoomToScale={emptyFunction}
- getScale={returnOne}>
- </DocumentView>;
- case "ink":
- return <div>INK</div>;
- case "library":
- return <div>LIBRARY</div>;
- }
+ chromeCollapsed={true}>
+ </CollectionFreeFormView>
+ </GestureOverlay>
+ );
}
- return "hello";
}
render() {
- console.log("rendering mobile");
+ const content = this.currentView === "main" ? this.mainContent : this.currentView === "ink" ? this.inkContent : <></>;
return (
<div className="mobile-container">
- {this.mainContent}
+ {content}
</div>
);
}
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 71369b625..b40179fbc 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -140,6 +140,10 @@ export class CurrentUserUtils {
});
}
+ static setupMobileInkingDoc(userDoc: Doc) {
+ return Docs.Create.FreeformDocument([], { x: 0, y: 0, width: 10, height: 20, title: "Mobile Inking", backgroundColor: "red" });
+ }
+
// setup the Creator button which will display the creator panel. This panel will include the drag creators and the color picker. when clicked, this panel will be displayed in the target container (ie, sidebarContainer)
static setupToolsPanel(sidebarContainer: Doc, doc: Doc) {
// setup a masonry view of all he creators