Skip to content

Commit

Permalink
Change location attachment to have dynamic height depending on messag…
Browse files Browse the repository at this point in the history
…e list size
  • Loading branch information
nuno-vieira committed Jan 8, 2025
1 parent b24d16d commit 2e48e69
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class LocationAttachmentSnapshotView: _View, ThemeProvider {
var didTapOnLocation: (() -> Void)?
var didTapOnStopSharingLocation: (() -> Void)?

let mapHeightRatio: CGFloat = 0.7
let mapOptions: MKMapSnapshotter.Options = .init()
let mapHeight: CGFloat = 150

static var snapshotsCache: NSCache<NSString, UIImage> = .init()
var snapshotter: MKMapSnapshotter?
Expand Down Expand Up @@ -119,7 +119,6 @@ class LocationAttachmentSnapshotView: _View, ThemeProvider {

let container = VContainer(spacing: 0, alignment: .center) {
imageView
.height(mapHeight)
sharingStatusView
.height(30)
stopButton
Expand All @@ -133,6 +132,7 @@ class LocationAttachmentSnapshotView: _View, ThemeProvider {
activityIndicatorView.centerXAnchor.constraint(equalTo: imageView.centerXAnchor),
activityIndicatorView.centerYAnchor.constraint(equalTo: imageView.centerYAnchor),
imageView.widthAnchor.constraint(equalTo: container.widthAnchor),
imageView.heightAnchor.constraint(equalTo: imageView.widthAnchor, multiplier: mapHeightRatio),
avatarView.centerXAnchor.constraint(equalTo: imageView.centerXAnchor),
avatarView.centerYAnchor.constraint(equalTo: imageView.centerYAnchor),
avatarView.widthAnchor.constraint(equalToConstant: 30),
Expand Down Expand Up @@ -203,7 +203,7 @@ class LocationAttachmentSnapshotView: _View, ThemeProvider {
return
}

mapOptions.size = CGSize(width: frame.width, height: mapHeight)
mapOptions.size = CGSize(width: frame.width, height: frame.width * mapHeightRatio)

if let cachedSnapshot = getCachedSnapshot() {
imageView.image = cachedSnapshot
Expand Down

0 comments on commit 2e48e69

Please sign in to comment.