Files
RedLintu16andClaude Opus 5.5 64ec524ba0 CrossSound for Apple platforms
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-14 13:28:34 -07:00

69 lines
2.7 KiB
Swift
Executable File

// CrossSoundActivityAttributes.swift
//
// KEPT ONLY TO CLEAN UP AFTER ITSELF. CrossSound no longer has a Live
// Activity — see LiveActivityCleanup for why the Dynamic Island could not be
// removed without removing the activity — but an activity outlives the process
// that started it, and ending a leftover one requires the very type it was
// started with. Nothing else references this; once no install in the wild can
// still be running one, it goes with LiveActivityCleanup.
//
// Lifted verbatim (fields, order, doc comments) from
// ios/CrossSoundShared/CrossSoundActivityAttributes.swift (CrossSound-Flutter),
// where dual target membership put it in both processes.
//
// Adaptations for the SPM move only: `public` access (it now crosses a module
// boundary) with an explicit memberwise init, and `#if os(iOS)` because
// CrossSoundKit also builds this package for macOS, where ActivityKit's types
// are marked unavailable (canImport succeeds there, so it cannot be the guard).
#if os(iOS)
import ActivityKit
import Foundation
@available(iOS 16.1, *)
public struct CrossSoundActivityAttributes: ActivityAttributes {
// The live, changing content — pushed on every now-playing / download change.
public struct ContentState: Codable, Hashable {
public var title: String
public var artist: String
public var isPlaying: Bool
public var isLiked: Bool
/// Seconds.
public var position: TimeInterval
public var duration: TimeInterval
/// Wall-clock time `position` was sampled, so the bar can advance on its own
/// between updates (start = updatedAt - position). Same trick the home-screen
/// widget uses with ProgressView(timerInterval:). Set it to Date() at
/// construction time or the bar drifts.
public var updatedAt: Date
/// Optional download overlay. `downloadProgress < 0` = no active download.
public var downloadTitle: String
public var downloadProgress: Double
public init(
title: String, artist: String, isPlaying: Bool, isLiked: Bool,
position: TimeInterval, duration: TimeInterval, updatedAt: Date,
downloadTitle: String, downloadProgress: Double
) {
self.title = title
self.artist = artist
self.isPlaying = isPlaying
self.isLiked = isLiked
self.position = position
self.duration = duration
self.updatedAt = updatedAt
self.downloadTitle = downloadTitle
self.downloadProgress = downloadProgress
}
}
// Static attributes — nothing varies per-activity (the red/white identity is fixed).
public var name: String = "CrossSound"
public init() {}
}
#endif