Commit e1f1d4b7 by Tonk

get setting data from redux

parent ae1efc0a
......@@ -2,31 +2,29 @@ import React from 'react';
import { View, StyleSheet } from 'react-native';
import { ListItem, Body, Text, Icon, Right, Switch, List } from 'native-base';
import { theme, color } from '../../../constants/Styles';
import { connect } from 'react-redux';
const data = {
breaker: 'Main Breaker',
name: 'Main Breaker',
description: 'Lorem ipsum dolorsit amet,consectetur adipiscing elit. Cras sagitti.',
rcbo: 10,
notification: true,
};
export default class SettingScreen extends React.Component {
class SettingScreen extends React.Component {
static navigationOptions = ({ navigation }) => ({
title: 'Setting',
});
state = {
data: this.props.allDeviceInfo[0],
};
render() {
const { data } = this.state;
return (
<View style={[theme.container]}>
<List style={styles.ListItemContainer}>
<ListItem itemDivider>
<Body>
<Text style={theme.description}>{data.breaker.toUpperCase()}</Text>
<Text style={theme.description}>{data.type.toUpperCase()}</Text>
</Body>
</ListItem>
<ListItem
onPress={() =>
this.props.navigation.navigate('SettingData', {
breaker: data.breaker,
breaker: data.type,
field: 'Name',
data: data.name,
})
......@@ -45,7 +43,7 @@ export default class SettingScreen extends React.Component {
<ListItem
onPress={() =>
this.props.navigation.navigate('SettingData', {
breaker: data.breaker,
breaker: data.type,
field: 'Description',
data: data.description,
})
......@@ -61,7 +59,15 @@ export default class SettingScreen extends React.Component {
<Icon name="arrow-forward" />
</Right>
</ListItem>
<ListItem>
<ListItem
onPress={() =>
this.props.navigation.navigate('SettingData', {
breaker: data.type,
field: 'RCBO',
data: data.rcbo,
})
}
>
<Body>
<Text style={[theme.normalText, theme.textDark]}>RCBO</Text>
<Text note numberOfLines={1} style={theme.description}>
......@@ -92,6 +98,11 @@ export default class SettingScreen extends React.Component {
);
}
}
const mapStateToProps = state => ({
allDeviceInfo: state.allDataReducer.allDeviceInfo,
});
export default connect(mapStateToProps)(SettingScreen);
const styles = StyleSheet.create({
ListItemContainer: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment