51 lines
1.1 KiB
Swift
51 lines
1.1 KiB
Swift
import SwiftUI
|
|
import SFSafeSymbols
|
|
|
|
struct ImagesView: View {
|
|
|
|
@EnvironmentObject
|
|
var content: Content
|
|
|
|
let maximumItemWidth: CGFloat = 300
|
|
|
|
let aspectRatio: CGFloat = 1.5
|
|
|
|
let spacing: CGFloat = 20
|
|
|
|
@State
|
|
private var selectedImage: ImageResource?
|
|
|
|
@State
|
|
private var showImageDetails = false
|
|
|
|
var body: some View {
|
|
NavigationSplitView {
|
|
List(content.images, selection: $selectedImage) { image in
|
|
Text(image.id)
|
|
.tag(image)
|
|
}
|
|
} content: {
|
|
if let selectedImage {
|
|
ImagesContentView(image: selectedImage)
|
|
.layoutPriority(1)
|
|
} else {
|
|
Text("Select an image in the sidebar")
|
|
}
|
|
} detail: {
|
|
if let selectedImage {
|
|
ImageDetailsView(image: selectedImage)
|
|
.frame(maxWidth: 350)
|
|
} else {
|
|
EmptyView()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
let content = Content()
|
|
content.images = MockImage.images
|
|
return ImagesView()
|
|
.environmentObject(content)
|
|
}
|