[ADD] AppScreenshot view with ImageProcessor to automatically rotate landscape screenshots

This commit is contained in:
Fabian Thies
2023-01-16 18:59:39 +01:00
committed by Joe Mattiello
parent b9177e89c6
commit 6aaadc79e5
4 changed files with 21 additions and 30 deletions

View File

@@ -24,7 +24,7 @@
"location" : "https://github.com/fabianthdev/AsyncImage", "location" : "https://github.com/fabianthdev/AsyncImage",
"state" : { "state" : {
"branch" : "main", "branch" : "main",
"revision" : "04fe7c66f8362b863c926b87a6d5d9820ffc5bad" "revision" : "018a4fffea025066d795ebb025c2769183f3fffb"
} }
}, },
{ {

View File

@@ -12,21 +12,20 @@ import AsyncImage
struct AppScreenshot: View { struct AppScreenshot: View {
let url: URL let url: URL
var apectRatio: CGFloat = 9/16 var aspectRatio: CGFloat = 9/16
static let processor = Self.ScreenshotProcessor() static let processor = Self.ScreenshotProcessor()
var body: some View { var body: some View {
Text("") AsyncImage(url: self.url, processor: Self.processor) { image in
// AsyncImage(url: self.url, processor: Self.processor) { image in image
// image .resizable()
// .resizable() } placeholder: {
// } placeholder: { Rectangle()
// Rectangle() .foregroundColor(.secondary)
// .foregroundColor(.secondary) }
// } .aspectRatio(self.aspectRatio, contentMode: .fit)
// .aspectRatio(aspectRatio, contentMode: .fit) .cornerRadius(8)
// .cornerRadius(8)
} }
} }
@@ -40,3 +39,11 @@ extension AppScreenshot {
} }
} }
} }
struct AppScreenshot_Previews: PreviewProvider {
static var previews: some View {
AppScreenshot(url: URL(string: "https://apps.sidestore.io/apps/sidestore/v0.1.1/browse-dark.png")!)
}
}

View File

@@ -28,15 +28,7 @@ struct AppScreenshotsScrollView: View {
SwiftUI.Button { SwiftUI.Button {
self.selectedScreenshotIndex = i self.selectedScreenshotIndex = i
} label: { } label: {
AsyncImage(url: url) { image in AppScreenshot(url: url)
image
.resizable()
} placeholder: {
Rectangle()
.foregroundColor(.secondary)
}
.aspectRatio(aspectRatio, contentMode: .fit)
.cornerRadius(8)
} }
} }
} }

View File

@@ -24,15 +24,7 @@ struct BrowseAppPreviewView: View {
if !storeApp.screenshotURLs.isEmpty { if !storeApp.screenshotURLs.isEmpty {
HStack { HStack {
ForEach(storeApp.screenshotURLs.prefix(2)) { url in ForEach(storeApp.screenshotURLs.prefix(2)) { url in
AsyncImage(url: url) { image in AppScreenshot(url: url)
image
.resizable()
.aspectRatio(contentMode: .fit)
} placeholder: {
Color(UIColor.secondarySystemBackground)
.aspectRatio(9/16, contentMode: .fit)
}
.cornerRadius(8)
} }
} }
.frame(height: 300) .frame(height: 300)