Skip to content

Commit

Permalink
ConcentrationBadge
Browse files Browse the repository at this point in the history
  • Loading branch information
mountrcg committed Nov 7, 2024
1 parent 19141f6 commit 5d3c544
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
41 changes: 27 additions & 14 deletions FreeAPS/Sources/Modules/Home/View/HomeRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ extension Home {
)
}

@FetchRequest(
entity: InsulinConcentration.entity(), sortDescriptors: [NSSortDescriptor(key: "date", ascending: true)]
) var concentration: FetchedResults<InsulinConcentration>

@ViewBuilder func header(_: GeometryProxy) -> some View {
HStack {
Spacer()
Expand Down Expand Up @@ -710,26 +714,35 @@ extension Home {
var body: some View {
GeometryReader { geo in
VStack(spacing: 0) {
ZStack(alignment: .bottomTrailing) {
ZStack(alignment: .bottom) {
glucoseView
if let eventualBG = state.eventualBG {
Text(
"" + targetFormatter.string(
from: (
state.units == .mmolL ? eventualBG
.asMmolL : Decimal(eventualBG)
) as NSNumber
)!
)
.font(.system(size: 18, weight: .bold)).foregroundColor(.secondary)
.offset(x: 45, y: 4)
}
HStack {
if (concentration.last?.concentration ?? 1) != 1,
!state.settingsManager.settings
.hideInsulinBadge
{
NonStandardInsulin(concentration: concentration.last?.concentration ?? 1, pod: false)
}
Spacer()
if let eventualBG = state.eventualBG {
Text(
"" + targetFormatter.string(
from: (
state.units == .mmolL ? eventualBG
.asMmolL : Decimal(eventualBG)
) as NSNumber
)!
)
.font(.system(size: 18, weight: .bold)).foregroundColor(.secondary)
// .offset(x: 45, y: 4)
}
}.padding(.horizontal)
}.padding(.top, 10)

Spacer()

header(geo)
.padding(.top, 15)
// .padding(.top, 15)
.padding(.horizontal, 10)

Spacer()
Expand Down
6 changes: 3 additions & 3 deletions FreeAPS/Sources/Views/ViewModifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@ struct NonStandardInsulin: View {

var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 15)
RoundedRectangle(cornerRadius: 20)
.fill(.red)
.frame(width: 33, height: 15)
.frame(width: 40, height: 20)
.overlay {
Text("U" + (formatter.string(from: concentration * 100 as NSNumber) ?? ""))
.font(.system(size: 9))
.font(.system(size: 12))
.foregroundStyle(.white)
}
}
Expand Down

0 comments on commit 5d3c544

Please sign in to comment.