Various fixes

This commit is contained in:
Ilya Laktyushin
2023-07-11 06:48:28 +02:00
parent 0d69b86b92
commit 5ad9671d70
13 changed files with 820 additions and 378 deletions

View File

@@ -240,7 +240,7 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
if !hasArrow {
let backgroundColor: UIColor
var enableSaturation = true
if case let .customBlur(color) = style {
if case let .customBlur(color, _) = style {
backgroundColor = color
enableSaturation = false
} else {
@@ -297,7 +297,7 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
} else {
var enableSaturation = true
let backgroundColor: UIColor
if case let .customBlur(color) = style {
if case let .customBlur(color, _) = style {
backgroundColor = color
enableSaturation = false
} else if case .light = style {
@@ -356,10 +356,11 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
case let .entities(text, entities):
attributedText = stringWithAppliedEntities(text, entities: entities, baseColor: textColor, linkColor: textColor, baseFont: baseFont, linkFont: baseFont, boldFont: boldFont, italicFont: italicFont, boldItalicFont: boldItalicFont, fixedFont: fixedFont, blockQuoteFont: baseFont, underlineLinks: true, external: false, message: nil)
case let .markdown(text):
let linkColor = UIColor(rgb: 0x64d2ff)
let markdownAttributes = MarkdownAttributes(
body: MarkdownAttributeSet(font: baseFont, textColor: textColor),
bold: MarkdownAttributeSet(font: boldFont, textColor: textColor),
link: MarkdownAttributeSet(font: baseFont, textColor: textColor),
link: MarkdownAttributeSet(font: boldFont, textColor: linkColor),
linkAttribute: { _ in
return nil
}
@@ -560,14 +561,16 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
var backgroundHeight: CGFloat
switch self.tooltipStyle {
case .default, .gradient, .customBlur, .wide:
case .default, .gradient:
backgroundHeight = max(animationSize.height, textSize.height) + contentVerticalInset * 2.0
case .wide:
backgroundHeight = max(animationSize.height, textSize.height) + contentVerticalInset * 2.0 + 4.0
case let .customBlur(_, inset):
backgroundHeight = max(animationSize.height, textSize.height) + contentVerticalInset * 2.0 + inset * 2.0
case .light:
backgroundHeight = max(28.0, max(animationSize.height, textSize.height) + 4.0 * 2.0)
}
if case .wide = self.tooltipStyle {
backgroundHeight += 4.0
} else if self.actionButtonNode != nil {
if self.actionButtonNode != nil {
backgroundHeight += 4.0
}
@@ -739,6 +742,7 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
}
}
private var didRequestDismiss = false
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
if let event = event {
if let _ = self.openActiveTextItem, let result = self.textNode.hitTest(self.view.convert(point, to: self.textNode.view), with: event) {
@@ -753,14 +757,19 @@ private final class TooltipScreenNode: ViewControllerTracingNode {
if let actionButtonNode = self.actionButtonNode, let result = actionButtonNode.hitTest(self.convert(point, to: actionButtonNode), with: event) {
return result
}
switch self.shouldDismissOnTouch(point, self.containerNode.frame) {
case .ignore:
break
case let .dismiss(consume):
self.requestDismiss()
if consume {
return self.view
if !self.didRequestDismiss {
switch self.shouldDismissOnTouch(point, self.containerNode.frame) {
case .ignore:
break
case let .dismiss(consume):
self.requestDismiss()
if consume {
self.didRequestDismiss = true
return self.view
}
}
} else {
return self.view
}
return nil
}
@@ -915,7 +924,7 @@ public final class TooltipScreen: ViewController {
public enum Style {
case `default`
case light
case customBlur(UIColor)
case customBlur(UIColor, CGFloat)
case gradient(UIColor, UIColor)
case wide
}