Skip to content

Commit

Permalink
Fix for weird popover bug I can't explain. Replace the popover with s…
Browse files Browse the repository at this point in the history
…heet.
  • Loading branch information
Jon-b-m committed May 26, 2023
1 parent 49d265e commit f7ecb89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ extension OverrideProfilesConfig {
@Published var isPreset: Bool = false
@Published var presets: [OverridePresets] = []
@Published var selection: OverridePresets?
@Published var isPromtPresented: Bool = false
@Published var advancedSettings: Bool = false
@Published var isfAndCr: Bool = true
@Published var isf: Bool = true
Expand Down Expand Up @@ -121,7 +120,6 @@ extension OverrideProfilesConfig {
}
}
try? self.coredataContext.save()
isPromtPresented = false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extension OverrideProfilesConfig {
@State private var showAlert = false
@State private var showingDetail = false
@State private var alertSring = ""
@State var isSheetPresented: Bool = false

@Environment(\.dismiss) var dismiss
@Environment(\.managedObjectContext) var moc
Expand Down Expand Up @@ -42,20 +43,20 @@ extension OverrideProfilesConfig {

var presetPopover: some View {
Form {
Section(header: Text("Enter Profile Name")) {
Section {
TextField("Name Of Profile", text: $state.profileName)
Button {
} header: { Text("Enter Name of Profile") }

Section {
Button("Save") {
state.savePreset()
isSheetPresented = false
}
.disabled(state.profileName.isEmpty || fetchedProfiles.filter({ $0.name == state.profileName }).isNotEmpty)

label: { Text("Save") }
.disabled(
state.profileName == "" ||
fetchedProfiles.filter({ $0.name == state.profileName }).isNotEmpty
)
Button {
state.isPromtPresented = false }
label: { Text("Cancel") }
Button("Cancel") {
isSheetPresented = false
}
}
}
}
Expand Down Expand Up @@ -220,7 +221,6 @@ extension OverrideProfilesConfig {
(state.percentage == 100 && !state.override_target && !state.smbIsOff) ||
(!state._indefinite && state.duration == 0) || (state.override_target && state.target == 0)
)
// .tint(.blue)
.buttonStyle(BorderlessButtonStyle())
.font(.callout)
.controlSize(.mini)
Expand All @@ -241,7 +241,7 @@ extension OverrideProfilesConfig {
}
)
Button {
state.isPromtPresented.toggle()
isSheetPresented = true
}
label: { Text("Save as Profile") }
.tint(.orange)
Expand All @@ -253,7 +253,8 @@ extension OverrideProfilesConfig {
(!state._indefinite && state.duration == 0) || (state.override_target && state.target == 0)
)
}
.popover(isPresented: $state.isPromtPresented) {

.sheet(isPresented: $isSheetPresented) {
presetPopover
}
}
Expand Down

0 comments on commit f7ecb89

Please sign in to comment.