Skip to content

Commit

Permalink
[LOOP-5069] Presets Bugs (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
Camji55 authored Jan 14, 2025
1 parent 44ec303 commit 3d07070
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4752,7 +4752,7 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LOCALIZED_STRING_MACRO_NAMES = (
NSLocalizedString,
CFLocalizedString,
Expand Down Expand Up @@ -4862,7 +4862,7 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LOCALIZED_STRING_MACRO_NAMES = (
NSLocalizedString,
CFLocalizedString,
Expand Down Expand Up @@ -5298,7 +5298,7 @@
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LOCALIZED_STRING_MACRO_NAMES = (
NSLocalizedString,
CFLocalizedString,
Expand Down
8 changes: 8 additions & 0 deletions Loop/Managers/TemporaryPresetsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ class TemporaryPresetsManager {
}

overrideHistory.recordOverride(preMealOverride)

if let newPreset = preMealOverride {
for observer in self.presetActivationObservers {
observer.presetActivated(context: newPreset.context, duration: newPreset.duration)
}

scheduleClearOverride(override: newPreset)
}

notify(forChange: .preferences)
}
Expand Down
5 changes: 2 additions & 3 deletions Loop/Views/Presets/Components/EditOverrideDurationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct EditOverrideDurationView: View {
DatePicker("On until", selection: $dateSelection, displayedComponents: .hourAndMinute)
.padding(6)
.padding(.leading, 10)
.background(Color.white.cornerRadius(10))
.background(Color(UIColor.systemBackground).cornerRadius(10))

Spacer()
}
Expand All @@ -73,8 +73,7 @@ struct EditOverrideDurationView: View {
}
.buttonStyle(ActionButtonStyle())
.padding([.top, .horizontal])
.background(Color.white)
.shadow(color: .black.opacity(0.05), radius: 4, x: 0, y: -4)
.background(Color(UIColor.secondarySystemBackground))
.disabled(buttonDisabled)
}
}
Expand Down
6 changes: 5 additions & 1 deletion Loop/Views/Presets/Components/PresetDetentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ struct PresetDetentView: View {
case .start:
Button("Start Preset") {
viewModel.startPreset(preset)
dismiss()
}
.buttonStyle(ActionButtonStyle())
.disabled(viewModel.activePreset != nil && preset.id != viewModel.activePreset?.id)
Expand Down Expand Up @@ -106,6 +107,8 @@ struct PresetDetentView: View {
}
}

@State var sheetContentHeight: Double = 0

var body: some View {
NavigationStack {
VStack(spacing: 24) {
Expand Down Expand Up @@ -142,7 +145,8 @@ struct PresetDetentView: View {
.toolbar(.hidden)
.padding(.top)
.padding(16)
.presentationHuggingDetent()
.readContentHeight(to: $sheetContentHeight)
}
.sheetDetent(height: sheetContentHeight)
}
}
3 changes: 1 addition & 2 deletions Loop/Views/Presets/PresetsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ struct PresetsView: View {
Button(action: {}) {
Image(systemName: "plus")
}
// .disabled(!viewModel.hasCompletedTraining)
.disabled(true) // [LOOP-5055] Revert this after phase 1 of presets 2.0. https://tidepool.atlassian.net/browse/LOOP-5055?focusedCommentId=61276
.disabled(!viewModel.hasCompletedTraining)
}

LazyVStack(spacing: 12) {
Expand Down
9 changes: 6 additions & 3 deletions Loop/Views/StatusTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,18 @@ struct StatusTableView: View {

func isDisabled(action: ToolbarAction) -> Bool {
switch action {
case .addCarbs, .bolus, .settings:
case .addCarbs, .bolus, .settings, .presets:
false
case .presets:
!viewModel.onboardingManager.isComplete
}
}

var body: some View {
wrappedView
.onChange(of: viewModel.settingsViewModel.presetsViewModel.activePreset) { _, _ in
Task {
await viewController.reloadData(animated: true)
}
}
.sheet(item: $viewModel.pendingPreset) { _ in
PresetDetentView(
viewModel: viewModel.settingsViewModel.presetsViewModel
Expand Down

0 comments on commit 3d07070

Please sign in to comment.