Skip to content

Commit 79132b0

Browse files
committed
log out
1 parent b1924d1 commit 79132b0

File tree

5 files changed

+32
-7
lines changed

5 files changed

+32
-7
lines changed

src/pages/Profile/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,25 @@ import {
33
Text,
44
View
55
} from 'react-native'
6+
import { connect } from 'react-redux'
7+
import DLButton from '../../components/Button'
68
import styles from '../../styles'
9+
import { changeStack } from '../../store/actions/login'
710

8-
export default class Profile extends Component {
11+
class Profile extends Component {
912
render() {
1013
return (
1114
<View style={styles.container}>
12-
<Text>Profile Page</Text>
15+
<DLButton
16+
buttonStyle={styles.logoutButton}
17+
title='Log out'
18+
onPress={() => this.props.switch()}
19+
/>
1320
</View>
1421
)
1522
}
1623
}
24+
25+
export default connect(undefined, {
26+
switch: changeStack
27+
})(Profile)

src/routes/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@ AppStack = ({ isLaunching }) => (
106106
</Stack.Navigator>
107107
)
108108

109-
const SwitchStack = ({ isLaunching }) => (
110-
<NavigationContainer>
111-
<AppStack isLaunching={isLaunching} />
112-
</NavigationContainer>
113-
)
109+
const SwitchStack = ({ isLaunching }) => {
110+
console.log('------', isLaunching)
111+
return (
112+
<NavigationContainer>
113+
<AppStack isLaunching={isLaunching} />
114+
</NavigationContainer>
115+
)
116+
}
114117

115118
export default connect((state) => ({
116119
isLaunching: state.Login.isLaunching

src/store/actions/login.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
} from '../types/login'
44

55
export function changeStack() {
6+
console.log('--------')
67
return {
78
type: CHNAGE_STACK
89
}

src/store/reducers/login.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const initialState = {
99
export default function reducer(state = initialState, action) {
1010
switch (action.type) {
1111
case CHNAGE_STACK:
12+
console.log('--------state', state.isLaunching)
1213
return {
1314
...state,
1415
isLaunching: !state.isLaunching

src/styles/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ const styles = StyleSheet.create({
3232
resizeMode: 'cover'
3333
},
3434
buttonContainer: {
35+
display: 'flex',
36+
justifyContent: 'center',
37+
alignItems: 'center',
3538
width: 60,
3639
height: 30,
3740
borderRadius: 15,
@@ -143,6 +146,12 @@ const styles = StyleSheet.create({
143146
backgroundColor: '#6699ff',
144147
marginTop: 10,
145148
width: 130
149+
},
150+
logoutButton: {
151+
backgroundColor: '#6699ff',
152+
width: 150,
153+
height: 40,
154+
borderRadius: 20
146155
}
147156
})
148157

0 commit comments

Comments
 (0)