Merge branch '261-add-toast-messages-to-disabled-save-buttons' into 'master'
added toast button to disabled save button Closes #261 See merge request bloodyhealth/drip!131
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import React, { Component } from 'react'
|
||||
import {
|
||||
View, TouchableOpacity, Text, Alert
|
||||
View, TouchableOpacity, Text, Alert, ToastAndroid
|
||||
} from 'react-native'
|
||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import styles, {iconStyles} from '../../../styles'
|
||||
import {sharedDialogs as labels} from '../../../i18n/en/cycle-day'
|
||||
|
||||
|
||||
export default class ActionButtonFooter extends Component {
|
||||
render() {
|
||||
const {
|
||||
@@ -43,19 +44,26 @@ export default class ActionButtonFooter extends Component {
|
||||
}, {
|
||||
title: labels.save,
|
||||
action: () => {
|
||||
saveAction()
|
||||
if (autoShowDayView) navigateToOverView()
|
||||
if(saveDisabled) {
|
||||
ToastAndroid.show(labels.disabledInfo, ToastAndroid.LONG);
|
||||
console.log()
|
||||
} else {
|
||||
saveAction()
|
||||
if (autoShowDayView) navigateToOverView()
|
||||
}
|
||||
|
||||
},
|
||||
disabledCondition: saveDisabled,
|
||||
icon: 'content-save-outline'
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
<View style={styles.menu}>
|
||||
{buttons.map(({ title, action, disabledCondition, icon }, i) => {
|
||||
const textStyle = [styles.menuText]
|
||||
if (disabledCondition) textStyle.push(styles.menuTextInActive)
|
||||
if (disabledCondition) {
|
||||
textStyle.push(styles.menuTextInActive);
|
||||
}
|
||||
const iconStyle = disabledCondition ?
|
||||
Object.assign(
|
||||
{},
|
||||
@@ -68,7 +76,6 @@ export default class ActionButtonFooter extends Component {
|
||||
<TouchableOpacity
|
||||
onPress={action}
|
||||
style={styles.menuItem}
|
||||
disabled={disabledCondition}
|
||||
key={i.toString()}
|
||||
>
|
||||
<Icon name={icon} {...iconStyle} />
|
||||
@@ -76,9 +83,10 @@ export default class ActionButtonFooter extends Component {
|
||||
{title.toLowerCase()}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,5 +92,6 @@ export const sharedDialogs = {
|
||||
areYouSureToUnset: 'Are you sure you want to unset all entered data?',
|
||||
reallyUnsetData: 'Yes, I am sure',
|
||||
save: 'Save',
|
||||
unset: 'Unset'
|
||||
unset: 'Unset',
|
||||
disabledInfo: 'There is some data missing'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user