Added a zoom view to see the images better!!
This commit is contained in:
parent
c1f584b1e1
commit
062545b4ff
@ -10,6 +10,8 @@ import SwiftUI
|
||||
struct ScanItemView: View {
|
||||
@Environment(\.modelContext) var ctx
|
||||
|
||||
@State private var isZoomed = false
|
||||
|
||||
let scan: Scan
|
||||
private let translucentColour = Color(red: 0.6, green: 0.8, blue: 1, opacity: 0.4)
|
||||
|
||||
@ -18,7 +20,9 @@ struct ScanItemView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
HStack {
|
||||
if !isZoomed {
|
||||
Image(uiImage: scan.uiImages.first ?? UIImage(systemName: "questionmark")!)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
@ -26,6 +30,12 @@ struct ScanItemView: View {
|
||||
.padding(4)
|
||||
.background(translucentColour)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 12))
|
||||
.onTapGesture {
|
||||
withAnimation(.linear) {
|
||||
isZoomed = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
Text("\(scan.uiImages.count) \(scan.uiImages.count == 1 ? "Page" : "Pages")")
|
||||
@ -54,7 +64,7 @@ struct ScanItemView: View {
|
||||
}
|
||||
|
||||
Button { delete() } label: {
|
||||
Image(systemName: "trash.fill").tint(.red)
|
||||
Image(systemName: "xmark").bold().tint(.red)
|
||||
.padding(8)
|
||||
.background(translucentColour)
|
||||
.clipShape(Circle())
|
||||
@ -65,6 +75,26 @@ struct ScanItemView: View {
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
if isZoomed {
|
||||
TabView {
|
||||
ForEach(scan.uiImages, id: \.self) { img in
|
||||
Image(uiImage: img)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(maxHeight: 400)
|
||||
.onTapGesture {
|
||||
withAnimation(.linear) {
|
||||
isZoomed = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(height: 400)
|
||||
.tabViewStyle(PageTabViewStyle())
|
||||
}
|
||||
|
||||
}
|
||||
.padding()
|
||||
.background(Color(red: 0.4, green: 0.6, blue: 0.9, opacity: 0.8))
|
||||
|
Loading…
x
Reference in New Issue
Block a user