From 094c9ba25cc025f885fe7db4ec6524c16e6e9de2 Mon Sep 17 00:00:00 2001 From: John Lyon-Smith Date: Mon, 9 Apr 2018 08:37:07 -0700 Subject: [PATCH] Fix bugs and issues before first production build --- mobile/package.json | 1 + mobile/src/ARViewer/ARViewer.js | 75 ++++++++++++++++++++------------- mobile/src/Home/Home.js | 4 +- mobile/src/WorkItem/WorkItem.js | 2 +- mobile/src/ui/BoundInput.js | 8 +++- 5 files changed, 56 insertions(+), 34 deletions(-) diff --git a/mobile/package.json b/mobile/package.json index dec32cf..039d1be 100644 --- a/mobile/package.json +++ b/mobile/package.json @@ -12,6 +12,7 @@ "scripts": { "start": "react-native start", "android": "react-native run-android", + "android:release": "cd android; rm -rf ./app/build && ./gradlew assembleRelease", "ios": "react-native run-ios", "test": "node node_modules/jest/bin/jest.js", "postinstall": "sed -i '' 's/#import /#import \"RCTValueAnimatedNode.h\"/' ./node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h; sed -i '' 's/#import /#import \"fishhook.h\"/' ./node_modules/react-native/Libraries/WebSocket/RCTReconnectingWebSocket.m" diff --git a/mobile/src/ARViewer/ARViewer.js b/mobile/src/ARViewer/ARViewer.js index 7b14058..f851e80 100644 --- a/mobile/src/ARViewer/ARViewer.js +++ b/mobile/src/ARViewer/ARViewer.js @@ -1,5 +1,5 @@ -import React from 'react' -import { StyleSheet, View, TouchableHighlight, Image } from 'react-native' +import React from "react" +import { StyleSheet, View, TouchableHighlight, Image } from "react-native" import { ViroARSceneNavigator, ViroARScene, @@ -10,62 +10,75 @@ import { ViroSpotLight, Viro3DObject, ViroSurface, -} from 'react-viro' -import autobind from 'autobind-decorator' -import backImage from './images/back.png' +} from "react-viro" +import autobind from "autobind-decorator" +import backImage from "./images/back.png" const styles = { - buttons : { + buttons: { height: 80, width: 80, }, } const shapes = { - hardhat: { shape: require('./models/hardhat.obj'), materials: [ require('./models/hardhat.mtl') ] }, - question: { shape: require('./models/question.obj'), materials: [ require('./models/question.mtl') ] }, - clipboard: { shape: require('./models/question.obj'), materials: [ require('./models/clipboard.mtl') ] }, + // hardhat: { + // shape: require("./models/hardhat.obj"), + // materials: [require("./models/hardhat.mtl")], + // }, + // question: { + // shape: require("./models/question.obj"), + // materials: [require("./models/question.mtl")], + // }, + // clipboard: { + // shape: require("./models/clipboard.obj"), + // materials: [require("./models/clipboard.mtl")], + // }, } class WorkItemSceneAR extends React.Component { constructor(props) { super(props) this.state = { - position: [0, .2, 0], - scale: [.2, .2, .2], + position: [0, 0.2, 0], + scale: [0.2, 0.2, 0.2], } } render() { return ( - + + key="hardhat"> + shadowOpacity={0.9} + /> + source={shapes["hardhat"].shape} + type="OBJ" + /> + ignoreEventHandling={true} + /> @@ -76,23 +89,27 @@ class WorkItemSceneAR extends React.Component { export class ARViewer extends React.Component { constructor(props) { super(props) - } + } @autobind _handlePress() { - this.props.history.replace('/') + this.props.history.replace("/") } render() { return ( - + + style={{ width: "100%", height: "100%" }} + apiKey="06F37B6A-74DA-4A83-965A-7DE2209A5C46" + initialScene={{ scene: WorkItemSceneAR }} + /> - - + + diff --git a/mobile/src/Home/Home.js b/mobile/src/Home/Home.js index 0638b75..a576e7e 100644 --- a/mobile/src/Home/Home.js +++ b/mobile/src/Home/Home.js @@ -12,7 +12,6 @@ import MapView, { Marker } from "react-native-maps" import { Icon, Header } from "../ui" import { api } from "../API" import autobind from "autobind-decorator" -import pinImage from "./images/pin.png" import { ifIphoneX } from "react-native-iphone-x-helper" import { workItemTypeText, pad } from "../util" @@ -107,6 +106,7 @@ export class Home extends React.Component { title="Work Item Map" leftButton={{ icon: "logout", onPress: this.handleLogoutPress }} rightButton={{ icon: "glasses", onPress: this.handleGlassesPress }} + disabled /> { @@ -137,7 +137,7 @@ export class Home extends React.Component { workItemTypeText[workItem.workItemType] } description={workItem.address} - image={pinImage} + image={require("./images/pin.png")} anchor={{ x: 0.5, y: 1.0 }} onPress={(e) => this.handleMarkerPress(e, index)} /> diff --git a/mobile/src/WorkItem/WorkItem.js b/mobile/src/WorkItem/WorkItem.js index 18fc395..9ff965f 100644 --- a/mobile/src/WorkItem/WorkItem.js +++ b/mobile/src/WorkItem/WorkItem.js @@ -59,7 +59,7 @@ export class WorkItem extends React.Component { isDisabled: (r) => !(r.anyModified && r.allValid), }, location: { - isValid: true, + isValid: (r, v) => v !== "", isReadOnly: true, }, details: { diff --git a/mobile/src/ui/BoundInput.js b/mobile/src/ui/BoundInput.js index 9f4252b..11a4ebc 100644 --- a/mobile/src/ui/BoundInput.js +++ b/mobile/src/ui/BoundInput.js @@ -35,9 +35,13 @@ export class BoundInput extends React.Component { @autobind handleChangeText(newText) { const { binder, name } = this.props - const state = binder.getFieldState(name) - this.setState(binder.updateFieldValue(name, newText)) + // TODO: Sometimes this is undefined and causes a crash?! + if (binder) { + const state = binder.getFieldState(name) + + this.setState(binder.updateFieldValue(name, newText)) + } } render() {