Skip to content

Commit 0d4dc2a

Browse files
author
Isaac
committed
Roll back call text views
1 parent a188094 commit 0d4dc2a

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

submodules/TelegramUI/Components/Calls/CallScreen/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ swift_library(
7070
"//submodules/AppBundle",
7171
"//submodules/UIKitRuntimeUtils",
7272
"//submodules/TelegramPresentationData",
73-
"//submodules/Components/MultilineTextComponent",
7473
],
7574
visibility = [
7675
"//visibility:public",

submodules/TelegramUI/Components/Calls/CallScreen/Sources/Components/TitleView.swift

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Foundation
22
import UIKit
33
import ComponentFlow
4-
import MultilineTextComponent
54

65
final class TextView: UIView {
76
private struct Params: Equatable {
@@ -22,8 +21,6 @@ final class TextView: UIView {
2221
private var layoutState: LayoutState?
2322
private var animateContentsTransition: Bool = false
2423

25-
private let content = ComponentView<Empty>()
26-
2724
override init(frame: CGRect) {
2825
super.init(frame: CGRect())
2926

@@ -59,25 +56,17 @@ final class TextView: UIView {
5956
font = UIFont.systemFont(ofSize: fontSize, weight: UIFont.Weight(fontWeight))
6057
}
6158

59+
let paragraphStyle = NSMutableParagraphStyle()
60+
paragraphStyle.alignment = alignment
61+
paragraphStyle.lineSpacing = 0.6
6262
let attributedString = NSAttributedString(string: string, attributes: [
6363
.font: font,
6464
.foregroundColor: color,
65+
.paragraphStyle: paragraphStyle
6566
])
66-
67-
let contentSize = self.content.update(
68-
transition: .immediate,
69-
component: AnyComponent(MultilineTextComponent(
70-
text: .plain(attributedString),
71-
horizontalAlignment: alignment
72-
)),
73-
environment: {},
74-
containerSize: CGSize(width: constrainedWidth, height: 1000.0)
75-
)
76-
if let contentView = self.content.view {
77-
contentView.frame = CGRect(origin: CGPoint(), size: contentSize)
78-
}
79-
80-
let size = CGSize(width: min(constrainedWidth, contentSize.width), height: contentSize.height)
67+
let stringBounds = attributedString.boundingRect(with: CGSize(width: constrainedWidth, height: 200.0), options: .usesLineFragmentOrigin, context: nil)
68+
let stringSize = CGSize(width: ceil(stringBounds.width), height: ceil(stringBounds.height))
69+
let size = CGSize(width: min(constrainedWidth, stringSize.width), height: stringSize.height)
8170

8271
let layoutState = LayoutState(params: params, size: size, attributedString: attributedString)
8372
if self.layoutState != layoutState {
@@ -90,12 +79,10 @@ final class TextView: UIView {
9079
}
9180

9281
override func draw(_ rect: CGRect) {
93-
guard let _ = self.layoutState else {
82+
guard let layoutState = self.layoutState else {
9483
return
9584
}
9685

97-
if let contentView = self.content.view {
98-
contentView.draw(contentView.bounds)
99-
}
86+
layoutState.attributedString.draw(with: rect, options: [.truncatesLastVisibleLine, .usesLineFragmentOrigin], context: nil)
10087
}
10188
}

0 commit comments

Comments
 (0)