session-ios/Session/Conversations/Views & Modals/MessagesTableView.swift

41 lines
1.4 KiB
Swift
Raw Normal View History

final class MessagesTableView : UITableView {
var keyboardHeight: CGFloat = 0
2021-02-14 23:52:07 +01:00
// Overriding contentInset and adjustedContentInset is to keep them from changing when the
// conversation view controller is dismissed.
override var contentInset: UIEdgeInsets {
get { UIEdgeInsets(top: 0, leading: 0, bottom: MessagesTableView.baselineContentInset + keyboardHeight, trailing: 0) }
set { }
}
override var adjustedContentInset: UIEdgeInsets {
get { UIEdgeInsets(top: 0, leading: 0, bottom: MessagesTableView.baselineContentInset + keyboardHeight, trailing: 0) }
set { }
}
private static let baselineContentInset = Values.mediumSpacing
override init(frame: CGRect, style: UITableView.Style) {
super.init(frame: frame, style: style)
initialize()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
initialize()
}
private func initialize() {
register(VisibleMessageCell.self, forCellReuseIdentifier: VisibleMessageCell.identifier)
register(InfoMessageCell.self, forCellReuseIdentifier: InfoMessageCell.identifier)
2021-02-19 06:02:19 +01:00
register(TypingIndicatorCell.self, forCellReuseIdentifier: TypingIndicatorCell.identifier)
separatorStyle = .none
backgroundColor = .clear
showsVerticalScrollIndicator = false
contentInsetAdjustmentBehavior = .never
keyboardDismissMode = .interactive
}
}