Skip to content

Commit 9ba2ede

Browse files
committed
added basic components
1 parent e319903 commit 9ba2ede

File tree

22 files changed

+459
-94
lines changed

22 files changed

+459
-94
lines changed

App/App.js

Lines changed: 11 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -7,75 +7,25 @@
77
*/
88

99
import React from 'react';
10-
import {
11-
SafeAreaView,
12-
StyleSheet,
13-
ScrollView,
14-
View,
15-
Text,
16-
StatusBar,
17-
} from 'react-native';
10+
import store from './store/configureStore';
11+
import { Provider } from 'react-redux';
12+
1813

19-
import {
20-
Header,
21-
LearnMoreLinks,
22-
Colors,
23-
DebugInstructions,
24-
ReloadInstructions,
25-
} from 'react-native/Libraries/NewAppScreen';
2614
import { Navigation } from './navigation';
2715
import NavigationService from './utils/navigationService';
2816

2917
const App = () => {
3018
return (
31-
32-
33-
<Navigation
34-
ref={navigatorRef => {
35-
NavigationService.setTopLevelNavigator(navigatorRef);
36-
}}
37-
/>
38-
19+
20+
<Provider store={store}>
21+
<Navigation
22+
ref={navigatorRef => {
23+
NavigationService.setTopLevelNavigator(navigatorRef);
24+
}}
25+
/>
26+
</Provider>
3927
);
4028
};
4129

42-
const styles = StyleSheet.create({
43-
scrollView: {
44-
backgroundColor: Colors.lighter,
45-
},
46-
engine: {
47-
position: 'absolute',
48-
right: 0,
49-
},
50-
body: {
51-
backgroundColor: Colors.white,
52-
},
53-
sectionContainer: {
54-
marginTop: 32,
55-
paddingHorizontal: 24,
56-
},
57-
sectionTitle: {
58-
fontSize: 24,
59-
fontWeight: '600',
60-
color: Colors.black,
61-
},
62-
sectionDescription: {
63-
marginTop: 8,
64-
fontSize: 18,
65-
fontWeight: '400',
66-
color: Colors.dark,
67-
},
68-
highlight: {
69-
fontWeight: '700',
70-
},
71-
footer: {
72-
color: Colors.dark,
73-
fontSize: 12,
74-
fontWeight: '600',
75-
padding: 4,
76-
paddingRight: 12,
77-
textAlign: 'right',
78-
},
79-
});
8030

8131
export default App;

App/assets/images/fidisys.png

16.4 KB
Loading

App/components/container.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { View,SafeAreaView } from 'react-native';
3+
import {GlobalStyle} from '../theme/global';
4+
5+
6+
export const Container = ({style,children}) => {
7+
return (
8+
<SafeAreaView style={{flex: 1}}>
9+
10+
<View style={[style,GlobalStyle.mainContainer]}>
11+
{children}
12+
</View>
13+
</SafeAreaView>
14+
)
15+
}

App/components/content.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import { View,ScrollView } from 'react-native';
3+
4+
5+
export const Content = ({style,children}) => {
6+
return (
7+
<ScrollView
8+
showsVerticalScrollIndicator
9+
contentContainerStyle={[{
10+
padding: 10
11+
},style]}>
12+
{children}
13+
</ScrollView>
14+
15+
)
16+
}

App/components/header.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { View,StatusBar } from 'react-native';
3+
4+
5+
export const Header = ({style,statusbarColor,barStyle,children}) => {
6+
console.log(children)
7+
return (
8+
<View style={[{
9+
height: 55,
10+
width: '100%',
11+
flexDirection: 'row',
12+
justifyContent: 'space-evenly',
13+
alignItems: 'center',
14+
15+
backgroundColor: 'red'
16+
},style]}>
17+
<StatusBar backgroundColor={statusbarColor} barStyle={barStyle}/>
18+
{children}
19+
</View>
20+
21+
)
22+
}

App/components/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Container } from './container';
2+
import { Header } from './header';
3+
import { Content } from './content'
4+
export {
5+
Container,
6+
Header,
7+
Content
8+
}

App/containers/about/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
import React, {PureComponent} from 'react';
22
import {View, Text, Button} from 'react-native';
33
import {GlobalStyle} from '../../theme/global';
4+
import { Container, Header, Content } from '../../components/index';
45

