Skip to content

Commit

Permalink
Merge pull request #16 from someoneAnyone/wip/add-mmol-support
Browse files Browse the repository at this point in the history
forgot to update today widget
  • Loading branch information
someoneAnyone committed Aug 26, 2015
2 parents aaa4fdd + eef76be commit 6e9ac9b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions NightscouterToday/SiteNSNowTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,35 @@ class SiteNSNowTableViewCell: UITableViewCell {
siteLastReadingLabel.text = watchEntry.dateTimeAgoString

if let sgvValue = watchEntry.sgv {
let color = colorForDesiredColorState(site.configuration!.boundedColorForGlucoseValue(sgvValue.sgv))

var boundedColor = configuration.boundedColorForGlucoseValue(sgvValue.sgv)
if units == .Mmol {
boundedColor = configuration.boundedColorForGlucoseValue(sgvValue.sgv.toMgdl)
}
let color = colorForDesiredColorState(boundedColor)

siteColorBlockView.backgroundColor = color

siteSgvLabel.text = "\(sgvValue.sgvString) \(sgvValue.direction.emojiForDirection)"
siteSgvLabel.textColor = color

siteDirectionLabel.text = "\(watchEntry.bgdelta.formattedForBGDelta) \(units.description)"
siteDirectionLabel.textColor = color


if let enabledOptions = configuration.enabledOptions {
let rawEnabled = contains(enabledOptions, EnabledOptions.rawbg)
if rawEnabled {
if let rawValue = watchEntry.raw {
let color = colorForDesiredColorState(configuration.boundedColorForGlucoseValue(rawValue))

let numberFormatter = NSNumberFormatter()
var raw = rawValue
var raw = "\(rawValue.formattedForMgdl)"
if configuration.displayUnits == .Mmol {
raw = rawValue.toMmol
numberFormatter.numberStyle = .DecimalStyle
numberFormatter.minimumFractionDigits = 1
numberFormatter.maximumFractionDigits = 1
numberFormatter.secondaryGroupingSize = 1
raw = rawValue.formattedForMmol
}

siteRawLabel?.textColor = color
siteRawLabel.text = "\(numberFormatter.stringFromNumber(raw)!) : \(sgvValue.noise)"
siteRawLabel.text = "\(raw) : \(sgvValue.noise)"
}
} else {
siteRawHeader.hidden = true
Expand Down

0 comments on commit 6e9ac9b

Please sign in to comment.