Ignore invalid inputs to the treatments textfields to ensure that the original treatment isn't just deleted

This commit is contained in:
Paul Plant 2022-04-30 17:00:56 +02:00
parent e7f0b9e91a
commit e946889aaa
1 changed files with 16 additions and 11 deletions

View File

@ -178,6 +178,9 @@ class TreatmentsInsertViewController : UIViewController {
} else {
// even though there is not a valid/useable number entered, only delete the treatment if the user has really changed it to zero. If they didn't enter zero then just disregard the input.
if let text = textField.text, let value = Double(text.replacingOccurrences(of: ",", with: ".")), value == 0 {
// text is nil or "0", set treatmentdeleted to true
treatMentEntryToUpdate.treatmentdeleted = true
@ -193,6 +196,8 @@ class TreatmentsInsertViewController : UIViewController {
}
}
switch treatMentEntryToUpdate.treatmentType {
case .Carbs: