Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions LoopFollow/Controllers/Nightscout/BGData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,19 @@ extension MainViewController {
let latestBG = entries[latestEntryIndex].sgv
let priorBG = entries[latestEntryIndex - 1].sgv
let deltaBG = latestBG - priorBG
let lastBGTime = entries[latestEntryIndex].date

self.updateServerText(with: sourceName)

// Set BGText with the latest BG value
self.setBGTextColor()
self.updateBGTextAppearance()

Observable.shared.bgText.value = Localizer.toDisplayUnits(String(latestBG))
if latestBG <= 39 {
Observable.shared.bgText.value = "LOW"
} else if latestBG >= 400 {
Observable.shared.bgText.value = "HIGH"
} else {
Observable.shared.bgText.value = Localizer.toDisplayUnits(String(latestBG))
}
Observable.shared.bg.value = latestBG

// Direction handling
Expand Down
10 changes: 8 additions & 2 deletions LoopFollow/ViewControllers/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
Storage.shared.colorBGText.$value
.receive(on: DispatchQueue.main)
.sink { [weak self] _ in
self?.setBGTextColor()
self?.updateBGTextAppearance()
}
.store(in: &cancellables)

Expand Down Expand Up @@ -1085,7 +1085,7 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
}
}

func setBGTextColor() {
func updateBGTextAppearance() {
if bgData.count > 0 {
let latestBG = bgData[bgData.count - 1].sgv
var color = NSUIColor.label
Expand All @@ -1105,6 +1105,12 @@ class MainViewController: UIViewController, UITableViewDataSource, ChartViewDele
}

BGText.textColor = color

if latestBG <= 39 || latestBG >= 400 {
BGText.font = UIFont.systemFont(ofSize: 65, weight: .black)
} else {
BGText.font = UIFont.systemFont(ofSize: 85, weight: .black)
}
}
}

Expand Down