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 {
|
struct ScanItemView: View {
|
||||||
@Environment(\.modelContext) var ctx
|
@Environment(\.modelContext) var ctx
|
||||||
|
|
||||||
|
@State private var isZoomed = false
|
||||||
|
|
||||||
let scan: Scan
|
let scan: Scan
|
||||||
private let translucentColour = Color(red: 0.6, green: 0.8, blue: 1, opacity: 0.4)
|
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 {
|
var body: some View {
|
||||||
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
|
if !isZoomed {
|
||||||
Image(uiImage: scan.uiImages.first ?? UIImage(systemName: "questionmark")!)
|
Image(uiImage: scan.uiImages.first ?? UIImage(systemName: "questionmark")!)
|
||||||
.resizable()
|
.resizable()
|
||||||
.scaledToFit()
|
.scaledToFit()
|
||||||
@ -26,6 +30,12 @@ struct ScanItemView: View {
|
|||||||
.padding(4)
|
.padding(4)
|
||||||
.background(translucentColour)
|
.background(translucentColour)
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 12))
|
.clipShape(RoundedRectangle(cornerRadius: 12))
|
||||||
|
.onTapGesture {
|
||||||
|
withAnimation(.linear) {
|
||||||
|
isZoomed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Text("\(scan.uiImages.count) \(scan.uiImages.count == 1 ? "Page" : "Pages")")
|
Text("\(scan.uiImages.count) \(scan.uiImages.count == 1 ? "Page" : "Pages")")
|
||||||
@ -54,7 +64,7 @@ struct ScanItemView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Button { delete() } label: {
|
Button { delete() } label: {
|
||||||
Image(systemName: "trash.fill").tint(.red)
|
Image(systemName: "xmark").bold().tint(.red)
|
||||||
.padding(8)
|
.padding(8)
|
||||||
.background(translucentColour)
|
.background(translucentColour)
|
||||||
.clipShape(Circle())
|
.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()
|
.padding()
|
||||||
.background(Color(red: 0.4, green: 0.6, blue: 0.9, opacity: 0.8))
|
.background(Color(red: 0.4, green: 0.6, blue: 0.9, opacity: 0.8))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user