@@ -30,6 +30,8 @@ class ChatAccessoryView : Button {
30
30
31
31
private weak var model : ChatAccessoryModel ?
32
32
33
+ private let backgroundView = SimpleLayer ( )
34
+
33
35
private var quoteView : ImageView ?
34
36
35
37
private let borderLayer = DashLayer ( )
@@ -43,7 +45,7 @@ class ChatAccessoryView : Button {
43
45
headerView. isSelectable = false
44
46
addSubview ( headerView)
45
47
46
-
48
+ self . layer ? . addSublayer ( backgroundView )
47
49
self . layer? . addSublayer ( borderLayer)
48
50
49
51
}
@@ -69,13 +71,13 @@ class ChatAccessoryView : Button {
69
71
70
72
71
73
72
- let x : CGFloat = model. leftInset + ( model. isSideAccessory ? 10 : 0 )
74
+ let x : CGFloat = model. leftInset// + (model.isSideAccessory ? 10 : 0)
73
75
74
- let headerRect = CGRect ( origin: NSMakePoint ( x + model. mediaInset, ( model . isSideAccessory ? 5 : 0 ) + model. topOffset + 2 ) , size: headerView. frame. size)
76
+ let headerRect = CGRect ( origin: NSMakePoint ( x + model. mediaInset, model. topOffset + 2 ) , size: headerView. frame. size)
75
77
transition. updateFrame ( view: headerView, frame: headerRect)
76
78
77
79
if let textView = textView {
78
- let textRect = CGRect ( origin: NSMakePoint ( x, headerRect. height + ( model . isSideAccessory ? 5 : 0 ) + model. topOffset + 2 ) , size: textView. frame. size)
80
+ let textRect = CGRect ( origin: NSMakePoint ( x, headerRect. height + model. topOffset + 2 ) , size: textView. frame. size)
79
81
transition. updateFrame ( view: textView, frame: textRect)
80
82
if let view = shimmerEffect {
81
83
let rect = CGRect ( origin: textRect. origin, size: view. frame. size)
@@ -86,16 +88,16 @@ class ChatAccessoryView : Button {
86
88
if let quoteView = quoteView {
87
89
transition. updateFrame ( view: quoteView, frame: NSMakeRect ( size. width - quoteView. frame. width - 2 , 2 , quoteView. frame. width, quoteView. frame. height) )
88
90
}
91
+ transition. updateFrame ( layer: backgroundView, frame: size. bounds)
89
92
90
93
}
91
94
92
95
func updateModel( _ model: ChatAccessoryModel , animated: Bool ) {
93
96
self . model = model
94
- self . backgroundColor = model. presentation. background
95
97
96
98
var cornerRadius : CGFloat = 0
97
99
if model. modelType == . modern {
98
- cornerRadius = 4
100
+ cornerRadius = . cornerRadius
99
101
} else {
100
102
if model. isSideAccessory {
101
103
cornerRadius = . cornerRadius
@@ -120,9 +122,9 @@ class ChatAccessoryView : Button {
120
122
x = 0
121
123
height = model. size. height
122
124
case . classic:
123
- x = model . isSideAccessory ? 10 : 0
124
- y = model. isSideAccessory ? 5 : 0 + model . topOffset
125
- height = model. size. height - model. topOffset - ( model . isSideAccessory ? 10 : 0 )
125
+ x = 0
126
+ y = model. topOffset
127
+ height = model. size. height - model. topOffset
126
128
cornerRadius = width / 2
127
129
}
128
130
@@ -319,9 +321,14 @@ class ChatAccessoryView : Button {
319
321
if let model = model {
320
322
switch model. modelType {
321
323
case . modern:
322
- self . backgroundColor = model. presentation. colors. main. withAlphaComponent ( 0.1 )
324
+ self . backgroundView . backgroundColor = model. presentation. colors. main. withAlphaComponent ( 0.1 ) . cgColor
323
325
case . classic:
326
+ self . backgroundView. backgroundColor = model. presentation. background. cgColor
327
+ }
328
+ if model. isSideAccessory {
324
329
self . backgroundColor = model. presentation. background
330
+ } else {
331
+ self . backgroundColor = . clear
325
332
}
326
333
}
327
334
}
@@ -449,10 +456,6 @@ class ChatAccessoryModel: NSObject {
449
456
}
450
457
451
458
var modelType : ModelType {
452
- if isSideAccessory {
453
- return . classic
454
- }
455
-
456
459
return . modern
457
460
}
458
461
@@ -593,18 +596,15 @@ class ChatAccessoryModel: NSObject {
593
596
self . sizeToFit = sizeToFit
594
597
595
598
header? . measure ( width: width - leftInset - rightInset - ( quoteIcon != nil ? 12 : 0 ) )
596
- message? . measure ( width: width - leftInset - rightInset)
599
+ message? . measure ( width: width - leftInset - rightInset - 30 )
597
600
598
601
if let header = header, let message = message {
599
602
var model_w = max ( header. layoutSize. width + mediaInset, message. layoutSize. width) + leftInset + rightInset
600
- if isSideAccessory {
601
- model_w += 20
602
- }
603
603
if quoteIcon != nil {
604
604
model_w += 12
605
605
}
606
606
let width = sizeToFit ? model_w : width
607
- let height = max ( 38 , header. layoutSize. height + message. layoutSize. height + yInset * 2 + ( isSideAccessory ? 10 : 0 ) )
607
+ let height = max ( 38 , header. layoutSize. height + message. layoutSize. height + yInset * 2 )
608
608
self . size = NSMakeSize ( width, height)
609
609
self . size. height += topOffset
610
610
} else {
0 commit comments