mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 01:10:09 +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 {
|
guard let self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
controller?.inProgress = true
|
||||||
let authorizationPushConfiguration = self.sharedContext.authorizationPushConfiguration
|
let authorizationPushConfiguration = self.sharedContext.authorizationPushConfiguration
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> timeout(2.0, queue: .mainQueue(), alternate: .single(nil))
|
|> timeout(2.0, queue: .mainQueue(), alternate: .single(nil))
|
||||||
let _ = (authorizationPushConfiguration
|
let _ = (authorizationPushConfiguration
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] authorizationPushConfiguration in
|
|> deliverOnMainQueue).start(next: { [weak self] authorizationPushConfiguration in
|
||||||
if let strongSelf = self {
|
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
|
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 {
|
guard let entry = CodableEntry(ApplicationSpecificCounterNotice(value: value)) else {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -2619,15 +2619,15 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
|
|||||||
c.setItems(strongSelf.contextMenuMainItems(dismiss: dismiss) |> map { ContextController.Items(content: .list($0)) }, minHeight: nil)
|
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
|
items.append(.custom(SliderContextItem(minValue: 0.5, maxValue: 2.5, value: status.baseRate, valueChanged: { [weak self] newValue, finished in
|
||||||
// guard let strongSelf = self, let videoNode = strongSelf.videoNode else {
|
guard let strongSelf = self else {
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
// videoNode.setBaseRate(newValue)
|
strongSelf.updatePlaybackRate(newValue)
|
||||||
// if finished {
|
if finished {
|
||||||
// dismiss()
|
dismiss()
|
||||||
// }
|
}
|
||||||
// }), true))
|
}), true))
|
||||||
|
|
||||||
items.append(.separator)
|
items.append(.separator)
|
||||||
|
|
||||||
|
|||||||
@ -192,17 +192,17 @@ open class ManagedAnimationNode: ASDisplayNode {
|
|||||||
|
|
||||||
displayLinkUpdate = { [weak self] in
|
displayLinkUpdate = { [weak self] in
|
||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let timestamp = CACurrentMediaTime()
|
// let timestamp = CACurrentMediaTime()
|
||||||
var delta: Double
|
// var delta: Double
|
||||||
if let previousTimestamp = strongSelf.previousTimestamp {
|
// if let previousTimestamp = strongSelf.previousTimestamp {
|
||||||
delta = min(timestamp - previousTimestamp, 1.0 / 60.0)
|
// delta = min(timestamp - previousTimestamp, 1.0 / 60.0)
|
||||||
if let currentDelta = strongSelf.delta, currentDelta < delta {
|
// if let currentDelta = strongSelf.delta, currentDelta < delta {
|
||||||
delta = currentDelta
|
// delta = currentDelta
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
delta = 1.0 / 60.0
|
let delta = 1.0 / 60.0
|
||||||
}
|
// }
|
||||||
strongSelf.previousTimestamp = timestamp
|
// strongSelf.previousTimestamp = timestamp
|
||||||
strongSelf.delta = delta
|
strongSelf.delta = delta
|
||||||
|
|
||||||
strongSelf.updateAnimation()
|
strongSelf.updateAnimation()
|
||||||
|
|||||||
@ -527,14 +527,14 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi
|
|||||||
private func contextMenuSpeedItems(dismiss: @escaping () -> Void) -> Signal<[ContextMenuItem], NoError> {
|
private func contextMenuSpeedItems(dismiss: @escaping () -> Void) -> Signal<[ContextMenuItem], NoError> {
|
||||||
var items: [ContextMenuItem] = []
|
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
|
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)
|
self?.setRate?(AudioPlaybackRate(newValue), true)
|
||||||
// if finished {
|
if finished {
|
||||||
// dismiss()
|
dismiss()
|
||||||
// }
|
}
|
||||||
// }), true))
|
}), true))
|
||||||
|
|
||||||
// items.append(.separator)
|
items.append(.separator)
|
||||||
|
|
||||||
for (text, _, rate) in self.speedList(strings: self.strings) {
|
for (text, _, rate) in self.speedList(strings: self.strings) {
|
||||||
let isSelected = self.playbackBaseRate == rate
|
let isSelected = self.playbackBaseRate == rate
|
||||||
|
|||||||
@ -15,6 +15,7 @@ swift_library(
|
|||||||
"//submodules/Display:Display",
|
"//submodules/Display:Display",
|
||||||
"//submodules/ContextUI:ContextUI",
|
"//submodules/ContextUI:ContextUI",
|
||||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||||
|
"//submodules/AnimatedCountLabelNode:AnimatedCountLabelNode",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import Display
|
|||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import ContextUI
|
import ContextUI
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
|
import AnimatedCountLabelNode
|
||||||
|
|
||||||
public final class SliderContextItem: ContextMenuCustomItem {
|
public final class SliderContextItem: ContextMenuCustomItem {
|
||||||
private let minValue: CGFloat
|
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 final class SliderContextItemNode: ASDisplayNode, ContextMenuCustomNode {
|
||||||
private var presentationData: PresentationData
|
private var presentationData: PresentationData
|
||||||
|
|
||||||
private let backgroundTextNode: ImmediateTextNode
|
private let backgroundTextNode: ImmediateAnimatedCountLabelNode
|
||||||
|
|
||||||
private let foregroundNode: ASDisplayNode
|
private let foregroundNode: ASDisplayNode
|
||||||
private let foregroundTextNode: ImmediateTextNode
|
private let foregroundTextNode: ImmediateAnimatedCountLabelNode
|
||||||
|
|
||||||
let minValue: CGFloat
|
let minValue: CGFloat
|
||||||
let maxValue: CGFloat
|
let maxValue: CGFloat
|
||||||
@ -52,11 +53,8 @@ private final class SliderContextItemNode: ASDisplayNode, ContextMenuCustomNode
|
|||||||
self.value = value
|
self.value = value
|
||||||
self.valueChanged = valueChanged
|
self.valueChanged = valueChanged
|
||||||
|
|
||||||
self.backgroundTextNode = ImmediateTextNode()
|
self.backgroundTextNode = ImmediateAnimatedCountLabelNode()
|
||||||
self.backgroundTextNode.isAccessibilityElement = false
|
self.backgroundTextNode.alwaysOneDirection = true
|
||||||
self.backgroundTextNode.isUserInteractionEnabled = false
|
|
||||||
self.backgroundTextNode.displaysAsynchronously = false
|
|
||||||
self.backgroundTextNode.textAlignment = .left
|
|
||||||
|
|
||||||
self.foregroundNode = ASDisplayNode()
|
self.foregroundNode = ASDisplayNode()
|
||||||
self.foregroundNode.clipsToBounds = true
|
self.foregroundNode.clipsToBounds = true
|
||||||
@ -64,11 +62,8 @@ private final class SliderContextItemNode: ASDisplayNode, ContextMenuCustomNode
|
|||||||
self.foregroundNode.backgroundColor = UIColor(rgb: 0xffffff)
|
self.foregroundNode.backgroundColor = UIColor(rgb: 0xffffff)
|
||||||
self.foregroundNode.isUserInteractionEnabled = false
|
self.foregroundNode.isUserInteractionEnabled = false
|
||||||
|
|
||||||
self.foregroundTextNode = ImmediateTextNode()
|
self.foregroundTextNode = ImmediateAnimatedCountLabelNode()
|
||||||
self.foregroundTextNode.isAccessibilityElement = false
|
self.foregroundTextNode.alwaysOneDirection = true
|
||||||
self.foregroundTextNode.isUserInteractionEnabled = false
|
|
||||||
self.foregroundTextNode.displaysAsynchronously = false
|
|
||||||
self.foregroundTextNode.textAlignment = .left
|
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
@ -77,6 +72,27 @@ private final class SliderContextItemNode: ASDisplayNode, ContextMenuCustomNode
|
|||||||
self.addSubnode(self.backgroundTextNode)
|
self.addSubnode(self.backgroundTextNode)
|
||||||
self.addSubnode(self.foregroundNode)
|
self.addSubnode(self.foregroundNode)
|
||||||
self.foregroundNode.addSubnode(self.foregroundTextNode)
|
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() {
|
override func didLoad() {
|
||||||
@ -101,28 +117,43 @@ private final class SliderContextItemNode: ASDisplayNode, ContextMenuCustomNode
|
|||||||
let value = (self.value - self.minValue) / range
|
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)))
|
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)
|
let 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 _ = self.backgroundTextNode.updateLayout(CGSize(width: 70.0, height: .greatestFiniteMagnitude))
|
let backgroundTextColor = self.presentationData.theme.contextMenu.secondaryColor
|
||||||
let _ = self.foregroundTextNode.updateLayout(CGSize(width: 70.0, height: .greatestFiniteMagnitude))
|
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) {
|
func updateLayout(constrainedWidth: CGFloat, constrainedHeight: CGFloat) -> (CGSize, (CGSize, ContainedViewLayoutTransition) -> Void) {
|
||||||
let valueWidth: CGFloat = 70.0
|
let valueWidth: CGFloat = 70.0
|
||||||
let height: CGFloat = 45.0
|
let height: CGFloat = 45.0
|
||||||
|
|
||||||
var textSize = self.backgroundTextNode.updateLayout(CGSize(width: valueWidth, height: .greatestFiniteMagnitude))
|
var backgroundTextSize = self.backgroundTextNode.updateLayout(size: CGSize(width: 70.0, height: .greatestFiniteMagnitude), animated: true)
|
||||||
textSize.width = valueWidth
|
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
|
return (CGSize(width: height * 3.0, height: height), { size, transition in
|
||||||
let leftInset: CGFloat = 17.0
|
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.backgroundTextNode, frame: textFrame)
|
||||||
transition.updateFrameAdditive(node: self.foregroundTextNode, frame: textFrame)
|
transition.updateFrameAdditive(node: self.foregroundTextNode, frame: textFrame)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user