Сейчас это то, что я настроил в Swift. -
Код: Выделить всё
import SwiftUI
import Kingfisher
struct ImageView: View {
@StateObject var viewModel = viewModel()
let index: Int
@State var showSheet: Bool = false
@State var show: Bool = false
@State var currentAnnotationSelected: SelectedAnnotationModel?
@State var showDialog: Bool = false
@State var note: String = ""
@State var localY: CGFloat = 0
@State var globalY: CGFloat = 0
@State var localX: CGFloat = 0
@State var globalX: CGFloat = 0
var annotationIndex: Int = 0
var body: some View {
VStack {
KFImage.url(URL(string: viewModel.uri ?? ""))
.placeholder {ProgressView()}
.loadDiskFileSynchronously()
.cacheMemoryOnly()
.gesture(DragGesture(minimumDistance: 0, coordinateSpace: .local).onEnded { dragGesture in
self.localY = dragGesture.location.y
self.localX = dragGesture.location.x
showSheet = true
})
}
.sheet(isPresented: $showSheet) {
VStack {
AnnotationNote(x: Int(self.localX), y: Int(self.localY))
}
.presentationDetents([.medium])
.presentationDragIndicator(.visible)
}
.overlay {
VStack{
if(viewModel.annotations != [] && viewModel.annotations != nil) {
ForEach(Array((viewModel.annotations.enumerated())!), id: \.offset) { index, annotation in
Circle()
.frame(width: 15, height: 15)
.position(x: 100, y: 100)
//.position(x: CGFloat(annotation.coordinateX), y: CGFloat(annotation.coordinateY))
.onTapGesture {
currentAnnotationSelected = SelectedAnnotationModel(index: index, details: annotation)
self.showSheet = true
}
}
}
}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... oogle-maps