|
@@ -20,6 +20,15 @@ extension Bolus {
|
|
|
return formatter
|
|
return formatter
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private var gluoseFormatter: NumberFormatter {
|
|
|
|
|
+ let formatter = NumberFormatter()
|
|
|
|
|
+ formatter.numberStyle = .decimal
|
|
|
|
|
+ if state.units == .mmolL {
|
|
|
|
|
+ formatter.maximumFractionDigits = 1
|
|
|
|
|
+ } else { formatter.maximumFractionDigits = 0 }
|
|
|
|
|
+ return formatter
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private var fractionDigits: Int {
|
|
private var fractionDigits: Int {
|
|
|
if state.units == .mmolL {
|
|
if state.units == .mmolL {
|
|
|
return 1
|
|
return 1
|
|
@@ -36,20 +45,20 @@ extension Bolus {
|
|
|
value: Binding(
|
|
value: Binding(
|
|
|
get: {
|
|
get: {
|
|
|
if state.units == .mmolL {
|
|
if state.units == .mmolL {
|
|
|
- return state.currentBG * 0.0555
|
|
|
|
|
|
|
+ return state.currentBG.asMmolL
|
|
|
} else {
|
|
} else {
|
|
|
return state.currentBG
|
|
return state.currentBG
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
set: { newValue in
|
|
set: { newValue in
|
|
|
if state.units == .mmolL {
|
|
if state.units == .mmolL {
|
|
|
- state.currentBG = newValue * 0.0555
|
|
|
|
|
|
|
+ state.currentBG = newValue.asMmolL
|
|
|
} else {
|
|
} else {
|
|
|
state.currentBG = newValue
|
|
state.currentBG = newValue
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
),
|
|
),
|
|
|
- formatter: formatter,
|
|
|
|
|
|
|
+ formatter: gluoseFormatter,
|
|
|
autofocus: false,
|
|
autofocus: false,
|
|
|
cleanInput: true
|
|
cleanInput: true
|
|
|
)
|
|
)
|