Skip to content

Commit

Permalink
Adjusting vertical centering
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebash authored Feb 17, 2025
1 parent bb9267d commit e18bf14
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions LoopFollow/Contact/ContactImageUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class ContactImageUpdater {
// Format extraDelta based on the user's unit preference
let unitPreference = UserDefaultsRepository.units.value
let formattedExtraDelta: String
let yOffset: CGFloat = unitPreference == "mg/dL" ? 46 : 61 // Add 15 if mmol is selected
if unitPreference == "mg/dL" {
formattedExtraDelta = String(format: "%.0f", (extraDelta as NSString).doubleValue)
} else {
Expand All @@ -149,17 +150,17 @@ class ContactImageUpdater {

if contactType == "Trend" && ObservableUserDefaults.shared.contactTrend.value == "Separate" {
// Customizing image for Trend contact when value is Separate
let trendRect = CGRect(x: 0, y: 46, width: size.width, height: size.height - 80)
let trendRect = CGRect(x: 0, y: yOffset, width: size.width, height: size.height - 80)
extraTrend.draw(in: trendRect, withAttributes: trendAttributes)
} else if contactType == "Delta" && ObservableUserDefaults.shared.contactDelta.value == "Separate" {
// Customizing image for Delta contact when value is Separate
let deltaRect = CGRect(x: 0, y: 46, width: size.width, height: size.height - 80)
let deltaRect = CGRect(x: 0, y: yOffset, width: size.width, height: size.height - 80)
formattedExtraDelta.draw(in: deltaRect, withAttributes: deltaAttributes)
} else if contactType == "BG" {
// Customizing image for BG contact
let bgRect = extra.isEmpty
? CGRect(x: 0, y: 46, width: size.width, height: size.height - 80)
: CGRect(x: 0, y: 26, width: size.width, height: size.height / 2)
? CGRect(x: 0, y: yOffset, width: size.width, height: size.height - 80)
: CGRect(x: 0, y: yOffset - 20, width: size.width, height: size.height / 2)

bgValue.draw(in: bgRect, withAttributes: bgAttributes)

Expand Down

0 comments on commit e18bf14

Please sign in to comment.