2019-12-20 09:39:22 +00:00
|
|
|
/*
|
|
|
|
Copyright 2019 New Vector Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
import Reusable
|
|
|
|
|
2020-08-03 17:43:45 +00:00
|
|
|
/// `BubbleCellContentView` is a container view that display the default room message outer views and enables to manage them. Like pagination title, sender info, read receipts, reactions, encryption status.
|
2019-12-20 09:39:22 +00:00
|
|
|
@objcMembers
|
2020-01-14 19:02:34 +00:00
|
|
|
final class BubbleCellContentView: UIView, NibLoadable {
|
2019-12-20 09:39:22 +00:00
|
|
|
|
|
|
|
// MARK: - Properties
|
|
|
|
|
|
|
|
// MARK: Outlets
|
|
|
|
|
2020-07-31 16:26:09 +00:00
|
|
|
@IBOutlet weak var paginationTitleContainerView: UIView!
|
|
|
|
@IBOutlet weak var paginationLabel: UILabel!
|
|
|
|
@IBOutlet weak var paginationSeparatorView: UIView!
|
|
|
|
|
|
|
|
@IBOutlet weak var senderInfoContainerView: UIView!
|
|
|
|
@IBOutlet weak var avatarImageView: MXKImageView!
|
|
|
|
@IBOutlet weak var userNameLabel: UILabel!
|
|
|
|
@IBOutlet weak var userNameTouchMaskView: UIView!
|
2019-12-20 09:39:22 +00:00
|
|
|
|
|
|
|
@IBOutlet weak var innerContentView: UIView!
|
|
|
|
|
2020-07-31 16:26:09 +00:00
|
|
|
@IBOutlet weak var encryptionStatusContainerView: UIView!
|
|
|
|
@IBOutlet weak var encryptionImageView: UIImageView!
|
|
|
|
|
|
|
|
@IBOutlet weak var bubbleInfoContainer: UIView!
|
|
|
|
@IBOutlet weak var bubbleInfoContainerTopConstraint: NSLayoutConstraint!
|
|
|
|
|
2019-12-20 09:39:22 +00:00
|
|
|
@IBOutlet weak var readReceiptsContainerView: UIView!
|
|
|
|
@IBOutlet weak var readReceiptsContentView: UIView!
|
|
|
|
|
2020-07-31 16:26:09 +00:00
|
|
|
@IBOutlet weak var reactionsContainerView: UIView!
|
|
|
|
@IBOutlet weak var reactionsContentView: UIView!
|
2019-12-20 09:39:22 +00:00
|
|
|
|
2020-07-31 16:26:09 +00:00
|
|
|
@IBOutlet weak var bubbleOverlayContainer: UIView!
|
2020-01-14 19:02:34 +00:00
|
|
|
|
2019-12-20 09:39:22 +00:00
|
|
|
// MARK: Private
|
|
|
|
|
|
|
|
private var showReadReceipts: Bool {
|
|
|
|
get {
|
2020-01-14 19:02:34 +00:00
|
|
|
return !self.readReceiptsContainerView.isHidden
|
2019-12-20 09:39:22 +00:00
|
|
|
}
|
|
|
|
set {
|
|
|
|
self.readReceiptsContainerView.isHidden = !newValue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-31 16:26:09 +00:00
|
|
|
private var showReactions: Bool {
|
|
|
|
get {
|
|
|
|
return !self.reactionsContainerView.isHidden
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
self.reactionsContainerView.isHidden = !newValue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-14 19:02:34 +00:00
|
|
|
// MARK: Public
|
|
|
|
|
|
|
|
var showPaginationTitle: Bool {
|
|
|
|
get {
|
|
|
|
return !self.paginationTitleContainerView.isHidden
|
|
|
|
}
|
|
|
|
set {
|
2020-07-31 16:26:09 +00:00
|
|
|
self.paginationTitleContainerView.isHidden = !newValue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var showSenderInfo: Bool {
|
|
|
|
get {
|
|
|
|
return !self.senderInfoContainerView.isHidden
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
self.senderInfoContainerView.isHidden = !newValue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var showEncryptionStatus: Bool {
|
|
|
|
get {
|
|
|
|
return !self.encryptionStatusContainerView.isHidden
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
self.encryptionStatusContainerView.isHidden = !newValue
|
2020-01-14 19:02:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-20 09:39:22 +00:00
|
|
|
// MARK: - Setup
|
|
|
|
|
2020-01-14 19:02:34 +00:00
|
|
|
class func instantiate() -> BubbleCellContentView {
|
|
|
|
return BubbleCellContentView.loadFromNib()
|
2019-12-20 09:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - Public
|
|
|
|
|
|
|
|
func update(theme: Theme) {
|
|
|
|
self.backgroundColor = theme.backgroundColor
|
2020-01-14 19:02:34 +00:00
|
|
|
self.paginationLabel.textColor = theme.tintColor
|
|
|
|
self.paginationSeparatorView.backgroundColor = theme.tintColor
|
2019-12-20 09:39:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - BubbleCellReadReceiptsDisplayable
|
2020-01-14 19:02:34 +00:00
|
|
|
extension BubbleCellContentView: BubbleCellReadReceiptsDisplayable {
|
2019-12-20 09:39:22 +00:00
|
|
|
|
|
|
|
func addReadReceiptsView(_ readReceiptsView: UIView) {
|
|
|
|
self.readReceiptsContentView.vc_removeAllSubviews()
|
|
|
|
self.readReceiptsContentView.vc_addSubViewMatchingParent(readReceiptsView)
|
|
|
|
self.showReadReceipts = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func removeReadReceiptsView() {
|
|
|
|
self.showReadReceipts = false
|
|
|
|
self.readReceiptsContentView.vc_removeAllSubviews()
|
|
|
|
}
|
|
|
|
}
|
2020-07-31 16:26:09 +00:00
|
|
|
|
|
|
|
// MARK: - BubbleCellReactionsDisplayable
|
|
|
|
extension BubbleCellContentView: BubbleCellReactionsDisplayable {
|
|
|
|
|
|
|
|
func addReactionsView(_ reactionsView: UIView) {
|
|
|
|
self.reactionsContentView.vc_removeAllSubviews()
|
|
|
|
self.reactionsContentView.vc_addSubViewMatchingParent(reactionsView)
|
|
|
|
self.showReactions = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func removeReactionsView() {
|
|
|
|
self.showReactions = false
|
|
|
|
self.reactionsContentView.vc_removeAllSubviews()
|
|
|
|
}
|
|
|
|
}
|