[ADD] Full-screen app screenshot preview

This commit is contained in:
Fabian Thies
2022-12-23 16:02:57 +01:00
committed by Joe Mattiello
parent 5697c4c063
commit 6a6fc22995
3 changed files with 99 additions and 9 deletions

View File

@@ -19,25 +19,36 @@ struct AppScreenshotsScrollView: View {
var aspectRatio: CGFloat = 9/16
var height: CGFloat = 400
@State var selectedScreenshotIndex: Int?
var body: some View {
ScrollView(.horizontal, showsIndicators: false) {
HStack {
ForEach(urls) { url in
AsyncImage(url: url) { image in
image
.resizable()
} placeholder: {
Rectangle()
.foregroundColor(.secondary)
ForEach(Array(urls.enumerated()), id: \.offset) { i, url in
SwiftUI.Button {
self.selectedScreenshotIndex = i
} label: {
AsyncImage(url: url) { image in
image
.resizable()
} placeholder: {
Rectangle()
.foregroundColor(.secondary)
}
.aspectRatio(aspectRatio, contentMode: .fit)
.cornerRadius(8)
}
.aspectRatio(aspectRatio, contentMode: .fit)
.cornerRadius(8)
}
}
.padding(.horizontal)
}
.frame(height: height)
.shadow(radius: 12)
.sheet(item: self.$selectedScreenshotIndex) { index in
NavigationView {
AppScreenshotsPreview(urls: urls, aspectRatio: aspectRatio, initialIndex: index)
}
}
}
}
@@ -47,3 +58,9 @@ extension AppScreenshotsScrollView: Equatable {
lhs.urls == rhs.urls && lhs.aspectRatio == rhs.aspectRatio && lhs.height == rhs.height
}
}
extension Int: Identifiable {
public var id: Int {
self
}
}