mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-09 07:41:40 +00:00
UI fixes
This commit is contained in:
parent
781a633521
commit
a7a090cfcd
@ -42,6 +42,8 @@ final class ChatListBadgeNode: ASDisplayNode {
|
|||||||
private var text: String?
|
private var text: String?
|
||||||
private var content: ChatListBadgeContent?
|
private var content: ChatListBadgeContent?
|
||||||
|
|
||||||
|
private var isHiddenInternal = false
|
||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
self.backgroundNode = ASImageNode()
|
self.backgroundNode = ASImageNode()
|
||||||
self.backgroundNode.isLayerBacked = true
|
self.backgroundNode.isLayerBacked = true
|
||||||
@ -114,6 +116,7 @@ final class ChatListBadgeNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if currentIsEmpty && !nextIsEmpty {
|
if currentIsEmpty && !nextIsEmpty {
|
||||||
|
strongSelf.isHiddenInternal = false
|
||||||
strongSelf.layer.animateScale(from: 0.0001, to: 1.2, duration: 0.2, removeOnCompletion: false, completion: { [weak self] finished in
|
strongSelf.layer.animateScale(from: 0.0001, to: 1.2, duration: 0.2, removeOnCompletion: false, completion: { [weak self] finished in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.layer.animateScale(from: 1.15, to: 1.0, duration: 0.12, removeOnCompletion: false)
|
strongSelf.layer.animateScale(from: 1.15, to: 1.0, duration: 0.12, removeOnCompletion: false)
|
||||||
@ -121,6 +124,7 @@ final class ChatListBadgeNode: ASDisplayNode {
|
|||||||
})
|
})
|
||||||
} else if !currentIsEmpty && !nextIsEmpty && currentContent?.text != content.text {
|
} else if !currentIsEmpty && !nextIsEmpty && currentContent?.text != content.text {
|
||||||
var animateScale = true
|
var animateScale = true
|
||||||
|
strongSelf.isHiddenInternal = false
|
||||||
if let currentText = currentContent?.text, let currentValue = Int(currentText), let text = content.text, let value = Int(text) {
|
if let currentText = currentContent?.text, let currentValue = Int(currentText), let text = content.text, let value = Int(text) {
|
||||||
if value < currentValue {
|
if value < currentValue {
|
||||||
animateScale = false
|
animateScale = false
|
||||||
@ -148,7 +152,8 @@ final class ChatListBadgeNode: ASDisplayNode {
|
|||||||
snapshotView.layer.animatePosition(from: CGPoint(), to: CGPoint(x: (badgeWidth - previousBadgeWidth) / 2.0, y: -8.0), duration: 0.15, timingFunction: kCAMediaTimingFunctionEaseInEaseOut, removeOnCompletion: false, additive: true)
|
snapshotView.layer.animatePosition(from: CGPoint(), to: CGPoint(x: (badgeWidth - previousBadgeWidth) / 2.0, y: -8.0), duration: 0.15, timingFunction: kCAMediaTimingFunctionEaseInEaseOut, removeOnCompletion: false, additive: true)
|
||||||
}
|
}
|
||||||
animateTextNode = true
|
animateTextNode = true
|
||||||
} else if !currentIsEmpty && nextIsEmpty {
|
} else if !currentIsEmpty && nextIsEmpty && !strongSelf.isHiddenInternal {
|
||||||
|
strongSelf.isHiddenInternal = true
|
||||||
strongSelf.layer.animateScale(from: 1.0, to: 0.0001, duration: 0.12, removeOnCompletion: true, completion: { [weak self] finished in
|
strongSelf.layer.animateScale(from: 1.0, to: 0.0001, duration: 0.12, removeOnCompletion: true, completion: { [weak self] finished in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.isHidden = true
|
strongSelf.isHidden = true
|
||||||
@ -158,8 +163,10 @@ final class ChatListBadgeNode: ASDisplayNode {
|
|||||||
} else {
|
} else {
|
||||||
if case .none = content {
|
if case .none = content {
|
||||||
strongSelf.isHidden = true
|
strongSelf.isHidden = true
|
||||||
|
strongSelf.isHiddenInternal = true
|
||||||
} else {
|
} else {
|
||||||
strongSelf.isHidden = false
|
strongSelf.isHidden = false
|
||||||
|
strongSelf.isHiddenInternal = false
|
||||||
}
|
}
|
||||||
if case .text = content {
|
if case .text = content {
|
||||||
strongSelf.textNode.alpha = 1.0
|
strongSelf.textNode.alpha = 1.0
|
||||||
|
|||||||
@ -293,7 +293,7 @@ enum ChatListNodeScrollPosition {
|
|||||||
case top
|
case top
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ChatListNodeEmtpyState: Equatable {
|
enum ChatListNodeEmptyState: Equatable {
|
||||||
case notEmpty(containsChats: Bool)
|
case notEmpty(containsChats: Bool)
|
||||||
case empty(isLoading: Bool)
|
case empty(isLoading: Bool)
|
||||||
}
|
}
|
||||||
@ -365,8 +365,8 @@ final class ChatListNode: ListView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var isEmptyUpdated: ((ChatListNodeEmtpyState) -> Void)?
|
var isEmptyUpdated: ((ChatListNodeEmptyState) -> Void)?
|
||||||
private var currentIsEmptyState: ChatListNodeEmtpyState?
|
private var currentIsEmptyState: ChatListNodeEmptyState?
|
||||||
|
|
||||||
var addedVisibleChatsWithPeerIds: (([PeerId]) -> Void)?
|
var addedVisibleChatsWithPeerIds: (([PeerId]) -> Void)?
|
||||||
|
|
||||||
@ -1141,7 +1141,7 @@ final class ChatListNode: ListView {
|
|||||||
strongSelf._ready.set(true)
|
strongSelf._ready.set(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
let isEmptyState: ChatListNodeEmtpyState
|
let isEmptyState: ChatListNodeEmptyState
|
||||||
if transition.chatListView.isLoading {
|
if transition.chatListView.isLoading {
|
||||||
isEmptyState = .empty(isLoading: true)
|
isEmptyState = .empty(isLoading: true)
|
||||||
} else if transition.chatListView.filteredEntries.isEmpty {
|
} else if transition.chatListView.filteredEntries.isEmpty {
|
||||||
|
|||||||
@ -785,6 +785,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var game: TelegramMediaGame?
|
||||||
var webpage: TelegramMediaWebpage?
|
var webpage: TelegramMediaWebpage?
|
||||||
var invoice: TelegramMediaInvoice?
|
var invoice: TelegramMediaInvoice?
|
||||||
for media in message.media {
|
for media in message.media {
|
||||||
@ -792,6 +793,8 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode {
|
|||||||
webpage = media
|
webpage = media
|
||||||
} else if let media = media as? TelegramMediaInvoice {
|
} else if let media = media as? TelegramMediaInvoice {
|
||||||
invoice = media
|
invoice = media
|
||||||
|
} else if let media = media as? TelegramMediaGame {
|
||||||
|
game = media
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -904,6 +907,8 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode {
|
|||||||
fetchStatus = actualFetchStatus
|
fetchStatus = actualFetchStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let gifTitle = game != nil ? strings.Message_Game.uppercased() : strings.Message_Animation.uppercased()
|
||||||
|
|
||||||
switch fetchStatus {
|
switch fetchStatus {
|
||||||
case let .Fetching(_, progress):
|
case let .Fetching(_, progress):
|
||||||
let adjustedProgress = max(progress, 0.027)
|
let adjustedProgress = max(progress, 0.027)
|
||||||
@ -922,10 +927,10 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode {
|
|||||||
if let size = file.size {
|
if let size = file.size {
|
||||||
let sizeString = "\(dataSizeString(Int(Float(size) * progress), forceDecimal: true, decimalSeparator: decimalSeparator)) / \(dataSizeString(size, forceDecimal: true, decimalSeparator: decimalSeparator))"
|
let sizeString = "\(dataSizeString(Int(Float(size) * progress), forceDecimal: true, decimalSeparator: decimalSeparator)) / \(dataSizeString(size, forceDecimal: true, decimalSeparator: decimalSeparator))"
|
||||||
if file.isAnimated && (!automaticDownload || !automaticPlayback) {
|
if file.isAnimated && (!automaticDownload || !automaticPlayback) {
|
||||||
badgeContent = .mediaDownload(backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, duration: "GIF " + sizeString, size: nil, muted: false, active: false)
|
badgeContent = .mediaDownload(backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, duration: "\(gifTitle) " + sizeString, size: nil, muted: false, active: false)
|
||||||
}
|
}
|
||||||
else if let duration = file.duration, !message.flags.contains(.Unsent) {
|
else if let duration = file.duration, !message.flags.contains(.Unsent) {
|
||||||
let durationString = file.isAnimated ? "GIF" : stringForDuration(playerDuration > 0 ? playerDuration : duration, position: playerPosition)
|
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : duration, position: playerPosition)
|
||||||
if isMediaStreamable(message: message, media: file) {
|
if isMediaStreamable(message: message, media: file) {
|
||||||
badgeContent = .mediaDownload(backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, duration: durationString, size: active ? sizeString : nil, muted: muted, active: active)
|
badgeContent = .mediaDownload(backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, duration: durationString, size: active ? sizeString : nil, muted: muted, active: active)
|
||||||
mediaDownloadState = .fetching(progress: automaticPlayback ? nil : adjustedProgress)
|
mediaDownloadState = .fetching(progress: automaticPlayback ? nil : adjustedProgress)
|
||||||
@ -1019,17 +1024,17 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let file = media as? TelegramMediaFile, let duration = file.duration {
|
if let file = media as? TelegramMediaFile, let duration = file.duration {
|
||||||
let durationString = file.isAnimated ? "GIF" : stringForDuration(playerDuration > 0 ? playerDuration : duration, position: playerPosition)
|
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : duration, position: playerPosition)
|
||||||
badgeContent = .mediaDownload(backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, duration: durationString, size: nil, muted: muted, active: false)
|
badgeContent = .mediaDownload(backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, duration: durationString, size: nil, muted: muted, active: false)
|
||||||
}
|
}
|
||||||
case .Remote:
|
case .Remote:
|
||||||
state = .download(bubbleTheme.mediaOverlayControlForegroundColor)
|
state = .download(bubbleTheme.mediaOverlayControlForegroundColor)
|
||||||
if let file = self.media as? TelegramMediaFile {
|
if let file = self.media as? TelegramMediaFile {
|
||||||
if file.isAnimated && (!automaticDownload || !automaticPlayback) {
|
if file.isAnimated && (!automaticDownload || !automaticPlayback) {
|
||||||
let string = "GIF " + dataSizeString(file.size ?? 0, decimalSeparator: decimalSeparator)
|
let string = "\(gifTitle) " + dataSizeString(file.size ?? 0, decimalSeparator: decimalSeparator)
|
||||||
badgeContent = .mediaDownload(backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, duration: string, size: nil, muted: false, active: false)
|
badgeContent = .mediaDownload(backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, duration: string, size: nil, muted: false, active: false)
|
||||||
} else {
|
} else {
|
||||||
let durationString = file.isAnimated ? "GIF" : stringForDuration(playerDuration > 0 ? playerDuration : (file.duration ?? 0), position: playerPosition)
|
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : (file.duration ?? 0), position: playerPosition)
|
||||||
if wideLayout {
|
if wideLayout {
|
||||||
if isMediaStreamable(message: message, media: file) {
|
if isMediaStreamable(message: message, media: file) {
|
||||||
state = automaticPlayback ? .none : .play(bubbleTheme.mediaOverlayControlForegroundColor)
|
state = automaticPlayback ? .none : .play(bubbleTheme.mediaOverlayControlForegroundColor)
|
||||||
|
|||||||
@ -232,7 +232,7 @@ final class SelectablePeerNode: ASDisplayNode {
|
|||||||
|
|
||||||
let avatarFrame = self.avatarNode.frame
|
let avatarFrame = self.avatarNode.frame
|
||||||
|
|
||||||
self.onlineNode.frame = CGRect(origin: CGPoint(x: avatarFrame.width - self.onlineNode.frame.width + 2.0, y: avatarFrame.height - self.onlineNode.frame.height + 2.0), size: self.onlineNode.frame.size)
|
self.onlineNode.frame = CGRect(origin: CGPoint(x: avatarFrame.maxX - self.onlineNode.frame.width + 9.0, y: avatarFrame.maxY - self.onlineNode.frame.height + 2.0), size: self.onlineNode.frame.size)
|
||||||
|
|
||||||
if let checkView = self.checkView {
|
if let checkView = self.checkView {
|
||||||
let checkSize = checkView.bounds.size
|
let checkSize = checkView.bounds.size
|
||||||
|
|||||||
@ -126,7 +126,6 @@ final class ShareControllerPeerGridItem: GridItem {
|
|||||||
final class ShareControllerPeerGridItemNode: GridItemNode {
|
final class ShareControllerPeerGridItemNode: GridItemNode {
|
||||||
private var currentState: (Account, RenderedPeer, Bool)?
|
private var currentState: (Account, RenderedPeer, Bool)?
|
||||||
private let peerNode: SelectablePeerNode
|
private let peerNode: SelectablePeerNode
|
||||||
|
|
||||||
|
|
||||||
var controllerInteraction: ShareControllerInteraction?
|
var controllerInteraction: ShareControllerInteraction?
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user