mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Audio rate fixes
This commit is contained in:
parent
30f9746d16
commit
1502134ca6
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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 {
|
||||
|
@ -1628,6 +1628,7 @@ public final class EntityKeyboardTopPanelComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
private var didReorderItems = false
|
||||
private func beginReordering(itemView: ComponentHostView<EntityKeyboardTopPanelItemEnvironment>) {
|
||||
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
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user