@@ -24,7 +24,6 @@ open class SBUBaseMessageCell: UITableViewCell {
24
24
} ( )
25
25
26
26
public lazy var dateView : UIView = MessageDateView ( )
27
-
28
27
29
28
// MARK: - Private
30
29
var theme : SBUMessageCellTheme = SBUTheme . messageCellTheme
@@ -69,7 +68,8 @@ open class SBUBaseMessageCell: UITableViewCell {
69
68
/// This function handles the initialization of autolayouts.
70
69
open func setupAutolayout( ) {
71
70
self . stackView
72
- . setConstraint ( from: self . contentView, left: 0 , right: 0 , top: 16 , bottom: 0 )
71
+ . setConstraint ( from: self . contentView, left: 0 , top: 16 , bottom: 0 )
72
+ . setConstraint ( from: self . contentView, right: 0 , priority: . defaultHigh)
73
73
}
74
74
75
75
/// This function handles the initialization of styles.
@@ -112,6 +112,9 @@ open class SBUBaseMessageCell: UITableViewCell {
112
112
var tapHandlerToProfileImage : ( ( ) -> Void ) ? = nil
113
113
var tapHandlerToContent : ( ( ) -> Void ) ? = nil
114
114
var longPressHandlerToContent : ( ( ) -> Void ) ? = nil
115
+ var emojiTapHandler : ( ( _ emojiKey: String ) -> Void ) ? = nil
116
+ var moreEmojiTapHandler : ( ( ) -> Void ) ? = nil
117
+ var emojiLongPressHandler : ( ( _ emojiKey: String ) -> Void ) ? = nil
115
118
}
116
119
117
120
@@ -213,12 +216,9 @@ public class MessageProfileView: UIView {
213
216
}
214
217
215
218
func setupAutolayout( ) {
216
- let width = leftSpace + imageSize + rightSpace
217
- self . setConstraint ( width: width, height: imageSize)
218
-
219
219
self . imageView
220
220
. setConstraint ( width: imageSize, height: imageSize)
221
- . setConstraint ( from: self , centerX : true , centerY : true )
221
+ . setConstraint ( from: self , left : leftSpace , right : rightSpace , top : 0 , bottom : 0 )
222
222
}
223
223
224
224
func setupStyles( ) {
@@ -288,19 +288,15 @@ public class UserNameView: UIView {
288
288
self . backgroundColor = . clear
289
289
290
290
self . button. titleLabel? . font = theme. userNameFont
291
+ self . button. contentHorizontalAlignment = . left
291
292
self . button. setTitleColor ( theme. userNameTextColor, for: . normal)
292
293
}
293
-
294
- public override func layoutSubviews( ) {
295
- super. layoutSubviews ( )
296
-
297
- self . setupStyles ( )
298
- }
299
-
294
+
300
295
func configure( username: String ) {
301
296
self . username = username
302
297
self . button. setTitle ( username, for: . normal)
303
298
self . button. sizeToFit ( )
299
+ self . setupStyles ( )
304
300
self . setNeedsLayout ( )
305
301
}
306
302
}
@@ -444,3 +440,66 @@ public class MessageStateView: UIView {
444
440
self . updateConstraints ( )
445
441
}
446
442
}
443
+
444
+ class MessageDetailContainerView : UIView {
445
+
446
+ var isSelected : Bool = false
447
+ var position : MessagePosition = . left
448
+
449
+ let stackView : UIStackView = {
450
+ let stackView = UIStackView ( )
451
+ stackView. axis = . vertical
452
+ return stackView
453
+ } ( )
454
+
455
+ override init ( frame: CGRect ) {
456
+ super. init ( frame: frame)
457
+ self . setupViews ( )
458
+ self . setupAutolayout ( )
459
+ self . setupStyles ( )
460
+ }
461
+
462
+ @available ( * , unavailable, renamed: " MessageContentDetailView() " )
463
+ required init ? ( coder: NSCoder ) {
464
+ super. init ( coder: coder)
465
+ }
466
+
467
+ func setupViews( ) {
468
+ self . addSubview ( self . stackView)
469
+ }
470
+
471
+ func setupAutolayout( ) {
472
+ self . stackView. setConstraint ( from: self , left: 0 , right: 0 , top: 0 , bottom: 0 )
473
+ }
474
+
475
+ func setupStyles( ) {
476
+ self . layer. cornerRadius = 16
477
+ self . layer. borderColor = UIColor . clear. cgColor
478
+ self . layer. borderWidth = 1
479
+ self . clipsToBounds = true
480
+ self . setBackgroundColor ( )
481
+ }
482
+
483
+ func setBackgroundColor( ) {
484
+
485
+ let theme = SBUTheme . messageCellTheme
486
+
487
+ switch self . position {
488
+ case . left:
489
+ self . backgroundColor = self . isSelected ? theme. leftPressedBackgroundColor : theme. leftBackgroundColor
490
+ case . right:
491
+ self . backgroundColor = self . isSelected ? theme. rightPressedBackgroundColor : theme. rightBackgroundColor
492
+ case . center:
493
+ break
494
+ }
495
+
496
+ }
497
+
498
+ func configure( position: MessagePosition , isSelected: Bool ) {
499
+ self . position = position
500
+ self . isSelected = isSelected
501
+
502
+ self . setBackgroundColor ( )
503
+ self . setNeedsLayout ( )
504
+ }
505
+ }
0 commit comments