Added mascot dialog on game first start

This commit is contained in:
Arnaud Vergnet 2020-07-18 19:51:07 +02:00
parent 3989652c29
commit 746303b35a
4 changed files with 47 additions and 1 deletions

View file

@ -379,6 +379,11 @@
"level": "Level: ",
"time": "Time: ",
"exit": "leave Game"
},
"mascotDialog": {
"title": "Play !",
"message": "Play.",
"button": "Yes !"
}
},
"debug": {

View file

@ -378,6 +378,11 @@
"level": "Niveau: ",
"time": "Temps: ",
"exit": "Quitter"
},
"mascotDialog": {
"title": "Jeu !",
"message": "Jouer.",
"button": "Oui !"
}
},
"debug": {

View file

@ -100,6 +100,11 @@ export default class AsyncStorageManager {
default: '1',
current: '',
},
gameStartShowBanner: {
key: 'gameStartShowBanner',
default: '1',
current: '',
},
proxiwashWatchedMachines: {
key: 'proxiwashWatchedMachines',
default: '[]',

View file

@ -5,6 +5,10 @@ import {StackNavigationProp} from "@react-navigation/stack";
import type {CustomTheme} from "../../../managers/ThemeManager";
import {Button, Headline, withTheme} from "react-native-paper";
import {View} from "react-native";
import i18n from "i18n-js";
import {MASCOT_STYLE} from "../../../components/Mascot/Mascot";
import MascotPopup from "../../../components/Mascot/MascotPopup";
import AsyncStorageManager from "../../../managers/AsyncStorageManager";
type Props = {
navigation: StackNavigationProp,
@ -12,11 +16,23 @@ type Props = {
}
type State = {
mascotDialogVisible: boolean,
}
class GameStartScreen extends React.Component<Props, State> {
state = {
mascotDialogVisible: AsyncStorageManager.getInstance().preferences.gameStartShowBanner.current === "1",
}
hideMascotDialog = () => {
AsyncStorageManager.getInstance().savePref(
AsyncStorageManager.getInstance().preferences.gameStartShowBanner.key,
'0'
);
this.setState({mascotDialogVisible: false})
};
render() {
return (
<View style={{flex: 1}}>
@ -27,6 +43,21 @@ class GameStartScreen extends React.Component<Props, State> {
>
PLAY
</Button>
<MascotPopup
visible={this.state.mascotDialogVisible}
title={i18n.t("screens.game.mascotDialog.title")}
message={i18n.t("screens.game.mascotDialog.message")}
icon={"gamepad-variant"}
buttons={{
action: null,
cancel: {
message: i18n.t("screens.game.mascotDialog.button"),
icon: "check",
onPress: this.hideMascotDialog,
}
}}
emotion={MASCOT_STYLE.COOL}
/>
</View>
);
}