You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
session-ios/Session/Conversations/Views & Modals/InsetLockableTableView.swift

36 lines
1.1 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import UIKit
/// This custom UITableView allows us to lock the contentOffset to a specific value - it's current used to prevent
/// the ConversationVC first responder resignation from making the MediaGalleryDetailViewController transition
/// from looking buggy (ie. the table scrolls down with the resignation during the transition)
public class InsetLockableTableView: UITableView {
public var lockContentOffset: Bool = false {
didSet {
guard !lockContentOffset else { return }
self.contentOffset = newOffset
}
}
public var oldOffset: CGPoint = .zero
public var newOffset: CGPoint = .zero
public override func layoutSubviews() {
newOffset = self.contentOffset
guard !lockContentOffset else {
self.contentOffset = CGPoint(
x: newOffset.x,
y: oldOffset.y
)
super.layoutSubviews()
return
}
super.layoutSubviews()
oldOffset = self.contentOffset
}
}