[Widgets]: Enhanced to isolate operations from multiple views of same widget type

This commit is contained in:
Magesh K
2025-01-11 03:25:25 +05:30
parent f69b293004
commit e29d9f7904
12 changed files with 346 additions and 245 deletions

View File

@@ -55,9 +55,9 @@ extension View
}
@ViewBuilder
func pageUpButton(_ widgetID: String) -> some View {
func pageUpButton(_ widgetID: Int?) -> some View {
if #available(iOSApplicationExtension 17, *) {
Button(intent: PaginationIntent(.up, widgetID)){
Button(intent: PaginationIntent(widgetID, .up)){
self
}
.buttonStyle(.plain)
@@ -67,9 +67,9 @@ extension View
}
@ViewBuilder
func pageDownButton(_ widgetID: String) -> some View {
func pageDownButton(_ widgetID: Int?) -> some View {
if #available(iOSApplicationExtension 17, *) {
Button(intent: PaginationIntent(.down, widgetID)){
Button(intent: PaginationIntent(widgetID, .down)){
self
}
.buttonStyle(.plain)

View File

@@ -7,49 +7,50 @@
//
import AppIntents
import Intents
import WidgetKit
public enum Direction: String, Sendable{
case up = "up"
case down = "down"
case up
case down
}
public struct NavigationEvent {
let direction: Direction?
var consumed: Bool = false
}
@available(iOS 17, *)
final class PaginationIntent: AppIntent, @unchecked Sendable {
class PaginationIntent: AppIntent, @unchecked Sendable {
static var title: LocalizedStringResource { "Page Navigation Intent" }
static var isDiscoverable: Bool { false }
private let COMMON_WIDGET_ID = 1
static var title: LocalizedStringResource = "Page Navigation Intent"
static var isDiscoverable: Bool = false
@Parameter(title: "widgetID")
var widgetID: Int
@Parameter(title: "Direction")
var direction: String
@Parameter(title: "WidgetID")
var widgetID: String
required init(){}
var uuid: String = UUID().uuidString
required init(){
print()
}
init(_ direction: Direction, _ widgetID: String){
init(_ widgetID: Int?, _ direction: Direction){
// if id was not passed in, then we assume the widget isn't customized yet
// hence we use the common ID, if this is not present in registry of PageInfoManager
// then it will return nil, triggering to show first page in the provider
self.widgetID = widgetID ?? COMMON_WIDGET_ID
self.direction = direction.rawValue
self.widgetID = widgetID
}
func perform() async throws -> some IntentResult {
// if let widgetID = self.widgetID
// {
// WidgetCenter.shared.reloadTimelines(ofKind: widgetID)
// }
// return .result()
let result = try await WidgetUpdateIntent(
Direction(rawValue: self.direction),
self.widgetID
).perform()
return result
let widgetIdString = String(widgetID)
DispatchQueue(label: widgetIdString).sync {
let navigationEvent = NavigationEvent(direction: Direction(rawValue: direction))
PageInfoManager.shared.setPageInfo(for: widgetID, value: navigationEvent)
WidgetCenter.shared.reloadTimelines(ofKind: widgetIdString)
}
return .result()
}
}

View File

@@ -11,32 +11,9 @@ import AppIntents
@available(iOS 17, *)
final class WidgetUpdateIntent: WidgetConfigurationIntent, @unchecked Sendable {
static var title: LocalizedStringResource { "Intent for WidgetAppIntentConfiguration receiver type" }
static var title: LocalizedStringResource { "Widget ID update Intent" }
static var isDiscoverable: Bool { false }
var uuid: String = UUID().uuidString
private var widgetID: String?
@Parameter(title: "ID", description: "Change this to unique ID to keep changes isolated from other widgets", default: "1")
var ID: String?
// this static hack is required, coz we are making these intents stateful
private static var directionMap: [String: Direction] = [:]
init(){
print()
}
func getDirection( _ widgetID: String) -> Direction? {
// remove it, since the event is processed. if needed it will be added again
return Self.directionMap.removeValue(forKey: widgetID)
}
init(_ direction: Direction?, _ widgetID: String){
Self.directionMap[widgetID] = direction
}
func perform() async throws -> some IntentResult {
return .result()
}
@Parameter(title: "ID", description: "Provide a numeric ID to identify the widget", default: 1)
var ID: Int?
}

View File

@@ -0,0 +1,31 @@
//
// PageInfoManager.swift
// AltStore
//
// Created by Magesh K on 11/01/25.
// Copyright © 2025 SideStore. All rights reserved.
//
// This is a utility class
class PageInfoManager {
static var shared = PageInfoManager()
private var pageInfoMap: [Int: NavigationEvent] = [:]
private init() {}
func setPageInfo(for key: Int, value: NavigationEvent?) {
pageInfoMap[key] = value
}
func getPageInfo(for key: Int) -> NavigationEvent? {
return pageInfoMap[key]
}
func popPageInfo(for key: Int) -> NavigationEvent? {
return pageInfoMap.removeValue(forKey: key)
}
func clearAll() {
pageInfoMap.removeAll()
}
}

View File

@@ -8,7 +8,7 @@
/// Simulator data generator
#if DEBUG
#if targetEnvironment(simulator)
@available(iOS 17, *)
extension ActiveAppsTimelineProvider {
@@ -18,7 +18,7 @@ extension ActiveAppsTimelineProvider {
// this dummy data is for simulator (uncomment when testing ActiveAppsWidget pagination)
if (apps.count > 0){
let app = apps[0]
for i in 0..<10 {
for i in 1...10 {
let name = "\(app.name) - \(i)"
let x = AppSnapshot(name: name,
bundleIdentifier: app.bundleIdentifier,

View File

@@ -8,77 +8,88 @@
import WidgetKit
protocol Navigation{
var direction: Direction? { get }
protocol WidgetInfo{
var ID: Int? { get }
}
@available(iOS 17, *)
class ActiveAppsTimelineProvider: AppsTimelineProviderBase<Navigation> {
let uuid = UUID().uuidString
class ActiveAppsTimelineProvider<T: WidgetInfo>: AppsTimelineProviderBase<WidgetInfo> {
public struct WidgetData: WidgetInfo {
let ID: Int?
}
private let dataHolder: PaginationDataHolder
private let widgetID: String
init(kind: String){
print("Executing ActiveAppsTimelineProvider.init() for instance \(uuid)")
let itemsPerPage = ActiveAppsWidget.Constants.MAX_ROWS_PER_PAGE
self.dataHolder = PaginationDataHolder(itemsPerPage: itemsPerPage)
self.widgetID = kind
}
override func getUpdatedData(_ apps: [AppSnapshot], _ context: Navigation?) -> [AppSnapshot] {
guard let context = context else { return apps }
deinit{
// if this provider goes out of scope, clear all entries
PageInfoManager.shared.clearAll()
}
override func getUpdatedData(_ apps: [AppSnapshot], _ context: WidgetInfo?) -> [AppSnapshot] {
var apps = apps
// #if DEBUG
// apps = getSimulatedData(apps: apps)
// #endif
#if targetEnvironment(simulator)
apps = getSimulatedData(apps: apps)
#endif
if let direction = context.direction{
// get paged data if available
switch (direction){
case Direction.up:
apps = dataHolder.prevPage(inItems: apps, whenUnavailable: .current)!
case Direction.down:
apps = dataHolder.nextPage(inItems: apps, whenUnavailable: .current)!
var currentPageApps = dataHolder.currentPage(inItems: apps)
if let widgetInfo = context,
let widgetID = widgetInfo.ID {
var navEvent: NavigationEvent? = PageInfoManager.shared.getPageInfo(for: widgetID)
if let event = navEvent,
let direction = event.direction
{
// process navigation request only if event wasn't consumed yet
if !event.consumed {
switch (direction){
case Direction.up:
currentPageApps = dataHolder.prevPage(inItems: apps, whenUnavailable: .current)!
case Direction.down:
currentPageApps = dataHolder.nextPage(inItems: apps, whenUnavailable: .current)!
}
// mark the event as consumed
// this prevents duplicate getUpdatedData() requests for same navigation event
navEvent!.consumed = true
}
}
}else{
// retain what ever page we were on as-is
apps = dataHolder.currentPage(inItems: apps)
PageInfoManager.shared.setPageInfo(for: widgetID, value: navEvent)
}
return apps
return currentPageApps
}
}
/// TimelineProvider for WidgetAppIntentConfiguration widget type
@available(iOS 17, *)
extension ActiveAppsTimelineProvider: AppIntentTimelineProvider {
struct IntentData: Navigation{
let direction: Direction?
}
typealias Intent = WidgetUpdateIntent
func snapshot(for intent: Intent, in context: Context) async -> AppsEntry {
let data = IntentData(direction: intent.getDirection(widgetID))
func snapshot(for intent: Intent, in context: Context) async -> AppsEntry<WidgetInfo> {
// system retains the previously configured ID value and posts the same here
let widgetData = WidgetData(ID: intent.ID)
let bundleIDs = await super.fetchActiveAppBundleIDs()
let snapshot = await self.snapshot(for: bundleIDs, in: data)
let snapshot = await self.snapshot(for: bundleIDs, in: widgetData)
return snapshot
}
func timeline(for intent: Intent, in context: Context) async -> Timeline<AppsEntry> {
let data = IntentData(direction: intent.getDirection(widgetID))
func timeline(for intent: Intent, in context: Context) async -> Timeline<AppsEntry<WidgetInfo>> {
// system retains the previously configured ID value and posts the same here
let widgetData = WidgetData(ID: intent.ID)
let bundleIDs = await self.fetchActiveAppBundleIDs()
let timeline = await self.timeline(for: bundleIDs, in: data)
let timeline = await self.timeline(for: bundleIDs, in: widgetData)
return timeline
}

View File

@@ -11,25 +11,28 @@ import CoreData
import AltStoreCore
struct AppsEntry: TimelineEntry
struct AppsEntry<T>: TimelineEntry
{
var date: Date
var relevance: TimelineEntryRelevance?
var apps: [AppSnapshot]
var isPlaceholder: Bool = false
var context: T?
}
class AppsTimelineProviderBase<T>
{
typealias Entry = AppsEntry
func placeholder(in context: TimelineProviderContext) -> AppsEntry
func placeholder(in context: TimelineProviderContext) -> AppsEntry<T>
{
return AppsEntry(date: Date(), apps: [], isPlaceholder: true)
}
func snapshot(for appBundleIDs: [String], in context: T? = nil) async -> AppsEntry
func snapshot(for appBundleIDs: [String], in context: T? = nil) async -> AppsEntry<T>
{
do
{
@@ -39,19 +42,19 @@ class AppsTimelineProviderBase<T>
apps = getUpdatedData(apps, context)
let entry = AppsEntry(date: Date(), apps: apps)
let entry = AppsEntry(date: Date(), apps: apps, context: context)
return entry
}
catch
{
print("Failed to prepare widget snapshot:", error)
let entry = AppsEntry(date: Date(), apps: [])
let entry = AppsEntry(date: Date(), apps: [], context: context)
return entry
}
}
func timeline(for appBundleIDs: [String], in context: T? = nil) async -> Timeline<AppsEntry>
func timeline(for appBundleIDs: [String], in context: T? = nil) async -> Timeline<AppsEntry<T>>
{
do
{
@@ -61,7 +64,14 @@ class AppsTimelineProviderBase<T>
apps = getUpdatedData(apps, context)
let entries = self.makeEntries(for: apps)
var entries = self.makeEntries(for: apps, in: context)
// #if targetEnvironment(simulator)
// if let first = entries.first{
// entries = [first]
// }
// #endif
let timeline = Timeline(entries: entries, policy: .atEnd)
return timeline
}
@@ -69,7 +79,7 @@ class AppsTimelineProviderBase<T>
{
print("Failed to prepare widget timeline:", error)
let entry = AppsEntry(date: Date(), apps: [])
let entry = AppsEntry(date: Date(), apps: [], context: context)
let timeline = Timeline(entries: [entry], policy: .atEnd)
return timeline
}
@@ -109,7 +119,7 @@ extension AppsTimelineProviderBase
return apps
}
func makeEntries(for snapshots: [AppSnapshot]) -> [AppsEntry]
func makeEntries(for snapshots: [AppSnapshot], in context: T? = nil) -> [AppsEntry<T>]
{
let sortedAppsByExpirationDate = snapshots.sorted { $0.expirationDate < $1.expirationDate }
guard let firstExpiringApp = sortedAppsByExpirationDate.first, let lastExpiringApp = sortedAppsByExpirationDate.last else { return [] }
@@ -118,16 +128,16 @@ extension AppsTimelineProviderBase
let numberOfDays = lastExpiringApp.expirationDate.numberOfCalendarDays(since: currentDate)
// Generate a timeline consisting of one entry per day.
var entries: [AppsEntry] = []
var entries: [AppsEntry<T>] = []
switch numberOfDays
{
case ..<0:
let entry = AppsEntry(date: currentDate, relevance: TimelineEntryRelevance(score: 0.0), apps: snapshots)
let entry = AppsEntry(date: currentDate, relevance: TimelineEntryRelevance(score: 0.0), apps: snapshots, context: context)
entries.append(entry)
case 0:
let entry = AppsEntry(date: currentDate, relevance: TimelineEntryRelevance(score: 1.0), apps: snapshots)
let entry = AppsEntry(date: currentDate, relevance: TimelineEntryRelevance(score: 1.0), apps: snapshots, context: context)
entries.append(entry)
default:
@@ -151,7 +161,7 @@ extension AppsTimelineProviderBase
score = 0
}
let entry = AppsEntry(date: entryDate, relevance: TimelineEntryRelevance(score: score), apps: snapshots)
let entry = AppsEntry(date: entryDate, relevance: TimelineEntryRelevance(score: score), apps: snapshots, context: context)
return entry
}
@@ -188,11 +198,11 @@ extension AppsTimelineProviderBase
}
}
class AppsTimelineProvider: AppsTimelineProviderBase<ViewAppIntent>, IntentTimelineProvider
typealias Intent = ViewAppIntent
class AppsTimelineProvider: AppsTimelineProviderBase<Intent>, IntentTimelineProvider
{
typealias Intent = ViewAppIntent
func getSnapshot(for intent: Intent, in context: Context, completion: @escaping (AppsEntry) -> Void)
func getSnapshot(for intent: Intent, in context: Context, completion: @escaping (AppsEntry<Intent>) -> Void)
{
Task<Void, Never> {
let bundleIDs = [intent.app?.identifier ?? StoreApp.altstoreAppID]
@@ -202,7 +212,7 @@ class AppsTimelineProvider: AppsTimelineProviderBase<ViewAppIntent>, IntentTimel
}
}
func getTimeline(for intent: Intent, in context: Context, completion: @escaping (Timeline<AppsEntry>) -> Void)
func getTimeline(for intent: Intent, in context: Context, completion: @escaping (Timeline<AppsEntry<Intent>>) -> Void)
{
Task<Void, Never> {
let bundleIDs = [intent.app?.identifier ?? StoreApp.altstoreAppID]

View File

@@ -11,6 +11,8 @@ import WidgetKit
import AltStoreCore
import GameplayKit
private extension Color
{
static let altGradientLight = Color.init(.displayP3, red: 123.0/255.0, green: 200.0/255.0, blue: 176.0/255.0)
@@ -19,6 +21,9 @@ private extension Color
static let altGradientExtraDark = Color.init(.displayP3, red: 2.0/255.0, green: 82.0/255.0, blue: 103.0/255.0)
}
struct WidgetTag: WidgetInfo{
let ID: Int?
}
//@available(iOS 17, *)
struct ActiveAppsWidget: Widget
@@ -27,22 +32,17 @@ struct ActiveAppsWidget: Widget
static let MAX_ROWS_PER_PAGE: UInt = 3
}
let ID = UUID().uuidString
public var body: some WidgetConfiguration {
print("Executing ActiveAppsWidget.body for instance \(ID)")
if #available(iOS 17, *)
{
let widgetID = "ActiveApps - \(UUID().uuidString)"
let widgetConfig = AppIntentConfiguration(
kind: widgetID,
// intent: PaginationIntent.self, // Use the defined AppIntent
intent: WidgetUpdateIntent.self, // Use the defined AppIntent
provider: ActiveAppsTimelineProvider(kind: widgetID)
intent: WidgetUpdateIntent.self,
provider: ActiveAppsTimelineProvider<WidgetTag>(kind: widgetID)
) { entry in
ActiveAppsWidgetView(entry: entry, widgetID: widgetID)
ActiveAppsWidgetView(entry: entry)
}
.supportedFamilies([.systemMedium])
.configurationDisplayName("Active Apps")
@@ -62,17 +62,7 @@ struct ActiveAppsWidget: Widget
@available(iOS 17, *)
private struct ActiveAppsWidgetView: View
{
var entry: AppsEntry
var widgetID: String
let ID = UUID().uuidString
init(entry: AppsEntry, widgetID: String) {
print("Executing ActiveAppsWidgetView.init() for instance \(ID)")
self.entry = entry
self.widgetID = widgetID
}
var entry: AppsEntry<WidgetInfo>
@Environment(\.colorScheme)
private var colorScheme
@@ -103,104 +93,131 @@ private struct ActiveAppsWidgetView: View
private var content: some View {
GeometryReader { (geometry) in
let itemsPerPage = ActiveAppsWidget.Constants.MAX_ROWS_PER_PAGE
let preferredRowHeight = (geometry.size.height / Double(itemsPerPage)) - 8
let rowHeight = min(preferredRowHeight, geometry.size.height / 2)
HStack(alignment: .center) {
LazyVStack(spacing: 12) {
ForEach(Array(entry.apps.enumerated()), id: \.offset) { index, app in
let icon: UIImage = app.icon ?? UIImage(named: "SideStore")!
// 1024x1024 images are not supported by previews but supported by device
// so we scale the image to 97% so as to reduce its actual size but not too much
// to somewhere below value, acceptable by previews ie < 1042x948
let scalingFactor = 0.97
let resizedSize = CGSize(
width: icon.size.width * scalingFactor,
height: icon.size.height * scalingFactor
)
let resizedIcon = icon.resizing(to: resizedSize)!
let daysRemaining = app.expirationDate.numberOfCalendarDays(since: entry.date)
let cornerRadius = rowHeight / 5.0
HStack(spacing: 10) {
Image(uiImage: resizedIcon)
.resizable()
.aspectRatio(contentMode: .fit)
.cornerRadius(cornerRadius)
VStack(alignment: .leading, spacing: 1) {
Text(app.name)
.font(.system(size: 15, weight: .semibold, design: .rounded))
let text = if entry.date > app.expirationDate
{
Text("Expired")
}
else
{
Text("Expires in \(daysRemaining) ") + (daysRemaining == 1 ? Text("day") : Text("days"))
}
text
.font(.system(size: 13, weight: .semibold, design: .rounded))
.foregroundStyle(.secondary)
}
Spacer()
Countdown(startDate: app.refreshedDate,
endDate: app.expirationDate,
currentDate: entry.date,
strokeWidth: 3.0) // Slightly thinner circle stroke width
.background {
Color.black.opacity(0.1)
.mask(Capsule())
.padding(.all, -5)
}
.font(.system(size: 16, weight: .semibold, design: .rounded))
// this modifier invalidates the view (disables userinteraction and shows a blinking effect)
// until new timeline events occur, unless a observable boolean state is presented as parameter
.invalidatableContent()
.activatesRefreshAllAppsIntent()
}
.frame(height: rowHeight)
}
}
appsListView(reader: geometry)
Spacer(minLength: 16)
let buttonWidth: CGFloat = 16
VStack {
Image(systemName: "arrow.up")
.resizable()
.frame(width: buttonWidth, height: buttonWidth)
.opacity(0.3)
// .mask(Capsule())
.pageUpButton(widgetID)
Spacer()
Image(systemName: "arrow.down")
.resizable()
.frame(width: buttonWidth, height: buttonWidth)
.opacity(0.3)
// .mask(Capsule())
.pageDownButton(widgetID)
}
.padding(.vertical)
navigationBarView()
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
private func appsListView(reader: GeometryProxy) -> some View {
let itemsPerPage = ActiveAppsWidget.Constants.MAX_ROWS_PER_PAGE
let preferredRowHeight = (reader.size.height / Double(itemsPerPage)) - 8
let rowHeight = min(preferredRowHeight, reader.size.height / 2)
return LazyVStack(spacing: 12) {
ForEach(Array(entry.apps.enumerated()), id: \.offset) { index, app in
appEntryRowView(app: app, rowHeight: rowHeight)
}
}
}
private func appEntryRowView(app: AppSnapshot, rowHeight: Double) -> some View {
let icon: UIImage = app.icon ?? UIImage(named: "SideStore")!
// 1024x1024 images are not supported by previews but supported by device
// so we scale the image to 97% so as to reduce its actual size but not too much
// to somewhere below value, acceptable by previews ie < 1042x948
let scalingFactor = 0.97
let resizedSize = CGSize(
width: icon.size.width * scalingFactor,
height: icon.size.height * scalingFactor
)
let resizedIcon = icon.resizing(to: resizedSize)!
let cornerRadius = rowHeight / 5.0
return HStack(spacing: 10) {
Image(uiImage: resizedIcon)
.resizable()
.aspectRatio(contentMode: .fit)
.cornerRadius(cornerRadius)
appDetailsView(app)
Spacer()
countDownView(app)
}
.frame(height: rowHeight)
}
private func appDetailsView(_ app: AppSnapshot) -> some View {
let daysRemaining = app.expirationDate.numberOfCalendarDays(since: entry.date)
return VStack(alignment: .leading, spacing: 1) {
Text(app.name)
.font(.system(size: 15, weight: .semibold, design: .rounded))
let text = if entry.date > app.expirationDate
{
Text("Expired")
}
else
{
Text("Expires in \(daysRemaining) ") + (daysRemaining == 1 ? Text("day") : Text("days"))
}
text
.font(.system(size: 13, weight: .semibold, design: .rounded))
.foregroundStyle(.secondary)
}
}
private func countDownView(_ app: AppSnapshot) -> some View {
Countdown(startDate: app.refreshedDate,
endDate: app.expirationDate,
currentDate: entry.date,
strokeWidth: 3.0) // Slightly thinner circle stroke width
.background {
Color.black.opacity(0.1)
.mask(Capsule())
.padding(.all, -5)
}
.font(.system(size: 16, weight: .semibold, design: .rounded))
// this modifier invalidates the view (disables user interaction and shows a blinking effect)
.invalidatableContent()
.activatesRefreshAllAppsIntent()
}
private func navigationBarView() -> some View {
let buttonWidth: CGFloat = 16
let widgetID = entry.context?.ID
return VStack {
Image(systemName: "arrow.up")
.resizable()
.frame(width: buttonWidth, height: buttonWidth)
.opacity(0.3)
// .mask(Capsule())
.pageUpButton(widgetID)
Spacer()
Image(systemName: "arrow.down")
.resizable()
.frame(width: buttonWidth, height: buttonWidth)
.opacity(0.3)
// .mask(Capsule())
.pageDownButton(widgetID)
}
.padding(.vertical)
}
private var placeholder: some View {
Text("App Not Found")
.font(.system(.body, design: .rounded))
@@ -216,14 +233,14 @@ private struct ActiveAppsWidgetView: View
let expiredDate = Date().addingTimeInterval(1 * 60 * 60 * 24 * 7)
let (altstore, delta, clip, longAltStore, longDelta, longClip) = AppSnapshot.makePreviewSnapshots()
AppsEntry(date: Date(), apps: [altstore, delta, clip])
AppsEntry(date: Date(), apps: [longAltStore, longDelta, longClip])
AppsEntry<Any>(date: Date(), apps: [altstore, delta, clip])
AppsEntry<Any>(date: Date(), apps: [longAltStore, longDelta, longClip])
AppsEntry(date: expiredDate, apps: [altstore, delta, clip])
AppsEntry<Any>(date: expiredDate, apps: [altstore, delta, clip])
AppsEntry(date: Date(), apps: [altstore, delta])
AppsEntry(date: Date(), apps: [altstore])
AppsEntry<Any>(date: Date(), apps: [altstore, delta])
AppsEntry<Any>(date: Date(), apps: [altstore])
AppsEntry(date: Date(), apps: [])
AppsEntry(date: Date(), apps: [], isPlaceholder: true)
AppsEntry<Any>(date: Date(), apps: [])
AppsEntry<Any>(date: Date(), apps: [], isPlaceholder: true)
}

View File

@@ -39,7 +39,7 @@ struct AppDetailWidget: Widget
private struct AppDetailWidgetView: View
{
var entry: AppsEntry
var entry: AppsEntry<Intent>
var body: some View {
Group {
@@ -200,11 +200,11 @@ private extension AppDetailWidgetView
} timeline: {
let expiredDate = Date().addingTimeInterval(1 * 60 * 60 * 24 * 7)
let (altstore, _, _, longAltStore, _, _) = AppSnapshot.makePreviewSnapshots()
AppsEntry(date: Date(), apps: [altstore])
AppsEntry(date: Date(), apps: [longAltStore])
AppsEntry<Any>(date: Date(), apps: [altstore])
AppsEntry<Any>(date: Date(), apps: [longAltStore])
AppsEntry(date: expiredDate, apps: [altstore])
AppsEntry<Any>(date: expiredDate, apps: [altstore])
AppsEntry(date: Date(), apps: [])
AppsEntry(date: Date(), apps: [], isPlaceholder: true)
AppsEntry<Any>(date: Date(), apps: [])
AppsEntry<Any>(date: Date(), apps: [], isPlaceholder: true)
}

View File

@@ -70,7 +70,7 @@ extension ComplicationView
@available(iOS 16, *)
private struct ComplicationView: View
{
let entry: AppsEntry
let entry: AppsEntry<Intent>
let style: Style
var body: some View {
@@ -144,10 +144,10 @@ private let widgetFamily = if #available(iOS 16, *) { WidgetFamily.accessoryCirc
let expiredDate = Date().addingTimeInterval(1 * 60 * 60 * 24 * 7)
let (altstore, _, _, longAltStore, _, _) = AppSnapshot.makePreviewSnapshots()
AppsEntry(date: Date(), apps: [altstore])
AppsEntry(date: Date(), apps: [longAltStore])
AppsEntry<Any>(date: Date(), apps: [altstore])
AppsEntry<Any>(date: Date(), apps: [longAltStore])
AppsEntry(date: expiredDate, apps: [altstore])
AppsEntry<Any>(date: expiredDate, apps: [altstore])
}
@available(iOS 17, *)
@@ -157,8 +157,8 @@ private let widgetFamily = if #available(iOS 16, *) { WidgetFamily.accessoryCirc
let expiredDate = Date().addingTimeInterval(1 * 60 * 60 * 24 * 7)
let (altstore, _, _, longAltStore, _, _) = AppSnapshot.makePreviewSnapshots()
AppsEntry(date: Date(), apps: [altstore])
AppsEntry(date: Date(), apps: [longAltStore])
AppsEntry<Any>(date: Date(), apps: [altstore])
AppsEntry<Any>(date: Date(), apps: [longAltStore])
AppsEntry(date: expiredDate, apps: [altstore])
AppsEntry<Any>(date: expiredDate, apps: [altstore])
}