diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/BUILD b/submodules/TelegramUI/Components/Calls/CallScreen/BUILD index 3b5094fe29..62764fd205 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/BUILD +++ b/submodules/TelegramUI/Components/Calls/CallScreen/BUILD @@ -70,7 +70,6 @@ swift_library( "//submodules/AppBundle", "//submodules/UIKitRuntimeUtils", "//submodules/TelegramPresentationData", - "//submodules/Components/MultilineTextComponent", ], visibility = [ "//visibility:public", diff --git a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/TitleView.swift b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/TitleView.swift index 157bfccf7c..9d94c24a1d 100644 --- a/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/TitleView.swift +++ b/submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/TitleView.swift @@ -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() - 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) } }