fix #45 - setting value for battery, calibration, missed reading alerts was wrong when unit is mmol

This commit is contained in:
Johan Degraeve 2020-01-03 22:05:45 +01:00
parent a6a6e2a20d
commit 35fec1d16c
2 changed files with 7 additions and 3 deletions

View File

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>3122</string>
<string>3125</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>

View File

@ -212,16 +212,20 @@ extension AlertSettingsViewControllerData {
if AlertSettingsViewControllerData.getAlertKind(alertKind: alertKind).valueNeedsConversionToMmol() && !UserDefaults.standard.bloodGlucoseUnitIsMgDl {
keyboardType = .decimalPad
}
let alert = UIAlertController(title: AlertSettingsViewControllerData.getAlertKind(alertKind: alertKind).alertTitle(), message: Texts_Alerts.changeAlertValue + " (" + alertKindAsAlertKind.valueUnitText(transmitterType: UserDefaults.standard.transmitterType) + ")", keyboardType: keyboardType, text: Double(value).mgdlToMmolAndToString(mgdl: UserDefaults.standard.bloodGlucoseUnitIsMgDl), placeHolder: nil, actionTitle: nil, cancelTitle: nil, actionHandler: { (text:String) in
let alert = UIAlertController(title: AlertSettingsViewControllerData.getAlertKind(alertKind: alertKind).alertTitle(), message: Texts_Alerts.changeAlertValue + " (" + alertKindAsAlertKind.valueUnitText(transmitterType: UserDefaults.standard.transmitterType) + ")", keyboardType: keyboardType, text: Double(value).mgdlToMmolAndToString(mgdl: UserDefaults.standard.bloodGlucoseUnitIsMgDl || !AlertSettingsViewControllerData.getAlertKind(alertKind: self.alertKind).valueNeedsConversionToMmol()), placeHolder: nil, actionTitle: nil, cancelTitle: nil, actionHandler: { (text:String) in
if var asdouble = text.toDouble() {
if !UserDefaults.standard.bloodGlucoseUnitIsMgDl {
if !UserDefaults.standard.bloodGlucoseUnitIsMgDl && AlertSettingsViewControllerData.getAlertKind(alertKind: self.alertKind).valueNeedsConversionToMmol() {
asdouble = asdouble.mmolToMgdl()
}
self.value = Int16(asdouble)
tableView.reloadRows(at: [IndexPath(row: Setting.value.rawValue, section: 0)], with: .none)
// checkIfPropertiesChanged
self.checkIfPropertiesChanged()
}
}, cancelHandler: nil)
// present the alert