Fix not being able to tap attachments in the timeline

This commit is contained in:
Shadowfacts 2022-12-25 10:27:19 -05:00
parent e676075d5b
commit 15a7cd5f65
1 changed files with 27 additions and 12 deletions

View File

@ -19,6 +19,7 @@ class AttachmentsContainerView: UIView {
var attachments: [Attachment]!
let attachmentViews: NSHashTable<AttachmentView> = .weakObjects()
let attachmentStacks: NSHashTable<UIStackView> = .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([