Browse Source

Use transparent header for game

Arnaud Vergnet 1 year ago
parent
commit
92603cbaf7
2 changed files with 19 additions and 14 deletions
  1. 3
    0
      src/navigation/MainNavigator.js
  2. 16
    14
      src/screens/Game/screens/GameStartScreen.js

+ 3
- 0
src/navigation/MainNavigator.js View File

@@ -98,6 +98,9 @@ function MainStackComponent(props: {
98 98
         MainStack,
99 99
         GameStartScreen,
100 100
         i18n.t('screens.game.title'),
101
+        true,
102
+        null,
103
+        'transparent',
101 104
       )}
102 105
       <MainStack.Screen
103 106
         name="game-main"

+ 16
- 14
src/screens/Game/screens/GameStartScreen.js View File

@@ -384,22 +384,24 @@ class GameStartScreen extends React.Component<PropsType> {
384 384
   recoverGameScore() {
385 385
     const {route} = this.props;
386 386
     this.gameStats = route.params;
387
-    this.isHighScore =
388
-      this.scores.length === 0 || this.gameStats.score > this.scores[0];
389
-    for (let i = 0; i < 3; i += 1) {
390
-      if (this.scores.length > i && this.gameStats.score > this.scores[i]) {
391
-        this.scores.splice(i, 0, this.gameStats.score);
392
-        break;
393
-      } else if (this.scores.length <= i) {
394
-        this.scores.push(this.gameStats.score);
395
-        break;
387
+    if (this.gameStats.score != null) {
388
+      this.isHighScore =
389
+        this.scores.length === 0 || this.gameStats.score > this.scores[0];
390
+      for (let i = 0; i < 3; i += 1) {
391
+        if (this.scores.length > i && this.gameStats.score > this.scores[i]) {
392
+          this.scores.splice(i, 0, this.gameStats.score);
393
+          break;
394
+        } else if (this.scores.length <= i) {
395
+          this.scores.push(this.gameStats.score);
396
+          break;
397
+        }
396 398
       }
399
+      if (this.scores.length > 3) this.scores.splice(3, 1);
400
+      AsyncStorageManager.set(
401
+        AsyncStorageManager.PREFERENCES.gameScores.key,
402
+        this.scores,
403
+      );
397 404
     }
398
-    if (this.scores.length > 3) this.scores.splice(3, 1);
399
-    AsyncStorageManager.set(
400
-      AsyncStorageManager.PREFERENCES.gameScores.key,
401
-      this.scores,
402
-    );
403 405
   }
404 406
 
405 407
   render(): React.Node {

Loading…
Cancel
Save