Files
Termind/TFI/Application/MobileScreenAwakeController.swift
T
Kaede Akino 632d913bb3 feat(terminal): add device-local experience preferences
Add local Bell and screen-awake controls with per-session bell observation and scene-aware effects. Provide foreground Connection Journey success haptics independent of terminal preferences.

Replace the notification sound with an original bell resource, make AudioToolbox completion queue-safe, and group mobile theme settings.
2026-10-17 02:20:38 +08:00

30 lines
964 B
Swift

import Foundation
import TermindDomain
@MainActor
final class MobileScreenAwakeController {
private var requestingScenes: Set<UUID> = []
private let setIdleTimerDisabled: @MainActor (Bool) -> Void
init(setIdleTimerDisabled: @escaping @MainActor (Bool) -> Void) {
self.setIdleTimerDisabled = setIdleTimerDisabled
}
static func wantsAwake(
preferences: TerminalExperiencePreferences, isActive: Bool, workspaceKind: ConnectionHistoryEntry.Kind?
) -> Bool {
preferences.keepScreenAwake && isActive && workspaceKind != nil && workspaceKind != .sftp
}
func update(sceneID: UUID, wantsAwake: Bool) {
let wasAwake = !requestingScenes.isEmpty
if wantsAwake {
requestingScenes.insert(sceneID)
} else {
requestingScenes.remove(sceneID)
}
let isAwake = !requestingScenes.isEmpty
if wasAwake != isAwake { setIdleTimerDisabled(isAwake) }
}
}