56
export default class AboutScreen extends PureComponent {
67
render() {
78
return (
8-
<View style={[GlobalStyle.mainContainer]}>
9+
<Container>
10+
<Header
11+
barStyle="dark-content"
12+
statusbarColor="white">
13+
<Text>Header</Text>
14+
</Header>
15+
<Content>
916
<Text>AboutScreen</Text>
1017
<Button
1118
onPress={() => this.props.navigation.push('details')}
1219
title="go to details"></Button>
13-
</View>
20+
</Content>
21+
22+
</Container>
1423
);
1524
}
1625
}

App/containers/details/index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
import React, {PureComponent} from 'react';
22
import {View, Text, Button} from 'react-native';
3+
import { Container, Header, Content } from '../../components/index';
34

45
export default class DetailsScreens extends PureComponent {
56
constructor(props) {
67
super(props);
78
}
89
render() {
910
return (
10-
<View
11+
<Container
1112
style={{
1213
flex: 1,
1314
justifyContent: 'center',
1415
alignItems: 'center',
1516
}}>
16-
<Text>Details</Text>
17-
<Button
17+
<Header
18+
barStyle="dark-content"
19+
statusbarColor="white">
20+
<Button
1821
onPress={() => this.props.navigation.pop()}
1922
title="go Back"></Button>
20-
</View>
23+
<Text>Details</Text>
24+
</Header>
25+
26+
</Container>
2127
);
2228
}
2329
}

App/containers/login/actions.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as loginTypes from './types';
2+
3+
export const login = loginData => ({
4+
type: loginTypes.LOGIN,
5+
loginData
6+
});
7+
8+
export const LogOut = () => ({
9+
type: loginTypes.LOGOUT
10+
});
11+
12+
export const loginSuccess = user =>({
13+
type: loginTypes.LOGIN_SUCCESS,
14+
user
15+
});
16+
17+
export const loginError = () =>({
18+
type: loginTypes.LOGIN_ERROR
19+
});

App/containers/login/index.js

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,67 @@
11
import React, {PureComponent} from 'react';
2-
import {View, Text, Button} from 'react-native';
2+
import {View, Text,Image, Button, StyleSheet} from 'react-native';
33
import NavigationService from '../../utils/navigationService';
44
import storageService from '../../utils/storageService';
5+
import { connect } from 'react-redux';
6+
import * as loginActions from './actions';
57

6-
export default class LoginScreen extends PureComponent {
8+
class LoginScreen extends PureComponent {
9+
constructor(props) {
10+
super(props)
11+
}
712
render() {
813
return (
914
<View
1015
style={{
1116
flex: 1,
12-
padding: 20,
13-
justifyContent: 'center',
17+
padding: 30,
18+
justifyContent: 'space-evenly',
1419
alignItems: 'center',
1520
}}>
16-
<Text>Login</Text>
21+
<Image style={[style.image]}
22+
source={require('../../assets/images/fidisys.png')}></Image>
23+
<Text style={[style.title]}>A React-Native Boilerplate with redux,saga and react navigation</Text>
1724
<Button
25+
style={[style.button]}
1826
onPress={() => {
19-
storageService.setApiKey('12345');
20-
NavigationService.navigate('Home');
27+
this.props.login({token: '12345'});
28+
2129
}}
22-
title="click"></Button>
30+
title="Login"></Button>
2331
</View>
2432
);
2533
}
2634
}
35+
36+
const mapStateToProps = state => {
37+
return {
38+
...state
39+
};
40+
};
41+
const mapDispatchToProps = dispatch => {
42+
return {
43+
login: loginData => dispatch(loginActions.login(loginData))
44+
};
45+
};
46+
47+
export default connect(
48+
mapStateToProps,
49+
mapDispatchToProps
50+
)(LoginScreen);
51+
52+
export const style = StyleSheet.create({
53+
image:{
54+
width: 300,
55+
height: 100,
56+
resizeMode: 'cover',
57+
},
58+
title: {
59+
paddingHorizontal: 15,
60+
fontWeight: 'bold',
61+
textAlign: 'center',
62+
color: '#754abc'
63+
},
64+
button: {
65+
backgroundColor: 'green'
66+
}
67+
})

0 commit comments

Comments
 (0)