diff --git a/game.js b/game.js
index 2a05043..0161465 100644
--- a/game.js
+++ b/game.js
@@ -14,6 +14,9 @@ import {
TouchableHighlight,
AsyncStorage,
} from 'react-native';
+
+import AwesomeAlert from 'react-native-awesome-alerts';
+
const STORAGE_KEY = '@Game:data';
var timeLimit=10;
var timer = null;
@@ -36,6 +39,7 @@ export default class Game extends Component {
currentScore: 0,
timeout: 0,
playing: false,
+ showAlert: false,
holes: [false, false, false,
false, false, false,
false, false, false]
@@ -97,7 +101,8 @@ export default class Game extends Component {
playing: false,
})
if(this.state.currentScore>this.state.highScore){
- alert('YEAH! you got a new high score');
+ // alert('YEAH! you got a new high score');
+ this._showAlert();
this.setState({
highScore: ""+this.state.currentScore,
})
@@ -113,6 +118,18 @@ export default class Game extends Component {
.done();
}
+ _showAlert = () => {
+ this.setState({
+ showAlert: true
+ });
+ };
+
+ _hideAlert = () => {
+ this.setState({
+ showAlert: false
+ });
+ };
+
componentDidMount(){
AsyncStorage.getItem(STORAGE_KEY)
.then((value)=>{
@@ -124,6 +141,8 @@ export default class Game extends Component {
}
render() {
+ const { showAlert } = this.state;
+
return (
@@ -181,6 +200,21 @@ export default class Game extends Component {
onPress={this._startGame.bind(this)}
disabled={this.state.playing}/>
+ {
+ this._hideAlert();
+ }}
+ />
);
}
diff --git a/index.ios.js b/index.ios.js
index 1c9a047..f19ba1a 100644
--- a/index.ios.js
+++ b/index.ios.js
@@ -12,42 +12,6 @@ import {
View
} from 'react-native';
-export default class testapp extends Component {
- render() {
- return (
-
-
- Welcome to React Native!
-
-
- To get started, edit index.ios.js
-
-
- Press Cmd+R to reload,{'\n'}
- Cmd+D or shake for dev menu
-
-
- );
- }
-}
+import Game from './game.js';
-const styles = StyleSheet.create({
- container: {
- flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
- backgroundColor: '#F5FCFF',
- },
- welcome: {
- fontSize: 20,
- textAlign: 'center',
- margin: 10,
- },
- instructions: {
- textAlign: 'center',
- color: '#333333',
- marginBottom: 5,
- },
-});
-
-AppRegistry.registerComponent('testapp', () => testapp);
+AppRegistry.registerComponent('Game', () => Game);
diff --git a/package.json b/package.json
index dfb3c95..e21e92b 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,8 @@
},
"dependencies": {
"react": "16.0.0-alpha.12",
- "react-native": "0.46.4"
+ "react-native": "0.46.4",
+ "react-native-awesome-alerts": "^1.0.7"
},
"devDependencies": {
"babel-jest": "20.0.3",
diff --git a/yarn.lock b/yarn.lock
index 7222d7c..004500b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4464,6 +4464,12 @@ react-devtools-core@2.3.1:
shell-quote "^1.6.1"
ws "^2.0.3"
+react-native-awesome-alerts@^1.0.7:
+ version "1.0.7"
+ resolved "https://registry.yarnpkg.com/react-native-awesome-alerts/-/react-native-awesome-alerts-1.0.7.tgz#60344ab2044b994b77a9fc95f612b8347e31d1d6"
+ dependencies:
+ prop-types "^15.5.10"
+
react-native-scripts@^1.11.1:
version "1.11.1"
resolved "https://registry.yarnpkg.com/react-native-scripts/-/react-native-scripts-1.11.1.tgz#a9f0a5c91a85d34acee9ec9012cf614665670b80"