5858: Modification of the event send according to coordinate type

This commit is contained in:
MaximeE
2022-03-31 16:52:16 +02:00
parent 3d58e94e6b
commit af9a524273
11 changed files with 71 additions and 29 deletions
@@ -38,7 +38,14 @@ class UserLocationAnnotatonView: MGLUserLocationAnnotationView {
// TODO: Use a reuseIdentifier
super.init(annotation: userLocationAnnotation, reuseIdentifier: nil)
self.addUserMarkerView(with: userLocationAnnotation.avatarData)
switch userLocationAnnotation.coordinateType {
case .user:
self.addUserMarkerView(with: userLocationAnnotation.avatarData)
case .pin, .generic:
self.addPinMarkerView()
@unknown default:
return
}
}
required init?(coder: NSCoder) {
@@ -55,12 +62,26 @@ class UserLocationAnnotatonView: MGLUserLocationAnnotationView {
}).view else {
return
}
addMarkerView(with: avatarImageView)
}
private func addPinMarkerView() {
guard let pinImageView = UIHostingController(rootView: LocationSharingMarkerView(backgroundColor: theme.colors.accent) {
Image(uiImage: Asset.Images.locationPinIcon.image)
.resizable()
.shapedBorder(color: theme.colors.accent, borderWidth: 3, shape: Circle())
}).view else {
return
}
addMarkerView(with: pinImageView)
}
private func addMarkerView(with imageView: UIView) {
addSubview(imageView)
addSubview(avatarImageView)
addConstraints([topAnchor.constraint(equalTo: avatarImageView.topAnchor),
leadingAnchor.constraint(equalTo: avatarImageView.leadingAnchor),
bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor),
trailingAnchor.constraint(equalTo: avatarImageView.trailingAnchor)])
addConstraints([topAnchor.constraint(equalTo: imageView.topAnchor),
leadingAnchor.constraint(equalTo: imageView.leadingAnchor),
bottomAnchor.constraint(equalTo: imageView.bottomAnchor),
trailingAnchor.constraint(equalTo: imageView.trailingAnchor)])
}
}