diff --git a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift index 46b0050389..3381739f4a 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift @@ -2746,7 +2746,21 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } let text: String? let rate: CGFloat? - if baseRate == .x1 { + if case let .sliderCommit(previousValue, newValue) = changeType { + let value = String(format: "%0.1f", baseRate.doubleValue) + if baseRate == .x1 { + text = presentationData.strings.Conversation_AudioRateTooltipNormal + } else { + text = presentationData.strings.Conversation_AudioRateTooltipCustom(value).string + } + if newValue > previousValue { + rate = .infinity + } else if newValue < previousValue { + rate = -.infinity + } else { + rate = nil + } + } else if baseRate == .x1 { text = presentationData.strings.Conversation_AudioRateTooltipNormal rate = 1.0 } else if baseRate == .x1_5 { @@ -2756,19 +2770,8 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { text = presentationData.strings.Conversation_AudioRateTooltipSpeedUp rate = 2.0 } else { - let value = String(format: "%0.1f", baseRate.doubleValue) - text = presentationData.strings.Conversation_AudioRateTooltipCustom(value).string - if case let .sliderCommit(previousValue, newValue) = changeType { - if newValue > previousValue { - rate = .infinity - } else if newValue < previousValue { - rate = -.infinity - } else { - rate = nil - } - } else { - rate = nil - } + text = nil + rate = nil } var showTooltip = true if case .sliderChange = changeType { diff --git a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift index 788731a6ec..0e2f115332 100644 --- a/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/UniversalVideoGalleryItem.swift @@ -2629,6 +2629,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode { guard let strongSelf = self else { return } + let newValue = normalizeValue(newValue) strongSelf.updatePlaybackRate(newValue) if finished { //dismiss() @@ -2852,3 +2853,7 @@ final class HeaderContextReferenceContentSource: ContextReferenceContentSource { return ContextControllerReferenceViewInfo(referenceView: self.sourceNode.view, contentAreaInScreenSpace: UIScreen.main.bounds) } } + +private func normalizeValue(_ value: CGFloat) -> CGFloat { + return round(value * 10.0) / 10.0 +} diff --git a/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift b/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift index e02b80d015..0fe4e35b7d 100644 --- a/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift +++ b/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift @@ -18,6 +18,10 @@ import SliderContextItem private let titleFont = Font.regular(12.0) private let subtitleFont = Font.regular(10.0) +private func normalizeValue(_ value: CGFloat) -> CGFloat { + return round(value * 10.0) / 10.0 +} + private class MediaHeaderItemNode: ASDisplayNode { private let titleNode: TextNode private let subtitleNode: TextNode @@ -528,6 +532,7 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi let previousValue = self.playbackBaseRate?.doubleValue ?? 1.0 let sliderItem: ContextMenuItem = .custom(SliderContextItem(minValue: 0.5, maxValue: 2.5, value: previousValue, valueChanged: { [weak self] newValue, finished in + let newValue = normalizeValue(newValue) self?.setRate?(AudioPlaybackRate(newValue), .sliderChange) if finished { scheduleTooltip(.sliderCommit(previousValue, newValue)) diff --git a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift index eb71cec93c..d9a0790e70 100644 --- a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift +++ b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift @@ -699,7 +699,21 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } let text: String? let rate: CGFloat? - if baseRate == .x1 { + if case let .sliderCommit(previousValue, newValue) = changeType { + let value = String(format: "%0.1f", baseRate.doubleValue) + if baseRate == .x1 { + text = presentationData.strings.Conversation_AudioRateTooltipNormal + } else { + text = presentationData.strings.Conversation_AudioRateTooltipCustom(value).string + } + if newValue > previousValue { + rate = .infinity + } else if newValue < previousValue { + rate = -.infinity + } else { + rate = nil + } + } else if baseRate == .x1 { text = presentationData.strings.Conversation_AudioRateTooltipNormal rate = 1.0 } else if baseRate == .x1_5 { @@ -709,19 +723,8 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { text = presentationData.strings.Conversation_AudioRateTooltipSpeedUp rate = 2.0 } else { - let value = String(format: "%0.1f", baseRate.doubleValue) - text = presentationData.strings.Conversation_AudioRateTooltipCustom(value).string - if case let .sliderCommit(previousValue, newValue) = changeType { - if newValue > previousValue { - rate = .infinity - } else if newValue < previousValue { - rate = -.infinity - } else { - rate = nil - } - } else { - rate = nil - } + text = nil + rate = nil } var showTooltip = true if case .sliderChange = changeType { diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift index 34303c44e6..493ed6d3a3 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardTopPanelComponent.swift @@ -1628,6 +1628,7 @@ public final class EntityKeyboardTopPanelComponent: Component { } } + private var didReorderItems = false private func beginReordering(itemView: ComponentHostView) { if let currentReorderingItemView = self.currentReorderingItemView { if let componentView = currentReorderingItemView.componentView { @@ -1702,7 +1703,9 @@ public final class EntityKeyboardTopPanelComponent: Component { self.currentReorderingItemId = nil self.temporaryReorderingOrderIndex = nil - self.component?.reorderItems(self.items) + if self.didReorderItems { + self.component?.reorderItems(self.items) + } //self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) } @@ -1721,14 +1724,14 @@ public final class EntityKeyboardTopPanelComponent: Component { let containerFrame = itemLayout.containerFrame(at: i) if containerFrame.intersects(localReorderingItemFrame) { let temporaryReorderingOrderIndex: (id: AnyHashable, index: Int) = (currentReorderingItemId, i) - let hadPrevous = self.temporaryReorderingOrderIndex != nil + let hadPrevious = self.temporaryReorderingOrderIndex != nil if self.temporaryReorderingOrderIndex?.id != temporaryReorderingOrderIndex.id || self.temporaryReorderingOrderIndex?.index != temporaryReorderingOrderIndex.index { self.temporaryReorderingOrderIndex = temporaryReorderingOrderIndex - if hadPrevous { + if hadPrevious { self.reorderingHapticFeedback.tap() } - + self.didReorderItems = true self.state?.updated(transition: Transition(animation: .curve(duration: 0.3, curve: .spring))) } break diff --git a/submodules/TelegramUI/Sources/OverlayPlayerControlsNode.swift b/submodules/TelegramUI/Sources/OverlayPlayerControlsNode.swift index ac64fd5774..06dba02b60 100644 --- a/submodules/TelegramUI/Sources/OverlayPlayerControlsNode.swift +++ b/submodules/TelegramUI/Sources/OverlayPlayerControlsNode.swift @@ -18,6 +18,10 @@ import ContextUI import SliderContextItem import UndoUI +private func normalizeValue(_ value: CGFloat) -> CGFloat { + return round(value * 10.0) / 10.0 +} + private func generateBackground(theme: PresentationTheme) -> UIImage? { return generateImage(CGSize(width: 20.0, height: 10.0 + 8.0), rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) @@ -1031,6 +1035,7 @@ final class OverlayPlayerControlsNode: ASDisplayNode { let previousValue = self.currentRate?.doubleValue ?? 1.0 let sliderItem: ContextMenuItem = .custom(SliderContextItem(minValue: 0.5, maxValue: 2.5, value: previousValue, valueChanged: { [weak self] newValue, finished in + let newValue = normalizeValue(newValue) self?.control?(.setBaseRate(AudioPlaybackRate(newValue))) if finished { scheduleTooltip(.sliderCommit(previousValue, newValue)) @@ -1082,7 +1087,21 @@ final class OverlayPlayerControlsNode: ASDisplayNode { let presentationData = self.presentationData let text: String? let rate: CGFloat? - if baseRate == .x1 { + if case let .sliderCommit(previousValue, newValue) = changeType { + let value = String(format: "%0.1f", baseRate.doubleValue) + if baseRate == .x1 { + text = presentationData.strings.Conversation_AudioRateTooltipNormal + } else { + text = presentationData.strings.Conversation_AudioRateTooltipCustom(value).string + } + if newValue > previousValue { + rate = .infinity + } else if newValue < previousValue { + rate = -.infinity + } else { + rate = nil + } + } else if baseRate == .x1 { text = presentationData.strings.Conversation_AudioRateTooltipNormal rate = 1.0 } else if baseRate == .x1_5 { @@ -1092,19 +1111,8 @@ final class OverlayPlayerControlsNode: ASDisplayNode { text = presentationData.strings.Conversation_AudioRateTooltipSpeedUp rate = 2.0 } else { - let value = String(format: "%0.1f", baseRate.doubleValue) - text = presentationData.strings.Conversation_AudioRateTooltipCustom(value).string - if case let .sliderCommit(previousValue, newValue) = changeType { - if newValue > previousValue { - rate = .infinity - } else if newValue < previousValue { - rate = -.infinity - } else { - rate = nil - } - } else { - rate = nil - } + text = nil + rate = nil } var showTooltip = true if case .sliderChange = changeType { diff --git a/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoListPaneNode.swift b/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoListPaneNode.swift index 8a23dd1484..f785e9da7d 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoListPaneNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/Panes/PeerInfoListPaneNode.swift @@ -293,7 +293,21 @@ final class PeerInfoListPaneNode: ASDisplayNode, PeerInfoPaneNode { let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } let text: String? let rate: CGFloat? - if baseRate == .x1 { + if case let .sliderCommit(previousValue, newValue) = changeType { + let value = String(format: "%0.1f", baseRate.doubleValue) + if baseRate == .x1 { + text = presentationData.strings.Conversation_AudioRateTooltipNormal + } else { + text = presentationData.strings.Conversation_AudioRateTooltipCustom(value).string + } + if newValue > previousValue { + rate = .infinity + } else if newValue < previousValue { + rate = -.infinity + } else { + rate = nil + } + } else if baseRate == .x1 { text = presentationData.strings.Conversation_AudioRateTooltipNormal rate = 1.0 } else if baseRate == .x1_5 { @@ -303,19 +317,8 @@ final class PeerInfoListPaneNode: ASDisplayNode, PeerInfoPaneNode { text = presentationData.strings.Conversation_AudioRateTooltipSpeedUp rate = 2.0 } else { - let value = String(format: "%0.1f", baseRate.doubleValue) - text = presentationData.strings.Conversation_AudioRateTooltipCustom(value).string - if case let .sliderCommit(previousValue, newValue) = changeType { - if newValue > previousValue { - rate = .infinity - } else if newValue < previousValue { - rate = -.infinity - } else { - rate = nil - } - } else { - rate = nil - } + text = nil + rate = nil } var showTooltip = true if case .sliderChange = changeType { diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 1c7e8dc590..2f30b57732 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -11008,14 +11008,22 @@ private final class AccountPeerContextItemNode: ASDisplayNode, ContextMenuCustom let textFrame = CGRect(origin: CGPoint(x: sideInset, y: verticalOrigin), size: textSize) transition.updateFrameAdditive(node: self.textNode, frame: textFrame) - if case let .user(user) = self.item.peer, let emojiStatus = user.emojiStatus { + var iconContent: EmojiStatusComponent.Content? + if case let .user(user) = self.item.peer { + if let emojiStatus = user.emojiStatus { + iconContent = .animation(content: .customEmoji(fileId: emojiStatus.fileId), size: CGSize(width: 28.0, height: 28.0), placeholderColor: self.presentationData.theme.list.mediaPlaceholderColor, themeColor: self.presentationData.theme.list.itemAccentColor, loopMode: .forever) + } else if user.isPremium { + iconContent = .premium(color: self.presentationData.theme.list.itemAccentColor) + } + } + if let iconContent { let emojiStatusSize = self.emojiStatusView.update( transition: .immediate, component: AnyComponent(EmojiStatusComponent( context: self.item.context, animationCache: self.item.context.animationCache, animationRenderer: self.item.context.animationRenderer, - content: .animation(content: .customEmoji(fileId: emojiStatus.fileId), size: CGSize(width: 28.0, height: 28.0), placeholderColor: self.presentationData.theme.list.mediaPlaceholderColor, themeColor: self.presentationData.theme.list.itemAccentColor, loopMode: .forever), + content: iconContent, isVisibleForAnimations: true, action: nil )),