mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Various fixes
This commit is contained in:
@@ -172,6 +172,7 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
public let titleRightIconNode: ASImageNode
|
||||
public let titleCredibilityIconView: ComponentHostView<Empty>
|
||||
public let titleVerifiedIconView: ComponentHostView<Empty>
|
||||
public let titleStatusIconView: ComponentHostView<Empty>
|
||||
public let activityNode: ChatTitleActivityNode
|
||||
|
||||
private let button: HighlightTrackingButtonNode
|
||||
@@ -185,6 +186,7 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
private var titleRightIcon: ChatTitleIcon = .none
|
||||
private var titleCredibilityIcon: ChatTitleCredibilityIcon = .none
|
||||
private var titleVerifiedIcon: ChatTitleCredibilityIcon = .none
|
||||
private var titleStatusIcon: ChatTitleCredibilityIcon = .none
|
||||
|
||||
private var presenceManager: PeerPresenceStatusManager?
|
||||
|
||||
@@ -232,6 +234,7 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
var titleRightIcon: ChatTitleIcon = .none
|
||||
var titleCredibilityIcon: ChatTitleCredibilityIcon = .none
|
||||
var titleVerifiedIcon: ChatTitleCredibilityIcon = .none
|
||||
var titleStatusIcon: ChatTitleCredibilityIcon = .none
|
||||
var isEnabled = true
|
||||
switch titleContent {
|
||||
case let .peer(peerView, customTitle, _, isScheduledMessages, isMuted, _, isEnabledValue):
|
||||
@@ -272,15 +275,15 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
} else if peer.isScam {
|
||||
titleCredibilityIcon = .scam
|
||||
} else if let emojiStatus = peer.emojiStatus, !premiumConfiguration.isPremiumDisabled {
|
||||
if peer is TelegramChannel, peer.isVerified {
|
||||
titleVerifiedIcon = .verified
|
||||
}
|
||||
titleCredibilityIcon = .emojiStatus(emojiStatus)
|
||||
} else if peer.isVerified {
|
||||
titleVerifiedIcon = .verified
|
||||
titleStatusIcon = .emojiStatus(emojiStatus)
|
||||
} else if peer.isPremium && !premiumConfiguration.isPremiumDisabled {
|
||||
titleCredibilityIcon = .premium
|
||||
} else if let verificationIconFileId = peer.verificationIconFileId {
|
||||
}
|
||||
|
||||
if peer.isVerified {
|
||||
titleCredibilityIcon = .verified
|
||||
}
|
||||
if let verificationIconFileId = peer.verificationIconFileId {
|
||||
titleVerifiedIcon = .emojiStatus(PeerEmojiStatus(fileId: verificationIconFileId, expirationDate: nil))
|
||||
}
|
||||
}
|
||||
@@ -412,6 +415,11 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
updated = true
|
||||
}
|
||||
|
||||
if titleStatusIcon != self.titleStatusIcon {
|
||||
self.titleStatusIcon = titleStatusIcon
|
||||
updated = true
|
||||
}
|
||||
|
||||
if titleRightIcon != self.titleRightIcon {
|
||||
self.titleRightIcon = titleRightIcon
|
||||
switch titleRightIcon {
|
||||
@@ -720,6 +728,9 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
self.titleVerifiedIconView = ComponentHostView()
|
||||
self.titleVerifiedIconView.isUserInteractionEnabled = false
|
||||
|
||||
self.titleStatusIconView = ComponentHostView()
|
||||
self.titleStatusIconView.isUserInteractionEnabled = false
|
||||
|
||||
self.activityNode = ChatTitleActivityNode()
|
||||
self.button = HighlightTrackingButtonNode()
|
||||
|
||||
@@ -746,6 +757,7 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
strongSelf.activityNode.layer.removeAnimation(forKey: "opacity")
|
||||
strongSelf.titleCredibilityIconView.layer.removeAnimation(forKey: "opacity")
|
||||
strongSelf.titleVerifiedIconView.layer.removeAnimation(forKey: "opacity")
|
||||
strongSelf.titleStatusIconView.layer.removeAnimation(forKey: "opacity")
|
||||
strongSelf.titleTextNode.alpha = 0.4
|
||||
strongSelf.activityNode.alpha = 0.4
|
||||
strongSelf.titleCredibilityIconView.alpha = 0.4
|
||||
@@ -755,6 +767,7 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
strongSelf.activityNode.alpha = 1.0
|
||||
strongSelf.titleCredibilityIconView.alpha = 1.0
|
||||
strongSelf.titleVerifiedIconView.alpha = 1.0
|
||||
strongSelf.titleStatusIconView.alpha = 1.0
|
||||
strongSelf.titleTextNode.layer.animateAlpha(from: 0.4, to: 1.0, duration: 0.2)
|
||||
strongSelf.activityNode.layer.animateAlpha(from: 0.4, to: 1.0, duration: 0.2)
|
||||
}
|
||||
@@ -803,6 +816,7 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
var rightIconWidth: CGFloat = 0.0
|
||||
var credibilityIconWidth: CGFloat = 0.0
|
||||
var verifiedIconWidth: CGFloat = 0.0
|
||||
var statusIconWidth: CGFloat = 0.0
|
||||
|
||||
if let image = self.titleLeftIconNode.image {
|
||||
if self.titleLeftIconNode.supernode == nil {
|
||||
@@ -845,6 +859,14 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
titleVerifiedContent = .animation(content: .customEmoji(fileId: emojiStatus.fileId), size: CGSize(width: 32.0, height: 32.0), placeholderColor: self.theme.list.mediaPlaceholderColor, themeColor: self.theme.list.itemAccentColor, loopMode: .count(2))
|
||||
}
|
||||
|
||||
let titleStatusContent: EmojiStatusComponent.Content
|
||||
switch self.titleStatusIcon {
|
||||
case let .emojiStatus(emojiStatus):
|
||||
titleStatusContent = .animation(content: .customEmoji(fileId: emojiStatus.fileId), size: CGSize(width: 32.0, height: 32.0), placeholderColor: self.theme.list.mediaPlaceholderColor, themeColor: self.theme.list.itemAccentColor, loopMode: .count(2))
|
||||
default:
|
||||
titleStatusContent = .none
|
||||
}
|
||||
|
||||
let titleCredibilitySize = self.titleCredibilityIconView.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(EmojiStatusComponent(
|
||||
@@ -873,6 +895,20 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
containerSize: CGSize(width: 20.0, height: 20.0)
|
||||
)
|
||||
|
||||
let titleStatusSize = self.titleStatusIconView.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(EmojiStatusComponent(
|
||||
context: self.context,
|
||||
animationCache: self.animationCache,
|
||||
animationRenderer: self.animationRenderer,
|
||||
content: titleStatusContent,
|
||||
isVisibleForAnimations: true,
|
||||
action: nil
|
||||
)),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: 20.0, height: 20.0)
|
||||
)
|
||||
|
||||
if self.titleCredibilityIcon != .none {
|
||||
self.titleTextNode.view.addSubview(self.titleCredibilityIconView)
|
||||
credibilityIconWidth = titleCredibilitySize.width + 3.0
|
||||
@@ -891,6 +927,15 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
}
|
||||
}
|
||||
|
||||
if self.titleStatusIcon != .none {
|
||||
self.titleTextNode.view.addSubview(self.titleStatusIconView)
|
||||
statusIconWidth = titleStatusSize.width + 3.0
|
||||
} else {
|
||||
if self.titleStatusIconView.superview != nil {
|
||||
self.titleStatusIconView.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
|
||||
if let image = self.titleRightIconNode.image {
|
||||
if self.titleRightIconNode.supernode == nil {
|
||||
self.titleTextNode.addSubnode(self.titleRightIconNode)
|
||||
@@ -913,9 +958,10 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
titleInsets.left = verifiedIconWidth + 2.0
|
||||
}
|
||||
|
||||
var titleSize = self.titleTextNode.updateLayout(size: CGSize(width: clearBounds.width - leftIconWidth - credibilityIconWidth - verifiedIconWidth - rightIconWidth - titleSideInset * 2.0, height: size.height), insets: titleInsets, animated: titleTransition.isAnimated)
|
||||
var titleSize = self.titleTextNode.updateLayout(size: CGSize(width: clearBounds.width - leftIconWidth - credibilityIconWidth - verifiedIconWidth - statusIconWidth - rightIconWidth - titleSideInset * 2.0, height: size.height), insets: titleInsets, animated: titleTransition.isAnimated)
|
||||
titleSize.width += credibilityIconWidth
|
||||
titleSize.width += verifiedIconWidth
|
||||
titleSize.width += statusIconWidth
|
||||
|
||||
let activitySize = self.activityNode.updateLayout(CGSize(width: clearBounds.size.width - titleSideInset * 2.0, height: clearBounds.size.height), alignment: .center)
|
||||
let titleInfoSpacing: CGFloat = 0.0
|
||||
@@ -966,23 +1012,26 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
|
||||
self.titleCredibilityIconView.frame = CGRect(origin: CGPoint(x: nextIconX - titleCredibilitySize.width, y: floor((titleFrame.height - titleCredibilitySize.height) / 2.0)), size: titleCredibilitySize)
|
||||
nextIconX -= titleCredibilitySize.width
|
||||
|
||||
self.titleStatusIconView.frame = CGRect(origin: CGPoint(x: nextIconX - titleStatusSize.width, y: floor((titleFrame.height - titleStatusSize.height) / 2.0)), size: titleStatusSize)
|
||||
nextIconX -= titleStatusSize.width
|
||||
|
||||
if let image = self.titleRightIconNode.image {
|
||||
self.titleRightIconNode.frame = CGRect(origin: CGPoint(x: titleFrame.width + 3.0 + UIScreenPixel, y: 6.0), size: image.size)
|
||||
}
|
||||
} else {
|
||||
let titleSize = self.titleTextNode.updateLayout(size: CGSize(width: floor(clearBounds.width / 2.0 - leftIconWidth - credibilityIconWidth - verifiedIconWidth - rightIconWidth - titleSideInset * 2.0), height: size.height), animated: titleTransition.isAnimated)
|
||||
let titleSize = self.titleTextNode.updateLayout(size: CGSize(width: floor(clearBounds.width / 2.0 - leftIconWidth - credibilityIconWidth - verifiedIconWidth - statusIconWidth - rightIconWidth - titleSideInset * 2.0), height: size.height), animated: titleTransition.isAnimated)
|
||||
let activitySize = self.activityNode.updateLayout(CGSize(width: floor(clearBounds.width / 2.0), height: size.height), alignment: .center)
|
||||
|
||||
let titleInfoSpacing: CGFloat = 8.0
|
||||
let combinedWidth = titleSize.width + leftIconWidth + credibilityIconWidth + verifiedIconWidth + rightIconWidth + activitySize.width + titleInfoSpacing
|
||||
let combinedWidth = titleSize.width + leftIconWidth + credibilityIconWidth + verifiedIconWidth + statusIconWidth + rightIconWidth + activitySize.width + titleInfoSpacing
|
||||
|
||||
titleFrame = CGRect(origin: CGPoint(x: leftIconWidth + floor((clearBounds.width - combinedWidth) / 2.0), y: floor((size.height - titleSize.height) / 2.0)), size: titleSize)
|
||||
|
||||
titleTransition.updateFrameAdditiveToCenter(view: self.titleContainerView, frame: titleFrame)
|
||||
titleTransition.updateFrameAdditiveToCenter(node: self.titleTextNode, frame: CGRect(origin: CGPoint(), size: titleFrame.size))
|
||||
|
||||
self.activityNode.frame = CGRect(origin: CGPoint(x: floor((clearBounds.width - combinedWidth) / 2.0 + titleSize.width + leftIconWidth + credibilityIconWidth + verifiedIconWidth + rightIconWidth + titleInfoSpacing), y: floor((size.height - activitySize.height) / 2.0)), size: activitySize)
|
||||
self.activityNode.frame = CGRect(origin: CGPoint(x: floor((clearBounds.width - combinedWidth) / 2.0 + titleSize.width + leftIconWidth + credibilityIconWidth + verifiedIconWidth + statusIconWidth + rightIconWidth + titleInfoSpacing), y: floor((size.height - activitySize.height) / 2.0)), size: activitySize)
|
||||
|
||||
if let image = self.titleLeftIconNode.image {
|
||||
self.titleLeftIconNode.frame = CGRect(origin: CGPoint(x: titleFrame.minX, y: titleFrame.minY + 4.0), size: image.size)
|
||||
@@ -995,6 +1044,9 @@ public final class ChatTitleView: UIView, NavigationBarTitleView {
|
||||
self.titleCredibilityIconView.frame = CGRect(origin: CGPoint(x: nextIconX - titleCredibilitySize.width, y: floor((titleFrame.height - titleCredibilitySize.height) / 2.0)), size: titleCredibilitySize)
|
||||
nextIconX -= titleCredibilitySize.width
|
||||
|
||||
self.titleStatusIconView.frame = CGRect(origin: CGPoint(x: nextIconX - titleStatusSize.width, y: floor((titleFrame.height - titleStatusSize.height) / 2.0)), size: titleStatusSize)
|
||||
nextIconX -= titleStatusSize.width
|
||||
|
||||
if let image = self.titleRightIconNode.image {
|
||||
self.titleRightIconNode.frame = CGRect(origin: CGPoint(x: titleFrame.maxX - image.size.width, y: titleFrame.minY + 6.0), size: image.size)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user