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
         "level": "Level: ",
379
         "level": "Level: ",
380
         "time": "Time: ",
380
         "time": "Time: ",
381
         "exit": "leave Game"
381
         "exit": "leave Game"
382
+      },
383
+      "mascotDialog": {
384
+        "title": "Play !",
385
+        "message": "Play.",
386
+        "button": "Yes !"
382
       }
387
       }
383
     },
388
     },
384
     "debug": {
389
     "debug": {

+ 5
- 0
locales/fr.json View File

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

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

100
             default: '1',
100
             default: '1',
101
             current: '',
101
             current: '',
102
         },
102
         },
103
+        gameStartShowBanner: {
104
+            key: 'gameStartShowBanner',
105
+            default: '1',
106
+            current: '',
107
+        },
103
         proxiwashWatchedMachines: {
108
         proxiwashWatchedMachines: {
104
             key: 'proxiwashWatchedMachines',
109
             key: 'proxiwashWatchedMachines',
105
             default: '[]',
110
             default: '[]',

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

5
 import type {CustomTheme} from "../../../managers/ThemeManager";
5
 import type {CustomTheme} from "../../../managers/ThemeManager";
6
 import {Button, Headline, withTheme} from "react-native-paper";
6
 import {Button, Headline, withTheme} from "react-native-paper";
7
 import {View} from "react-native";
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
 type Props = {
13
 type Props = {
10
     navigation: StackNavigationProp,
14
     navigation: StackNavigationProp,
12
 }
16
 }
13
 
17
 
14
 type State = {
18
 type State = {
15
-
19
+    mascotDialogVisible: boolean,
16
 }
20
 }
17
 
21
 
18
 class GameStartScreen extends React.Component<Props, State> {
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
     render() {
36
     render() {
21
         return (
37
         return (
22
             <View style={{flex: 1}}>
38
             <View style={{flex: 1}}>
27
                 >
43
                 >
28
                     PLAY
44
                     PLAY
29
                 </Button>
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
             </View>
61
             </View>
31
         );
62
         );
32
     }
63
     }

Loading…
Cancel
Save