From 15a7cd5f6501a9d64d00182795f3df1a9cb21ba6 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 25 Dec 2022 10:27:19 -0500 Subject: [PATCH] Fix not being able to tap attachments in the timeline --- .../AttachmentsContainerView.swift | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/Tusker/Views/Attachments/AttachmentsContainerView.swift b/Tusker/Views/Attachments/AttachmentsContainerView.swift index 8123aacd..1ce11f62 100644 --- a/Tusker/Views/Attachments/AttachmentsContainerView.swift +++ b/Tusker/Views/Attachments/AttachmentsContainerView.swift @@ -19,6 +19,7 @@ class AttachmentsContainerView: UIView { var attachments: [Attachment]! let attachmentViews: NSHashTable = .weakObjects() + let attachmentStacks: NSHashTable = .weakObjects() var moreView: UIView? var blurView: UIVisualEffectView? @@ -68,6 +69,8 @@ class AttachmentsContainerView: UIView { attachmentViews.allObjects.forEach { $0.removeFromSuperview() } attachmentViews.removeAllObjects() + attachmentStacks.allObjects.forEach { $0.removeFromSuperview() } + attachmentStacks.removeAllObjects() moreView?.removeFromSuperview() var accessibilityElements = [Any]() @@ -96,6 +99,7 @@ class AttachmentsContainerView: UIView { left, right ]) + attachmentStacks.add(stack) fillView(stack) sendSubviewToBack(stack) NSLayoutConstraint.activate([ @@ -116,13 +120,16 @@ class AttachmentsContainerView: UIView { bottomRight.layer.cornerRadius = 5 bottomRight.layer.maskedCorners = .layerMaxXMaxYCorner bottomRight.layer.masksToBounds = true + let innerStack = createAttachmentsStack(axis: .vertical, arrangedSubviews: [ + topRight, + bottomRight + ]) + attachmentStacks.add(innerStack) let outerStack = createAttachmentsStack(axis: .horizontal, arrangedSubviews: [ left, - createAttachmentsStack(axis: .vertical, arrangedSubviews: [ - topRight, - bottomRight - ]) + innerStack, ]) + attachmentStacks.add(outerStack) fillView(outerStack) sendSubviewToBack(outerStack) NSLayoutConstraint.activate([ @@ -145,6 +152,7 @@ class AttachmentsContainerView: UIView { topLeft, bottomLeft ]) + attachmentStacks.add(left) let topRight = createAttachmentView(index: 1, hSize: .half, vSize: .half) topRight.layer.cornerRadius = 5 topRight.layer.maskedCorners = .layerMaxXMinYCorner @@ -153,13 +161,16 @@ class AttachmentsContainerView: UIView { bottomRight.layer.cornerRadius = 5 bottomRight.layer.maskedCorners = .layerMaxXMaxYCorner bottomRight.layer.masksToBounds = true + let right = createAttachmentsStack(axis: .vertical, arrangedSubviews: [ + topRight, + bottomRight + ]) + attachmentStacks.add(right) let outerStack = createAttachmentsStack(axis: .horizontal, arrangedSubviews: [ left, - createAttachmentsStack(axis: .vertical, arrangedSubviews: [ - topRight, - bottomRight - ]) + right, ]) + attachmentStacks.add(outerStack) fillView(outerStack) sendSubviewToBack(outerStack) NSLayoutConstraint.activate([ @@ -201,17 +212,21 @@ class AttachmentsContainerView: UIView { topLeft, bottomLeft ]) + attachmentStacks.add(left) let topRight = createAttachmentView(index: 1, hSize: .half, vSize: .half) topRight.layer.cornerRadius = 5 topRight.layer.maskedCorners = .layerMaxXMinYCorner topRight.layer.masksToBounds = true + let right = createAttachmentsStack(axis: .vertical, arrangedSubviews: [ + topRight, + moreView + ]) + attachmentStacks.add(right) let outerStack = createAttachmentsStack(axis: .horizontal, arrangedSubviews: [ left, - createAttachmentsStack(axis: .vertical, arrangedSubviews: [ - topRight, - moreView - ]) + right, ]) + attachmentStacks.add(outerStack) fillView(outerStack) sendSubviewToBack(outerStack) NSLayoutConstraint.activate([