From 5f0978904344ea83389f1ace1b80686105c20e50 Mon Sep 17 00:00:00 2001 From: lesmaux Date: Sun, 30 Sep 2018 17:17:26 +1300 Subject: [PATCH] Added game sign in menus --- App.js | 48 ++++++++++++++++--------- components/join-button.js | 7 ++-- components/new-button.js | 4 +-- components/room-input.js | 73 ++++++++++++++++++++++++++++----------- 4 files changed, 90 insertions(+), 42 deletions(-) diff --git a/App.js b/App.js index e30c3e6..2b4ae5c 100644 --- a/App.js +++ b/App.js @@ -9,14 +9,15 @@ import { ScrollView, TextInput, TouchableHighlight, - View + View, + Modal } from 'react-native'; import RunInfo from './components/run-info'; import RunInfoNumeric from './components/run-info-num'; import MapView from 'react-native-maps'; -import NewButton from "./components/new-button"; +import WalkButton from "./components/new-button"; import JoinButton from "./components/join-button"; import CapturedArea from "./components/captured-area"; import RoomInput from "./components/room-input"; @@ -49,7 +50,10 @@ export default class App extends Component { ] }); }, null, {enableHighAccuracy: true, timeout: 20000, distanceFilter: 10}); + this.state = { + username: "", + gameNumber: "", walkMarkers: [], captures: [ new CapturedArea("fanded", [ @@ -69,6 +73,9 @@ export default class App extends Component { watchID }; } + setGameNumber(user, number){ + this.setState({username: user, gameNumber: number}) + } componentWillUnmount() { navigator.geolocation.stopWatch(this.state.watchID); @@ -106,21 +113,23 @@ export default class App extends Component { ) } - + + {"name: " + this.state.username + "\ngame: " + this.state.gameNumber} + + + + this.roomInputModal = instance} + join={(user, number) => this.setGameNumber(user, number)}/> - - {this.setState({walkMarkers: []})}}/> + + {this.setState({walkMarkers: []})}}/> - - {}}/> - {}}/> - {}}/> - {}}/> - - + this.roomInputModal.setModalVisible(true)}/> @@ -130,10 +139,6 @@ export default class App extends Component { const styles = StyleSheet.create({ infoWrapper: { - // position: 'absolute', - // left: 0, - // bottom: 0, - // right: 0, paddingVertical: 0, flexDirection: 'row', flex: 1 @@ -147,7 +152,7 @@ const styles = StyleSheet.create({ flexDirection: 'column', flex: 1 }, - new: { + walk: { // position: 'absolute', // left: 0, // bottom: 60, @@ -156,9 +161,18 @@ const styles = StyleSheet.create({ flexDirection: 'row', flex: 1 }, + modal:{ + backgroundColor: 'white', + margin: 0, // This is the important style you need to set + alignItems: undefined, + justifyContent: undefined, + }, map: { ...StyleSheet.absoluteFillObject }, + gameNumber:{ + fontSize: 30, + }, container: { flex: 1, diff --git a/components/join-button.js b/components/join-button.js index 956328c..ddb9ed4 100644 --- a/components/join-button.js +++ b/components/join-button.js @@ -11,7 +11,7 @@ import { export default class JoinButton extends Component { constructor(props) { super(props); - this.join = this.props.join; + this.modal = this.props.modal; this.state = { value: this.props.value}; } @@ -23,13 +23,14 @@ export default class JoinButton extends Component { return ( this.join()} + onPress= {() => this.modal()} // style={sharedStyles.new} > - Join + Join Room ) } } + diff --git a/components/new-button.js b/components/new-button.js index 2aa0162..f071a85 100644 --- a/components/new-button.js +++ b/components/new-button.js @@ -8,7 +8,7 @@ import { View } from 'react-native'; -export default class NewButton extends Component { +export default class WalkButton extends Component { constructor(props) { super(props); this.erase = this.props.erase; @@ -26,7 +26,7 @@ export default class NewButton extends Component { onPress= {() => this.erase()} // style={sharedStyles.new} > - + { Alert.alert('Modal has been closed.'); - }}> - + }} + style={styles.modal}> - Hello World! + Enter Game ID: + this.setState({userText: text})} + /> + this.setState({gameText: texta})} + /> + + + { + this.join(this.state.userText, this.state.gameText); + this.setModalVisible(!this.state.modalVisible) + }}> + Join + { this.setModalVisible(!this.state.modalVisible); }}> - Hide ModalW + Cancel - - - - { - this.setModalVisible(true); - }}> - Show Modal - + + ); } -} \ No newline at end of file +} +const styles = StyleSheet.create({ + modal: { + backgroundColor: 'white', + margin: 15, + alignItems: undefined, + justifyContent: undefined, + } +}) \ No newline at end of file