mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Various improvements
This commit is contained in:
@@ -262,13 +262,16 @@ final class CameraLiveStreamComponent: Component {
|
||||
public final class StreamAsComponent: Component {
|
||||
let context: AccountContext
|
||||
let peerId: EnginePeer.Id
|
||||
let isCustomTarget: Bool
|
||||
|
||||
public init(
|
||||
context: AccountContext,
|
||||
peerId: EnginePeer.Id
|
||||
peerId: EnginePeer.Id,
|
||||
isCustomTarget: Bool
|
||||
) {
|
||||
self.context = context
|
||||
self.peerId = peerId
|
||||
self.isCustomTarget = isCustomTarget
|
||||
}
|
||||
|
||||
public static func ==(lhs: StreamAsComponent, rhs: StreamAsComponent) -> Bool {
|
||||
@@ -278,6 +281,9 @@ public final class StreamAsComponent: Component {
|
||||
if lhs.peerId != rhs.peerId {
|
||||
return false
|
||||
}
|
||||
if lhs.isCustomTarget != rhs.isCustomTarget {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -321,7 +327,8 @@ public final class StreamAsComponent: Component {
|
||||
})
|
||||
}
|
||||
|
||||
self.avatarNode.frame = CGRect(origin: .zero, size: CGSize(width: 32.0, height: 32.0))
|
||||
let avatarSize = CGSize(width: 32.0, height: 32.0)
|
||||
self.avatarNode.frame = CGRect(origin: .zero, size: avatarSize)
|
||||
if let peer = self.peer {
|
||||
self.avatarNode.setPeer(
|
||||
context: component.context,
|
||||
@@ -341,7 +348,7 @@ public final class StreamAsComponent: Component {
|
||||
environment: {},
|
||||
containerSize: CGSize(width: availableSize.width - 38.0, height: availableSize.height)
|
||||
)
|
||||
let titleFrame = CGRect(origin: CGPoint(x: 42.0, y: 1.0), size: titleSize)
|
||||
let titleFrame = CGRect(origin: CGPoint(x: 42.0, y: component.isCustomTarget ? floorToScreenPixels((avatarSize.height - titleSize.height) / 2.0) : 1.0), size: titleSize)
|
||||
if let titleView = self.title.view {
|
||||
if titleView.superview == nil {
|
||||
self.addSubview(titleView)
|
||||
@@ -349,29 +356,34 @@ public final class StreamAsComponent: Component {
|
||||
titleView.frame = titleFrame
|
||||
}
|
||||
|
||||
let subtitleSize = self.subtitle.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(
|
||||
MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(string: "change", font: Font.regular(11.0), textColor: UIColor(white: 1.0, alpha: 0.8), paragraphAlignment: .left))
|
||||
)
|
||||
),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: availableSize.width - 50.0, height: availableSize.height)
|
||||
)
|
||||
let subtitleFrame = CGRect(origin: CGPoint(x: 42.0, y: titleFrame.maxY + 2.0), size: subtitleSize)
|
||||
if let subtitleView = self.subtitle.view {
|
||||
if subtitleView.superview == nil {
|
||||
self.addSubview(subtitleView)
|
||||
var maxWidth = titleFrame.maxX
|
||||
if !component.isCustomTarget {
|
||||
//TODO:localize
|
||||
let subtitleSize = self.subtitle.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(
|
||||
MultilineTextComponent(
|
||||
text: .plain(NSAttributedString(string: "change", font: Font.regular(11.0), textColor: UIColor(white: 1.0, alpha: 0.8), paragraphAlignment: .left))
|
||||
)
|
||||
),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: availableSize.width - 50.0, height: availableSize.height)
|
||||
)
|
||||
let subtitleFrame = CGRect(origin: CGPoint(x: 42.0, y: titleFrame.maxY + 2.0), size: subtitleSize)
|
||||
if let subtitleView = self.subtitle.view {
|
||||
if subtitleView.superview == nil {
|
||||
self.addSubview(subtitleView)
|
||||
}
|
||||
subtitleView.frame = subtitleFrame
|
||||
}
|
||||
subtitleView.frame = subtitleFrame
|
||||
|
||||
if let icon = self.arrow.image {
|
||||
self.arrow.frame = CGRect(origin: CGPoint(x: subtitleFrame.maxX + 1.0, y: floorToScreenPixels(subtitleFrame.midY - icon.size.height / 2.0) + 1.0), size: icon.size).insetBy(dx: 1.0, dy: 1.0)
|
||||
}
|
||||
maxWidth = max(maxWidth, subtitleFrame.maxX + 16.0)
|
||||
}
|
||||
|
||||
if let icon = self.arrow.image {
|
||||
self.arrow.frame = CGRect(origin: CGPoint(x: subtitleFrame.maxX + 1.0, y: floorToScreenPixels(subtitleFrame.midY - icon.size.height / 2.0) + 1.0), size: icon.size).insetBy(dx: 1.0, dy: 1.0)
|
||||
}
|
||||
|
||||
return CGSize(width: max(titleFrame.maxX, subtitleFrame.maxX + 16.0), height: 32.0)
|
||||
return CGSize(width: maxWidth, height: avatarSize.height)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user