moderately successfully added animations to zoom between the views,,, will improve that

This commit is contained in:
breadone 2024-07-03 22:10:08 +12:00
parent 062545b4ff
commit fc005d8183
No known key found for this signature in database

View File

@ -9,6 +9,7 @@ import SwiftUI
struct ScanItemView: View { struct ScanItemView: View {
@Environment(\.modelContext) var ctx @Environment(\.modelContext) var ctx
@Namespace private var animation
@State private var isZoomed = false @State private var isZoomed = false
@ -26,12 +27,13 @@ struct ScanItemView: View {
Image(uiImage: scan.uiImages.first ?? UIImage(systemName: "questionmark")!) Image(uiImage: scan.uiImages.first ?? UIImage(systemName: "questionmark")!)
.resizable() .resizable()
.scaledToFit() .scaledToFit()
.matchedGeometryEffect(id: "images", in: animation)
.frame(maxWidth: 70, maxHeight: 70) .frame(maxWidth: 70, maxHeight: 70)
.padding(4) .padding(4)
.background(translucentColour) .background(translucentColour)
.clipShape(RoundedRectangle(cornerRadius: 12)) .clipShape(RoundedRectangle(cornerRadius: 12))
.onTapGesture { .onTapGesture {
withAnimation(.linear) { withAnimation(.spring) {
isZoomed = true isZoomed = true
} }
} }
@ -85,12 +87,13 @@ struct ScanItemView: View {
.scaledToFit() .scaledToFit()
.frame(maxHeight: 400) .frame(maxHeight: 400)
.onTapGesture { .onTapGesture {
withAnimation(.linear) { withAnimation(.spring) {
isZoomed = false isZoomed = false
} }
} }
} }
} }
.matchedGeometryEffect(id: "images", in: animation)
.frame(height: 400) .frame(height: 400)
.tabViewStyle(PageTabViewStyle()) .tabViewStyle(PageTabViewStyle())
} }