mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-11-03 06:14:14 +01:00
Ghostgram for iOS, rebuilt from scratch on Telegram iOS 13.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
31 lines
1.0 KiB
Swift
31 lines
1.0 KiB
Swift
import SwiftSignalKit
|
|
import PasscodeCore
|
|
|
|
/// Separates an actual passcode lock from the legacy UI gate, which also blocks
|
|
/// interaction while UIKit is temporarily inactive (for example, during Face ID).
|
|
final class AppLockStatus {
|
|
private struct State {
|
|
let isPasscodeLocked: Bool
|
|
let isApplicationActive: Bool
|
|
}
|
|
|
|
private let state = Promise<State>()
|
|
|
|
var isPasscodeLocked: Signal<Bool, NoError> {
|
|
return self.state.get()
|
|
|> map { $0.isPasscodeLocked }
|
|
|> distinctUntilChanged
|
|
}
|
|
|
|
var isCurrentlyLocked: Signal<Bool, NoError> {
|
|
return self.state.get()
|
|
|> map { !$0.isApplicationActive || $0.isPasscodeLocked }
|
|
|> distinctUntilChanged
|
|
}
|
|
|
|
func update(isPasscodeLocked: Bool, isApplicationActive: Bool, isApplicationInForeground: Bool = true) {
|
|
PasscodeSession.setApplicationAvailable(isApplicationInForeground && !isPasscodeLocked)
|
|
self.state.set(.single(State(isPasscodeLocked: isPasscodeLocked, isApplicationActive: isApplicationActive)))
|
|
}
|
|
}
|