diff --git a/mobile/src/API.js b/mobile/src/API.js
index f199444..d4f7092 100644
--- a/mobile/src/API.js
+++ b/mobile/src/API.js
@@ -3,6 +3,8 @@ import io from "socket.io-client"
import { AsyncStorage } from "react-native"
const authTokenName = "AuthToken"
+const backendName = "backendName"
+
let baseURL = null
let apiPath = null
//
@@ -46,6 +48,15 @@ class API extends EventEmitter {
super()
this.user = { pending: true }
+ AsyncStorage.getItem(backendName)
+ .then((backend) => {
+ this.backend = backend
+ })
+ .catch((err) => {
+ this.backend = "normal"
+ AsyncStorage.setItem(backendName, this.backend)
+ })
+
AsyncStorage.getItem(authTokenName)
.then((token) => {
if (!token) {
@@ -105,8 +116,8 @@ class API extends EventEmitter {
return this.user
}
- get apiURL() {
- return baseURL + apiPath
+ get backend() {
+ return this.backend
}
makeImageUrl(id, size) {
diff --git a/mobile/src/Auth/Login.js b/mobile/src/Auth/Login.js
index a254e17..a9b3590 100644
--- a/mobile/src/Auth/Login.js
+++ b/mobile/src/Auth/Login.js
@@ -8,8 +8,9 @@ import {
TextInput,
View,
Button,
+ TouchableWithoutFeedback,
} from "react-native"
-import { MessageModal } from "../Modal"
+import { MessageModal, ApiModal } from "../Modal"
import logoImage from "./images/deighton.png"
import { FormBinder } from "react-form-binder"
import { api } from "../API"
@@ -48,9 +49,6 @@ export class Login extends React.Component {
alignItems: "center",
justifyContent: "center",
},
- logo: {
- width: "50%",
- },
inputRow: {
paddingTop: 10,
width: "60%",
@@ -79,6 +77,7 @@ export class Login extends React.Component {
this.state = {
binder: new FormBinder({ email: "john@lyon-smith.org" }, Login.bindings),
messageModal: null,
+ apiModal: null,
}
}
@@ -110,16 +109,28 @@ export class Login extends React.Component {
this.setState({ messageModal: null })
}
+ @autobind
+ handleApiDismiss() {
+ this.setState({ apiModal: null })
+ }
+
+ @autobind
+ handleApiPress() {
+ this.setState({ apiModal: {} })
+ }
+
render() {
- const { messageModal } = this.state
+ const { messageModal, apiModal } = this.state
return (
-
+
+
+
+
{Platform.OS === "ios" && }
)
diff --git a/mobile/src/Home/Home.js b/mobile/src/Home/Home.js
index 6b207cd..0638b75 100644
--- a/mobile/src/Home/Home.js
+++ b/mobile/src/Home/Home.js
@@ -55,6 +55,17 @@ export class Home extends React.Component {
}
}
+ @autobind
+ handleMarkerPress(e, sectionIndex) {
+ if (this.sectionList) {
+ this.sectionList.scrollToLocation({
+ sectionIndex,
+ itemIndex: 0,
+ viewOffset: 45,
+ })
+ }
+ }
+
@autobind
handleWorkItemsListPress() {
this.props.history.push("/workitemlist")
@@ -116,14 +127,19 @@ export class Home extends React.Component {
latitudeDelta: 0.0922,
longitudeDelta: 0.0922,
}}>
- {sections.map((section, index) => (
+ {sections.map((workItem, index) => (
this.handleMarkerPress(e, index)}
/>
))}
@@ -152,8 +168,10 @@ export class Home extends React.Component {
/>
(this.sectionList = ref)}
style={{ width: "100%", flexGrow: 1 }}
sections={sections}
+ stickySectionHeadersEnabled={true}
renderSectionHeader={({ section: workItem }) => (
)}
+ keyExtractor={(item) => item._id}
renderItem={({ item: activity, section }) => {
return (
+
+
+
+ OK
+
+
+
+ )
+ }
+}
diff --git a/mobile/src/Modal/MessageModal.js b/mobile/src/Modal/MessageModal.js
index 3431147..fe266a0 100644
--- a/mobile/src/Modal/MessageModal.js
+++ b/mobile/src/Modal/MessageModal.js
@@ -1,9 +1,9 @@
-import React, { Component } from 'react'
-import Modal from 'react-native-modal'
-import PropTypes from 'prop-types'
-import { View, Text, TouchableOpacity } from 'react-native'
-import { Icon } from '../ui'
-import autobind from 'autobind-decorator'
+import React, { Component } from "react"
+import Modal from "react-native-modal"
+import PropTypes from "prop-types"
+import { View, Text, TouchableOpacity } from "react-native"
+import { Icon } from "../ui"
+import autobind from "autobind-decorator"
export class MessageModal extends Component {
static propTypes = {
@@ -11,7 +11,7 @@ export class MessageModal extends Component {
icon: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
detail: PropTypes.string,
- onDismiss: PropTypes.func
+ onDismiss: PropTypes.func,
}
@autobind
@@ -23,40 +23,48 @@ export class MessageModal extends Component {
}
}
- constructor(props) {
- super(props)
- this.state = {
-
- }
- }
-
render() {
const { open, icon, message, detail } = this.props
return (
-
+
-
+
{message}
{detail}
-
- OK
+ OK
)
}
-}
\ No newline at end of file
+}
diff --git a/mobile/src/Modal/index.js b/mobile/src/Modal/index.js
index 7852cbf..08b28e2 100644
--- a/mobile/src/Modal/index.js
+++ b/mobile/src/Modal/index.js
@@ -1 +1,2 @@
-export { MessageModal } from './MessageModal'
\ No newline at end of file
+export { MessageModal } from "./MessageModal"
+export { ApiModal } from "./ApiModal"