mirror of
https://github.com/home-assistant/iOS.git
synced 2026-04-12 14:30:51 -05:00
<!-- Thank you for submitting a Pull Request and helping to improve Home Assistant. Please complete the following sections to help the processing and review of your changes. Please do not delete anything from this template. --> ## Summary <!-- Provide a brief summary of the changes you have made and most importantly what they aim to achieve --> This PR adds experimental mTLS support, it does not work properly on older iOS versions neither on Apple Watch yet. Mac Catalyst TBD how well it works. This PR modifies: - WebView connection - Alamofire token exchange - Webhook - Websocket (pending HAKit PR) Pending implementation/check - [ ] Apple Watch - [ ] Background usage (widgets, shortcuts, notifications) - [x] Mac Catalyst - [ ] Background refresh - [x] [HAKit PR](https://github.com/home-assistant/HAKit/pull/92/changes#diff-1ccd1173574d21603ee9aab6340ee5c825e62b94f112362346a931b10463594b) ## Screenshots <!-- If this is a user-facing change not in the frontend, please include screenshots in light and dark mode. --> Happy path: https://github.com/user-attachments/assets/8d41d871-8cb8-4498-8e09-24716fff6971 ## Link to pull request in Documentation repository <!-- Pull requests that add, change or remove functionality must have a corresponding pull request in the Companion App Documentation repository (https://github.com/home-assistant/companion.home-assistant). Please add the number of this pull request after the "#" --> Documentation: home-assistant/companion.home-assistant# ## Any other notes <!-- If there is any other information of note, like if this Pull Request is part of a bigger change, please include it here. -->
33 lines
999 B
Swift
33 lines
999 B
Swift
import SwiftUI
|
|
|
|
public struct ScreenCaptureProtectionModifier: ViewModifier {
|
|
private let blurRadius: CGFloat
|
|
@State private var isScreenCaptured = false
|
|
|
|
public init(blurRadius: CGFloat = 8) {
|
|
self.blurRadius = blurRadius
|
|
}
|
|
|
|
public func body(content: Content) -> some View {
|
|
#if !os(watchOS)
|
|
content
|
|
.blur(radius: isScreenCaptured ? blurRadius : 0)
|
|
.animation(.easeInOut(duration: 0.2), value: isScreenCaptured)
|
|
.onAppear {
|
|
isScreenCaptured = UIScreen.main.isCaptured
|
|
}
|
|
.onReceive(NotificationCenter.default.publisher(for: UIScreen.capturedDidChangeNotification)) { _ in
|
|
isScreenCaptured = UIScreen.main.isCaptured
|
|
}
|
|
#else
|
|
content
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public extension View {
|
|
func screenCaptureProtected(blurRadius: CGFloat = 16) -> some View {
|
|
modifier(ScreenCaptureProtectionModifier(blurRadius: blurRadius))
|
|
}
|
|
}
|