Browse Source

Added mascot dialog on game first start

Arnaud Vergnet 3 years ago
parent
commit
746303b35a

+ 5
- 0
locales/en.json View File

@@ -379,6 +379,11 @@
379 379
         "level": "Level: ",
380 380
         "time": "Time: ",
381 381
         "exit": "leave Game"
382
+      },
383
+      "mascotDialog": {
384
+        "title": "Play !",
385
+        "message": "Play.",
386
+        "button": "Yes !"
382 387
       }
383 388
     },
384 389
     "debug": {

+ 5
- 0
locales/fr.json View File

@@ -378,6 +378,11 @@
378 378
         "level": "Niveau: ",
379 379
         "time": "Temps: ",
380 380
         "exit": "Quitter"
381
+      },
382
+      "mascotDialog": {
383
+        "title": "Jeu !",
384
+        "message": "Jouer.",
385
+        "button": "Oui !"
381 386
       }
382 387
     },
383 388
     "debug": {

+ 5
- 0
src/managers/AsyncStorageManager.js View File

@@ -100,6 +100,11 @@ export default class AsyncStorageManager {
100 100
             default: '1',
101 101
             current: '',
102 102
         },
103
+        gameStartShowBanner: {
104
+            key: 'gameStartShowBanner',
105
+            default: '1',
106
+            current: '',
107
+        },
103 108
         proxiwashWatchedMachines: {
104 109
             key: 'proxiwashWatchedMachines',
105 110
             default: '[]',

+ 32
- 1
src/screens/Game/screens/GameStartScreen.js View File

@@ -5,6 +5,10 @@ import {StackNavigationProp} from "@react-navigation/stack";
5 5
 import type {CustomTheme} from "../../../managers/ThemeManager";
6 6
 import {Button, Headline, withTheme} from "react-native-paper";
7 7
 import {View} from "react-native";
8
+import i18n from "i18n-js";
9
+import {MASCOT_STYLE} from "../../../components/Mascot/Mascot";
10
+import MascotPopup from "../../../components/Mascot/MascotPopup";
11
+import AsyncStorageManager from "../../../managers/AsyncStorageManager";
8 12
 
9 13
 type Props = {
10 14
     navigation: StackNavigationProp,
@@ -12,11 +16,23 @@ type Props = {
12 16
 }
13 17
 
14 18
 type State = {
15
-
19
+    mascotDialogVisible: boolean,
16 20
 }
17 21
 
18 22
 class GameStartScreen extends React.Component<Props, State> {
19 23
 
24
+    state = {
25
+        mascotDialogVisible: AsyncStorageManager.getInstance().preferences.gameStartShowBanner.current === "1",
26
+    }
27
+
28
+    hideMascotDialog = () => {
29
+        AsyncStorageManager.getInstance().savePref(
30
+            AsyncStorageManager.getInstance().preferences.gameStartShowBanner.key,
31
+            '0'
32
+        );
33
+        this.setState({mascotDialogVisible: false})
34
+    };
35
+
20 36
     render() {
21 37
         return (
22 38
             <View style={{flex: 1}}>
@@ -27,6 +43,21 @@ class GameStartScreen extends React.Component<Props, State> {
27 43
                 >
28 44
                     PLAY
29 45
                 </Button>
46
+                <MascotPopup
47
+                    visible={this.state.mascotDialogVisible}
48
+                    title={i18n.t("screens.game.mascotDialog.title")}
49
+                    message={i18n.t("screens.game.mascotDialog.message")}
50
+                    icon={"gamepad-variant"}
51
+                    buttons={{
52
+                        action: null,
53
+                        cancel: {
54
+                            message: i18n.t("screens.game.mascotDialog.button"),
55
+                            icon: "check",
56
+                            onPress: this.hideMascotDialog,
57
+                        }
58
+                    }}
59
+                    emotion={MASCOT_STYLE.COOL}
60
+                />
30 61
             </View>
31 62
         );
32 63
     }

Loading…
Cancel
Save