Commit cd1feaf6 by HaOuiha

update setting

parent 9c8958a2
...@@ -52,8 +52,21 @@ class updateDetailScreen extends Component { ...@@ -52,8 +52,21 @@ class updateDetailScreen extends Component {
toggleModal = visible => this.setState({ isVisible: visible }); toggleModal = visible => this.setState({ isVisible: visible });
setDefualtValue = data => {
switch (this.state.field) {
case 'Name':
return data === '' ? 'Untitled' : data;
case 'Description':
return data;
case 'RCBO':
return data;
default:
return data;
}
};
handleConfirm = () => { handleConfirm = () => {
this.props.updateDetail(this.state.field, this.state.data); this.props.updateDetail(this.state.field, this.setDefualtValue(this.state.data));
this.toggleModal(false); this.toggleModal(false);
this.props.navigation.navigate('Setting'); this.props.navigation.navigate('Setting');
}; };
......
...@@ -312,7 +312,6 @@ class SmartMeterDetailScreen extends Component { ...@@ -312,7 +312,6 @@ class SmartMeterDetailScreen extends Component {
}, 3000); }, 3000);
}; };
// let isSubOn = this.props.shadow[`ML${indexMcbLinks + 1}`][`L${indexMcbLinks + 1}B${indexSubBreakers + 1}`];
return ( return (
<View <View
style={{ style={{
...@@ -334,7 +333,7 @@ class SmartMeterDetailScreen extends Component { ...@@ -334,7 +333,7 @@ class SmartMeterDetailScreen extends Component {
<Left style={{ flex: 4 }}> <Left style={{ flex: 4 }}>
<View> <View>
<Text style={[theme.normalText, theme.textDark]}> <Text style={[theme.normalText, theme.textDark]}>
{subBreaker.name {subBreaker.name !== `Sub Breaker ${indexSubBreakers + 1}` || 'Untitled'
? `Sub Breaker ${indexSubBreakers + 1} [${ ? `Sub Breaker ${indexSubBreakers + 1} [${
subBreaker.name.length < 20 subBreaker.name.length < 20
? subBreaker.name ? subBreaker.name
...@@ -349,7 +348,7 @@ class SmartMeterDetailScreen extends Component { ...@@ -349,7 +348,7 @@ class SmartMeterDetailScreen extends Component {
</Left> </Left>
<Right> <Right>
<Switch <Switch
disabled={this.props.shadow.SM1.BK_S === 0 ? true : false} disabled={this.props.breakerStatus.SM1.BK_S === 0 ? true : false}
value={subBreaker.isPowerOn} value={subBreaker.isPowerOn}
onValueChange={value => { onValueChange={value => {
this.state.isWaiting ? null : handleOnPressSubBreakerSwitch(value); this.state.isWaiting ? null : handleOnPressSubBreakerSwitch(value);
...@@ -374,7 +373,7 @@ class SmartMeterDetailScreen extends Component { ...@@ -374,7 +373,7 @@ class SmartMeterDetailScreen extends Component {
> >
<Left style={{ flex: 4 }}> <Left style={{ flex: 4 }}>
<Text style={[theme.normalText, theme.textDark]}> <Text style={[theme.normalText, theme.textDark]}>
{mcbLink.name {mcbLink.name !== `MCB Link ${indexMcbLinks + 1}` || 'Untitled'
? `MCB Link ${indexMcbLinks + 1} [${ ? `MCB Link ${indexMcbLinks + 1} [${
mcbLink.name.length < 20 ? mcbLink.name : `${mcbLink.name.substr(0, 17)}...` mcbLink.name.length < 20 ? mcbLink.name : `${mcbLink.name.substr(0, 17)}...`
}]` }]`
...@@ -471,7 +470,7 @@ const mapStateToProps = state => ({ ...@@ -471,7 +470,7 @@ const mapStateToProps = state => ({
error: state.timersReducer.error, error: state.timersReducer.error,
existedMcbLinksData: state.timersReducer.existedMcbLinksData, existedMcbLinksData: state.timersReducer.existedMcbLinksData,
existedSubBreakersData: state.timersReducer.existedSubBreakersData, existedSubBreakersData: state.timersReducer.existedSubBreakersData,
shadow: state.currentSelectedDeviceReducer.shadow, // shadow: state.currentSelectedDeviceReducer.shadow,
breakerStatus: state.currentSelectedDeviceReducer.breakerStatus, breakerStatus: state.currentSelectedDeviceReducer.breakerStatus,
desiredBreakerStatus: state.currentSelectedDeviceReducer.desiredBreakerStatus, desiredBreakerStatus: state.currentSelectedDeviceReducer.desiredBreakerStatus,
......
...@@ -124,7 +124,9 @@ class TimerScreen extends PureComponent { ...@@ -124,7 +124,9 @@ class TimerScreen extends PureComponent {
const { currentSelectedData } = this.props; const { currentSelectedData } = this.props;
let pickerSelectData = [ let pickerSelectData = [
{ {
label: `Main Device ${currentSelectedData.name ? `[${currentSelectedData.name}]` : ''}`, label: `Main Device ${
currentSelectedData.name !== 'Main Device' || 'Untitled' ? `[${currentSelectedData.name}]` : ''
}`,
value: 'main', value: 'main',
color: color.darkGrey, color: color.darkGrey,
}, },
...@@ -133,7 +135,9 @@ class TimerScreen extends PureComponent { ...@@ -133,7 +135,9 @@ class TimerScreen extends PureComponent {
if (this.props.existedMcbLinksData) { if (this.props.existedMcbLinksData) {
this.props.existedMcbLinksData.map((mcbLink, index) => { this.props.existedMcbLinksData.map((mcbLink, index) => {
pickerSelectData.push({ pickerSelectData.push({
label: `MCB Link ${index + 1} ${mcbLink.name ? `[${mcbLink.name}]` : ''} `, label: `MCB Link ${index + 1} ${
mcbLink.name !== `MCB Link ${index + 1}` || 'Untitled' ? `[${mcbLink.name}]` : ''
} `,
value: index + 1, value: index + 1,
color: color.darkGrey, color: color.darkGrey,
}); });
...@@ -273,7 +277,7 @@ class TimerScreen extends PureComponent { ...@@ -273,7 +277,7 @@ class TimerScreen extends PureComponent {
}); });
} }
console.log(this.state); // console.log(this.state);
}; };
componentDidMount = () => { componentDidMount = () => {
...@@ -369,7 +373,9 @@ class TimerScreen extends PureComponent { ...@@ -369,7 +373,9 @@ class TimerScreen extends PureComponent {
containerStyle={styles.checkboxContainer} containerStyle={styles.checkboxContainer}
fontFamily={'Avenir-Roman'} fontFamily={'Avenir-Roman'}
textStyle={{ fontWeight: 'normal', color: color.darkGrey }} textStyle={{ fontWeight: 'normal', color: color.darkGrey }}
title={`Sub Breaker ${item.id} ${item.name ? `[${item.name}]` : ''}`} title={`Sub Breaker ${item.id} ${
item.name !== `Sub Breaker ${item.id}` || 'Untitled' ? `[${item.name}]` : ''
}`}
checked={this.state.subBreakerList[index].selected} checked={this.state.subBreakerList[index].selected}
checkedIcon={ checkedIcon={
<Icon <Icon
...@@ -559,7 +565,9 @@ class TimerScreen extends PureComponent { ...@@ -559,7 +565,9 @@ class TimerScreen extends PureComponent {
containerStyle={styles.checkboxContainer} containerStyle={styles.checkboxContainer}
fontFamily={'Avenir-Roman'} fontFamily={'Avenir-Roman'}
textStyle={{ fontWeight: 'normal', color: color.darkGrey }} textStyle={{ fontWeight: 'normal', color: color.darkGrey }}
title={`Sub Breaker ${item.id} ${item.name ? `[${item.name}]` : ''}`} title={`Sub Breaker ${item.id} ${
item.name !== `Sub Breaker ${item.id}` || 'Untitled' ? `[${item.name}]` : ''
}`}
checked={this.state.subBreakerList[index].selected} checked={this.state.subBreakerList[index].selected}
checkedIcon={<Icon name="md-checkbox" style={{ color: color.primary, fontSize: 26 }} />} checkedIcon={<Icon name="md-checkbox" style={{ color: color.primary, fontSize: 26 }} />}
uncheckedIcon={ uncheckedIcon={
......
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