mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-25 09:32:46 +00:00
Video avatar fixes
This commit is contained in:
parent
6f4d9df1a3
commit
1bcdf64ebe
@ -96,6 +96,22 @@ public final class AvatarGalleryControllerPresentationArguments {
|
||||
}
|
||||
}
|
||||
|
||||
public func normalizeEntries(_ entries: [AvatarGalleryEntry]) -> [AvatarGalleryEntry] {
|
||||
var updatedEntries: [AvatarGalleryEntry] = []
|
||||
let count: Int32 = Int32(entries.count)
|
||||
var index: Int32 = 0
|
||||
for entry in entries {
|
||||
let indexData = GalleryItemIndexData(position: index, totalCount: count)
|
||||
if case let .topImage(representations, _, immediateThumbnailData) = entry {
|
||||
updatedEntries.append(.topImage(representations, indexData, immediateThumbnailData))
|
||||
} else if case let .image(id, reference, representations, videoRepresentations, peer, date, _, messageId, immediateThumbnailData) = entry {
|
||||
updatedEntries.append(.image(id, reference, representations, videoRepresentations, peer, date, indexData, messageId, immediateThumbnailData))
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
return updatedEntries
|
||||
}
|
||||
|
||||
public func initialAvatarGalleryEntries(peer: Peer) -> [AvatarGalleryEntry] {
|
||||
var initialEntries: [AvatarGalleryEntry] = []
|
||||
if !peer.profileImageRepresentations.isEmpty, let peerReference = PeerReference(peer) {
|
||||
@ -540,22 +556,6 @@ public class AvatarGalleryController: ViewController, StandalonePresentableContr
|
||||
}
|
||||
}
|
||||
|
||||
private func normalizeEntries(_ entries: [AvatarGalleryEntry]) -> [AvatarGalleryEntry] {
|
||||
var updatedEntries: [AvatarGalleryEntry] = []
|
||||
let count: Int32 = Int32(entries.count)
|
||||
var index: Int32 = 0
|
||||
for entry in entries {
|
||||
let indexData = GalleryItemIndexData(position: index, totalCount: count)
|
||||
if case let .topImage(representations, _, immediateThumbnailData) = entry {
|
||||
updatedEntries.append(.topImage(representations, indexData, immediateThumbnailData))
|
||||
} else if case let .image(id, reference, representations, videoRepresentations, peer, date, _, messageId, immediateThumbnailData) = entry {
|
||||
updatedEntries.append(.image(id, reference, representations, videoRepresentations, peer, date, indexData, messageId, immediateThumbnailData))
|
||||
}
|
||||
index += 1
|
||||
}
|
||||
return updatedEntries
|
||||
}
|
||||
|
||||
private func setMainEntry(_ rawEntry: AvatarGalleryEntry) {
|
||||
var entry = rawEntry
|
||||
if case .topImage = entry, !self.entries.isEmpty {
|
||||
@ -600,7 +600,7 @@ public class AvatarGalleryController: ViewController, StandalonePresentableContr
|
||||
canDelete = false
|
||||
}
|
||||
|
||||
entries = self.normalizeEntries(entries)
|
||||
entries = normalizeEntries(entries)
|
||||
|
||||
self.galleryNode.pager.replaceItems(entries.map({ entry in PeerAvatarImageGalleryItem(context: self.context, peer: peer, presentationData: presentationData, entry: entry, sourceHasRoundCorners: self.sourceHasRoundCorners, delete: canDelete ? { [weak self] in
|
||||
self?.deleteEntry(entry)
|
||||
|
||||
@ -738,7 +738,7 @@ final class PeerInfoAvatarListContainerNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
}
|
||||
self.galleryEntries = entries
|
||||
self.galleryEntries = normalizeEntries(entries)
|
||||
self.items = items
|
||||
self.itemsUpdated?(items)
|
||||
self.currentIndex = 0
|
||||
@ -767,7 +767,7 @@ final class PeerInfoAvatarListContainerNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
}
|
||||
self.galleryEntries = entries
|
||||
self.galleryEntries = normalizeEntries(entries)
|
||||
self.items = items
|
||||
self.itemsUpdated?(items)
|
||||
self.currentIndex = max(0, previousIndex - 1)
|
||||
@ -2072,6 +2072,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
|
||||
private let videoCallsEnabled: Bool
|
||||
|
||||
private(set) var isAvatarExpanded: Bool
|
||||
private(set) var twoLineInfo = false
|
||||
|
||||
let avatarListNode: PeerInfoAvatarListNode
|
||||
|
||||
@ -2332,7 +2333,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
|
||||
if self.isSettings, let user = peer as? TelegramUser {
|
||||
let formattedPhone = formatPhoneNumber(user.phone ?? "")
|
||||
subtitleString = NSAttributedString(string: formattedPhone, font: Font.regular(15.0), textColor: presentationData.theme.list.itemSecondaryTextColor)
|
||||
usernameString = NSAttributedString(string: user.addressName.flatMap { "@superlongusernamehere\($0)" } ?? "", font: Font.regular(15.0), textColor: presentationData.theme.list.itemAccentColor)
|
||||
usernameString = NSAttributedString(string: user.addressName.flatMap { "@\($0)" } ?? "", font: Font.regular(15.0), textColor: presentationData.theme.list.itemAccentColor)
|
||||
} else if let statusData = statusData {
|
||||
let subtitleColor: UIColor
|
||||
if statusData.isActivity {
|
||||
@ -2414,6 +2415,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
|
||||
usernameFrame = CGRect(origin: CGPoint(x: subtitleFrame.maxX + usernameSpacing, y: titleFrame.maxY + 1.0), size: usernameSize)
|
||||
}
|
||||
}
|
||||
self.twoLineInfo = twoLineInfo
|
||||
|
||||
let singleTitleLockOffset: CGFloat = (peer?.id == self.context.account.peerId || subtitleSize.height.isZero) ? 8.0 : 0.0
|
||||
|
||||
@ -2556,7 +2558,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
|
||||
|
||||
var panelWithAvatarHeight: CGFloat = (self.isSettings ? 40.0 : 112.0) + avatarSize
|
||||
if twoLineInfo {
|
||||
panelWithAvatarHeight += 7.0
|
||||
panelWithAvatarHeight += 17.0
|
||||
}
|
||||
let buttonsCollapseStart = titleCollapseOffset
|
||||
let buttonsCollapseEnd = panelWithAvatarHeight - (navigationHeight - statusBarHeight) + 10.0
|
||||
@ -2816,7 +2818,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
|
||||
if self.isAvatarExpanded {
|
||||
resolvedRegularHeight = expandedAvatarListSize.height + expandedAvatarControlsHeight
|
||||
} else {
|
||||
resolvedRegularHeight = (self.isSettings ? 40.0 : 112.0) + avatarSize + navigationHeight
|
||||
resolvedRegularHeight = panelWithAvatarHeight + navigationHeight
|
||||
}
|
||||
|
||||
let backgroundFrame: CGRect
|
||||
|
||||
@ -5372,7 +5372,10 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
|
||||
guard let (_, navigationHeight) = self.validLayout else {
|
||||
return
|
||||
}
|
||||
let height: CGFloat = self.isSettings ? 140.0 : 212.0
|
||||
var height: CGFloat = self.isSettings ? 140.0 : 212.0
|
||||
if self.headerNode.twoLineInfo {
|
||||
height += 17.0
|
||||
}
|
||||
if !self.state.isEditing {
|
||||
if targetContentOffset.pointee.y < height {
|
||||
if targetContentOffset.pointee.y < height / 2.0 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user