Skip to content

Commit 6e9ac9b

Browse files
committed
Merge pull request #16 from someoneAnyone/wip/add-mmol-support
forgot to update today widget
2 parents aaa4fdd + eef76be commit 6e9ac9b

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

NightscouterToday/SiteNSNowTableViewCell.swift

+12-9
Original file line numberDiff line numberDiff line change
@@ -63,32 +63,35 @@ class SiteNSNowTableViewCell: UITableViewCell {
6363
siteLastReadingLabel.text = watchEntry.dateTimeAgoString
6464

6565
if let sgvValue = watchEntry.sgv {
66-
let color = colorForDesiredColorState(site.configuration!.boundedColorForGlucoseValue(sgvValue.sgv))
66+
67+
var boundedColor = configuration.boundedColorForGlucoseValue(sgvValue.sgv)
68+
if units == .Mmol {
69+
boundedColor = configuration.boundedColorForGlucoseValue(sgvValue.sgv.toMgdl)
70+
}
71+
let color = colorForDesiredColorState(boundedColor)
72+
6773
siteColorBlockView.backgroundColor = color
74+
6875
siteSgvLabel.text = "\(sgvValue.sgvString) \(sgvValue.direction.emojiForDirection)"
6976
siteSgvLabel.textColor = color
7077

7178
siteDirectionLabel.text = "\(watchEntry.bgdelta.formattedForBGDelta) \(units.description)"
7279
siteDirectionLabel.textColor = color
80+
7381

7482
if let enabledOptions = configuration.enabledOptions {
7583
let rawEnabled = contains(enabledOptions, EnabledOptions.rawbg)
7684
if rawEnabled {
7785
if let rawValue = watchEntry.raw {
7886
let color = colorForDesiredColorState(configuration.boundedColorForGlucoseValue(rawValue))
7987

80-
let numberFormatter = NSNumberFormatter()
81-
var raw = rawValue
88+
var raw = "\(rawValue.formattedForMgdl)"
8289
if configuration.displayUnits == .Mmol {
83-
raw = rawValue.toMmol
84-
numberFormatter.numberStyle = .DecimalStyle
85-
numberFormatter.minimumFractionDigits = 1
86-
numberFormatter.maximumFractionDigits = 1
87-
numberFormatter.secondaryGroupingSize = 1
90+
raw = rawValue.formattedForMmol
8891
}
8992

9093
siteRawLabel?.textColor = color
91-
siteRawLabel.text = "\(numberFormatter.stringFromNumber(raw)!) : \(sgvValue.noise)"
94+
siteRawLabel.text = "\(raw) : \(sgvValue.noise)"
9295
}
9396
} else {
9497
siteRawHeader.hidden = true

0 commit comments

Comments
 (0)