Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI for MetricsHabitPreview #5

Merged
merged 1 commit into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions components/MetricsHabitPreview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import {View, Text, StyleSheet} from 'react-native'

export default class MetricsHabitPreview extends React.Component {
render() {
return (
<View style = {styles.container}>
<Text style={styles.habitText}>{this.props.habitName}</Text>
<View style={styles.streakContainer}>
<Text style={styles.streakText}>{this.props.streak}</Text>
<Text>in a row!</Text>
</View>
</View>
);
}
}

const styles = StyleSheet.create({

container: {
height: 50,
width: 300,
backgroundColor: 'lightgray',
flexDirection: 'row',
alignItems: 'flex-start',
justifyContent: 'space-between',
borderColor: 'black',
borderWidth: 2,
marginBottom: 10
},
streakContainer: {
height: 45,
width: 100,
backgroundColor: 'white',
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'center'
},
habitText: {
fontWeight: 'bold',
fontSize: 30
},
streakText: {
fontWeight: 'bold',
fontSize: 20
}
})
19 changes: 16 additions & 3 deletions screens/MetricsHomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
StyleSheet
} from 'react-native'
import { connect } from 'react-redux';
import MetricsHabitPreview from '../components/MetricsHabitPreview';

const mapStateToProps = (state) => {
return {
Expand All @@ -21,8 +22,13 @@ const mapDispatchToProps = (dispatch) => {
class MetricsHomeScreen extends React.Component {
render() {
return (
<View style={styles.container}>
<Text> Metrics Home Screen </Text>
<View style = {styles.container}>
<Text>Metrics Home Screen</Text>
<View style = {styles.previews}>
<MetricsHabitPreview habitName='Habit' streak='18'/>
<MetricsHabitPreview habitName='Habit2' streak='14'/>
<MetricsHabitPreview habitName='Habit3' streak='12'/>
</View>
</View>
)
}
Expand All @@ -32,7 +38,14 @@ const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
justifyContent: 'center',
},
previews: {
flex: 1,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
padding: 30
}
})

Expand Down