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