Implement code highlight colors

This commit is contained in:
Ali
2023-11-02 20:19:24 +04:00
parent 6bddf8ac47
commit 5ab45be3c7
11 changed files with 141 additions and 55 deletions

View File

@@ -278,15 +278,21 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
public let background: UIColor
public let foreground: UIColor
public let lineStyle: LineStyle
public let codeBackground: UIColor
public let codeForeground: UIColor
public init(
background: UIColor,
foreground: UIColor,
lineStyle: LineStyle
lineStyle: LineStyle,
codeBackground: UIColor,
codeForeground: UIColor
) {
self.background = background
self.foreground = foreground
self.lineStyle = lineStyle
self.codeBackground = codeBackground
self.codeForeground = codeForeground
}
public static func ==(lhs: Quote, rhs: Quote) -> Bool {
@@ -299,6 +305,12 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
if lhs.lineStyle != rhs.lineStyle {
return false
}
if !lhs.codeBackground.isEqual(rhs.codeBackground) {
return false
}
if !lhs.codeForeground.isEqual(rhs.codeForeground) {
return false
}
return true
}
}
@@ -830,6 +842,7 @@ private final class QuoteBackgroundView: UIView {
var primaryColor: UIColor
var secondaryColor: UIColor?
var tertiaryColor: UIColor?
let backgroundColor: UIColor?
switch value.kind {
case .quote:
@@ -846,10 +859,13 @@ private final class QuoteBackgroundView: UIView {
secondaryColor = secondaryColorValue
tertiaryColor = tertiaryColorValue
}
backgroundColor = nil
case .code:
self.iconView.isHidden = true
primaryColor = .gray
primaryColor = theme.codeForeground
backgroundColor = theme.codeBackground
}
self.backgroundView.update(
@@ -858,6 +874,7 @@ private final class QuoteBackgroundView: UIView {
primaryColor: primaryColor,
secondaryColor: secondaryColor,
thirdColor: tertiaryColor,
backgroundColor: backgroundColor,
pattern: nil,
animation: .None
)