Fact check improvements

This commit is contained in:
Ilya Laktyushin
2024-05-20 17:30:54 +04:00
parent abe1e40e2a
commit 21898f4207
9 changed files with 343 additions and 45 deletions

View File

@@ -124,6 +124,7 @@ public final class TextFieldComponent: Component {
public let externalState: ExternalState
public let fontSize: CGFloat
public let textColor: UIColor
public let accentColor: UIColor
public let insets: UIEdgeInsets
public let hideKeyboard: Bool
public let customInputView: UIView?
@@ -147,6 +148,7 @@ public final class TextFieldComponent: Component {
externalState: ExternalState,
fontSize: CGFloat,
textColor: UIColor,
accentColor: UIColor,
insets: UIEdgeInsets,
hideKeyboard: Bool,
customInputView: UIView?,
@@ -169,6 +171,7 @@ public final class TextFieldComponent: Component {
self.externalState = externalState
self.fontSize = fontSize
self.textColor = textColor
self.accentColor = accentColor
self.insets = insets
self.hideKeyboard = hideKeyboard
self.customInputView = customInputView
@@ -205,6 +208,9 @@ public final class TextFieldComponent: Component {
if lhs.textColor != rhs.textColor {
return false
}
if lhs.accentColor != rhs.accentColor {
return false
}
if lhs.insets != rhs.insets {
return false
}
@@ -308,13 +314,13 @@ public final class TextFieldComponent: Component {
let inputState = f(self.inputState)
let currentAttributedText = self.textView.attributedText
let updatedAttributedText = textAttributedStringForStateText(inputState.inputText, fontSize: component.fontSize, textColor: component.textColor, accentTextColor: component.textColor, writingDirection: nil, spoilersRevealed: self.spoilersRevealed, availableEmojis: Set(component.context.animatedEmojiStickersValue.keys), emojiViewProvider: self.emojiViewProvider)
let updatedAttributedText = textAttributedStringForStateText(inputState.inputText, fontSize: component.fontSize, textColor: component.textColor, accentTextColor: component.accentColor, writingDirection: nil, spoilersRevealed: self.spoilersRevealed, availableEmojis: Set(component.context.animatedEmojiStickersValue.keys), emojiViewProvider: self.emojiViewProvider)
if currentAttributedText != updatedAttributedText {
self.textView.attributedText = updatedAttributedText
}
self.textView.selectedRange = NSMakeRange(inputState.selectionRange.lowerBound, inputState.selectionRange.count)
refreshChatTextInputAttributes(textView: self.textView, primaryTextColor: component.textColor, accentTextColor: component.textColor, baseFontSize: component.fontSize, spoilersRevealed: self.spoilersRevealed, availableEmojis: Set(component.context.animatedEmojiStickersValue.keys), emojiViewProvider: self.emojiViewProvider)
refreshChatTextInputAttributes(textView: self.textView, primaryTextColor: component.textColor, accentTextColor: component.accentColor, baseFontSize: component.fontSize, spoilersRevealed: self.spoilersRevealed, availableEmojis: Set(component.context.animatedEmojiStickersValue.keys), emojiViewProvider: self.emojiViewProvider)
self.updateEntities()
@@ -446,7 +452,7 @@ public final class TextFieldComponent: Component {
guard let component = self.component else {
return
}
refreshChatTextInputAttributes(textView: self.textView, primaryTextColor: component.textColor, accentTextColor: component.textColor, baseFontSize: component.fontSize, spoilersRevealed: self.spoilersRevealed, availableEmojis: Set(component.context.animatedEmojiStickersValue.keys), emojiViewProvider: self.emojiViewProvider)
refreshChatTextInputAttributes(textView: self.textView, primaryTextColor: component.textColor, accentTextColor: component.accentColor, baseFontSize: component.fontSize, spoilersRevealed: self.spoilersRevealed, availableEmojis: Set(component.context.animatedEmojiStickersValue.keys), emojiViewProvider: self.emojiViewProvider)
refreshChatTextInputTypingAttributes(self.textView, textColor: component.textColor, baseFontSize: component.fontSize)
self.textView.updateTextContainerInset()
@@ -951,7 +957,7 @@ public final class TextFieldComponent: Component {
self.textView.isScrollEnabled = false
refreshChatTextInputAttributes(textView: self.textView, primaryTextColor: component.textColor, accentTextColor: component.textColor, baseFontSize: component.fontSize, spoilersRevealed: self.spoilersRevealed, availableEmojis: Set(component.context.animatedEmojiStickersValue.keys), emojiViewProvider: self.emojiViewProvider)
refreshChatTextInputAttributes(textView: self.textView, primaryTextColor: component.textColor, accentTextColor: component.accentColor, baseFontSize: component.fontSize, spoilersRevealed: self.spoilersRevealed, availableEmojis: Set(component.context.animatedEmojiStickersValue.keys), emojiViewProvider: self.emojiViewProvider)
refreshChatTextInputTypingAttributes(self.textView, textColor: component.textColor, baseFontSize: component.fontSize)
if self.textView.subviews.count > 1, animated {