Added game sign in menus
This commit is contained in:
@@ -9,14 +9,15 @@ import {
|
|||||||
ScrollView,
|
ScrollView,
|
||||||
TextInput,
|
TextInput,
|
||||||
TouchableHighlight,
|
TouchableHighlight,
|
||||||
View
|
View,
|
||||||
|
Modal
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
import RunInfo from './components/run-info';
|
import RunInfo from './components/run-info';
|
||||||
import RunInfoNumeric from './components/run-info-num';
|
import RunInfoNumeric from './components/run-info-num';
|
||||||
|
|
||||||
import MapView from 'react-native-maps';
|
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 JoinButton from "./components/join-button";
|
||||||
import CapturedArea from "./components/captured-area";
|
import CapturedArea from "./components/captured-area";
|
||||||
import RoomInput from "./components/room-input";
|
import RoomInput from "./components/room-input";
|
||||||
@@ -49,7 +50,10 @@ export default class App extends Component<Props> {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
}, null, {enableHighAccuracy: true, timeout: 20000, distanceFilter: 10});
|
}, null, {enableHighAccuracy: true, timeout: 20000, distanceFilter: 10});
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
username: "",
|
||||||
|
gameNumber: "",
|
||||||
walkMarkers: [],
|
walkMarkers: [],
|
||||||
captures: [
|
captures: [
|
||||||
new CapturedArea("fanded", [
|
new CapturedArea("fanded", [
|
||||||
@@ -69,6 +73,9 @@ export default class App extends Component<Props> {
|
|||||||
watchID
|
watchID
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
setGameNumber(user, number){
|
||||||
|
this.setState({username: user, gameNumber: number})
|
||||||
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
navigator.geolocation.stopWatch(this.state.watchID);
|
navigator.geolocation.stopWatch(this.state.watchID);
|
||||||
@@ -106,21 +113,23 @@ export default class App extends Component<Props> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
</MapView>
|
</MapView>
|
||||||
<RoomInput/>
|
<Text style={styles.gameNumber}>
|
||||||
|
{"name: " + this.state.username + "\ngame: " + this.state.gameNumber}
|
||||||
|
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<RoomInput
|
||||||
|
ref={instance => this.roomInputModal = instance}
|
||||||
|
join={(user, number) => this.setGameNumber(user, number)}/>
|
||||||
<View style={styles.menu}>
|
<View style={styles.menu}>
|
||||||
|
|
||||||
<View style={styles.new}>
|
<View style={styles.walk}>
|
||||||
<NewButton erase={() => {this.setState({walkMarkers: []})}}/>
|
<WalkButton erase={() => {this.setState({walkMarkers: []})}}/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={styles.infoWrapper}>
|
<View style={styles.infoWrapper}>
|
||||||
|
<JoinButton
|
||||||
<JoinButton join={() => {}}/>
|
modal={() => this.roomInputModal.setModalVisible(true)}/>
|
||||||
<JoinButton join={() => {}}/>
|
|
||||||
<JoinButton join={() => {}}/>
|
|
||||||
<JoinButton join={() => {}}/>
|
|
||||||
|
|
||||||
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -130,10 +139,6 @@ export default class App extends Component<Props> {
|
|||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
infoWrapper: {
|
infoWrapper: {
|
||||||
// position: 'absolute',
|
|
||||||
// left: 0,
|
|
||||||
// bottom: 0,
|
|
||||||
// right: 0,
|
|
||||||
paddingVertical: 0,
|
paddingVertical: 0,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
flex: 1
|
flex: 1
|
||||||
@@ -147,7 +152,7 @@ const styles = StyleSheet.create({
|
|||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
flex: 1
|
flex: 1
|
||||||
},
|
},
|
||||||
new: {
|
walk: {
|
||||||
// position: 'absolute',
|
// position: 'absolute',
|
||||||
// left: 0,
|
// left: 0,
|
||||||
// bottom: 60,
|
// bottom: 60,
|
||||||
@@ -156,9 +161,18 @@ const styles = StyleSheet.create({
|
|||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
flex: 1
|
flex: 1
|
||||||
},
|
},
|
||||||
|
modal:{
|
||||||
|
backgroundColor: 'white',
|
||||||
|
margin: 0, // This is the important style you need to set
|
||||||
|
alignItems: undefined,
|
||||||
|
justifyContent: undefined,
|
||||||
|
},
|
||||||
map: {
|
map: {
|
||||||
...StyleSheet.absoluteFillObject
|
...StyleSheet.absoluteFillObject
|
||||||
},
|
},
|
||||||
|
gameNumber:{
|
||||||
|
fontSize: 30,
|
||||||
|
},
|
||||||
|
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
export default class JoinButton extends Component {
|
export default class JoinButton extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.join = this.props.join;
|
this.modal = this.props.modal;
|
||||||
this.state = { value: this.props.value};
|
this.state = { value: this.props.value};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,13 +23,14 @@ export default class JoinButton extends Component {
|
|||||||
return (
|
return (
|
||||||
<View style ={[sharedStyles.runInfoWrapper, {flex: 1}]}>
|
<View style ={[sharedStyles.runInfoWrapper, {flex: 1}]}>
|
||||||
<TouchableHighlight
|
<TouchableHighlight
|
||||||
onPress= {() => this.join()}
|
onPress= {() => this.modal()}
|
||||||
// style={sharedStyles.new}
|
// style={sharedStyles.new}
|
||||||
>
|
>
|
||||||
<Text style={{fontSize: 25, textAlign: 'center'}}>Join</Text>
|
<Text style={{fontSize: 25, textAlign: 'center'}}>Join Room</Text>
|
||||||
</TouchableHighlight>
|
</TouchableHighlight>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
View
|
View
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
|
||||||
export default class NewButton extends Component {
|
export default class WalkButton extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.erase = this.props.erase;
|
this.erase = this.props.erase;
|
||||||
|
|||||||
+50
-17
@@ -1,9 +1,24 @@
|
|||||||
import React, {Component} from 'react';
|
import React, {Component} from 'react';
|
||||||
import {Modal, Text, TouchableHighlight, View, Alert} from 'react-native';
|
import {
|
||||||
|
Modal,
|
||||||
|
Text,
|
||||||
|
TouchableHighlight,
|
||||||
|
View,
|
||||||
|
Alert,
|
||||||
|
StyleSheet,
|
||||||
|
TextInput
|
||||||
|
} from 'react-native';
|
||||||
|
|
||||||
class RoomInput extends Component {
|
export default class RoomInput extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.join = this.props.join;;
|
||||||
|
|
||||||
|
}
|
||||||
state = {
|
state = {
|
||||||
modalVisible: false,
|
modalVisible: false,
|
||||||
|
gameText: "",
|
||||||
|
userText: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
setModalVisible(visible) {
|
setModalVisible(visible) {
|
||||||
@@ -12,35 +27,53 @@ class RoomInput extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={{marginTop: 22}}>
|
<View>
|
||||||
<Modal
|
<Modal
|
||||||
animationType="slide"
|
|
||||||
transparent={false}
|
|
||||||
visible={this.state.modalVisible}
|
visible={this.state.modalVisible}
|
||||||
onRequestClose={() => {
|
onRequestClose={() => {
|
||||||
Alert.alert('Modal has been closed.');
|
Alert.alert('Modal has been closed.');
|
||||||
}}>
|
}}
|
||||||
<View style={{marginTop: 22}}>
|
style={styles.modal}>
|
||||||
<View>
|
<View>
|
||||||
<Text>Hello World!</Text>
|
<Text>Enter Game ID:</Text>
|
||||||
|
<TextInput
|
||||||
|
style={styles.textInput}
|
||||||
|
placeholder="Username"
|
||||||
|
onChangeText={(text) => this.setState({userText: text})}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
style={styles.textInput}
|
||||||
|
placeholder="Game No."
|
||||||
|
onChangeText={(texta) => this.setState({gameText: texta})}
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<TouchableHighlight
|
||||||
|
onPress={() => {
|
||||||
|
this.join(this.state.userText, this.state.gameText);
|
||||||
|
this.setModalVisible(!this.state.modalVisible)
|
||||||
|
}}>
|
||||||
|
<Text>Join</Text>
|
||||||
|
</TouchableHighlight>
|
||||||
|
|
||||||
<TouchableHighlight
|
<TouchableHighlight
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.setModalVisible(!this.state.modalVisible);
|
this.setModalVisible(!this.state.modalVisible);
|
||||||
}}>
|
}}>
|
||||||
<Text>Hide Modal</Text>W
|
<Text>Cancel</Text>
|
||||||
</TouchableHighlight>
|
</TouchableHighlight>
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<TouchableHighlight
|
|
||||||
onPress={() => {
|
|
||||||
this.setModalVisible(true);
|
|
||||||
}}>
|
|
||||||
<Text>Show Modal</Text>
|
|
||||||
</TouchableHighlight>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
modal: {
|
||||||
|
backgroundColor: 'white',
|
||||||
|
margin: 15,
|
||||||
|
alignItems: undefined,
|
||||||
|
justifyContent: undefined,
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user