[AltWidget] Adds interactive Active Apps widget to view + refresh all active apps (iOS 17+)

This commit is contained in:
Riley Testut
2023-09-01 13:27:28 -05:00
parent c7932bf7b1
commit 21c2f8d5ce
16 changed files with 495 additions and 7 deletions

View File

@@ -39,3 +39,51 @@ extension AppSnapshot
self.icon = application?.icon?.resizing(toFill: CGSize(width: 180, height: 180))
}
}
extension AppSnapshot
{
static func makePreviewSnapshots() -> (altstore: AppSnapshot, delta: AppSnapshot, clip: AppSnapshot, longAltStore: AppSnapshot, longDelta: AppSnapshot, longClip: AppSnapshot)
{
let shortRefreshedDate = Calendar.current.date(byAdding: .day, value: -2, to: Date()) ?? Date()
let shortExpirationDate = Calendar.current.date(byAdding: .day, value: 7, to: shortRefreshedDate) ?? Date()
let longRefreshedDate = Calendar.current.date(byAdding: .day, value: -100, to: Date()) ?? Date()
let longExpirationDate = Calendar.current.date(byAdding: .day, value: 365, to: longRefreshedDate) ?? Date()
let altstore = AppSnapshot(name: "AltStore",
bundleIdentifier: "com.rileytestut.AltStore",
expirationDate: shortExpirationDate,
refreshedDate: shortRefreshedDate,
tintColor: .altPrimary,
icon: UIImage(named: "AltStore"))
let delta = AppSnapshot(name: "Delta",
bundleIdentifier: "com.rileytestut.Delta",
expirationDate: shortExpirationDate,
refreshedDate: shortRefreshedDate,
tintColor: .deltaPrimary,
icon: UIImage(named: "Delta"))
let clip = AppSnapshot(name: "Clip",
bundleIdentifier: "com.rileytestut.Clip",
expirationDate: shortExpirationDate,
refreshedDate: shortRefreshedDate,
tintColor: .clipPrimary,
icon: UIImage(named: "Clip"))
let longAltStore = altstore.with(refreshedDate: longRefreshedDate, expirationDate: longExpirationDate)
let longDelta = delta.with(refreshedDate: longRefreshedDate, expirationDate: longExpirationDate)
let longClip = clip.with(refreshedDate: longRefreshedDate, expirationDate: longExpirationDate)
return (altstore, delta, clip, longAltStore, longDelta, longClip)
}
private func with(refreshedDate: Date, expirationDate: Date) -> AppSnapshot
{
var app = self
app.refreshedDate = refreshedDate
app.expirationDate = expirationDate
return app
}
}