mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[AltWidget] Replaces legacy PreviewProvider previews with #Preview macro
This commit is contained in:
@@ -171,51 +171,18 @@ private extension AppDetailWidgetView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct WidgetView_Previews: PreviewProvider {
|
#Preview(as: .systemSmall) {
|
||||||
static var previews: some View {
|
AppDetailWidget()
|
||||||
let shortRefreshedDate = Calendar.current.date(byAdding: .day, value: -2, to: Date()) ?? Date()
|
} timeline: {
|
||||||
let shortExpirationDate = Calendar.current.date(byAdding: .day, value: 7, to: shortRefreshedDate) ?? Date()
|
let expiredDate = Date().addingTimeInterval(1 * 60 * 60 * 24 * 7)
|
||||||
let expiredExpirationDate = Calendar.current.date(byAdding: .day, value: -155, to: Date()) ?? Date()
|
let (altstore, delta, clip, _, longDelta, _) = AppSnapshot.makePreviewSnapshots()
|
||||||
|
|
||||||
let longRefreshedDate = Calendar.current.date(byAdding: .day, value: -100, to: Date()) ?? Date()
|
AppsEntry(date: Date(), apps: [altstore])
|
||||||
let longExpirationDate = Calendar.current.date(byAdding: .day, value: 365, to: longRefreshedDate) ?? Date()
|
AppsEntry(date: Date(), apps: [delta])
|
||||||
|
AppsEntry(date: Date(), apps: [longDelta])
|
||||||
let altstore = AppSnapshot(name: "AltStore",
|
|
||||||
bundleIdentifier: Bundle.Info.appbundleIdentifier,
|
AppsEntry(date: expiredDate, apps: [delta])
|
||||||
expirationDate: shortExpirationDate,
|
|
||||||
refreshedDate: shortRefreshedDate,
|
AppsEntry(date: Date(), apps: [])
|
||||||
tintColor: .altPrimary,
|
AppsEntry(date: Date(), apps: [], isPlaceholder: true)
|
||||||
icon: UIImage(named: "AltStore"))
|
|
||||||
|
|
||||||
let delta = AppSnapshot(name: "Delta",
|
|
||||||
bundleIdentifier: "com.rileytestut.Delta",
|
|
||||||
expirationDate: longExpirationDate,
|
|
||||||
refreshedDate: longRefreshedDate,
|
|
||||||
tintColor: .deltaPrimary,
|
|
||||||
icon: UIImage(named: "Delta"))
|
|
||||||
|
|
||||||
let expiredDelta = AppSnapshot(name: "Delta",
|
|
||||||
bundleIdentifier: "com.rileytestut.Delta",
|
|
||||||
expirationDate: expiredExpirationDate,
|
|
||||||
refreshedDate: shortRefreshedDate,
|
|
||||||
tintColor: .deltaPrimary,
|
|
||||||
icon: UIImage(named: "Delta"))
|
|
||||||
|
|
||||||
return Group {
|
|
||||||
AppDetailWidgetView(entry: AppsEntry(date: Date(), apps: [altstore]))
|
|
||||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
|
||||||
|
|
||||||
AppDetailWidgetView(entry: AppsEntry(date: Date(), apps: [delta]))
|
|
||||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
|
||||||
|
|
||||||
AppDetailWidgetView(entry: AppsEntry(date: Date(), apps: [expiredDelta]))
|
|
||||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
|
||||||
|
|
||||||
AppDetailWidgetView(entry: AppsEntry(date: Date(), apps: []))
|
|
||||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
|
||||||
|
|
||||||
AppDetailWidgetView(entry: AppsEntry(date: Date(), apps: [], isPlaceholder: true))
|
|
||||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,49 +134,28 @@ private struct ComplicationView: View
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS 16, *)
|
private let widgetFamily = if #available(iOS 16, *) { WidgetFamily.accessoryCircular } else { WidgetFamily.systemSmall }
|
||||||
struct ComplicationView_Previews: PreviewProvider {
|
|
||||||
static var previews: some View {
|
#Preview("Text", as: widgetFamily) {
|
||||||
let shortRefreshedDate = Calendar.current.date(byAdding: .day, value: -2, to: Date()) ?? Date()
|
TextLockScreenWidget()
|
||||||
let shortExpirationDate = Calendar.current.date(byAdding: .day, value: 7, to: shortRefreshedDate) ?? Date()
|
} timeline: {
|
||||||
|
let expiredDate = Date().addingTimeInterval(1 * 60 * 60 * 24 * 7)
|
||||||
let longRefreshedDate = Calendar.current.date(byAdding: .day, value: -100, to: Date()) ?? Date()
|
let (altstore, _, _, longAltStore, _, _) = AppSnapshot.makePreviewSnapshots()
|
||||||
let longExpirationDate = Calendar.current.date(byAdding: .day, value: 365, to: longRefreshedDate) ?? Date()
|
|
||||||
|
AppsEntry(date: Date(), apps: [altstore])
|
||||||
let expiredDate = shortExpirationDate.addingTimeInterval(1 * 60 * 60 * 24)
|
AppsEntry(date: Date(), apps: [longAltStore])
|
||||||
|
|
||||||
let weekAltstore = AppSnapshot(name: "AltStore",
|
AppsEntry(date: expiredDate, apps: [altstore])
|
||||||
bundleIdentifier: Bundle.Info.appbundleIdentifier,
|
}
|
||||||
expirationDate: shortExpirationDate,
|
|
||||||
refreshedDate: shortRefreshedDate,
|
#Preview("Icon", as: widgetFamily) {
|
||||||
tintColor: .altPrimary,
|
IconLockScreenWidget()
|
||||||
icon: UIImage(named: "AltStore"))
|
} timeline: {
|
||||||
|
let expiredDate = Date().addingTimeInterval(1 * 60 * 60 * 24 * 7)
|
||||||
let yearAltstore = AppSnapshot(name: "AltStore",
|
let (altstore, _, _, longAltStore, _, _) = AppSnapshot.makePreviewSnapshots()
|
||||||
bundleIdentifier: Bundle.Info.appbundleIdentifier,
|
|
||||||
expirationDate: longExpirationDate,
|
AppsEntry(date: Date(), apps: [altstore])
|
||||||
refreshedDate: longRefreshedDate,
|
AppsEntry(date: Date(), apps: [longAltStore])
|
||||||
tintColor: .altPrimary,
|
|
||||||
icon: UIImage(named: "AltStore"))
|
AppsEntry(date: expiredDate, apps: [altstore])
|
||||||
|
|
||||||
return Group {
|
|
||||||
ComplicationView(entry: AppsEntry(date: Date(), apps: [weekAltstore]), style: .icon)
|
|
||||||
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
|
||||||
|
|
||||||
ComplicationView(entry: AppsEntry(date: expiredDate, apps: [weekAltstore]), style: .icon)
|
|
||||||
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
|
||||||
|
|
||||||
ComplicationView(entry: AppsEntry(date: longRefreshedDate, apps: [yearAltstore]), style: .icon)
|
|
||||||
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
|
||||||
|
|
||||||
ComplicationView(entry: AppsEntry(date: Date(), apps: [weekAltstore]), style: .text)
|
|
||||||
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
|
||||||
|
|
||||||
ComplicationView(entry: AppsEntry(date: expiredDate, apps: [weekAltstore]), style: .text)
|
|
||||||
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
|
||||||
|
|
||||||
ComplicationView(entry: AppsEntry(date: longRefreshedDate, apps: [yearAltstore]), style: .text)
|
|
||||||
.previewContext(WidgetPreviewContext(family: .accessoryCircular))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user