HotFix: Focus Mode Detection

This commit is contained in:
Hariharan Mudaliar 2026-03-07 21:19:41 +05:30
commit a5734c2246
No known key found for this signature in database
GPG key ID: 025583EB0BE5640E
2 changed files with 166 additions and 34 deletions

View file

@ -56,6 +56,7 @@ struct DoNotDisturbLiveActivity: View {
.onAppear(perform: handleInitialState)
.onChange(of: manager.isDoNotDisturbActive, handleFocusStateChange)
.onChange(of: manager.focusToastTrigger, handleFocusModeSwitchToast)
.onChange(of: focusToastMode, handleToastModeSettingChange)
.onDisappear(perform: cancelPendingTasks)
}
@ -388,6 +389,31 @@ struct DoNotDisturbLiveActivity: View {
}
}
/// When the user toggles between toast / persistent mode while focus is active,
/// re-expand the view so the wings become visible again.
private func handleToastModeSettingChange(_ oldValue: Bool, _ newToastMode: Bool) {
guard manager.isDoNotDisturbActive else { return }
cancelPendingTasks()
if newToastMode {
// Switched TO toast mode — show a brief expansion then collapse.
withAnimation(.spring(response: 0.35, dampingFraction: 0.85)) {
isExpanded = true
showInactiveIcon = false
iconScale = 1.0
}
scheduleTransientCollapse()
} else {
// Switched TO persistent mode — ensure wings are expanded.
withAnimation(.spring(response: 0.35, dampingFraction: 0.85)) {
isExpanded = true
showInactiveIcon = false
iconScale = 1.0
}
}
}
private func triggerInactiveAnimation() {
withAnimation(.spring(response: 0.3, dampingFraction: 0.9)) {
isExpanded = true