From 1e11ac6f09f47c82aa0439a3ff6ed731d7f2345f Mon Sep 17 00:00:00 2001 From: lochungtin Date: Mon, 31 May 2021 02:20:36 +0100 Subject: [PATCH] home screen layout --- src/data/color.ts | 2 +- src/navigation/index.tsx | 2 +- src/screens/main.tsx | 54 +++++++++++++++++++++++++++++++++------- src/screens/styles.ts | 49 +++++++++++++++++++++++++++++++++--- 4 files changed, 93 insertions(+), 14 deletions(-) diff --git a/src/data/color.ts b/src/data/color.ts index 3ccdfbe..cfd7535 100644 --- a/src/data/color.ts +++ b/src/data/color.ts @@ -19,7 +19,7 @@ export const darktheme: ColorSchemeType = { large: '#3d3934', }, textColor: '#E0E0E0', - textboxColor: '#3E3E3E', + textboxColor: '#272727', btnColor: '#A0A0A0', accentColor: '#EB864D' } \ No newline at end of file diff --git a/src/navigation/index.tsx b/src/navigation/index.tsx index 8948d27..cb3bf39 100644 --- a/src/navigation/index.tsx +++ b/src/navigation/index.tsx @@ -14,7 +14,7 @@ class AppNav extends React.Component { return ( - + diff --git a/src/screens/main.tsx b/src/screens/main.tsx index 8d69c99..7c30a51 100644 --- a/src/screens/main.tsx +++ b/src/screens/main.tsx @@ -1,30 +1,66 @@ +import { StackNavigationProp } from '@react-navigation/stack' import React from 'react'; import { TouchableOpacity, Text, View, } from 'react-native'; +import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import { connect } from 'react-redux'; import BoardView from '../components/Board'; import { darktheme } from '../data/color'; -import { ScreenStyles } from './styles'; +import { MainStyles, ScreenStyles } from './styles'; import Board from '../game/board'; import { saveGameState } from '../redux/action'; import { store } from '../redux/store'; -class Screen extends React.Component { +interface NavProps { + navigation: StackNavigationProp +} + +class Screen extends React.Component { newGame = () => store.dispatch(saveGameState({ ...new Board(4) })); render() { return ( - - - - New Game - - - + + 2 0 4 8 + + + + + Score + + + {10000} + + + + + High Score + + + {10000} + + + + + + { }}> + + + + + + { }}> + + + this.props.navigation.navigate('Records')}> + + + + ); diff --git a/src/screens/styles.ts b/src/screens/styles.ts index 35511d1..e81da7a 100644 --- a/src/screens/styles.ts +++ b/src/screens/styles.ts @@ -1,4 +1,6 @@ -import { StyleSheet } from 'react-native'; +import { Dimensions, StyleSheet } from 'react-native'; + +export const screenWidth = Dimensions.get('screen').width; export const ScreenStyles = StyleSheet.create({ screen: { @@ -6,10 +8,51 @@ export const ScreenStyles = StyleSheet.create({ display: 'flex', flex: 1, flexDirection: 'column', - justifyContent: 'flex-start', + justifyContent: 'center', }, }); export const MainStyles = StyleSheet.create({ - + titleText: { + fontSize: 45, + marginBottom: 30, + }, + scoreBar: { + alignItems: 'center', + display: 'flex', + flexDirection: 'row', + justifyContent: 'space-between', + marginBottom: 20, + width: screenWidth * 0.9, + }, + scoreContainer: { + alignItems: 'center', + borderRadius: 10, + display: 'flex', + flexDirection: 'column', + height: 80, + justifyContent: 'space-evenly', + width: screenWidth * 0.42, + }, + scoreLabelText: { + fontSize: 12, + }, + scoreText: { + fontSize: 17, + }, + functionBarOuter: { + alignItems: 'center', + display: 'flex', + flexDirection: 'row', + justifyContent: 'flex-end', + marginBottom: 20, + width: screenWidth * 0.85, + }, + functionBar: { + alignItems: 'center', + display: 'flex', + flexDirection: 'row', + justifyContent: 'space-between', + width: screenWidth * 0.6, + }, });