diff --git a/android/app/build.gradle b/android/app/build.gradle index f533abf..82b573a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,5 +1,7 @@ apply plugin: "com.android.application" +apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" + import com.android.build.OutputFile /** diff --git a/src/navigation/index.tsx b/src/navigation/index.tsx index 35f2952..8948d27 100644 --- a/src/navigation/index.tsx +++ b/src/navigation/index.tsx @@ -5,7 +5,7 @@ import { StatusBar } from 'react-native'; import { connect } from 'react-redux'; import Main from '../screens/main'; -import Leaderboard from '../screens/leaderboard'; +import Records from '../screens/records'; const Root = createStackNavigator(); @@ -16,7 +16,7 @@ class AppNav extends React.Component { - + ); diff --git a/src/redux/action.ts b/src/redux/action.ts index b93549f..3573ba2 100644 --- a/src/redux/action.ts +++ b/src/redux/action.ts @@ -1,10 +1,15 @@ -import Board from '../game/board'; -import { ActionType, GameConfig } from '../utils/types'; +import { ActionType, GameConfig, RecordType, } from '../utils/types'; export enum ActionName { - SAVE_GAME_STATE + SAVE_GAME_STATE, + SAVE_RECORDS, } +export const updateRecords = (payload: Array): ActionType => ({ + type: ActionName.SAVE_RECORDS, + payload +}); + export const saveGameState = (payload: GameConfig): ActionType => ({ type: ActionName.SAVE_GAME_STATE, payload, diff --git a/src/redux/reducer.ts b/src/redux/reducer.ts index a1164c3..f2d1eb2 100644 --- a/src/redux/reducer.ts +++ b/src/redux/reducer.ts @@ -2,10 +2,15 @@ import { combineReducers } from 'redux'; import { ActionName } from './action'; -import { ActionType, GameConfig } from '../utils/types'; +import { ActionType, GameConfig, RecordType } from '../utils/types'; -const saveGame = (board: GameConfig = null, action: ActionType) => action.type === ActionName.SAVE_GAME_STATE ? action.payload : board; +const saveGame = (board: GameConfig = null, action: ActionType) => + action.type === ActionName.SAVE_GAME_STATE ? action.payload : board; + +const saveRecords = (records: Array = [], action: ActionType) => + action.type === ActionName.SAVE_RECORDS ? action.payload : records; export default combineReducers({ game: saveGame, + records: saveRecords, }) diff --git a/src/screens/leaderboard.tsx b/src/screens/records.tsx similarity index 100% rename from src/screens/leaderboard.tsx rename to src/screens/records.tsx diff --git a/src/utils/types.ts b/src/utils/types.ts index 5a395a7..6037739 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -6,11 +6,6 @@ export interface CoordinatePair { col: number; } -export interface MergingPairs { - mergee: CoordinatePair, - merger: CoordinatePair, -} - // game config export interface GameConfig { board: Array>, @@ -50,3 +45,9 @@ export interface TileColorSchemeType { '2048': string, large: string, } + +// game records +export interface RecordType { + topTile: number, + score: number, +}