Bring the SwiftUI app in line with the Apple-native mock and keep pending approvals actionable from Live Activities and watch complications.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import Foundation
|
||||
|
||||
#if canImport(ActivityKit) && os(iOS)
|
||||
import ActivityKit
|
||||
#endif
|
||||
|
||||
struct ApprovalActivityPayload: Codable, Hashable {
|
||||
let requestID: String
|
||||
let title: String
|
||||
let appName: String
|
||||
let source: String
|
||||
let handle: String
|
||||
let location: String
|
||||
let createdAt: Date
|
||||
}
|
||||
|
||||
extension ApprovalRequest {
|
||||
var activityAppName: String {
|
||||
source
|
||||
.replacingOccurrences(of: "auth.", with: "")
|
||||
.replacingOccurrences(of: ".idp.global", with: ".idp.global")
|
||||
}
|
||||
|
||||
var activityLocation: String {
|
||||
"Berlin, DE"
|
||||
}
|
||||
|
||||
var activityExpiryDate: Date {
|
||||
createdAt.addingTimeInterval(risk == .elevated ? 180 : 300)
|
||||
}
|
||||
|
||||
func activityPayload(handle: String) -> ApprovalActivityPayload {
|
||||
ApprovalActivityPayload(
|
||||
requestID: id.uuidString,
|
||||
title: title,
|
||||
appName: activityAppName,
|
||||
source: source,
|
||||
handle: handle,
|
||||
location: activityLocation,
|
||||
createdAt: createdAt
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#if canImport(ActivityKit) && os(iOS)
|
||||
struct ApprovalActivityAttributes: ActivityAttributes {
|
||||
struct ContentState: Codable, Hashable {
|
||||
let requestID: String
|
||||
let title: String
|
||||
let appName: String
|
||||
let source: String
|
||||
let handle: String
|
||||
let location: String
|
||||
}
|
||||
|
||||
let requestID: String
|
||||
let createdAt: Date
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user