|
@@ -75,33 +75,35 @@ extension DataTable {
|
|
|
private var treatmentsList: some View {
|
|
private var treatmentsList: some View {
|
|
|
List {
|
|
List {
|
|
|
HStack {
|
|
HStack {
|
|
|
- Button(action: { showFutureEntries.toggle() }, label: {
|
|
|
|
|
|
|
+ Button(action: { showNonPumpInsulin = true
|
|
|
|
|
+ state.nonPumpInsulinDate = Date() }, label: {
|
|
|
HStack {
|
|
HStack {
|
|
|
- Image(systemName: showFutureEntries ? "calendar.badge.minus" : "calendar.badge.plus")
|
|
|
|
|
- .foregroundColor(Color.accentColor)
|
|
|
|
|
- Text(showFutureEntries ? "Hide Future" : "Show Future")
|
|
|
|
|
|
|
+ Image(systemName: "syringe")
|
|
|
|
|
+ Text("Add")
|
|
|
.foregroundColor(Color.secondary)
|
|
.foregroundColor(Color.secondary)
|
|
|
.font(.caption)
|
|
.font(.caption)
|
|
|
-
|
|
|
|
|
}.frame(maxWidth: .infinity, alignment: .leading)
|
|
}.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
-
|
|
|
|
|
}).buttonStyle(.borderless)
|
|
}).buttonStyle(.borderless)
|
|
|
|
|
|
|
|
Spacer()
|
|
Spacer()
|
|
|
|
|
|
|
|
- Button(action: { showNonPumpInsulin = true
|
|
|
|
|
- state.nonPumpInsulinDate = Date() }, label: {
|
|
|
|
|
|
|
+ Button(action: { showFutureEntries.toggle() }, label: {
|
|
|
HStack {
|
|
HStack {
|
|
|
- Text("Add")
|
|
|
|
|
|
|
+ Text(showFutureEntries ? "Hide Future" : "Show Future")
|
|
|
.foregroundColor(Color.secondary)
|
|
.foregroundColor(Color.secondary)
|
|
|
.font(.caption)
|
|
.font(.caption)
|
|
|
-
|
|
|
|
|
- Image(systemName: "syringe")
|
|
|
|
|
- .foregroundColor(Color.accentColor)
|
|
|
|
|
|
|
+ Image(systemName: showFutureEntries ? "calendar.badge.minus" : "calendar.badge.plus")
|
|
|
}.frame(maxWidth: .infinity, alignment: .trailing)
|
|
}.frame(maxWidth: .infinity, alignment: .trailing)
|
|
|
-
|
|
|
|
|
}).buttonStyle(.borderless)
|
|
}).buttonStyle(.borderless)
|
|
|
- }
|
|
|
|
|
|
|
+ }.listRowBackground(
|
|
|
|
|
+ Rectangle()
|
|
|
|
|
+ .cornerRadius(20)
|
|
|
|
|
+ .background(Color.clear)
|
|
|
|
|
+ .foregroundColor(
|
|
|
|
|
+ colorScheme == .dark ? Color(.systemBackground) :
|
|
|
|
|
+ Color(.secondarySystemBackground)
|
|
|
|
|
+ )
|
|
|
|
|
+ ).listRowSeparator(.hidden, edges: .bottom)
|
|
|
|
|
|
|
|
if !state.treatments.isEmpty {
|
|
if !state.treatments.isEmpty {
|
|
|
if !showFutureEntries {
|
|
if !showFutureEntries {
|
|
@@ -126,16 +128,24 @@ extension DataTable {
|
|
|
private var glucoseList: some View {
|
|
private var glucoseList: some View {
|
|
|
List {
|
|
List {
|
|
|
HStack {
|
|
HStack {
|
|
|
- Text("Time").foregroundStyle(.secondary)
|
|
|
|
|
- Spacer()
|
|
|
|
|
- Text(state.units.rawValue).foregroundStyle(.secondary)
|
|
|
|
|
Button(
|
|
Button(
|
|
|
action: { showManualGlucose = true
|
|
action: { showManualGlucose = true
|
|
|
state.manualGlucose = 0 },
|
|
state.manualGlucose = 0 },
|
|
|
label: { Image(systemName: "plus.circle.fill").foregroundStyle(.secondary)
|
|
label: { Image(systemName: "plus.circle.fill").foregroundStyle(.secondary)
|
|
|
}
|
|
}
|
|
|
).buttonStyle(.borderless)
|
|
).buttonStyle(.borderless)
|
|
|
- }
|
|
|
|
|
|
|
+ Text(state.units.rawValue).foregroundStyle(.secondary)
|
|
|
|
|
+ Spacer()
|
|
|
|
|
+ Text("Time").foregroundStyle(.secondary)
|
|
|
|
|
+ }.listRowBackground(
|
|
|
|
|
+ Rectangle()
|
|
|
|
|
+ .background(Color.clear)
|
|
|
|
|
+ .foregroundColor(
|
|
|
|
|
+ colorScheme == .dark ? Color(.systemBackground) :
|
|
|
|
|
+ Color(.secondarySystemBackground)
|
|
|
|
|
+ )
|
|
|
|
|
+ ).listRowSeparator(.hidden, edges: .bottom)
|
|
|
|
|
+
|
|
|
if !state.glucose.isEmpty {
|
|
if !state.glucose.isEmpty {
|
|
|
ForEach(state.glucose) { item in
|
|
ForEach(state.glucose) { item in
|
|
|
glucoseView(item, isManual: item.glucose)
|
|
glucoseView(item, isManual: item.glucose)
|
|
@@ -171,7 +181,6 @@ extension DataTable {
|
|
|
HStack {
|
|
HStack {
|
|
|
let limitLow: Decimal = state.units == .mmolL ? 0.8 : 40
|
|
let limitLow: Decimal = state.units == .mmolL ? 0.8 : 40
|
|
|
let limitHigh: Decimal = state.units == .mgdL ? 14 : 720
|
|
let limitHigh: Decimal = state.units == .mgdL ? 14 : 720
|
|
|
-
|
|
|
|
|
Button {
|
|
Button {
|
|
|
state.addManualGlucose()
|
|
state.addManualGlucose()
|
|
|
isAmountUnconfirmed = false
|
|
isAmountUnconfirmed = false
|
|
@@ -194,8 +203,6 @@ extension DataTable {
|
|
|
@ViewBuilder private func treatmentView(_ item: Treatment) -> some View {
|
|
@ViewBuilder private func treatmentView(_ item: Treatment) -> some View {
|
|
|
HStack {
|
|
HStack {
|
|
|
Image(systemName: "circle.fill").foregroundColor(item.color)
|
|
Image(systemName: "circle.fill").foregroundColor(item.color)
|
|
|
- Text(dateFormatter.string(from: item.date))
|
|
|
|
|
- .moveDisabled(true)
|
|
|
|
|
Text((item.isSMB ?? false) ? "SMB" : item.type.name)
|
|
Text((item.isSMB ?? false) ? "SMB" : item.type.name)
|
|
|
Text(item.amountText).foregroundColor(.secondary)
|
|
Text(item.amountText).foregroundColor(.secondary)
|
|
|
|
|
|
|
@@ -273,6 +280,9 @@ extension DataTable {
|
|
|
removeInsulinAlert!
|
|
removeInsulinAlert!
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ Spacer()
|
|
|
|
|
+ Text(dateFormatter.string(from: item.date))
|
|
|
|
|
+ .moveDisabled(true)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -341,8 +351,6 @@ extension DataTable {
|
|
|
@ViewBuilder private func glucoseView(_ item: Glucose, isManual: BloodGlucose) -> some View {
|
|
@ViewBuilder private func glucoseView(_ item: Glucose, isManual: BloodGlucose) -> some View {
|
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
|
HStack {
|
|
HStack {
|
|
|
- Text(dateFormatter.string(from: item.glucose.dateString))
|
|
|
|
|
- Spacer()
|
|
|
|
|
Text(item.glucose.glucose.map {
|
|
Text(item.glucose.glucose.map {
|
|
|
glucoseFormatter.string(from: Double(
|
|
glucoseFormatter.string(from: Double(
|
|
|
state.units == .mmolL ? $0.asMmolL : Decimal($0)
|
|
state.units == .mmolL ? $0.asMmolL : Decimal($0)
|
|
@@ -353,6 +361,9 @@ extension DataTable {
|
|
|
} else {
|
|
} else {
|
|
|
Text(item.glucose.direction?.symbol ?? "--")
|
|
Text(item.glucose.direction?.symbol ?? "--")
|
|
|
}
|
|
}
|
|
|
|
|
+ Spacer()
|
|
|
|
|
+
|
|
|
|
|
+ Text(dateFormatter.string(from: item.glucose.dateString))
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|