diff --git a/src/components/Tabbar/CustomTabBar.js b/src/components/Tabbar/CustomTabBar.js index 93f1c4f..682901c 100644 --- a/src/components/Tabbar/CustomTabBar.js +++ b/src/components/Tabbar/CustomTabBar.js @@ -78,7 +78,7 @@ class CustomTabBar extends React.Component { canPreventDefault: true, }); if (route.name === "home" && !event.defaultPrevented) - this.props.navigation.navigate('tetris'); + this.props.navigation.navigate('game-start'); } /** diff --git a/src/navigation/MainNavigator.js b/src/navigation/MainNavigator.js index 9afbf5e..8a21a8c 100644 --- a/src/navigation/MainNavigator.js +++ b/src/navigation/MainNavigator.js @@ -8,7 +8,7 @@ import DebugScreen from '../screens/About/DebugScreen'; import {createStackNavigator, TransitionPresets} from "@react-navigation/stack"; import i18n from "i18n-js"; import TabNavigator from "./TabNavigator"; -import GameScreen from "../screens/Game/GameScreen"; +import GameMainScreen from "../screens/Game/screens/GameMainScreen"; import VoteScreen from "../screens/Amicale/VoteScreen"; import LoginScreen from "../screens/Amicale/LoginScreen"; import {Platform} from "react-native"; @@ -27,6 +27,8 @@ import EquipmentScreen from "../screens/Amicale/Equipment/EquipmentListScreen"; import EquipmentLendScreen from "../screens/Amicale/Equipment/EquipmentRentScreen"; import EquipmentConfirmScreen from "../screens/Amicale/Equipment/EquipmentConfirmScreen"; import DashboardEditScreen from "../screens/Other/Settings/DashboardEditScreen"; +import GameStartScreen from "../screens/Game/screens/GameStartScreen"; +import GameEndScreen from "../screens/Game/screens/GameEndScreen"; const modalTransition = Platform.OS === 'ios' ? TransitionPresets.ModalPresentationIOS : TransitionPresets.ModalSlideFromBottomIOS; @@ -92,8 +94,22 @@ function MainStackComponent(props: { createTabNavigator: () => React.Node }) { }} /> + + { diff --git a/src/screens/Game/GameLogic.js b/src/screens/Game/logic/GameLogic.js similarity index 95% rename from src/screens/Game/GameLogic.js rename to src/screens/Game/logic/GameLogic.js index 98c1257..4d62b6f 100644 --- a/src/screens/Game/GameLogic.js +++ b/src/screens/Game/logic/GameLogic.js @@ -3,6 +3,7 @@ import Piece from "./Piece"; import ScoreManager from "./ScoreManager"; import GridManager from "./GridManager"; +import type {CustomTheme} from "../../../managers/ThemeManager"; export default class GameLogic { @@ -45,20 +46,20 @@ export default class GameLogic { #onClock: Function; endCallback: Function; - #colors: Object; + #theme: CustomTheme; - constructor(height: number, width: number, colors: Object) { + constructor(height: number, width: number, theme: CustomTheme) { this.#height = height; this.#width = width; this.#gameRunning = false; this.#gamePaused = false; - this.#colors = colors; + this.#theme = theme; this.#autoRepeatActivationDelay = 300; this.#autoRepeatDelay = 50; this.#nextPieces = []; this.#nextPiecesCount = 3; this.#scoreManager = new ScoreManager(); - this.#gridManager = new GridManager(this.getWidth(), this.getHeight(), this.#colors); + this.#gridManager = new GridManager(this.getWidth(), this.getHeight(), this.#theme); } getHeight(): number { @@ -179,7 +180,7 @@ export default class GameLogic { generateNextPieces() { while (this.#nextPieces.length < this.#nextPiecesCount) { - this.#nextPieces.push(new Piece(this.#colors)); + this.#nextPieces.push(new Piece(this.#theme)); } } @@ -219,7 +220,7 @@ export default class GameLogic { this.#gameTime = 0; this.#scoreManager = new ScoreManager(); this.#gameTick = GameLogic.levelTicks[this.#scoreManager.getLevel()]; - this.#gridManager = new GridManager(this.getWidth(), this.getHeight(), this.#colors); + this.#gridManager = new GridManager(this.getWidth(), this.getHeight(), this.#theme); this.#nextPieces = []; this.generateNextPieces(); this.createTetromino(); diff --git a/src/screens/Game/GridManager.js b/src/screens/Game/logic/GridManager.js similarity index 93% rename from src/screens/Game/GridManager.js rename to src/screens/Game/logic/GridManager.js index 9e19e96..0ea1819 100644 --- a/src/screens/Game/GridManager.js +++ b/src/screens/Game/logic/GridManager.js @@ -2,10 +2,10 @@ import Piece from "./Piece"; import ScoreManager from "./ScoreManager"; -import type {Coordinates} from './Shapes/BaseShape'; -import type {Grid} from "./components/GridComponent"; -import type {Cell} from "./components/CellComponent"; -import type {CustomTheme} from "../../managers/ThemeManager"; +import type {Coordinates} from '../Shapes/BaseShape'; +import type {Grid} from "../components/GridComponent"; +import type {Cell} from "../components/CellComponent"; +import type {CustomTheme} from "../../../managers/ThemeManager"; /** * Class used to manage the game grid diff --git a/src/screens/Game/Piece.js b/src/screens/Game/logic/Piece.js similarity index 90% rename from src/screens/Game/Piece.js rename to src/screens/Game/logic/Piece.js index daece82..2fbd084 100644 --- a/src/screens/Game/Piece.js +++ b/src/screens/Game/logic/Piece.js @@ -1,14 +1,14 @@ -import ShapeL from "./Shapes/ShapeL"; -import ShapeI from "./Shapes/ShapeI"; -import ShapeJ from "./Shapes/ShapeJ"; -import ShapeO from "./Shapes/ShapeO"; -import ShapeS from "./Shapes/ShapeS"; -import ShapeT from "./Shapes/ShapeT"; -import ShapeZ from "./Shapes/ShapeZ"; -import type {Coordinates} from './Shapes/BaseShape'; -import BaseShape from "./Shapes/BaseShape"; -import type {Grid} from "./components/GridComponent"; -import type {CustomTheme} from "../../managers/ThemeManager"; +import ShapeL from "../Shapes/ShapeL"; +import ShapeI from "../Shapes/ShapeI"; +import ShapeJ from "../Shapes/ShapeJ"; +import ShapeO from "../Shapes/ShapeO"; +import ShapeS from "../Shapes/ShapeS"; +import ShapeT from "../Shapes/ShapeT"; +import ShapeZ from "../Shapes/ShapeZ"; +import type {Coordinates} from '../Shapes/BaseShape'; +import BaseShape from "../Shapes/BaseShape"; +import type {Grid} from "../components/GridComponent"; +import type {CustomTheme} from "../../../managers/ThemeManager"; /** * Class used as an abstraction layer for shapes. diff --git a/src/screens/Game/ScoreManager.js b/src/screens/Game/logic/ScoreManager.js similarity index 100% rename from src/screens/Game/ScoreManager.js rename to src/screens/Game/logic/ScoreManager.js diff --git a/src/screens/Game/screens/GameEndScreen.js b/src/screens/Game/screens/GameEndScreen.js new file mode 100644 index 0000000..397212f --- /dev/null +++ b/src/screens/Game/screens/GameEndScreen.js @@ -0,0 +1,26 @@ +// @flow + +import * as React from "react"; +import {StackNavigationProp} from "@react-navigation/stack"; +import type {CustomTheme} from "../../../managers/ThemeManager"; +import {withTheme} from "react-native-paper"; + +type Props = { + navigation: StackNavigationProp, + theme: CustomTheme, +} + +type State = { + +} + +class GameEndScreen extends React.Component { + + render() { + return ( + null + ); + } +} + +export default withTheme(GameEndScreen); diff --git a/src/screens/Game/GameScreen.js b/src/screens/Game/screens/GameMainScreen.js similarity index 94% rename from src/screens/Game/GameScreen.js rename to src/screens/Game/screens/GameMainScreen.js index df14eba..e2afa0a 100644 --- a/src/screens/Game/GameScreen.js +++ b/src/screens/Game/screens/GameMainScreen.js @@ -4,14 +4,14 @@ import * as React from 'react'; import {Alert, View} from 'react-native'; import {IconButton, Text, withTheme} from 'react-native-paper'; import MaterialCommunityIcons from "react-native-vector-icons/MaterialCommunityIcons"; -import GameLogic from "./GameLogic"; -import type {Grid} from "./components/GridComponent"; -import GridComponent from "./components/GridComponent"; -import Preview from "./components/Preview"; +import GameLogic from "../logic/GameLogic"; +import type {Grid} from "../components/GridComponent"; +import GridComponent from "../components/GridComponent"; +import Preview from "../components/Preview"; import i18n from "i18n-js"; -import MaterialHeaderButtons, {Item} from "../../components/Overrides/CustomHeaderButton"; +import MaterialHeaderButtons, {Item} from "../../../components/Overrides/CustomHeaderButton"; import {StackNavigationProp} from "@react-navigation/stack"; -import type {CustomTheme} from "../../managers/ThemeManager"; +import type {CustomTheme} from "../../../managers/ThemeManager"; type Props = { navigation: StackNavigationProp, @@ -26,13 +26,13 @@ type State = { gameLevel: number, } -class GameScreen extends React.Component { +class GameMainScreen extends React.Component { logic: GameLogic; constructor(props) { super(props); - this.logic = new GameLogic(20, 10, this.props.theme.colors); + this.logic = new GameLogic(20, 10, this.props.theme); this.state = { grid: this.logic.getCurrentGrid(), gameRunning: false, @@ -287,4 +287,4 @@ class GameScreen extends React.Component { } -export default withTheme(GameScreen); +export default withTheme(GameMainScreen); diff --git a/src/screens/Game/screens/GameStartScreen.js b/src/screens/Game/screens/GameStartScreen.js new file mode 100644 index 0000000..1ed78e0 --- /dev/null +++ b/src/screens/Game/screens/GameStartScreen.js @@ -0,0 +1,36 @@ +// @flow + +import * as React from "react"; +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"; + +type Props = { + navigation: StackNavigationProp, + theme: CustomTheme, +} + +type State = { + +} + +class GameStartScreen extends React.Component { + + render() { + return ( + + Coucou + + + ); + } +} + +export default withTheme(GameStartScreen); +