Working multiple sneak peeks

This commit is contained in:
Hariharan Mudaliar 2025-11-11 00:17:40 +05:30
commit 4e4623532f
2 changed files with 17 additions and 8 deletions

View file

@ -472,13 +472,19 @@ struct ContentView: View {
else if coordinator.sneakPeek.type == .reminder { else if coordinator.sneakPeek.type == .reminder {
if !vm.hideOnClosed && Defaults[.sneakPeekStyles] == .standard, let reminder = reminderManager.activeReminder { if !vm.hideOnClosed && Defaults[.sneakPeekStyles] == .standard, let reminder = reminderManager.activeReminder {
GeometryReader { geo in GeometryReader { geo in
let chipColor = Color(nsColor: reminder.event.calendar.color).ensureMinimumBrightness(factor: 0.7)
HStack(spacing: 6) {
RoundedRectangle(cornerRadius: 2)
.fill(chipColor)
.frame(width: 8, height: 12)
MarqueeText( MarqueeText(
.constant(reminderSneakPeekText(for: reminder)), .constant(reminderSneakPeekText(for: reminder)),
textColor: reminderColor(for: reminder, now: reminderManager.currentDate), textColor: reminderColor(for: reminder, now: reminderManager.currentDate),
minDuration: 1, minDuration: 1,
frameWidth: geo.size.width frameWidth: max(0, geo.size.width - 18)
) )
} }
}
.padding(.bottom, 10) .padding(.bottom, 10)
} }
} }

View file

@ -349,15 +349,18 @@ final class ReminderLiveActivityManager: ObservableObject {
if criticalWindow > 0 && timeRemaining > 0 { if criticalWindow > 0 && timeRemaining > 0 {
if timeRemaining <= criticalWindow { if timeRemaining <= criticalWindow {
if !hasShownCriticalSneakPeek { if !hasShownCriticalSneakPeek {
let displayDuration = min(criticalWindow, max(timeRemaining - 2, 0))
if displayDuration > 0 {
DynamicIslandViewCoordinator.shared.toggleSneakPeek( DynamicIslandViewCoordinator.shared.toggleSneakPeek(
status: true, status: true,
type: .reminder, type: .reminder,
duration: Defaults[.reminderSneakPeekDuration], duration: displayDuration,
value: 0, value: 0,
icon: ReminderLiveActivityManager.criticalIconName icon: ReminderLiveActivityManager.criticalIconName
) )
hasShownCriticalSneakPeek = true hasShownCriticalSneakPeek = true
} }
}
} else { } else {
hasShownCriticalSneakPeek = false hasShownCriticalSneakPeek = false
} }