mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-13 08:43:27 +01:00
Supports both iPhone + iPad screenshots
Prefers showing screenshots for current device, but falls back to all screenshots if there are no relevant ones.
This commit is contained in:
@@ -23,6 +23,7 @@ extension SourceError
|
||||
case duplicate
|
||||
|
||||
case missingPermissionUsageDescription
|
||||
case missingScreenshotSize
|
||||
}
|
||||
|
||||
static func unsupported(_ source: Source) -> SourceError { SourceError(code: .unsupported, source: source) }
|
||||
@@ -36,6 +37,10 @@ extension SourceError
|
||||
static func missingPermissionUsageDescription(for permission: any ALTAppPermission, app: StoreApp, source: Source) -> SourceError {
|
||||
SourceError(code: .missingPermissionUsageDescription, source: source, app: app, permission: permission)
|
||||
}
|
||||
|
||||
static func missingScreenshotSize(for screenshot: AppScreenshot, source: Source) -> SourceError {
|
||||
SourceError(code: .missingScreenshotSize, source: source, app: screenshot.app, screenshotURL: screenshot.imageURL)
|
||||
}
|
||||
}
|
||||
|
||||
struct SourceError: ALTLocalizedError
|
||||
@@ -59,6 +64,9 @@ struct SourceError: ALTLocalizedError
|
||||
@UserInfoValue
|
||||
var permission: (any ALTAppPermission)?
|
||||
|
||||
@UserInfoValue
|
||||
var screenshotURL: URL?
|
||||
|
||||
var errorFailureReason: String {
|
||||
switch self.code
|
||||
{
|
||||
@@ -112,6 +120,14 @@ struct SourceError: ALTLocalizedError
|
||||
let permissionType = permission.type.localizedName ?? NSLocalizedString("Permission", comment: "")
|
||||
let failureReason = String(format: NSLocalizedString("The %@ '%@' for %@ is missing a usage description.", comment: ""), permissionType.lowercased(), permission.rawValue, appName)
|
||||
return failureReason
|
||||
|
||||
case .missingScreenshotSize:
|
||||
let appName = self.$app.name ?? String(format: NSLocalizedString("an app in source “%@”", comment: ""), self.$source.name)
|
||||
let baseMessage = String(format: NSLocalizedString("An iPad screenshot for %@ does not specify its size", comment: ""), appName)
|
||||
guard let screenshotURL else { return baseMessage + "." }
|
||||
|
||||
let failureReason = baseMessage + ": \(screenshotURL.absoluteString)"
|
||||
return failureReason
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user