From 091ff9e43857a3f9a129879376c713f2c03d6aa3 Mon Sep 17 00:00:00 2001 From: Nuno Vieira Date: Wed, 8 Jan 2025 15:36:23 +0000 Subject: [PATCH] Extract avatar size in snapshot view --- .../LocationAttachmentSnapshotView.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DemoApp/StreamChat/Components/CustomAttachments/LocationAttachment/LocationAttachmentSnapshotView.swift b/DemoApp/StreamChat/Components/CustomAttachments/LocationAttachment/LocationAttachmentSnapshotView.swift index 6ca711e194..82faf3322c 100644 --- a/DemoApp/StreamChat/Components/CustomAttachments/LocationAttachment/LocationAttachmentSnapshotView.swift +++ b/DemoApp/StreamChat/Components/CustomAttachments/LocationAttachment/LocationAttachmentSnapshotView.swift @@ -40,6 +40,8 @@ class LocationAttachmentSnapshotView: _View, ThemeProvider { let mapHeightRatio: CGFloat = 0.7 let mapOptions: MKMapSnapshotter.Options = .init() + let avatarSize: CGFloat = 30 + static var snapshotsCache: NSCache = .init() var snapshotter: MKMapSnapshotter? @@ -77,7 +79,7 @@ class LocationAttachmentSnapshotView: _View, ThemeProvider { view.translatesAutoresizingMaskIntoConstraints = false view.shouldShowOnlineIndicator = false view.layer.masksToBounds = true - view.layer.cornerRadius = 15 + view.layer.cornerRadius = avatarSize / 2 view.layer.borderWidth = 2 view.layer.borderColor = UIColor.white.cgColor view.isHidden = true @@ -135,8 +137,8 @@ class LocationAttachmentSnapshotView: _View, ThemeProvider { 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), - avatarView.heightAnchor.constraint(equalToConstant: 30) + avatarView.widthAnchor.constraint(equalToConstant: avatarSize), + avatarView.heightAnchor.constraint(equalToConstant: avatarSize) ]) }