Skip to content

Commit 9e30d13

Browse files
fix(ScheduleFloatingPanel): Call dismissView when necessary (#1810)
2 parents 0b1335c + ad7398b commit 9e30d13

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Mail/Views/Schedule/ScheduleFloatingPanel.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ struct ScheduleFloatingPanel: ViewModifier {
7575
let dismissView: (() -> Void)?
7676
let completionHandler: (Date) -> Void
7777

78+
private var isShowingAnyPanel: Bool {
79+
return isShowingFloatingPanel || isShowingCustomScheduleAlert
80+
}
81+
7882
func body(content: Content) -> some View {
7983
content
8084
.floatingPanel(isPresented: $isShowingFloatingPanel, title: type.floatingPanelTitle) {
@@ -86,6 +90,11 @@ struct ScheduleFloatingPanel: ViewModifier {
8690
completionHandler: completionHandler
8791
)
8892
.environmentObject(mailboxManager)
93+
.onDisappear {
94+
if !isShowingAnyPanel {
95+
dismissView?()
96+
}
97+
}
8998
}
9099
.customAlert(isPresented: $isShowingCustomScheduleAlert) {
91100
CustomScheduleAlertView(type: type, date: initialDate, isUpdating: isUpdating, confirmAction: completionHandler) {
@@ -95,16 +104,11 @@ struct ScheduleFloatingPanel: ViewModifier {
95104
if panelShouldBeShown {
96105
isShowingFloatingPanel = true
97106
panelShouldBeShown = false
98-
} else {
107+
} else if !isShowingAnyPanel {
99108
dismissView?()
100109
}
101110
}
102111
}
103112
.myKSuitePanel(isPresented: $isShowingMyKSuiteUpgrade, configuration: .mail)
104-
.onChange(of: isShowingFloatingPanel) { newValue in
105-
if !newValue && !isShowingCustomScheduleAlert {
106-
dismissView?()
107-
}
108-
}
109113
}
110114
}

0 commit comments

Comments
 (0)