Skip to content

Commit 8f0587d

Browse files
committed
Add card screen
1 parent 9a826ff commit 8f0587d

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

App.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React from 'react';
22
import { StyleSheet, Text, View, Platform } from 'react-native';
33
import { TabNavigator, StackNavigator } from 'react-navigation';
4+
import { Constants } from 'expo';
45
import DecksList from './components/DecksList';
56
import DeckDetail from './components/DeckDetail';
7+
import AddCard from './components/AddCard';
68
import AddDeck from './components/AddDeck';
79
import { getCurrentRouteName } from './utils/helpers';
810
import { black, white } from './utils/colors';
@@ -49,6 +51,9 @@ const MainNavigator = StackNavigator({
4951
},
5052
DeckDetail: {
5153
screen: DeckDetail
54+
},
55+
AddCard: {
56+
screen: AddCard
5257
}
5358
});
5459

@@ -75,6 +80,7 @@ export default class App extends React.Component {
7580

7681
const styles = StyleSheet.create({
7782
container: {
78-
flex: 1
83+
flex: 1,
84+
paddingTop: Platform.OS === 'ios' ? 0 : Constants.statusBarHeight
7985
}
8086
});

components/AddCard.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
import { StyleSheet, Text, View } from 'react-native';
3+
import { black, white } from '../utils/colors';
4+
5+
export default class AddCard extends React.Component {
6+
static navigationOptions = ({ navigation }) => ({
7+
headerTintColor: white,
8+
headerStyle: {
9+
backgroundColor: black
10+
},
11+
title: `Add Card for ${navigation.state.params.deckId}`
12+
});
13+
14+
render() {
15+
return (
16+
<View style={styles.container}>
17+
<Text style={styles.deckTitle}>Add Card {this.props.navigation.state.params.deckId}</Text>
18+
</View>
19+
);
20+
}
21+
}
22+
23+
const styles = StyleSheet.create({
24+
container: {
25+
flex: 1,
26+
justifyContent: 'center',
27+
alignItems: 'center'
28+
},
29+
deckTitle: {
30+
fontSize: 20
31+
}
32+
});

components/DeckDetail.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { StyleSheet, Text, View } from 'react-native';
2+
import { StyleSheet, Text, View, TouchableOpacity } from 'react-native';
33
import { black, white } from '../utils/colors';
44

55
export default class DeckDetail extends React.Component {
@@ -12,9 +12,15 @@ export default class DeckDetail extends React.Component {
1212
});
1313

1414
render() {
15+
const id = this.props.navigation.state.params.deckId;
1516
return (
1617
<View style={styles.container}>
17-
<Text style={styles.deckTitle}>Details - {this.props.navigation.state.params.deckId}</Text>
18+
<TouchableOpacity
19+
onPress={() => this.props.navigation.navigate('AddCard', { deckId: id })}
20+
>
21+
<Text style={styles.addCardBtn}>Add Card</Text>
22+
</TouchableOpacity>
23+
<Text style={styles.deckTitle}>Details - {id}</Text>
1824
</View>
1925
);
2026
}
@@ -28,5 +34,11 @@ const styles = StyleSheet.create({
2834
},
2935
deckTitle: {
3036
fontSize: 20
37+
},
38+
addCardBtn: {
39+
backgroundColor: black,
40+
color: white,
41+
fontWeight: 'bold',
42+
padding: 20
3143
}
3244
});

0 commit comments

Comments
 (0)