mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
e0d86049f7
commit
8188bc2858
@ -168,13 +168,13 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
controller?.inProgress = true
|
||||
let authorizationPushConfiguration = self.sharedContext.authorizationPushConfiguration
|
||||
|> take(1)
|
||||
|> timeout(2.0, queue: .mainQueue(), alternate: .single(nil))
|
||||
let _ = (authorizationPushConfiguration
|
||||
|> deliverOnMainQueue).start(next: { [weak self] authorizationPushConfiguration in
|
||||
if let strongSelf = self {
|
||||
controller?.inProgress = true
|
||||
strongSelf.actionDisposable.set((sendAuthorizationCode(accountManager: strongSelf.sharedContext.accountManager, account: strongSelf.account, phoneNumber: number, apiId: strongSelf.apiId, apiHash: strongSelf.apiHash, pushNotificationConfiguration: authorizationPushConfiguration, firebaseSecretStream: strongSelf.sharedContext.firebaseSecretStream, syncContacts: syncContacts, forcedPasswordSetupNotice: { value in
|
||||
guard let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value)) else {
|
||||
return nil
|
||||
|
@ -2619,15 +2619,15 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
||||
c.setItems(strongSelf.contextMenuMainItems(dismiss: dismiss) |> map { ContextController.Items(content: .list($0)) }, minHeight: nil)
|
||||
})))
|
||||
|
||||
// items.append(.custom(SliderContextItem(minValue: 0.05, maxValue: 2.5, value: status.baseRate, valueChanged: { [weak self] newValue, finished in
|
||||
// guard let strongSelf = self, let videoNode = strongSelf.videoNode else {
|
||||
// return
|
||||
// }
|
||||
// videoNode.setBaseRate(newValue)
|
||||
// if finished {
|
||||
// dismiss()
|
||||
// }
|
||||
// }), true))
|
||||
items.append(.custom(SliderContextItem(minValue: 0.5, maxValue: 2.5, value: status.baseRate, valueChanged: { [weak self] newValue, finished in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.updatePlaybackRate(newValue)
|
||||
if finished {
|
||||
dismiss()
|
||||
}
|
||||
}), true))
|
||||
|
||||
items.append(.separator)
|
||||
|
||||
|
@ -192,17 +192,17 @@ open class ManagedAnimationNode: ASDisplayNode {
|
||||
|
||||
displayLinkUpdate = { [weak self] in
|
||||
if let strongSelf = self {
|
||||
let timestamp = CACurrentMediaTime()
|
||||
var delta: Double
|
||||
if let previousTimestamp = strongSelf.previousTimestamp {
|
||||
delta = min(timestamp - previousTimestamp, 1.0 / 60.0)
|
||||
if let currentDelta = strongSelf.delta, currentDelta < delta {
|
||||
delta = currentDelta
|
||||
}
|
||||
} else {
|
||||
delta = 1.0 / 60.0
|
||||
}
|
||||
strongSelf.previousTimestamp = timestamp
|
||||
// let timestamp = CACurrentMediaTime()
|
||||
// var delta: Double
|
||||
// if let previousTimestamp = strongSelf.previousTimestamp {
|
||||
// delta = min(timestamp - previousTimestamp, 1.0 / 60.0)
|
||||
// if let currentDelta = strongSelf.delta, currentDelta < delta {
|
||||
// delta = currentDelta
|
||||
// }
|
||||
// } else {
|
||||
let delta = 1.0 / 60.0
|
||||
// }
|
||||
// strongSelf.previousTimestamp = timestamp
|
||||
strongSelf.delta = delta
|
||||
|
||||
strongSelf.updateAnimation()
|
||||
|
@ -527,14 +527,14 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi
|
||||
private func contextMenuSpeedItems(dismiss: @escaping () -> Void) -> Signal<[ContextMenuItem], NoError> {
|
||||
var items: [ContextMenuItem] = []
|
||||
|
||||
// items.append(.custom(SliderContextItem(minValue: 0.05, maxValue: 2.5, value: self.playbackBaseRate?.doubleValue ?? 1.0, valueChanged: { [weak self] newValue, finished in
|
||||
// self?.setRate?(AudioPlaybackRate(newValue), true)
|
||||
// if finished {
|
||||
// dismiss()
|
||||
// }
|
||||
// }), true))
|
||||
items.append(.custom(SliderContextItem(minValue: 0.5, maxValue: 2.5, value: self.playbackBaseRate?.doubleValue ?? 1.0, valueChanged: { [weak self] newValue, finished in
|
||||
self?.setRate?(AudioPlaybackRate(newValue), true)
|
||||
if finished {
|
||||
dismiss()
|
||||
}
|
||||
}), true))
|
||||
|
||||
// items.append(.separator)
|
||||
items.append(.separator)
|
||||
|
||||
for (text, _, rate) in self.speedList(strings: self.strings) {
|
||||
let isSelected = self.playbackBaseRate == rate
|
||||
|
@ -15,6 +15,7 @@ swift_library(
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/ContextUI:ContextUI",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/AnimatedCountLabelNode:AnimatedCountLabelNode",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -4,6 +4,7 @@ import Display
|
||||
import AsyncDisplayKit
|
||||
import ContextUI
|
||||
import TelegramPresentationData
|
||||
import AnimatedCountLabelNode
|
||||
|
||||
public final class SliderContextItem: ContextMenuCustomItem {
|
||||
private let minValue: CGFloat
|
||||
@ -23,15 +24,15 @@ public final class SliderContextItem: ContextMenuCustomItem {
|
||||
}
|
||||
}
|
||||
|
||||
private let textFont = Font.regular(17.0)
|
||||
private let textFont = Font.with(size: 17.0, design: .regular, traits: .monospacedNumbers)
|
||||
|
||||
private final class SliderContextItemNode: ASDisplayNode, ContextMenuCustomNode {
|
||||
private var presentationData: PresentationData
|
||||
|
||||
private let backgroundTextNode: ImmediateTextNode
|
||||
private let backgroundTextNode: ImmediateAnimatedCountLabelNode
|
||||
|
||||
private let foregroundNode: ASDisplayNode
|
||||
private let foregroundTextNode: ImmediateTextNode
|
||||
private let foregroundTextNode: ImmediateAnimatedCountLabelNode
|
||||
|
||||
let minValue: CGFloat
|
||||
let maxValue: CGFloat
|
||||
@ -51,24 +52,18 @@ private final class SliderContextItemNode: ASDisplayNode, ContextMenuCustomNode
|
||||
self.maxValue = maxValue
|
||||
self.value = value
|
||||
self.valueChanged = valueChanged
|
||||
|
||||
self.backgroundTextNode = ImmediateTextNode()
|
||||
self.backgroundTextNode.isAccessibilityElement = false
|
||||
self.backgroundTextNode.isUserInteractionEnabled = false
|
||||
self.backgroundTextNode.displaysAsynchronously = false
|
||||
self.backgroundTextNode.textAlignment = .left
|
||||
|
||||
self.backgroundTextNode = ImmediateAnimatedCountLabelNode()
|
||||
self.backgroundTextNode.alwaysOneDirection = true
|
||||
|
||||
self.foregroundNode = ASDisplayNode()
|
||||
self.foregroundNode.clipsToBounds = true
|
||||
self.foregroundNode.isAccessibilityElement = false
|
||||
self.foregroundNode.backgroundColor = UIColor(rgb: 0xffffff)
|
||||
self.foregroundNode.isUserInteractionEnabled = false
|
||||
|
||||
self.foregroundTextNode = ImmediateTextNode()
|
||||
self.foregroundTextNode.isAccessibilityElement = false
|
||||
self.foregroundTextNode.isUserInteractionEnabled = false
|
||||
self.foregroundTextNode.displaysAsynchronously = false
|
||||
self.foregroundTextNode.textAlignment = .left
|
||||
self.foregroundTextNode = ImmediateAnimatedCountLabelNode()
|
||||
self.foregroundTextNode.alwaysOneDirection = true
|
||||
|
||||
super.init()
|
||||
|
||||
@ -77,6 +72,27 @@ private final class SliderContextItemNode: ASDisplayNode, ContextMenuCustomNode
|
||||
self.addSubnode(self.backgroundTextNode)
|
||||
self.addSubnode(self.foregroundNode)
|
||||
self.foregroundNode.addSubnode(self.foregroundTextNode)
|
||||
|
||||
let stringValue = "1.0x"
|
||||
|
||||
let backgroundTextColor = self.presentationData.theme.contextMenu.secondaryColor
|
||||
let foregroundTextColor = UIColor.black
|
||||
|
||||
var backgroundSegments: [AnimatedCountLabelNode.Segment] = []
|
||||
var foregroundSegments: [AnimatedCountLabelNode.Segment] = []
|
||||
var textCount = 0
|
||||
for char in stringValue {
|
||||
if let intValue = Int(String(char)) {
|
||||
backgroundSegments.append(.number(intValue, NSAttributedString(string: String(char), font: textFont, textColor: backgroundTextColor)))
|
||||
foregroundSegments.append(.number(intValue, NSAttributedString(string: String(char), font: textFont, textColor: foregroundTextColor)))
|
||||
} else {
|
||||
backgroundSegments.append(.text(textCount, NSAttributedString(string: String(char), font: textFont, textColor: backgroundTextColor)))
|
||||
foregroundSegments.append(.text(textCount, NSAttributedString(string: String(char), font: textFont, textColor: foregroundTextColor)))
|
||||
textCount += 1
|
||||
}
|
||||
}
|
||||
self.backgroundTextNode.segments = backgroundSegments
|
||||
self.foregroundTextNode.segments = foregroundSegments
|
||||
}
|
||||
|
||||
override func didLoad() {
|
||||
@ -101,28 +117,43 @@ private final class SliderContextItemNode: ASDisplayNode, ContextMenuCustomNode
|
||||
let value = (self.value - self.minValue) / range
|
||||
transition.updateFrameAdditive(node: self.foregroundNode, frame: CGRect(origin: CGPoint(), size: CGSize(width: value * width, height: self.frame.height)))
|
||||
|
||||
var stringValue = String(format: "%.1fx", self.value)
|
||||
if stringValue.hasSuffix(".0x") {
|
||||
stringValue = stringValue.replacingOccurrences(of: ".0x", with: "x")
|
||||
}
|
||||
self.backgroundTextNode.attributedText = NSAttributedString(string: stringValue, font: textFont, textColor: UIColor(rgb: 0xffffff))
|
||||
self.foregroundTextNode.attributedText = NSAttributedString(string: stringValue, font: textFont, textColor: UIColor(rgb: 0x000000))
|
||||
let stringValue = String(format: "%.1fx", self.value)
|
||||
|
||||
let _ = self.backgroundTextNode.updateLayout(CGSize(width: 70.0, height: .greatestFiniteMagnitude))
|
||||
let _ = self.foregroundTextNode.updateLayout(CGSize(width: 70.0, height: .greatestFiniteMagnitude))
|
||||
let backgroundTextColor = self.presentationData.theme.contextMenu.secondaryColor
|
||||
let foregroundTextColor = UIColor.black
|
||||
|
||||
var backgroundSegments: [AnimatedCountLabelNode.Segment] = []
|
||||
var foregroundSegments: [AnimatedCountLabelNode.Segment] = []
|
||||
var textCount = 0
|
||||
for char in stringValue {
|
||||
if let intValue = Int(String(char)) {
|
||||
backgroundSegments.append(.number(intValue, NSAttributedString(string: String(char), font: textFont, textColor: backgroundTextColor)))
|
||||
foregroundSegments.append(.number(intValue, NSAttributedString(string: String(char), font: textFont, textColor: foregroundTextColor)))
|
||||
} else {
|
||||
backgroundSegments.append(.text(textCount, NSAttributedString(string: String(char), font: textFont, textColor: backgroundTextColor)))
|
||||
foregroundSegments.append(.text(textCount, NSAttributedString(string: String(char), font: textFont, textColor: foregroundTextColor)))
|
||||
textCount += 1
|
||||
}
|
||||
}
|
||||
self.backgroundTextNode.segments = backgroundSegments
|
||||
self.foregroundTextNode.segments = foregroundSegments
|
||||
|
||||
let _ = self.backgroundTextNode.updateLayout(size: CGSize(width: 70.0, height: .greatestFiniteMagnitude), animated: true)
|
||||
let _ = self.foregroundTextNode.updateLayout(size: CGSize(width: 70.0, height: .greatestFiniteMagnitude), animated: true)
|
||||
}
|
||||
|
||||
func updateLayout(constrainedWidth: CGFloat, constrainedHeight: CGFloat) -> (CGSize, (CGSize, ContainedViewLayoutTransition) -> Void) {
|
||||
let valueWidth: CGFloat = 70.0
|
||||
let height: CGFloat = 45.0
|
||||
|
||||
var textSize = self.backgroundTextNode.updateLayout(CGSize(width: valueWidth, height: .greatestFiniteMagnitude))
|
||||
textSize.width = valueWidth
|
||||
|
||||
var backgroundTextSize = self.backgroundTextNode.updateLayout(size: CGSize(width: 70.0, height: .greatestFiniteMagnitude), animated: true)
|
||||
backgroundTextSize.width = valueWidth
|
||||
let _ = self.foregroundTextNode.updateLayout(size: CGSize(width: 70.0, height: .greatestFiniteMagnitude), animated: true)
|
||||
|
||||
return (CGSize(width: height * 3.0, height: height), { size, transition in
|
||||
let leftInset: CGFloat = 17.0
|
||||
|
||||
let textFrame = CGRect(origin: CGPoint(x: leftInset, y: floor((size.height - textSize.height) / 2.0)), size: textSize)
|
||||
let textFrame = CGRect(origin: CGPoint(x: leftInset, y: floor((height - backgroundTextSize.height) / 2.0)), size: backgroundTextSize)
|
||||
transition.updateFrameAdditive(node: self.backgroundTextNode, frame: textFrame)
|
||||
transition.updateFrameAdditive(node: self.foregroundTextNode, frame: textFrame)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user