Add local Live Activity and Dynamic Island track display

This commit is contained in:
2026-09-13 11:27:58 +03:00
parent 2ca6201ad6
commit ddd44e8edb
16 changed files with 600 additions and 27 deletions
+26
View File
@@ -0,0 +1,26 @@
import ActivityKit
import Foundation
struct MusicActivityAttributes: ActivityAttributes {
struct ContentState: Codable, Hashable {
var title: String
var artist: String
var playing: Bool
var position: Double
var duration: Double
var updatedAt: Date
var connected: Bool
// Bound UTF-8, including pathological combining characters, below ActivityKit's 4 KB limit.
static func bounded(_ text: String) -> String {
var result = ""
for scalar in text.unicodeScalars {
guard result.utf8.count + scalar.utf8.count <= 256 else { break }
result.unicodeScalars.append(scalar)
}
return result
}
var progress: Double { duration > 0 ? min(1, max(0, position / duration)) : 0 }
}
}