|
|
@@ -109,55 +109,23 @@ extension Home {
|
|
|
return scene
|
|
|
}
|
|
|
|
|
|
- @ViewBuilder func header(_: GeometryProxy) -> some View {
|
|
|
- HStack {
|
|
|
- Spacer()
|
|
|
- pumpView
|
|
|
- Spacer()
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var cobIobView: some View {
|
|
|
- VStack(alignment: .leading, spacing: 12) {
|
|
|
- HStack {
|
|
|
- Text("IOB").font(.footnote).foregroundColor(.secondary)
|
|
|
- Text(
|
|
|
- (numberFormatter.string(from: (state.suggestion?.iob ?? 0) as NSNumber) ?? "0") +
|
|
|
- NSLocalizedString(" U", comment: "Insulin unit")
|
|
|
- )
|
|
|
- .font(.footnote).fontWeight(.bold)
|
|
|
- }.frame(alignment: .top)
|
|
|
- HStack {
|
|
|
- Text("COB").font(.footnote).foregroundColor(.secondary)
|
|
|
- Text(
|
|
|
- (numberFormatter.string(from: (state.suggestion?.cob ?? 0) as NSNumber) ?? "0") +
|
|
|
- NSLocalizedString(" g", comment: "gram of carbs")
|
|
|
- )
|
|
|
- .font(.footnote).fontWeight(.bold)
|
|
|
- }.frame(alignment: .bottom)
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- var cobIobView2: some View {
|
|
|
- HStack {
|
|
|
- Text("IOB").font(.callout).foregroundColor(.secondary)
|
|
|
- Text(
|
|
|
- (numberFormatter.string(from: (state.suggestion?.iob ?? 0) as NSNumber) ?? "0") +
|
|
|
- NSLocalizedString(" U", comment: "Insulin unit")
|
|
|
- )
|
|
|
- .font(.callout).fontWeight(.bold)
|
|
|
-
|
|
|
- Spacer()
|
|
|
-
|
|
|
- Text("COB").font(.callout).foregroundColor(.secondary)
|
|
|
- Text(
|
|
|
- (numberFormatter.string(from: (state.suggestion?.cob ?? 0) as NSNumber) ?? "0") +
|
|
|
- NSLocalizedString(" g", comment: "gram of carbs")
|
|
|
+ private var color: LinearGradient {
|
|
|
+ colorScheme == .dark ? LinearGradient(
|
|
|
+ gradient: Gradient(colors: [
|
|
|
+ Color("Background_1"),
|
|
|
+ Color("Background_1"),
|
|
|
+ Color("Background_2"),
|
|
|
+ Color("Background_1")
|
|
|
+ ]),
|
|
|
+ startPoint: .top,
|
|
|
+ endPoint: .bottom
|
|
|
+ )
|
|
|
+ :
|
|
|
+ LinearGradient(
|
|
|
+ gradient: Gradient(colors: [Color.gray.opacity(0.1)]),
|
|
|
+ startPoint: .top,
|
|
|
+ endPoint: .bottom
|
|
|
)
|
|
|
- .font(.callout).fontWeight(.bold)
|
|
|
-
|
|
|
- Spacer()
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
var glucoseView: some View {
|
|
|
@@ -406,32 +374,6 @@ extension Home {
|
|
|
.padding(.bottom)
|
|
|
}
|
|
|
|
|
|
- private func selectedProfile() -> (name: String, isOn: Bool) {
|
|
|
- var profileString = ""
|
|
|
- var display: Bool = false
|
|
|
-
|
|
|
- let duration = (fetchedPercent.first?.duration ?? 0) as Decimal
|
|
|
- let indefinite = fetchedPercent.first?.indefinite ?? false
|
|
|
- let addedMinutes = Int(duration)
|
|
|
- let date = fetchedPercent.first?.date ?? Date()
|
|
|
- if date.addingTimeInterval(addedMinutes.minutes.timeInterval) > Date() || indefinite {
|
|
|
- display.toggle()
|
|
|
- }
|
|
|
-
|
|
|
- if fetchedPercent.first?.enabled ?? false, !(fetchedPercent.first?.isPreset ?? false), display {
|
|
|
- profileString = NSLocalizedString("Custom Profile", comment: "Custom but unsaved Profile")
|
|
|
- } else if !(fetchedPercent.first?.enabled ?? false) || !display {
|
|
|
- profileString = NSLocalizedString("Normal Profile", comment: "Your normal Profile. Use a short string")
|
|
|
- } else {
|
|
|
- let id_ = fetchedPercent.first?.id ?? ""
|
|
|
- let profile = fetchedProfiles.filter({ $0.id == id_ }).first
|
|
|
- if profile != nil {
|
|
|
- profileString = profile?.name?.description ?? ""
|
|
|
- }
|
|
|
- }
|
|
|
- return (name: profileString, isOn: display)
|
|
|
- }
|
|
|
-
|
|
|
func highlightButtons() {
|
|
|
for i in 0 ..< timeButtons.count {
|
|
|
timeButtons[i].active = timeButtons[i].hours == state.hours
|
|
|
@@ -439,12 +381,11 @@ extension Home {
|
|
|
}
|
|
|
|
|
|
@ViewBuilder private func bottomPanel(_: GeometryProxy) -> some View {
|
|
|
- let colorRectangle: Color = colorScheme == .dark ? Color.black.opacity(0.8) : Color.white
|
|
|
let colorIcon: Color = (colorScheme == .dark ? Color.white : Color.black).opacity(0.9)
|
|
|
|
|
|
ZStack {
|
|
|
Rectangle()
|
|
|
- .fill(colorRectangle)
|
|
|
+ .fill(Color("Chart"))
|
|
|
.frame(height: UIScreen.main.bounds.height / 13)
|
|
|
.cornerRadius(15)
|
|
|
.shadow(
|
|
|
@@ -509,10 +450,6 @@ extension Home {
|
|
|
.buttonStyle(.borderless)
|
|
|
Spacer()
|
|
|
}
|
|
|
-
|
|
|
- // MARK: CANCEL OF PROFILE HAS TO BE IMPLEMENTED
|
|
|
-
|
|
|
- // MAYBE WITH A SMALL INDICATOR AT THE SYMBOL
|
|
|
Button {
|
|
|
state.showModal(for: .overrideProfilesConfig)
|
|
|
} label: {
|
|
|
@@ -591,9 +528,7 @@ extension Home {
|
|
|
|
|
|
@ViewBuilder func bolusProgressView(_: GeometryProxy, _ progress: Decimal) -> some View {
|
|
|
let colorRectangle: Color = colorScheme == .dark ? Color(
|
|
|
- red: 0.05490196078,
|
|
|
- green: 0.05490196078,
|
|
|
- blue: 0.05490196078
|
|
|
+ "Chart"
|
|
|
) : Color.white
|
|
|
|
|
|
let colorIcon = (colorScheme == .dark ? Color.white : Color.black).opacity(0.9)
|
|
|
@@ -750,9 +685,7 @@ extension Home {
|
|
|
|
|
|
@ViewBuilder func profileView(_: GeometryProxy) -> some View {
|
|
|
let colourChart: Color = colorScheme == .dark ? Color(
|
|
|
- red: 0.05490196078,
|
|
|
- green: 0.05490196078,
|
|
|
- blue: 0.05490196078
|
|
|
+ "Chart"
|
|
|
) : .white
|
|
|
|
|
|
if let overrideString = overrideString {
|
|
|
@@ -822,25 +755,6 @@ extension Home {
|
|
|
}
|
|
|
|
|
|
var body: some View {
|
|
|
- let colorBackground = colorScheme == .dark ? LinearGradient(
|
|
|
- gradient: Gradient(colors: [
|
|
|
- // RGB(10, 34, 55)
|
|
|
- Color(red: 0.03921568627, green: 0.1333333333, blue: 0.2156862745),
|
|
|
- // RGB(3, 15, 28)
|
|
|
- Color(red: 0.011, green: 0.058, blue: 0.109),
|
|
|
- // RGB(10, 34, 55)
|
|
|
- Color(red: 0.03921568627, green: 0.1333333333, blue: 0.2156862745)
|
|
|
- ]),
|
|
|
- startPoint: .top,
|
|
|
- endPoint: .bottom
|
|
|
- )
|
|
|
- :
|
|
|
- LinearGradient(gradient: Gradient(colors: [Color.gray.opacity(0.1)]), startPoint: .top, endPoint: .bottom)
|
|
|
- let colourChart: Color = colorScheme == .dark ? Color(
|
|
|
- red: 0.05490196078,
|
|
|
- green: 0.05490196078,
|
|
|
- blue: 0.05490196078
|
|
|
- ) : .white
|
|
|
GeometryReader { geo in
|
|
|
VStack(spacing: 0) {
|
|
|
Spacer()
|
|
|
@@ -872,7 +786,7 @@ extension Home {
|
|
|
profileView(geo).padding(.vertical)
|
|
|
|
|
|
RoundedRectangle(cornerRadius: 15)
|
|
|
- .fill(colourChart)
|
|
|
+ .fill(Color("Chart"))
|
|
|
.overlay(mainChart)
|
|
|
.clipShape(RoundedRectangle(cornerRadius: 15))
|
|
|
.shadow(
|
|
|
@@ -897,7 +811,7 @@ extension Home {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- .background(colorBackground)
|
|
|
+ .background(color)
|
|
|
.edgesIgnoringSafeArea(.all)
|
|
|
}
|
|
|
.onChange(of: state.hours) { _ in
|
|
|
@@ -917,9 +831,7 @@ extension Home {
|
|
|
.background(
|
|
|
RoundedRectangle(cornerRadius: 8, style: .continuous)
|
|
|
.fill(colorScheme == .dark ? Color(
|
|
|
- red: 0.05490196078,
|
|
|
- green: 0.05490196078,
|
|
|
- blue: 0.05490196078
|
|
|
+ "Chart"
|
|
|
) : Color(UIColor.darkGray))
|
|
|
)
|
|
|
.onTapGesture {
|