Skip to content

Commit 2592fbd

Browse files
committed
Number guesser added
1 parent 045b916 commit 2592fbd

31 files changed

+6446
-0
lines changed

gnum/.expo-shared/assets.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true,
3+
"40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true
4+
}

gnum/.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules/
2+
.expo/
3+
dist/
4+
npm-debug.*
5+
*.jks
6+
*.p8
7+
*.p12
8+
*.key
9+
*.mobileprovision
10+
*.orig.*
11+
web-build/
12+
13+
# macOS
14+
.DS_Store

gnum/App.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import React, { useState } from "react";
2+
import { StyleSheet, View } from "react-native";
3+
import * as Font from "expo-font";
4+
import AppLoading from "expo-app-loading";
5+
6+
import Header from "./components/Header";
7+
import StartGameScreen from "./screens/StartGameScreen";
8+
import GameScreen from "./screens/GameScreen";
9+
import GameOverScreen from "./screens/GameOverScreen";
10+
11+
const fetchFonts = () => {
12+
return Font.loadAsync({
13+
"open-sans": require("./assets/fonts/OpenSans-Regular.ttf"),
14+
"open-sans-bold": require("./assets/fonts/OpenSans-Bold.ttf"),
15+
});
16+
};
17+
18+
export default function App() {
19+
const [userNumber, setUserNumber] = useState();
20+
const [guessRounds, setGuessRounds] = useState(0);
21+
const [dataLoaded, setDataLoaded] = useState(false);
22+
23+
if (!dataLoaded) {
24+
return (
25+
<AppLoading
26+
startAsync={fetchFonts}
27+
onFinish={() => setDataLoaded(true)}
28+
onError={(err) => console.log(err)}
29+
/>
30+
);
31+
}
32+
33+
const configureNewGameHandler = () => {
34+
setGuessRounds(0);
35+
setUserNumber(null);
36+
};
37+
38+
const startGameHandler = (selectedNumber) => {
39+
setUserNumber(selectedNumber);
40+
setGuessRounds(0);
41+
};
42+
43+
const gameOverHandler = (numOfRounds) => {
44+
setGuessRounds(numOfRounds);
45+
};
46+
47+
let content = <StartGameScreen onStartGame={startGameHandler} />;
48+
49+
if (userNumber && guessRounds <= 0) {
50+
content = (
51+
<GameScreen userChoice={userNumber} onGameOver={gameOverHandler} />
52+
);
53+
} else if (guessRounds > 0) {
54+
content = (
55+
<GameOverScreen
56+
roundsNumber={guessRounds}
57+
userNumber={userNumber}
58+
onRestart={configureNewGameHandler}
59+
/>
60+
);
61+
}
62+
63+
return (
64+
<View style={styles.screen}>
65+
<Header title="Guess a Number" />
66+
{content}
67+
</View>
68+
);
69+
}
70+
71+
const styles = StyleSheet.create({
72+
screen: {
73+
flex: 1,
74+
},
75+
});

gnum/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Guess a Number
2+
3+
<p align="center">
4+
<img src="screen01.jpeg" width="25%" alt="tela da aplicação">
5+
<img src="screen02.jpeg" width="25%" alt="tela da aplicação">
6+
<img src="screen03.jpeg" width="25%" alt="tela da aplicação">
7+
<img src="screen04.jpeg" width="25%" alt="tela da aplicação">
8+
<img src="screen05.jpeg" width="25%" alt="tela da aplicação">
9+
</p>
10+
11+
> Pequeno projeto usando Expo, de um adivinhador de número pelo próprio app, responsivo para ambos portraits, projeto feito por Maximilian Schwarzmüller.

gnum/app.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"expo": {
3+
"name": "gnum",
4+
"slug": "gnum",
5+
"version": "1.0.0",
6+
"orientation": "default",
7+
"icon": "./assets/icon.png",
8+
"splash": {
9+
"image": "./assets/splash.png",
10+
"resizeMode": "contain",
11+
"backgroundColor": "#ffffff"
12+
},
13+
"updates": {
14+
"fallbackToCacheTimeout": 0
15+
},
16+
"assetBundlePatterns": [
17+
"**/*"
18+
],
19+
"ios": {
20+
"supportsTablet": true
21+
},
22+
"android": {
23+
"adaptiveIcon": {
24+
"foregroundImage": "./assets/adaptive-icon.png",
25+
"backgroundColor": "#FFFFFF"
26+
}
27+
},
28+
"web": {
29+
"favicon": "./assets/favicon.png"
30+
}
31+
}
32+
}

gnum/assets/adaptive-icon.png

17.1 KB
Loading

gnum/assets/favicon.png

1.43 KB
Loading
101 KB
Binary file not shown.
94.2 KB
Binary file not shown.

gnum/assets/icon.png

21.9 KB
Loading

0 commit comments

Comments
 (0)