Skip to content

Commit 6345fea

Browse files
authored
Merge pull request #707 from Lamercho/Lamercho/treatmentview-decimal-separator
fixes decimal separator on the top of treatment view according region
2 parents 295999d + 1714ed6 commit 6345fea

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

Trio/Sources/Helpers/Formatters.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extension Formatter {
3232
static let decimalFormatterWithTwoFractionDigits: NumberFormatter = {
3333
let formatter = NumberFormatter()
3434
formatter.numberStyle = .decimal
35+
formatter.locale = .current
3536
formatter.maximumFractionDigits = 2
3637
return formatter
3738
}()
@@ -51,6 +52,7 @@ extension Formatter {
5152
static let decimalFormatterWithOneFractionDigit: NumberFormatter = {
5253
let formatter = NumberFormatter()
5354
formatter.numberStyle = .decimal
55+
formatter.locale = .current
5456
formatter.maximumFractionDigits = 1
5557
return formatter
5658
}()
@@ -69,6 +71,7 @@ extension Formatter {
6971

7072
switch units {
7173
case .mmolL:
74+
formatter.locale = .current
7275
formatter.minimumFractionDigits = 1
7376
formatter.maximumFractionDigits = 1
7477
case .mgdL:
@@ -81,9 +84,9 @@ extension Formatter {
8184
static let bolusFormatter: NumberFormatter = {
8285
let formatter = NumberFormatter()
8386
formatter.numberStyle = .decimal
87+
formatter.locale = .current
8488
formatter.minimumIntegerDigits = 0
8589
formatter.maximumFractionDigits = 2
86-
formatter.decimalSeparator = "."
8790
return formatter
8891
}()
8992

Trio/Sources/Localizations/Main/Localizable.xcstrings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6429,6 +6429,9 @@
64296429
}
64306430
}
64316431
}
6432+
},
6433+
"%@ " : {
6434+
64326435
},
64336436
"%@ %@" : {
64346437
"localizations" : {
@@ -7752,6 +7755,7 @@
77527755
},
77537756
"%@ U" : {
77547757
"comment" : "Number of units insulin delivered",
7758+
"extractionState" : "stale",
77557759
"localizations" : {
77567760
"bg" : {
77577761
"stringUnit" : {

Trio/Sources/Modules/Treatments/View/ForecastChart.swift

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ struct ForecastChart: View {
2020
)) // min is 1.5h -> (1.5*1h = 1.5*(5*12*60))
2121
}
2222

23-
private var glucoseFormatter: NumberFormatter {
24-
let formatter = NumberFormatter()
25-
formatter.numberStyle = .decimal
26-
27-
if state.units == .mmolL {
28-
formatter.maximumFractionDigits = 1
29-
formatter.minimumFractionDigits = 1
30-
formatter.roundingMode = .halfUp
31-
} else {
32-
formatter.maximumFractionDigits = 0
33-
}
34-
return formatter
35-
}
36-
3723
private var selectedGlucose: GlucoseStored? {
3824
guard let selection = selection else { return nil }
3925
let range = selection.addingTimeInterval(-150) ... selection.addingTimeInterval(150)
@@ -73,8 +59,11 @@ struct ForecastChart: View {
7359

7460
HStack {
7561
Image(systemName: "syringe.fill")
76-
Text("\(state.amount.description) U")
62+
Text(
63+
"\(Formatter.bolusFormatter.string(from: state.amount as NSNumber) ?? state.amount.description) "
64+
) + Text(String(localized: "U", comment: "Insulin unit"))
7765
}
66+
7867
.font(.footnote)
7968
.foregroundStyle(.blue)
8069
.padding(8)
@@ -185,19 +174,19 @@ struct ForecastChart: View {
185174
HStack(spacing: 10) {
186175
HStack(spacing: 4) {
187176
Image(systemName: "circle.fill").foregroundStyle(Color.insulin)
188-
Text("IOB").foregroundStyle(Color.secondary)
177+
Text(String(localized: "IOB")).foregroundStyle(Color.secondary)
189178
}
190179
HStack(spacing: 4) {
191180
Image(systemName: "circle.fill").foregroundStyle(Color.uam)
192-
Text("UAM").foregroundStyle(Color.secondary)
181+
Text(String(localized: "UAM")).foregroundStyle(Color.secondary)
193182
}
194183
HStack(spacing: 4) {
195184
Image(systemName: "circle.fill").foregroundStyle(Color.zt)
196-
Text("ZT").foregroundStyle(Color.secondary)
185+
Text(String(localized: "ZT")).foregroundStyle(Color.secondary)
197186
}
198187
HStack(spacing: 4) {
199188
Image(systemName: "circle.fill").foregroundStyle(Color.orange)
200-
Text("COB").foregroundStyle(Color.secondary)
189+
Text(String(localized: "COB")).foregroundStyle(Color.secondary)
201190
}
202191
}.font(.caption2)
203192
}

0 commit comments

Comments
 (0)