Skip to content

Commit

Permalink
REFACTOR: Difficulty component @ New Deck
Browse files Browse the repository at this point in the history
Difficulty Level for decks is available
  • Loading branch information
diogosilverio committed Jan 20, 2018
1 parent a41040d commit 5eabd0f
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions components/flashcards/NewDeck.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import React, { Component } from 'react';
import {
TextInput,
Slider,
StyleSheet,
Text,
View,
TouchableOpacity
TextInput,
TouchableOpacity,
View
} from 'react-native';

import { MaterialIcons, MaterialCommunityIcons } from '@expo/vector-icons';

import DifficultyMeter from '../ui/DifficultyMeter';

import { COLOR_B_4, COLOR_B_5, COLOR_WHITE } from '../../utils/colors';

export default class NewDeck extends Component {

state = {
deck: {
name: '',
description: ''
description: '',
difficulty: 0
}
}

Expand Down Expand Up @@ -52,12 +56,31 @@ export default class NewDeck extends Component {
})
}} />

<View style={styles.btnContainer}>
<Text style={styles.text}>Difficulty Level</Text>
<View style={[styles.rowContainer, { width: '75%' }]}>
<Slider style={{ flex: 1 }} minimumValue={0} maximumValue={80} step={20}
value={this.state.deck.difficulty}
onValueChange={(difficulty) => {
this.setState((prev) => {
const prevDeck = prev.deck;
return {
deck: {
...prevDeck,
difficulty
}
}
});
}} />
<DifficultyMeter size={35} level={this.state.deck.difficulty} />
</View>

<View style={styles.rowContainer}>
<TouchableOpacity style={styles.cancelBtn} onPress={() => {
this.setState({
deck: {
name: '',
description: ''
description: '',
difficulty: 0
}
});
}}>
Expand All @@ -79,7 +102,7 @@ const styles = StyleSheet.create({
alignItems: 'center',
flex: 1
},
btnContainer: {
rowContainer: {
flexDirection: 'row',
justifyContent: 'space-between'
},
Expand Down

0 comments on commit 5eabd0f

Please sign in to comment.