From dd16986d79909efcb5db42a6127ff5b0753c12d8 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 12 Mar 2019 12:25:13 -0400 Subject: [PATCH] Avoid layout changes due to selection changes in media rail. --- SignalMessaging/Views/GalleryRailView.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SignalMessaging/Views/GalleryRailView.swift b/SignalMessaging/Views/GalleryRailView.swift index 2e52f9e06..66690ab2a 100644 --- a/SignalMessaging/Views/GalleryRailView.swift +++ b/SignalMessaging/Views/GalleryRailView.swift @@ -64,14 +64,17 @@ public class GalleryRailCellView: UIView { private(set) var isSelected: Bool = false func setIsSelected(_ isSelected: Bool) { + let borderWidth: CGFloat = 2 self.isSelected = isSelected + + // Reserve space for the selection border whether or not the cell is selected. + layoutMargins = UIEdgeInsets(top: 0, left: borderWidth, bottom: 0, right: borderWidth) + if isSelected { - layoutMargins = UIEdgeInsets(top: 0, left: 2, bottom: 0, right: 2) imageView.layer.borderColor = Theme.galleryHighlightColor.cgColor - imageView.layer.borderWidth = 2 - imageView.layer.cornerRadius = 2 + imageView.layer.borderWidth = borderWidth + imageView.layer.cornerRadius = borderWidth } else { - layoutMargins = .zero imageView.layer.borderWidth = 0 imageView.layer.cornerRadius = 0 }