@@ -93,7 +93,7 @@ class UIMessageView: UIView {
93
93
}
94
94
95
95
private var bubbleColor : UIColor {
96
- outgoing ? ColorManager . shared. selectedColor : UIColor . systemGray5 . withAlphaComponent ( 0.5 )
96
+ outgoing ? ColorManager . shared. selectedColor : ColorManager . shared . secondaryColor
97
97
}
98
98
99
99
private var textColor : UIColor {
@@ -114,7 +114,7 @@ class UIMessageView: UIView {
114
114
}
115
115
116
116
guard let text = message. text else { return false }
117
- return text. count > 24 || text. contains ( " \n " ) || !fullMessage. reactions. isEmpty
117
+ return text. count > 24 || text. contains ( " \n " ) || !fullMessage. reactions. isEmpty || text . containsEmoji
118
118
}
119
119
120
120
private let labelVerticalPadding : CGFloat = 9.0
@@ -333,8 +333,11 @@ class UIMessageView: UIView {
333
333
var items : [ String ] = [ ]
334
334
let nsString = message as NSString
335
335
336
- regex. enumerateMatches ( in: message, options: [ ] , range: NSRange ( location: 0 , length: message. utf16. count) ) { match, _, _ in
337
- guard let match = match, match. numberOfRanges > 1 else { return }
336
+ regex. enumerateMatches ( in: message, options: [ ] , range: NSRange (
337
+ location: 0 ,
338
+ length: message. utf16. count
339
+ ) ) { match, _, _ in
340
+ guard let match, match. numberOfRanges > 1 else { return }
338
341
339
342
let contentRange = match. range ( at: 1 )
340
343
if contentRange. location != NSNotFound {
@@ -553,3 +556,22 @@ extension NSLayoutConstraint {
553
556
return self
554
557
}
555
558
}
559
+
560
+ extension Character {
561
+ /// A simple emoji is one scalar and presented to the user as an Emoji
562
+ var isSimpleEmoji : Bool {
563
+ guard let firstScalar = unicodeScalars. first else { return false }
564
+ return firstScalar. properties. isEmoji && firstScalar. value > 0x238C
565
+ }
566
+
567
+ /// Checks if the scalars will be merged into an emoji
568
+ var isCombinedIntoEmoji : Bool { unicodeScalars. count > 1 && unicodeScalars. first? . properties. isEmoji ?? false }
569
+
570
+ var isEmoji : Bool { isSimpleEmoji || isCombinedIntoEmoji }
571
+ }
572
+
573
+ extension String {
574
+ var containsEmoji : Bool {
575
+ contains { $0. isEmoji }
576
+ }
577
+ }
0 commit comments