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,52 +20,80 @@ struct ScanItemView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack {
|
||||
Image(uiImage: scan.uiImages.first ?? UIImage(systemName: "questionmark")!)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(maxWidth: 70, maxHeight: 70)
|
||||
.padding(4)
|
||||
.background(translucentColour)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 12))
|
||||
VStack {
|
||||
HStack {
|
||||
if !isZoomed {
|
||||
Image(uiImage: scan.uiImages.first ?? UIImage(systemName: "questionmark")!)
|
||||
.resizable()
|
||||
.scaledToFit()
|
||||
.frame(maxWidth: 70, maxHeight: 70)
|
||||
.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")")
|
||||
.font(.title3)
|
||||
Text("\(scan.timestamp.formatted())")
|
||||
.font(.footnote)
|
||||
}
|
||||
.foregroundStyle(.white)
|
||||
Spacer()
|
||||
VStack(alignment: .leading) {
|
||||
Text("\(scan.uiImages.count) \(scan.uiImages.count == 1 ? "Page" : "Pages")")
|
||||
.font(.title3)
|
||||
Text("\(scan.timestamp.formatted())")
|
||||
.font(.footnote)
|
||||
}
|
||||
.foregroundStyle(.white)
|
||||
Spacer()
|
||||
|
||||
if scan.images.count == 1 {
|
||||
Button { scan.copyImages() } label: {
|
||||
Image(systemName: "doc.on.doc.fill").tint(.white)
|
||||
if scan.images.count == 1 {
|
||||
Button { scan.copyImages() } label: {
|
||||
Image(systemName: "doc.on.doc.fill").tint(.white)
|
||||
.padding(8)
|
||||
.background(translucentColour)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
}
|
||||
|
||||
ShareLink(items: scan.suiImages, preview: { _ in SharePreview("Scan", image: scan.suiImages.first!)} ) {
|
||||
Image(systemName: "square.and.arrow.up").tint(.white)
|
||||
.padding(8)
|
||||
.background(translucentColour)
|
||||
.offset(y: -2)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
|
||||
Button { delete() } label: {
|
||||
Image(systemName: "xmark").bold().tint(.red)
|
||||
.padding(8)
|
||||
.background(translucentColour)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
.contextMenu(menuItems: {
|
||||
Button("Delete All Scans", role: .destructive) {
|
||||
deleteAll()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
ShareLink(items: scan.suiImages, preview: { _ in SharePreview("Scan", image: scan.suiImages.first!)} ) {
|
||||
Image(systemName: "square.and.arrow.up").tint(.white)
|
||||
.padding(8)
|
||||
.background(translucentColour)
|
||||
.offset(y: -2)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
|
||||
Button { delete() } label: {
|
||||
Image(systemName: "trash.fill").tint(.red)
|
||||
.padding(8)
|
||||
.background(translucentColour)
|
||||
.clipShape(Circle())
|
||||
}
|
||||
.contextMenu(menuItems: {
|
||||
Button("Delete All Scans", role: .destructive) {
|
||||
deleteAll()
|
||||
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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user