1
1
import React from 'react'
2
- import { Platform , Text , View , Button } from 'react-native'
2
+ import { Platform , Text , View , Button , ActivityIndicator } from 'react-native'
3
3
import { connect } from 'react-redux'
4
4
import { PropTypes } from 'prop-types'
5
5
import ExampleActions from 'App/Stores/Example/Actions'
@@ -24,39 +24,42 @@ class ExampleScreen extends React.Component {
24
24
}
25
25
26
26
render ( ) {
27
- let isLoading = this . props . userIsLoading ? 'Data are loading...' : ''
28
- let user = this . props . user
29
- let error = this . props . userErrorMessage
30
- let result = null
31
- if ( user && ! error ) {
32
- result =
33
- "I'm a fake user, my name is " +
34
- user . name +
35
- '.\n' +
36
- ( this . props . liveInEurope ? 'I live in Europe !' : "I don't live in Europe." )
37
- }
38
-
39
27
return (
40
28
< View style = { Style . container } >
41
- < Text style = { Style . title } > TheCodingMachine boilerplate</ Text >
42
- < Text style = { Style . text } > To get started, edit App.js</ Text >
43
- < Text style = { Style . instructions } > { instructions } </ Text >
44
- < Text style = { Style . loading } > { isLoading } </ Text >
45
- { user && ! error ? (
46
- < Text style = { Style . result } > { result } </ Text >
29
+ { this . props . userIsLoading ? (
30
+ < ActivityIndicator size = "large" color = "#0000ff" />
47
31
) : (
48
- < Text style = { Style . error } > { error } </ Text >
32
+ < View >
33
+ < Text style = { Style . title } > TheCodingMachine boilerplate</ Text >
34
+ < Text style = { Style . text } > To get started, edit App.js</ Text >
35
+ < Text style = { Style . instructions } > { instructions } </ Text >
36
+ { this . props . userErrorMessage ? (
37
+ < Text style = { Style . error } > { this . props . userErrorMessage } </ Text >
38
+ ) : (
39
+ < View >
40
+ < Text style = { Style . result } >
41
+ { "I'm a fake user, my name is " }
42
+ { this . props . user . name }
43
+ </ Text >
44
+ < Text style = { Style . result } >
45
+ { this . props . liveInEurope ? 'I live in Europe !' : "I don't live in Europe." }
46
+ </ Text >
47
+ </ View >
48
+ ) }
49
+ < Button onPress = { this . props . fetchUser } title = "Refresh" />
50
+ </ View >
49
51
) }
50
- < Button onPress = { this . props . fetchUser } title = "Refresh" />
51
52
</ View >
52
53
)
53
54
}
54
55
}
55
56
56
- ExampleScreen . propsTypes = {
57
- user : PropTypes . number ,
57
+ ExampleScreen . propTypes = {
58
+ user : PropTypes . object ,
58
59
userIsLoading : PropTypes . bool ,
59
60
userErrorMessage : PropTypes . string ,
61
+ fetchUser : PropTypes . func ,
62
+ liveInEurope : PropTypes . bool ,
60
63
}
61
64
62
65
const mapStateToProps = ( state ) => ( {
0 commit comments