mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Roll back call text views
This commit is contained in:
parent
a1880941e9
commit
0d4dc2a7c7
@ -70,7 +70,6 @@ swift_library(
|
||||
"//submodules/AppBundle",
|
||||
"//submodules/UIKitRuntimeUtils",
|
||||
"//submodules/TelegramPresentationData",
|
||||
"//submodules/Components/MultilineTextComponent",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -1,7 +1,6 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import ComponentFlow
|
||||
import MultilineTextComponent
|
||||
|
||||
final class TextView: UIView {
|
||||
private struct Params: Equatable {
|
||||
@ -22,8 +21,6 @@ final class TextView: UIView {
|
||||
private var layoutState: LayoutState?
|
||||
private var animateContentsTransition: Bool = false
|
||||
|
||||
private let content = ComponentView<Empty>()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: CGRect())
|
||||
|
||||
@ -59,25 +56,17 @@ final class TextView: UIView {
|
||||
font = UIFont.systemFont(ofSize: fontSize, weight: UIFont.Weight(fontWeight))
|
||||
}
|
||||
|
||||
let paragraphStyle = NSMutableParagraphStyle()
|
||||
paragraphStyle.alignment = alignment
|
||||
paragraphStyle.lineSpacing = 0.6
|
||||
let attributedString = NSAttributedString(string: string, attributes: [
|
||||
.font: font,
|
||||
.foregroundColor: color,
|
||||
.paragraphStyle: paragraphStyle
|
||||
])
|
||||
|
||||
let contentSize = self.content.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(MultilineTextComponent(
|
||||
text: .plain(attributedString),
|
||||
horizontalAlignment: alignment
|
||||
)),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: constrainedWidth, height: 1000.0)
|
||||
)
|
||||
if let contentView = self.content.view {
|
||||
contentView.frame = CGRect(origin: CGPoint(), size: contentSize)
|
||||
}
|
||||
|
||||
let size = CGSize(width: min(constrainedWidth, contentSize.width), height: contentSize.height)
|
||||
let stringBounds = attributedString.boundingRect(with: CGSize(width: constrainedWidth, height: 200.0), options: .usesLineFragmentOrigin, context: nil)
|
||||
let stringSize = CGSize(width: ceil(stringBounds.width), height: ceil(stringBounds.height))
|
||||
let size = CGSize(width: min(constrainedWidth, stringSize.width), height: stringSize.height)
|
||||
|
||||
let layoutState = LayoutState(params: params, size: size, attributedString: attributedString)
|
||||
if self.layoutState != layoutState {
|
||||
@ -90,12 +79,10 @@ final class TextView: UIView {
|
||||
}
|
||||
|
||||
override func draw(_ rect: CGRect) {
|
||||
guard let _ = self.layoutState else {
|
||||
guard let layoutState = self.layoutState else {
|
||||
return
|
||||
}
|
||||
|
||||
if let contentView = self.content.view {
|
||||
contentView.draw(contentView.bounds)
|
||||
}
|
||||
layoutState.attributedString.draw(with: rect, options: [.truncatesLastVisibleLine, .usesLineFragmentOrigin], context: nil)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user