Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Commit

Permalink
home screen layout
Browse files Browse the repository at this point in the history
  • Loading branch information
lochungtin committed May 31, 2021
1 parent 02559de commit 1e11ac6
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/data/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const darktheme: ColorSchemeType = {
large: '#3d3934',
},
textColor: '#E0E0E0',
textboxColor: '#3E3E3E',
textboxColor: '#272727',
btnColor: '#A0A0A0',
accentColor: '#EB864D'
}
2 changes: 1 addition & 1 deletion src/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppNav extends React.Component {
return (
<NavigationContainer>
<StatusBar backgroundColor={'#0E0E0E'} />
<Root.Navigator>
<Root.Navigator screenOptions={{ headerShown: false }}>
<Root.Screen component={Main} name='Main' />
<Root.Screen component={Records} name='Records' />
</Root.Navigator>
Expand Down
54 changes: 45 additions & 9 deletions src/screens/main.tsx
Original file line number Diff line number Diff line change
@@ -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<any, any>
}

class Screen extends React.Component<NavProps> {

newGame = () => store.dispatch(saveGameState({ ...new Board(4) }));

render() {
return (
<View style={{ ...ScreenStyles.screen, backgroundColor: darktheme.bgColor }}>
<View style={{ height: 200 }} />
<TouchableOpacity onPress={this.newGame} style={{ backgroundColor: darktheme.btnColor }}>
<Text style={{ color: darktheme.textColor }}>
New Game
</Text>
</TouchableOpacity>
<View style={{ height: 100 }} />
<Text style={{ ...MainStyles.titleText, color: darktheme.textColor }}>
2 0 4 8
</Text>
<View style={MainStyles.scoreBar}>
<View style={{ ...MainStyles.scoreContainer, backgroundColor: darktheme.textboxColor }}>
<Text style={{ ...MainStyles.scoreLabelText, color: darktheme.textColor }}>
Score
</Text>
<Text style={{ ...MainStyles.scoreText, color: darktheme.textColor }}>
{10000}
</Text>
</View>
<View style={{ ...MainStyles.scoreContainer, backgroundColor: darktheme.textboxColor }}>
<Text style={{ ...MainStyles.scoreLabelText, color: darktheme.textColor }}>
High Score
</Text>
<Text style={{ ...MainStyles.scoreText, color: darktheme.textColor }}>
{10000}
</Text>
</View>
</View>
<View style={MainStyles.functionBarOuter}>
<View style={MainStyles.functionBar}>
<TouchableOpacity onPress={() => { }}>
<Icon color={darktheme.btnColor} name='backup-restore' size={40} />
</TouchableOpacity>
<TouchableOpacity onPress={this.newGame}>
<Icon color={darktheme.btnColor} name='sync' size={40} />
</TouchableOpacity>
<TouchableOpacity onPress={() => { }}>
<Icon color={darktheme.btnColor} name='lightbulb-outline' size={40} />
</TouchableOpacity>
<TouchableOpacity onPress={() => this.props.navigation.navigate('Records')}>
<Icon color={darktheme.btnColor} name='text-box-outline' size={40} />
</TouchableOpacity>
</View>
</View>
<BoardView />
</View >
);
Expand Down
49 changes: 46 additions & 3 deletions src/screens/styles.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,58 @@
import { StyleSheet } from 'react-native';
import { Dimensions, StyleSheet } from 'react-native';

export const screenWidth = Dimensions.get('screen').width;

export const ScreenStyles = StyleSheet.create({
screen: {
alignItems: 'center',
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,
},
});

0 comments on commit 1e11ac6

Please sign in to comment.