[feat] expand iOS network status and refine privacy prompts

This commit is contained in:
dijunkun
2026-09-28 23:26:03 +08:00
parent 163506f81e
commit f8535a797b
14 changed files with 820 additions and 209 deletions
@@ -11,7 +11,6 @@ struct PrivacyPreferences {
self.defaults = defaults
}
var hasMadeNetworkChoice: Bool { defaults.object(forKey: networkKey) != nil }
var hasNetworkConsent: Bool { defaults.bool(forKey: networkKey) }
var savesThumbnails: Bool {
hasNetworkConsent && defaults.bool(forKey: thumbnailsKey)
@@ -26,3 +25,32 @@ struct PrivacyPreferences {
defaults.set(allowed && hasNetworkConsent, forKey: thumbnailsKey)
}
}
/// Refusal dismisses the notice for this visit only. A background/foreground
/// round trip starts another visit; transient inactive states do not.
struct PrivacyNoticeState {
private(set) var isVisible: Bool
private var needsPresentationOnActivation = false
init(hasNetworkConsent: Bool) {
isVisible = !hasNetworkConsent
}
mutating func show() {
isVisible = true
}
mutating func dismiss() {
isVisible = false
}
mutating func didEnterBackground() {
needsPresentationOnActivation = true
}
mutating func didBecomeActive(hasNetworkConsent: Bool) {
guard needsPresentationOnActivation else { return }
needsPresentationOnActivation = false
isVisible = !hasNetworkConsent
}
}