|
|
@@ -23,7 +23,7 @@ extension Home {
|
|
|
@State var timeButtons: [Buttons] = [
|
|
|
Buttons(label: "2 hours", number: "2", active: false, hours: 2),
|
|
|
Buttons(label: "4 hours", number: "4", active: false, hours: 4),
|
|
|
- Buttons(label: "6 hours", number: "6", active: true, hours: 6),
|
|
|
+ Buttons(label: "6 hours", number: "6", active: false, hours: 6),
|
|
|
Buttons(label: "12 hours", number: "12", active: false, hours: 12),
|
|
|
Buttons(label: "24 hours", number: "24", active: false, hours: 24)
|
|
|
]
|
|
|
@@ -193,24 +193,6 @@ extension Home {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// var loopView: some View {
|
|
|
-// LoopView(
|
|
|
-// suggestion: $state.suggestion,
|
|
|
-// enactedSuggestion: $state.enactedSuggestion,
|
|
|
-// closedLoop: $state.closedLoop,
|
|
|
-// timerDate: $state.timerDate,
|
|
|
-// isLooping: $state.isLooping,
|
|
|
-// lastLoopDate: $state.lastLoopDate,
|
|
|
-// manualTempBasal: $state.manualTempBasal
|
|
|
-// ).onTapGesture {
|
|
|
-// isStatusPopupPresented = true
|
|
|
-// }.onLongPressGesture {
|
|
|
-// let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
|
|
|
-// impactHeavy.impactOccurred()
|
|
|
-// state.runLoop()
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
var tempBasalString: String? {
|
|
|
guard let tempRate = state.tempRate else {
|
|
|
return nil
|
|
|
@@ -340,10 +322,26 @@ extension Home {
|
|
|
Spacer()
|
|
|
|
|
|
if let overrideString = overrideString {
|
|
|
- Text("👤 " + overrideString)
|
|
|
- .font(.system(size: 12))
|
|
|
- .foregroundColor(.secondary)
|
|
|
- .padding(.trailing, 8)
|
|
|
+ HStack {
|
|
|
+ Text("👤 " + overrideString)
|
|
|
+ .font(.system(size: 12))
|
|
|
+ .foregroundColor(.secondary)
|
|
|
+ Image(systemName: "xmark")
|
|
|
+ .foregroundStyle(.secondary)
|
|
|
+ }
|
|
|
+ .alert(
|
|
|
+ "Return to Normal?", isPresented: $showCancelAlert,
|
|
|
+ actions: {
|
|
|
+ Button("No", role: .cancel) {}
|
|
|
+ Button("Yes", role: .destructive) {
|
|
|
+ state.cancelProfile()
|
|
|
+ }
|
|
|
+ }, message: { Text("This will change settings back to your normal profile.") }
|
|
|
+ )
|
|
|
+ .padding(.trailing, 8)
|
|
|
+ .onTapGesture {
|
|
|
+ showCancelAlert = true
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if state.closedLoop, state.settingsManager.preferences.maxIOB == 0 {
|
|
|
@@ -351,19 +349,50 @@ extension Home {
|
|
|
}
|
|
|
|
|
|
if let progress = state.bolusProgress {
|
|
|
- Text("Bolusing")
|
|
|
- .font(.system(size: 12, weight: .bold)).foregroundColor(.insulin)
|
|
|
- ProgressView(value: Double(progress))
|
|
|
- .progressViewStyle(BolusProgressViewStyle())
|
|
|
- .padding(.trailing, 8)
|
|
|
- .onTapGesture {
|
|
|
- state.cancelBolus()
|
|
|
- }
|
|
|
+ HStack {
|
|
|
+ Text("Bolusing")
|
|
|
+ .font(.system(size: 12, weight: .bold)).foregroundColor(.insulin)
|
|
|
+ ProgressView(value: Double(progress))
|
|
|
+ .progressViewStyle(BolusProgressViewStyle())
|
|
|
+ .padding(.trailing, 8)
|
|
|
+ }
|
|
|
+ .onTapGesture {
|
|
|
+ state.cancelBolus()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
.frame(maxWidth: .infinity, maxHeight: 30)
|
|
|
}
|
|
|
|
|
|
+ var timeInterval: some View {
|
|
|
+ HStack {
|
|
|
+ ForEach(timeButtons) { button in
|
|
|
+ Text(button.active ? NSLocalizedString(button.label, comment: "") : button.number).onTapGesture {
|
|
|
+ state.hours = button.hours
|
|
|
+ highlightButtons()
|
|
|
+ }
|
|
|
+ .foregroundStyle(button.active ? (colorScheme == .dark ? Color.white : Color.black).opacity(0.9) : .secondary)
|
|
|
+ .frame(maxHeight: 30).padding(.horizontal, 8)
|
|
|
+ .background(
|
|
|
+ button.active ?
|
|
|
+ // RGB(30, 60, 95)
|
|
|
+ (
|
|
|
+ colorScheme == .dark ? Color(red: 0.1176470588, green: 0.2352941176, blue: 0.3725490196) :
|
|
|
+ Color.white
|
|
|
+ ) :
|
|
|
+ Color
|
|
|
+ .clear
|
|
|
+ )
|
|
|
+ .cornerRadius(20)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .shadow(
|
|
|
+ color: Color.black.opacity(colorScheme == .dark ? 0.75 : 0.33),
|
|
|
+ radius: colorScheme == .dark ? 5 : 3
|
|
|
+ )
|
|
|
+ .font(buttonFont)
|
|
|
+ }
|
|
|
+
|
|
|
var legendPanel: some View {
|
|
|
ZStack {
|
|
|
HStack(alignment: .center) {
|
|
|
@@ -386,13 +415,6 @@ extension Home {
|
|
|
Text("ZT")
|
|
|
.font(.system(size: 12, weight: .bold)).foregroundColor(.zt)
|
|
|
}
|
|
|
-
|
|
|
-// Spacer()
|
|
|
-//
|
|
|
- //// loopView.padding(.top, 16)
|
|
|
-//
|
|
|
-// Spacer()
|
|
|
-
|
|
|
Group {
|
|
|
Circle().fill(Color.loopYellow).frame(width: 8, height: 8)
|
|
|
Text("COB")
|
|
|
@@ -419,36 +441,6 @@ extension Home {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var timeInterval: some View {
|
|
|
- HStack {
|
|
|
- ForEach(timeButtons) { button in
|
|
|
- Text(button.active ? NSLocalizedString(button.label, comment: "") : button.number).onTapGesture {
|
|
|
- let index = timeButtons.firstIndex(where: { $0.label == button.label }) ?? 0
|
|
|
- highlightButtons(index)
|
|
|
- state.hours = button.hours
|
|
|
- }
|
|
|
- .foregroundStyle(button.active ? (colorScheme == .dark ? Color.white : Color.black).opacity(0.9) : .secondary)
|
|
|
- .frame(maxHeight: 30).padding(.horizontal, 8)
|
|
|
- .background(
|
|
|
- button.active ?
|
|
|
- // RGB(30, 60, 95)
|
|
|
- (
|
|
|
- colorScheme == .dark ? Color(red: 0.1176470588, green: 0.2352941176, blue: 0.3725490196) :
|
|
|
- Color.white
|
|
|
- ) :
|
|
|
- Color
|
|
|
- .clear
|
|
|
- )
|
|
|
- .cornerRadius(20)
|
|
|
- }
|
|
|
- }
|
|
|
- .shadow(
|
|
|
- color: Color.black.opacity(colorScheme == .dark ? 0.75 : 0.33),
|
|
|
- radius: colorScheme == .dark ? 5 : 3
|
|
|
- )
|
|
|
- .font(buttonFont)
|
|
|
- }
|
|
|
-
|
|
|
var mainChart: some View {
|
|
|
ZStack {
|
|
|
if state.animatedBackground {
|
|
|
@@ -512,16 +504,10 @@ extension Home {
|
|
|
return (name: profileString, isOn: display)
|
|
|
}
|
|
|
|
|
|
- func highlightButtons(_ int: Int) {
|
|
|
- var index = 0
|
|
|
- repeat {
|
|
|
- if index == int {
|
|
|
- timeButtons[index].active = true
|
|
|
- } else {
|
|
|
- timeButtons[index].active = false
|
|
|
- }
|
|
|
- index += 1
|
|
|
- } while index < timeButtons.count
|
|
|
+ func highlightButtons() {
|
|
|
+ for i in 0 ..< timeButtons.count {
|
|
|
+ timeButtons[i].active = timeButtons[i].hours == state.hours
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@ViewBuilder private func bottomPanel(_: GeometryProxy) -> some View {
|
|
|
@@ -714,7 +700,11 @@ extension Home {
|
|
|
.background(colorBackground)
|
|
|
.edgesIgnoringSafeArea(.all)
|
|
|
}
|
|
|
- .onAppear(perform: configureView)
|
|
|
+ .onAppear {
|
|
|
+ configureView {
|
|
|
+ highlightButtons()
|
|
|
+ }
|
|
|
+ }
|
|
|
.navigationTitle("Home")
|
|
|
.navigationBarHidden(true)
|
|
|
.ignoresSafeArea(.keyboard)
|