mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-12 16:23:32 +01:00
Change AltStore naming to SideStore
This commit is contained in:
@@ -1,191 +0,0 @@
|
||||
//
|
||||
// AltWidget.swift
|
||||
// AltWidget
|
||||
//
|
||||
// Created by Riley Testut on 6/26/20.
|
||||
// Copyright © 2020 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
import UIKit
|
||||
import CoreData
|
||||
|
||||
import AltStoreCore
|
||||
import AltSign
|
||||
|
||||
struct AppEntry: TimelineEntry
|
||||
{
|
||||
var date: Date
|
||||
var relevance: TimelineEntryRelevance?
|
||||
|
||||
var app: AppSnapshot?
|
||||
var isPlaceholder: Bool = false
|
||||
}
|
||||
|
||||
struct AppSnapshot
|
||||
{
|
||||
var name: String
|
||||
var bundleIdentifier: String
|
||||
var expirationDate: Date
|
||||
var refreshedDate: Date
|
||||
|
||||
var tintColor: UIColor?
|
||||
var icon: UIImage?
|
||||
}
|
||||
|
||||
extension AppSnapshot
|
||||
{
|
||||
// Declared in extension so we retain synthesized initializer.
|
||||
init(installedApp: InstalledApp)
|
||||
{
|
||||
self.name = installedApp.name
|
||||
self.bundleIdentifier = installedApp.bundleIdentifier
|
||||
self.expirationDate = installedApp.expirationDate
|
||||
self.refreshedDate = installedApp.refreshedDate
|
||||
|
||||
self.tintColor = installedApp.storeApp?.tintColor
|
||||
|
||||
let application = ALTApplication(fileURL: installedApp.fileURL)
|
||||
self.icon = application?.icon?.resizing(toFill: CGSize(width: 180, height: 180))
|
||||
}
|
||||
}
|
||||
|
||||
struct Provider: IntentTimelineProvider
|
||||
{
|
||||
typealias Intent = ViewAppIntent
|
||||
typealias Entry = AppEntry
|
||||
|
||||
func placeholder(in context: Context) -> AppEntry
|
||||
{
|
||||
return AppEntry(date: Date(), app: nil, isPlaceholder: true)
|
||||
}
|
||||
|
||||
func getSnapshot(for configuration: ViewAppIntent, in context: Context, completion: @escaping (AppEntry) -> Void)
|
||||
{
|
||||
self.prepare { (result) in
|
||||
do
|
||||
{
|
||||
let context = try result.get()
|
||||
let snapshot = InstalledApp.fetchAltStore(in: context).map(AppSnapshot.init)
|
||||
|
||||
let entry = AppEntry(date: Date(), app: snapshot)
|
||||
completion(entry)
|
||||
}
|
||||
catch
|
||||
{
|
||||
print("Error preparing widget snapshot:", error)
|
||||
|
||||
let entry = AppEntry(date: Date(), app: nil)
|
||||
completion(entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getTimeline(for configuration: ViewAppIntent, in context: Context, completion: @escaping (Timeline<AppEntry>) -> Void) {
|
||||
self.prepare { (result) in
|
||||
autoreleasepool {
|
||||
do
|
||||
{
|
||||
let context = try result.get()
|
||||
|
||||
let installedApp: InstalledApp?
|
||||
|
||||
if let identifier = configuration.app?.identifier
|
||||
{
|
||||
let app = InstalledApp.first(satisfying: NSPredicate(format: "%K == %@", #keyPath(InstalledApp.bundleIdentifier), identifier),
|
||||
in: context)
|
||||
installedApp = app
|
||||
}
|
||||
else
|
||||
{
|
||||
installedApp = InstalledApp.fetchAltStore(in: context)
|
||||
}
|
||||
|
||||
guard let snapshot = installedApp.map(AppSnapshot.init) else { throw ALTError(.invalidApp) }
|
||||
|
||||
let currentDate = Calendar.current.startOfDay(for: Date())
|
||||
let numberOfDays = snapshot.expirationDate.numberOfCalendarDays(since: currentDate)
|
||||
|
||||
// Generate a timeline consisting of one entry per day.
|
||||
var entries: [AppEntry] = []
|
||||
|
||||
switch numberOfDays
|
||||
{
|
||||
case ..<0:
|
||||
let entry = AppEntry(date: currentDate, relevance: TimelineEntryRelevance(score: 0.0), app: snapshot)
|
||||
entries.append(entry)
|
||||
|
||||
case 0:
|
||||
let entry = AppEntry(date: currentDate, relevance: TimelineEntryRelevance(score: 1.0), app: snapshot)
|
||||
entries.append(entry)
|
||||
|
||||
default:
|
||||
// To reduce memory consumption, we only generate entries for the next week. This includes:
|
||||
// * 1 for each day the app is valid (up to 7)
|
||||
// * 1 "0 days remaining"
|
||||
// * 1 "Expired"
|
||||
let numberOfEntries = min(numberOfDays, 7) + 2
|
||||
|
||||
let appEntries = (0 ..< numberOfEntries).map { (dayOffset) -> AppEntry in
|
||||
let entryDate = Calendar.current.date(byAdding: .day, value: dayOffset, to: currentDate) ?? currentDate.addingTimeInterval(Double(dayOffset) * 60 * 60 * 24)
|
||||
|
||||
let daysSinceRefresh = entryDate.numberOfCalendarDays(since: snapshot.refreshedDate)
|
||||
let totalNumberOfDays = snapshot.expirationDate.numberOfCalendarDays(since: snapshot.refreshedDate)
|
||||
|
||||
let score = (entryDate <= snapshot.expirationDate) ? Float(daysSinceRefresh + 1) / Float(totalNumberOfDays + 1) : 0 // Expired apps have a score of 0.
|
||||
let entry = AppEntry(date: entryDate, relevance: TimelineEntryRelevance(score: score), app: snapshot)
|
||||
return entry
|
||||
}
|
||||
|
||||
entries.append(contentsOf: appEntries)
|
||||
}
|
||||
|
||||
let timeline = Timeline(entries: entries, policy: .atEnd)
|
||||
completion(timeline)
|
||||
}
|
||||
catch
|
||||
{
|
||||
print("Error preparing widget timeline:", error)
|
||||
|
||||
let entry = AppEntry(date: Date(), app: nil)
|
||||
let timeline = Timeline(entries: [entry], policy: .atEnd)
|
||||
completion(timeline)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func prepare(completion: @escaping (Result<NSManagedObjectContext, Error>) -> Void)
|
||||
{
|
||||
DatabaseManager.shared.start { (error) in
|
||||
if let error = error
|
||||
{
|
||||
completion(.failure(error))
|
||||
}
|
||||
else
|
||||
{
|
||||
DatabaseManager.shared.viewContext.perform {
|
||||
completion(.success(DatabaseManager.shared.viewContext))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@main
|
||||
struct AltWidget: Widget
|
||||
{
|
||||
private let kind: String = "AppDetail"
|
||||
|
||||
public var body: some WidgetConfiguration {
|
||||
return IntentConfiguration(kind: kind,
|
||||
intent: ViewAppIntent.self,
|
||||
provider: Provider()) { (entry) in
|
||||
WidgetView(entry: entry)
|
||||
}
|
||||
.supportedFamilies([.systemSmall])
|
||||
.configurationDisplayName("AltWidget")
|
||||
.description("View remaining days until your sideloaded apps expire.")
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.com.rileytestut.AltStore</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 23_120.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Group 23_180.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB |
@@ -1,98 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "2x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"scale" : "3x",
|
||||
"size" : "60x60"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "20x20"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "29x29"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "40x40"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "1x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "76x76"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"scale" : "2x",
|
||||
"size" : "83.5x83.5"
|
||||
},
|
||||
{
|
||||
"idiom" : "ios-marketing",
|
||||
"scale" : "1x",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "group16Copy2.pdf",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "icon-120.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "icon-180.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.0 KiB |
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
//
|
||||
// Countdown.swift
|
||||
// AltWidgetExtension
|
||||
//
|
||||
// Created by Riley Testut on 7/6/20.
|
||||
// Copyright © 2020 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import WidgetKit
|
||||
|
||||
struct Countdown: View
|
||||
{
|
||||
var startDate: Date?
|
||||
var endDate: Date?
|
||||
var currentDate: Date = Date()
|
||||
|
||||
@Environment(\.font) private var font
|
||||
|
||||
private var numberOfDays: Int {
|
||||
guard let date = self.endDate else { return 0 }
|
||||
|
||||
let numberOfDays = date.numberOfCalendarDays(since: self.currentDate)
|
||||
return numberOfDays
|
||||
}
|
||||
|
||||
private var fractionComplete: CGFloat {
|
||||
guard let startDate = self.startDate, let endDate = self.endDate else { return 1.0 }
|
||||
|
||||
let totalNumberOfDays = endDate.numberOfCalendarDays(since: startDate)
|
||||
let fractionComplete = CGFloat(self.numberOfDays) / CGFloat(totalNumberOfDays)
|
||||
return fractionComplete
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func overlay(progress: CGFloat) -> some View
|
||||
{
|
||||
let strokeStyle = StrokeStyle(lineWidth: 4.0, lineCap: .round, lineJoin: .round)
|
||||
|
||||
if self.numberOfDays > 9 || self.numberOfDays < 0 {
|
||||
Capsule(style: .continuous)
|
||||
.trim(from: 0.0, to: progress)
|
||||
.stroke(style: strokeStyle)
|
||||
}
|
||||
else {
|
||||
Circle()
|
||||
.trim(from: 0.0, to: progress)
|
||||
.rotation(Angle(degrees: -90), anchor: .center)
|
||||
.stroke(style: strokeStyle)
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Text("\(numberOfDays)")
|
||||
.font((font ?? .title).monospacedDigit())
|
||||
.bold()
|
||||
.opacity(endDate != nil ? 1 : 0)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 6)
|
||||
.overlay(
|
||||
ZStack {
|
||||
overlay(progress: 1.0)
|
||||
.opacity(0.3)
|
||||
|
||||
overlay(progress: fractionComplete)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
struct Countdown_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let startDate = Calendar.current.date(byAdding: .day, value: -2, to: Date()) ?? Date()
|
||||
Group {
|
||||
Countdown(startDate: startDate, endDate: Calendar.current.date(byAdding: .day, value: 7, to: startDate))
|
||||
Countdown(startDate: startDate, endDate: Calendar.current.date(byAdding: .day, value: 365, to: startDate))
|
||||
}
|
||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>ALTAppGroups</key>
|
||||
<array>
|
||||
<string>group.com.rileytestut.AltStore</string>
|
||||
</array>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>AltWidget</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.widgetkit-extension</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,195 +0,0 @@
|
||||
//
|
||||
// WidgetView.swift
|
||||
// AltStore
|
||||
//
|
||||
// Created by Riley Testut on 9/14/20.
|
||||
// Copyright © 2020 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
import AltStoreCore
|
||||
import AltSign
|
||||
import CoreData
|
||||
|
||||
struct WidgetView : View
|
||||
{
|
||||
var entry: AppEntry
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if let app = self.entry.app
|
||||
{
|
||||
let daysRemaining = app.expirationDate.numberOfCalendarDays(since: self.entry.date)
|
||||
|
||||
GeometryReader { (geometry) in
|
||||
Group {
|
||||
VStack(alignment: .leading) {
|
||||
VStack(alignment: .leading, spacing: 5) {
|
||||
let imageHeight = geometry.size.height * 0.4
|
||||
|
||||
Image(uiImage: app.icon ?? UIImage())
|
||||
.resizable()
|
||||
.aspectRatio(CGSize(width: 1, height: 1), contentMode: .fit)
|
||||
.frame(height: imageHeight)
|
||||
.mask(RoundedRectangle(cornerRadius: imageHeight / 5.0, style: .continuous))
|
||||
|
||||
Text(app.name.uppercased())
|
||||
.font(.system(size: 12, weight: .semibold, design: .rounded))
|
||||
.foregroundColor(.white)
|
||||
.lineLimit(1)
|
||||
.minimumScaleFactor(0.5)
|
||||
}
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
|
||||
Spacer(minLength: 0)
|
||||
|
||||
HStack(alignment: .center) {
|
||||
let expirationText: Text = {
|
||||
switch daysRemaining
|
||||
{
|
||||
case ..<0: return Text("Expired")
|
||||
case 1: return Text("1 day")
|
||||
default: return Text("\(daysRemaining) days")
|
||||
}
|
||||
}()
|
||||
|
||||
(
|
||||
Text("Expires in\n")
|
||||
.font(.system(size: 13, weight: .semibold, design: .rounded))
|
||||
.foregroundColor(Color.white.opacity(0.45)) +
|
||||
|
||||
expirationText
|
||||
.font(.system(size: 15, weight: .semibold, design: .rounded))
|
||||
.foregroundColor(.white)
|
||||
)
|
||||
.lineLimit(2)
|
||||
.lineSpacing(1.0)
|
||||
.minimumScaleFactor(0.5)
|
||||
|
||||
Spacer()
|
||||
|
||||
if daysRemaining >= 0
|
||||
{
|
||||
Countdown(startDate: app.refreshedDate,
|
||||
endDate: app.expirationDate,
|
||||
currentDate: self.entry.date)
|
||||
.font(.system(size: 20, weight: .semibold, design: .rounded))
|
||||
.foregroundColor(Color.white)
|
||||
.opacity(0.8)
|
||||
.fixedSize(horizontal: true, vertical: false)
|
||||
.offset(x: 5)
|
||||
}
|
||||
}
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
VStack {
|
||||
// Put conditional inside VStack, or else an empty view will be returned
|
||||
// if isPlaceholder == false, which messes up layout.
|
||||
if !entry.isPlaceholder
|
||||
{
|
||||
Text("App Not Found")
|
||||
.font(.system(.body, design: .rounded))
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(Color.white.opacity(0.4))
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
}
|
||||
}
|
||||
.background(backgroundView(icon: entry.app?.icon, tintColor: entry.app?.tintColor))
|
||||
}
|
||||
}
|
||||
|
||||
private extension WidgetView
|
||||
{
|
||||
func backgroundView(icon: UIImage? = nil, tintColor: UIColor? = nil) -> some View
|
||||
{
|
||||
let icon = icon ?? UIImage(named: "AltStore")!
|
||||
let tintColor = tintColor ?? .gray
|
||||
|
||||
let imageHeight = 60 as CGFloat
|
||||
let saturation = 1.8
|
||||
let blurRadius = 5 as CGFloat
|
||||
let tintOpacity = 0.45
|
||||
|
||||
return ZStack(alignment: .topTrailing) {
|
||||
// Blurred Image
|
||||
GeometryReader { geometry in
|
||||
ZStack {
|
||||
Image(uiImage: icon)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: imageHeight, height: imageHeight, alignment: .center)
|
||||
.saturation(saturation)
|
||||
.blur(radius: blurRadius, opaque: true)
|
||||
.scaleEffect(geometry.size.width / imageHeight, anchor: .center)
|
||||
|
||||
Color(tintColor)
|
||||
.opacity(tintOpacity)
|
||||
}
|
||||
}
|
||||
|
||||
Image("Badge")
|
||||
.resizable()
|
||||
.frame(width: 26, height: 26)
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct WidgetView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
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 expiredExpirationDate = Calendar.current.date(byAdding: .day, value: -155, to: Date()) ?? 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: 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 {
|
||||
WidgetView(entry: AppEntry(date: Date(), app: altstore))
|
||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
||||
|
||||
WidgetView(entry: AppEntry(date: Date(), app: delta))
|
||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
||||
|
||||
WidgetView(entry: AppEntry(date: Date(), app: expiredDelta))
|
||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
||||
|
||||
WidgetView(entry: AppEntry(date: Date(), app: nil))
|
||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
||||
|
||||
WidgetView(entry: AppEntry(date: Date(), app: nil, isPlaceholder: true))
|
||||
.previewContext(WidgetPreviewContext(family: .systemSmall))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user