Update Display to Swift 4.2

This commit is contained in:
Peter
2019-08-02 02:15:31 +03:00
parent d2482a2c8c
commit b97ff40a80
37 changed files with 180 additions and 241 deletions
@@ -5,7 +5,7 @@ import AsyncDisplayKit
public func addAccessibilityChildren(of node: ASDisplayNode, container: Any, to list: inout [Any]) {
if node.isAccessibilityElement {
let element = UIAccessibilityElement(accessibilityContainer: container)
element.accessibilityFrame = UIAccessibilityConvertFrameToScreenCoordinates(node.bounds, node.view)
element.accessibilityFrame = UIAccessibility.convertToScreenCoordinates(node.bounds, in: node.view)
element.accessibilityLabel = node.accessibilityLabel
element.accessibilityValue = node.accessibilityValue
element.accessibilityTraits = node.accessibilityTraits
@@ -139,7 +139,7 @@ final class ActionSheetControllerNode: ASDisplayNode, UIScrollViewDelegate {
}
self.itemGroupsContainerNode.animateDimViewsAlpha(from: 1.0, to: 0.0, duration: 0.3)
self.layer.animateBounds(from: self.bounds, to: self.bounds.offsetBy(dx: 0.0, dy: -self.bounds.size.height), duration: 0.35, timingFunction: kCAMediaTimingFunctionEaseOut, removeOnCompletion: false, completion: { [weak self, weak tempDimView] _ in
self.layer.animateBounds(from: self.bounds, to: self.bounds.offsetBy(dx: 0.0, dy: -self.bounds.size.height), duration: 0.35, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue, removeOnCompletion: false, completion: { [weak self, weak tempDimView] _ in
tempDimView?.removeFromSuperview()
self?.dismiss(cancelled)
@@ -60,7 +60,7 @@ public extension CALayer {
animation.fromValue = from
animation.toValue = to
animation.isRemovedOnCompletion = removeOnCompletion
animation.fillMode = kCAFillModeForwards
animation.fillMode = .forwards
if let completion = completion {
animation.delegate = CALayerAnimationDelegate(animation: animation, completion: completion)
}
@@ -76,7 +76,7 @@ public extension CALayer {
if !delay.isZero {
animation.beginTime = CACurrentMediaTime() + delay
animation.fillMode = kCAFillModeBoth
animation.fillMode = .both
}
return animation
@@ -94,10 +94,10 @@ public extension CALayer {
if let mediaTimingFunction = mediaTimingFunction {
animation.timingFunction = mediaTimingFunction
} else {
animation.timingFunction = CAMediaTimingFunction(name: timingFunction)
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName(rawValue: timingFunction))
}
animation.isRemovedOnCompletion = removeOnCompletion
animation.fillMode = kCAFillModeForwards
animation.fillMode = .forwards
animation.speed = speed
animation.isAdditive = additive
if let completion = completion {
@@ -106,7 +106,7 @@ public extension CALayer {
if !delay.isZero {
animation.beginTime = CACurrentMediaTime() + delay
animation.fillMode = kCAFillModeBoth
animation.fillMode = .both
}
return animation
@@ -169,7 +169,7 @@ public extension CALayer {
animation.fromValue = from
animation.toValue = to
animation.isRemovedOnCompletion = removeOnCompletion
animation.fillMode = kCAFillModeForwards
animation.fillMode = .forwards
if let completion = completion {
animation.delegate = CALayerAnimationDelegate(animation: animation, completion: completion)
}
@@ -200,10 +200,10 @@ public extension CALayer {
if let mediaTimingFunction = mediaTimingFunction {
animation.timingFunction = mediaTimingFunction
} else {
animation.timingFunction = CAMediaTimingFunction(name: timingFunction)
animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName(rawValue: timingFunction))
}
animation.isRemovedOnCompletion = removeOnCompletion
animation.fillMode = kCAFillModeForwards
animation.fillMode = .forwards
animation.speed = speed
animation.isAdditive = true
if let completion = completion {
@@ -213,19 +213,19 @@ public extension CALayer {
self.add(animation, forKey: key)
}
public func animateAlpha(from: CGFloat, to: CGFloat, duration: Double, delay: Double = 0.0, timingFunction: String = kCAMediaTimingFunctionEaseInEaseOut, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, completion: ((Bool) -> ())? = nil) {
public func animateAlpha(from: CGFloat, to: CGFloat, duration: Double, delay: Double = 0.0, timingFunction: String = CAMediaTimingFunctionName.easeInEaseOut.rawValue, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, completion: ((Bool) -> ())? = nil) {
self.animate(from: NSNumber(value: Float(from)), to: NSNumber(value: Float(to)), keyPath: "opacity", timingFunction: timingFunction, duration: duration, delay: delay, mediaTimingFunction: mediaTimingFunction, removeOnCompletion: removeOnCompletion, completion: completion)
}
public func animateScale(from: CGFloat, to: CGFloat, duration: Double, delay: Double = 0.0, timingFunction: String = kCAMediaTimingFunctionEaseInEaseOut, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
public func animateScale(from: CGFloat, to: CGFloat, duration: Double, delay: Double = 0.0, timingFunction: String = CAMediaTimingFunctionName.easeInEaseOut.rawValue, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
self.animate(from: NSNumber(value: Float(from)), to: NSNumber(value: Float(to)), keyPath: "transform.scale", timingFunction: timingFunction, duration: duration, delay: delay, mediaTimingFunction: mediaTimingFunction, removeOnCompletion: removeOnCompletion, completion: completion)
}
public func animateRotation(from: CGFloat, to: CGFloat, duration: Double, delay: Double = 0.0, timingFunction: String = kCAMediaTimingFunctionEaseInEaseOut, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
public func animateRotation(from: CGFloat, to: CGFloat, duration: Double, delay: Double = 0.0, timingFunction: String = CAMediaTimingFunctionName.easeInEaseOut.rawValue, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
self.animate(from: NSNumber(value: Float(from)), to: NSNumber(value: Float(to)), keyPath: "transform.rotation.z", timingFunction: timingFunction, duration: duration, delay: delay, mediaTimingFunction: mediaTimingFunction, removeOnCompletion: removeOnCompletion, completion: completion)
}
func animatePosition(from: CGPoint, to: CGPoint, duration: Double, delay: Double = 0.0, timingFunction: String = kCAMediaTimingFunctionEaseInEaseOut, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, additive: Bool = false, force: Bool = false, completion: ((Bool) -> Void)? = nil) {
func animatePosition(from: CGPoint, to: CGPoint, duration: Double, delay: Double = 0.0, timingFunction: String = CAMediaTimingFunctionName.easeInEaseOut.rawValue, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, additive: Bool = false, force: Bool = false, completion: ((Bool) -> Void)? = nil) {
if from == to && !force {
if let completion = completion {
completion(true)
@@ -245,20 +245,20 @@ public extension CALayer {
self.animate(from: NSValue(cgRect: from), to: NSValue(cgRect: to), keyPath: "bounds", timingFunction: timingFunction, duration: duration, mediaTimingFunction: mediaTimingFunction, removeOnCompletion: removeOnCompletion, additive: additive, completion: completion)
}
public func animateBoundsOriginXAdditive(from: CGFloat, to: CGFloat, duration: Double, timingFunction: String = kCAMediaTimingFunctionEaseInEaseOut, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
public func animateBoundsOriginXAdditive(from: CGFloat, to: CGFloat, duration: Double, timingFunction: String = CAMediaTimingFunctionName.easeInEaseOut.rawValue, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
self.animate(from: from as NSNumber, to: to as NSNumber, keyPath: "bounds.origin.x", timingFunction: timingFunction, duration: duration, mediaTimingFunction: mediaTimingFunction, removeOnCompletion: removeOnCompletion, additive: true, completion: completion)
}
public func animateBoundsOriginYAdditive(from: CGFloat, to: CGFloat, duration: Double, timingFunction: String = kCAMediaTimingFunctionEaseInEaseOut, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
public func animateBoundsOriginYAdditive(from: CGFloat, to: CGFloat, duration: Double, timingFunction: String = CAMediaTimingFunctionName.easeInEaseOut.rawValue, mediaTimingFunction: CAMediaTimingFunction? = nil, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
self.animate(from: from as NSNumber, to: to as NSNumber, keyPath: "bounds.origin.y", timingFunction: timingFunction, duration: duration, mediaTimingFunction: mediaTimingFunction, removeOnCompletion: removeOnCompletion, additive: true, completion: completion)
}
public func animateBoundsOriginXAdditive(from: CGFloat, to: CGFloat, duration: Double, mediaTimingFunction: CAMediaTimingFunction) {
self.animate(from: from as NSNumber, to: to as NSNumber, keyPath: "bounds.origin.x", timingFunction: kCAMediaTimingFunctionEaseInEaseOut, duration: duration, mediaTimingFunction: mediaTimingFunction, additive: true)
self.animate(from: from as NSNumber, to: to as NSNumber, keyPath: "bounds.origin.x", timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, duration: duration, mediaTimingFunction: mediaTimingFunction, additive: true)
}
public func animateBoundsOriginYAdditive(from: CGFloat, to: CGFloat, duration: Double, mediaTimingFunction: CAMediaTimingFunction) {
self.animate(from: from as NSNumber, to: to as NSNumber, keyPath: "bounds.origin.y", timingFunction: kCAMediaTimingFunctionEaseInEaseOut, duration: duration, mediaTimingFunction: mediaTimingFunction, additive: true)
self.animate(from: from as NSNumber, to: to as NSNumber, keyPath: "bounds.origin.y", timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, duration: duration, mediaTimingFunction: mediaTimingFunction, additive: true)
}
public func animatePositionKeyframes(values: [CGPoint], duration: Double, removeOnCompletion: Bool = true, completion: ((Bool) -> Void)? = nil) {
@@ -16,11 +16,11 @@ public extension ContainedViewLayoutTransitionCurve {
var timingFunction: String {
switch self {
case .easeInOut:
return kCAMediaTimingFunctionEaseInEaseOut
return CAMediaTimingFunctionName.easeInEaseOut.rawValue
case .spring:
return kCAMediaTimingFunctionSpring
case .custom:
return kCAMediaTimingFunctionEaseInEaseOut
return CAMediaTimingFunctionName.easeInEaseOut.rawValue
}
}
@@ -36,12 +36,12 @@ public extension ContainedViewLayoutTransitionCurve {
}
#if os(iOS)
var viewAnimationOptions: UIViewAnimationOptions {
var viewAnimationOptions: UIView.AnimationOptions {
switch self {
case .easeInOut:
return [.curveEaseInOut]
case .spring:
return UIViewAnimationOptions(rawValue: 7 << 16)
return UIView.AnimationOptions(rawValue: 7 << 16)
case .custom:
return []
}
@@ -24,7 +24,7 @@ final class ContextMenuActionNode: ASDisplayNode {
init(action: ContextMenuAction) {
self.actionArea = AccessibilityAreaNode()
self.actionArea.accessibilityTraits = UIAccessibilityTraitButton
self.actionArea.accessibilityTraits = .button
switch action.content {
case let .text(title, accessibilityLabel):
@@ -16,7 +16,7 @@ public final class ContextMenuController: ViewController, KeyShortcutResponder {
}
public var keyShortcuts: [KeyShortcut] {
return [KeyShortcut(input: UIKeyInputEscape, action: { [weak self] in
return [KeyShortcut(input: UIKeyCommand.inputEscape, action: { [weak self] in
if let strongSelf = self {
strongSelf.dismiss()
}
@@ -16,7 +16,7 @@ public class DisplayLinkDispatcher: NSObject {
} else {
self.displayLink = CADisplayLink(target: self, selector: #selector(self.run))
self.displayLink.isPaused = true
self.displayLink.add(to: RunLoop.main, forMode: RunLoopMode.commonModes)
self.displayLink.add(to: RunLoop.main, forMode: .common)
}
}
+4 -4
View File
@@ -69,15 +69,15 @@ public struct Font {
public extension NSAttributedString {
convenience init(string: String, font: UIFont? = nil, textColor: UIColor = UIColor.black, paragraphAlignment: NSTextAlignment? = nil) {
var attributes: [NSAttributedStringKey: AnyObject] = [:]
var attributes: [NSAttributedString.Key: AnyObject] = [:]
if let font = font {
attributes[NSAttributedStringKey.font] = font
attributes[NSAttributedString.Key.font] = font
}
attributes[NSAttributedStringKey.foregroundColor] = textColor
attributes[NSAttributedString.Key.foregroundColor] = textColor
if let paragraphAlignment = paragraphAlignment {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = paragraphAlignment
attributes[NSAttributedStringKey.paragraphStyle] = paragraphStyle
attributes[NSAttributedString.Key.paragraphStyle] = paragraphStyle
}
self.init(string: string, attributes: attributes)
}
+8 -8
View File
@@ -237,7 +237,7 @@ open class GridNode: GridNodeScroller, UIScrollViewDelegate {
}
}
public var indicatorStyle: UIScrollViewIndicatorStyle = .default {
public var indicatorStyle: UIScrollView.IndicatorStyle = .default {
didSet {
self.scrollView.indicatorStyle = self.indicatorStyle
}
@@ -1015,8 +1015,8 @@ open class GridNode: GridNodeScroller, UIScrollViewDelegate {
if !existingItemIndices.contains(index) {
if let _ = previousItemFrames[WrappedGridItemNode(node: itemNode)] {
self.removeItemNodeWithIndex(index, removeNode: false)
itemNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseIn, removeOnCompletion: false)
itemNode.layer.animateScale(from: 1.0, to: 0.1, duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseIn, removeOnCompletion: false, completion: { [weak itemNode] _ in
itemNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, timingFunction: CAMediaTimingFunctionName.easeIn.rawValue, removeOnCompletion: false)
itemNode.layer.animateScale(from: 1.0, to: 0.1, duration: 0.2, timingFunction: CAMediaTimingFunctionName.easeIn.rawValue, removeOnCompletion: false, completion: { [weak itemNode] _ in
itemNode?.removeFromSupernode()
})
} else {
@@ -1025,15 +1025,15 @@ open class GridNode: GridNodeScroller, UIScrollViewDelegate {
} else if let previousFrame = previousItemFrames[WrappedGridItemNode(node: itemNode)] {
itemNode.layer.animatePosition(from: CGPoint(x: previousFrame.midX, y: previousFrame.midY + contentOffset.y), to: itemNode.layer.position, duration: duration, timingFunction: timingFunction, mediaTimingFunction: mediaTimingFunction)
} else {
itemNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.12, timingFunction: kCAMediaTimingFunctionEaseIn)
itemNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.12, timingFunction: CAMediaTimingFunctionName.easeIn.rawValue)
itemNode.layer.animateSpring(from: 0.1 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.5)
}
}
for itemNode in removedNodes {
if let _ = previousItemFrames[WrappedGridItemNode(node: itemNode)] {
itemNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.18, timingFunction: kCAMediaTimingFunctionEaseIn, removeOnCompletion: false)
itemNode.layer.animateScale(from: 1.0, to: 0.1, duration: 0.18, timingFunction: kCAMediaTimingFunctionEaseIn, removeOnCompletion: false, completion: { [weak itemNode] _ in
itemNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.18, timingFunction: CAMediaTimingFunctionName.easeIn.rawValue, removeOnCompletion: false)
itemNode.layer.animateScale(from: 1.0, to: 0.1, duration: 0.18, timingFunction: CAMediaTimingFunctionName.easeIn.rawValue, removeOnCompletion: false, completion: { [weak itemNode] _ in
itemNode?.removeFromSupernode()
})
} else {
@@ -1055,7 +1055,7 @@ open class GridNode: GridNodeScroller, UIScrollViewDelegate {
} else if let previousFrame = previousItemFrames[WrappedGridItemNode(node: sectionNode)] {
sectionNode.layer.animatePosition(from: CGPoint(x: previousFrame.midX, y: previousFrame.midY + contentOffset.y), to: sectionNode.layer.position, duration: duration, timingFunction: timingFunction, mediaTimingFunction: mediaTimingFunction)
} else {
sectionNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseIn)
sectionNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2, timingFunction: CAMediaTimingFunctionName.easeIn.rawValue)
}
}
} else {
@@ -1121,7 +1121,7 @@ open class GridNode: GridNodeScroller, UIScrollViewDelegate {
if addedNodes {
if let verticalIndicator = verticalIndicator, self.scrollView.subviews.last !== verticalIndicator {
verticalIndicator.superview?.bringSubview(toFront: verticalIndicator)
verticalIndicator.superview?.bringSubviewToFront(verticalIndicator)
}
}
@@ -21,7 +21,7 @@ public class ImmediateTextNode: TextNode {
public var trailingLineWidth: CGFloat?
public var highlightAttributeAction: (([NSAttributedStringKey: Any]) -> NSAttributedStringKey?)? {
public var highlightAttributeAction: (([NSAttributedString.Key: Any]) -> NSAttributedString.Key?)? {
didSet {
if self.isNodeLoaded {
self.updateInteractiveActions()
@@ -29,8 +29,8 @@ public class ImmediateTextNode: TextNode {
}
}
public var tapAttributeAction: (([NSAttributedStringKey: Any]) -> Void)?
public var longTapAttributeAction: (([NSAttributedStringKey: Any]) -> Void)?
public var tapAttributeAction: (([NSAttributedString.Key: Any]) -> Void)?
public var longTapAttributeAction: (([NSAttributedString.Key: Any]) -> Void)?
public func updateLayout(_ constrainedSize: CGSize) -> CGSize {
let makeLayout = TextNode.asyncLayout(self)
@@ -43,7 +43,7 @@ open class LegacyPresentedController: ViewController {
self?.dismiss()
}*/
if !asPresentable {
self.addChildViewController(legacyController)
self.addChild(legacyController)
}
}
@@ -67,7 +67,7 @@ open class LegacyPresentedController: ViewController {
self.controllerNode.controllerView = self.legacyController.view
self.controllerNode.view.addSubview(self.legacyController.view)
self.legacyController.didMove(toParentViewController: self)
self.legacyController.didMove(toParent: self)
if let controllerLoaded = self.controllerLoaded {
controllerLoaded()
@@ -33,7 +33,7 @@ final class LegacyPresentedControllerNode: ASDisplayNode {
}
func animateModalOut(completion: @escaping () -> Void) {
self.layer.animatePosition(from: self.layer.position, to: CGPoint(x: self.layer.position.x, y: self.layer.position.y + self.layer.bounds.size.height), duration: 0.2, timingFunction: kCAMediaTimingFunctionEaseInEaseOut, removeOnCompletion: false, completion: { _ in
self.layer.animatePosition(from: self.layer.position, to: CGPoint(x: self.layer.position.x, y: self.layer.position.y + self.layer.bounds.size.height), duration: 0.2, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false, completion: { _ in
completion()
})
}
+38 -103
View File
@@ -6,8 +6,6 @@ import SwiftSignalKit
import DisplayPrivate
#endif
private let useBackgroundDeallocation = false
private let infiniteScrollSize: CGFloat = 10000.0
private let insertionAnimationDuration: Double = 0.4
@@ -359,7 +357,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}))
self.displayLink = CADisplayLink(target: DisplayLinkProxy(target: self), selector: #selector(DisplayLinkProxy.displayLinkEvent))
self.displayLink.add(to: RunLoop.main, forMode: RunLoopMode.commonModes)
self.displayLink.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
if #available(iOS 10.0, *) {
self.displayLink.preferredFramesPerSecond = 60
@@ -372,25 +370,15 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
self.pauseAnimations()
self.displayLink.invalidate()
if useBackgroundDeallocation {
assertionFailure()
/*for itemNode in self.itemNodes {
ASDeallocQueue.sharedDeallocation.releaseObject(inBackground: UnsafeMutablePointer(itemNode))
}
for itemHeaderNode in self.itemHeaderNodes {
ASDeallocQueue.sharedDeallocatio.releaseObject(inBackground: itemHeaderNode)
}*/
} else {
for i in (0 ..< self.itemNodes.count).reversed() {
var itemNode: AnyObject? = self.itemNodes[i]
self.itemNodes.remove(at: i)
ASPerformMainThreadDeallocation(&itemNode)
}
for key in self.itemHeaderNodes.keys {
var itemHeaderNode: AnyObject? = self.itemHeaderNodes[key]
self.itemHeaderNodes.removeValue(forKey: key)
ASPerformMainThreadDeallocation(&itemHeaderNode)
}
for i in (0 ..< self.itemNodes.count).reversed() {
var itemNode: AnyObject? = self.itemNodes[i]
self.itemNodes.remove(at: i)
ASPerformMainThreadDeallocation(&itemNode)
}
for key in self.itemHeaderNodes.keys {
var itemHeaderNode: AnyObject? = self.itemHeaderNodes[key]
self.itemHeaderNodes.removeValue(forKey: key)
ASPerformMainThreadDeallocation(&itemHeaderNode)
}
self.waitingForNodesDisposable.dispose()
@@ -446,8 +434,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
self.reorderNode = nil
if let itemNode = reorderNode.itemNode, itemNode.supernode == self {
self.reorderItemNodeToFront(itemNode)
reorderNode.animateCompletion(completion: { [weak itemNode, weak reorderNode] in
//itemNode?.isHidden = false
reorderNode.animateCompletion(completion: { [weak reorderNode] in
reorderNode?.removeFromSupernode()
})
self.setNeedsAnimations()
@@ -545,7 +532,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
}, selector: #selector(ListViewTimerProxy.timerEvent), userInfo: nil, repeats: false)
self.flashNodesDelayTimer = timer
RunLoop.main.add(timer, forMode: RunLoopMode.commonModes)
RunLoop.main.add(timer, forMode: RunLoop.Mode.common)
self.updateHeaderItemsFlashing(animated: true)
}
}
@@ -568,7 +555,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
}, selector: #selector(ListViewTimerProxy.timerEvent), userInfo: nil, repeats: false)
self.flashScrollIndicatorTimer = timer
RunLoop.main.add(timer, forMode: RunLoopMode.commonModes)
RunLoop.main.add(timer, forMode: RunLoop.Mode.common)
} else {
self.verticalScrollIndicator?.layer.removeAnimation(forKey: "opacity")
self.verticalScrollIndicator?.alpha = 1.0
@@ -1132,9 +1119,9 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
for itemNode in self.itemNodes {
if itemNode.isHighlightedInOverlay {
lowestOverlayNode = itemNode
itemNode.view.superview?.bringSubview(toFront: itemNode.view)
itemNode.view.superview?.bringSubviewToFront(itemNode.view)
if let verticalScrollIndicator = self.verticalScrollIndicator {
verticalScrollIndicator.view.superview?.bringSubview(toFront: verticalScrollIndicator.view)
verticalScrollIndicator.view.superview?.bringSubviewToFront(verticalScrollIndicator.view)
}
}
}
@@ -1154,18 +1141,18 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
} else if let itemHighlightOverlayBackground = self.itemHighlightOverlayBackground {
self.itemHighlightOverlayBackground = nil
for (_, headerNode) in self.itemHeaderNodes {
for (_, _) in self.itemHeaderNodes {
//self.view.bringSubview(toFront: headerNode.view)
}
//self.view.bringSubview(toFront: itemHighlightOverlayBackground.view)
for itemNode in self.itemNodes {
for _ in self.itemNodes {
//self.view.bringSubview(toFront: itemNode.view)
}
transition.updateAlpha(node: itemHighlightOverlayBackground, alpha: 0.0, completion: { [weak itemHighlightOverlayBackground] _ in
itemHighlightOverlayBackground?.removeFromSupernode()
})
if let verticalScrollIndicator = self.verticalScrollIndicator {
verticalScrollIndicator.view.superview?.bringSubview(toFront: verticalScrollIndicator.view)
verticalScrollIndicator.view.superview?.bringSubviewToFront(verticalScrollIndicator.view)
}
}
}
@@ -1650,12 +1637,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
if let strongSelf = self {
strongSelf.replayOperations(animated: animated, animateAlpha: options.contains(.AnimateAlpha), animateCrossfade: options.contains(.AnimateCrossfade), synchronous: options.contains(.Synchronous), animateTopItemVerticalOrigin: options.contains(.AnimateTopItemPosition), operations: updatedOperations, requestItemInsertionAnimationsIndices: options.contains(.RequestItemInsertionAnimations) ? insertedIndexSet : Set(), scrollToItem: scrollToItem, additionalScrollDistance: additionalScrollDistance, updateSizeAndInsets: updateSizeAndInsets, stationaryItemIndex: stationaryItemIndex, updateOpaqueState: updateOpaqueState, completion: {
if options.contains(.PreferSynchronousDrawing) {
let startTime = CACurrentMediaTime()
self?.recursivelyEnsureDisplaySynchronously(true)
let deltaTime = CACurrentMediaTime() - startTime
if false {
print("ListView: waited \(deltaTime * 1000.0) ms for nodes to display")
}
}
completion()
})
@@ -1666,12 +1648,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
let readyWithTimeout = combineLatest(readySignals)
|> deliverOnMainQueue
|> timeout(0.2, queue: Queue.mainQueue(), alternate: .single([]))
let startTime = CACurrentMediaTime()
self.waitingForNodesDisposable.set(readyWithTimeout.start(completed: {
let deltaTime = CACurrentMediaTime() - startTime
if false {
print("ListView: waited \(deltaTime * 1000.0) ms for nodes to load")
}
beginReplay()
}))
} else {
@@ -1905,7 +1882,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
if nextNode.index == nil && nextNode.subnodes == nil || nextNode.subnodes!.isEmpty {
let nextHeight = nextNode.apparentHeight
if abs(nextHeight - previousApparentHeight) < CGFloat.ulpOfOne {
if let animation = nextNode.animationForKey("apparentHeight") {
if let _ = nextNode.animationForKey("apparentHeight") {
node.apparentHeight = previousApparentHeight
offsetHeight = 0.0
@@ -2363,9 +2340,9 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
if hadInserts, let reorderNode = self.reorderNode, reorderNode.supernode != nil {
self.view.bringSubview(toFront: reorderNode.view)
self.view.bringSubviewToFront(reorderNode.view)
if let verticalScrollIndicator = self.verticalScrollIndicator {
verticalScrollIndicator.view.superview?.bringSubview(toFront: verticalScrollIndicator.view)
verticalScrollIndicator.view.superview?.bringSubviewToFront(verticalScrollIndicator.view)
}
}
@@ -2535,7 +2512,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
case let .Default(duration):
headerNodesTransition = (.animated(duration: max(duration ?? 0.3, updateSizeAndInsets.duration), curve: .easeInOut), false, -completeOffset)
let basicAnimation = CABasicAnimation(keyPath: "sublayerTransform")
basicAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
basicAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
basicAnimation.duration = updateSizeAndInsets.duration * UIView.animationDurationFactor()
basicAnimation.fromValue = NSValue(caTransform3D: CATransform3DMakeTranslation(0.0, -completeOffset, 0.0))
basicAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
@@ -2751,7 +2728,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
springAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
springAnimation.isRemovedOnCompletion = true
springAnimation.isAdditive = true
springAnimation.fillMode = kCAFillModeForwards
springAnimation.fillMode = CAMediaTimingFillMode.forwards
let k = Float(UIView.animationDurationFactor())
var speed: Float = 1.0
@@ -2767,7 +2744,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
reverseSpringAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
reverseSpringAnimation.isRemovedOnCompletion = true
reverseSpringAnimation.isAdditive = true
reverseSpringAnimation.fillMode = kCAFillModeForwards
reverseSpringAnimation.fillMode = CAMediaTimingFillMode.forwards
reverseSpringAnimation.speed = speed * Float(reverseSpringAnimation.duration / duration)
@@ -2776,7 +2753,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
case let .Default(duration):
if let duration = duration {
let basicAnimation = CABasicAnimation(keyPath: "sublayerTransform")
basicAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
basicAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
basicAnimation.duration = duration * UIView.animationDurationFactor()
basicAnimation.fromValue = NSValue(caTransform3D: CATransform3DMakeTranslation(0.0, -offset, 0.0))
basicAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
@@ -2784,7 +2761,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
basicAnimation.isAdditive = true
let reverseBasicAnimation = CABasicAnimation(keyPath: "sublayerTransform")
reverseBasicAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
reverseBasicAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut)
reverseBasicAnimation.duration = duration * UIView.animationDurationFactor()
reverseBasicAnimation.fromValue = NSValue(caTransform3D: CATransform3DMakeTranslation(0.0, offset, 0.0))
reverseBasicAnimation.toValue = NSValue(caTransform3D: CATransform3DIdentity)
@@ -2817,38 +2794,15 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
animation.completion = { _ in
for itemNode in temporaryPreviousNodes {
itemNode.removeFromSupernode()
if useBackgroundDeallocation {
assertionFailure()
//ASDeallocQueue.sharedDeallocation().releaseObject(inBackground: itemNode)
} else {
//ASPerformMainThreadDeallocation(itemNode)
}
}
for headerNode in temporaryHeaderNodes {
headerNode.removeFromSupernode()
if useBackgroundDeallocation {
assertionFailure()
//ASDeallocQueue.sharedDeallocation().releaseObject(inBackground: headerNode)
} else {
//ASPerformMainThreadDeallocation(headerNode)
}
}
}
self.layer.add(animation, forKey: nil)
if let verticalScrollIndicator = self.verticalScrollIndicator {
verticalScrollIndicator.layer.add(reverseAnimation, forKey: nil)
}
} else {
if useBackgroundDeallocation {
assertionFailure()
/*for itemNode in temporaryPreviousNodes {
ASDeallocQueue.sharedDeallocation().releaseObject(inBackground: itemNode)
}*/
} else {
for itemNode in temporaryPreviousNodes {
//ASPerformMainThreadDeallocation(itemNode)
}
}
}
}
@@ -2891,17 +2845,6 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
//print("replayOperations \(delta * 1000.0) ms")
}
for (previousNode, _) in previousApparentFrames {
if previousNode.supernode == nil {
if useBackgroundDeallocation {
assertionFailure()
//ASDeallocQueue.sharedDeallocatio.releaseObject(inBackground: previousNode)
} else {
//ASPerformMainThreadDeallocation(previousNode)
}
}
}
completion()
}
}
@@ -2974,7 +2917,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
if transition.1 {
headerNode.layer.animateBoundsOriginYAdditive(from: offset, to: 0.0, duration: duration, mediaTimingFunction: ContainedViewLayoutTransitionCurve.slide.mediaTimingFunction)
} else {
headerNode.layer.animateBoundsOriginYAdditive(from: offset, to: 0.0, duration: duration, mediaTimingFunction: CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut))
headerNode.layer.animateBoundsOriginYAdditive(from: offset, to: 0.0, duration: duration, mediaTimingFunction: CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut))
}
}
}
@@ -3122,10 +3065,8 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
updatedAccessoryItemNodeOrigin.x += updatedParentOrigin.x
updatedAccessoryItemNodeOrigin.y += updatedParentOrigin.y
updatedAccessoryItemNodeOrigin.y -= itemNode.bounds.origin.y
//updatedAccessoryItemNodeOrigin.y += itemNode.transitionOffset
var deltaHeight = itemNode.frame.size.height - nextItemNode.frame.size.height
//deltaHeight = 0.0
let deltaHeight = itemNode.frame.size.height - nextItemNode.frame.size.height
nextAccessoryItemNode.animateTransitionOffset(CGPoint(x: 0.0, y: updatedAccessoryItemNodeOrigin.y - previousAccessoryItemNodeOrigin.y - deltaHeight), beginAt: currentTimestamp, duration: insertionAnimationDuration * UIView.animationDurationFactor(), curve: listViewAnimationCurveSystem)
}
@@ -3343,12 +3284,6 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
let node = self.itemNodes[i]
if node.index == nil && node.apparentHeight <= CGFloat.ulpOfOne {
self.removeItemNodeAtIndex(i)
if useBackgroundDeallocation {
assertionFailure()
//ASDeallocQueue.sharedDeallocation().releaseObject(inBackground: node)
} else {
//ASPerformMainThreadDeallocation(node)
}
} else {
i += 1
}
@@ -3645,7 +3580,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
}, selector: #selector(ListViewTimerProxy.timerEvent), userInfo: nil, repeats: false)
strongSelf.selectionLongTapDelayTimer = timer
RunLoop.main.add(timer, forMode: RunLoopMode.commonModes)
RunLoop.main.add(timer, forMode: RunLoop.Mode.common)
}
}
break
@@ -3656,7 +3591,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
}, selector: #selector(ListViewTimerProxy.timerEvent), userInfo: nil, repeats: false)
self.selectionTouchDelayTimer = timer
RunLoop.main.add(timer, forMode: RunLoopMode.commonModes)
RunLoop.main.add(timer, forMode: RunLoop.Mode.common)
super.touchesBegan(touches, with: event)
@@ -3901,22 +3836,22 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
private func reorderItemNodeToFront(_ itemNode: ListViewItemNode) {
itemNode.view.superview?.bringSubview(toFront: itemNode.view)
itemNode.view.superview?.bringSubviewToFront(itemNode.view)
if let itemHighlightOverlayBackground = self.itemHighlightOverlayBackground {
itemHighlightOverlayBackground.view.superview?.bringSubview(toFront: itemHighlightOverlayBackground.view)
itemHighlightOverlayBackground.view.superview?.bringSubviewToFront(itemHighlightOverlayBackground.view)
}
if let verticalScrollIndicator = self.verticalScrollIndicator {
verticalScrollIndicator.view.superview?.bringSubview(toFront: verticalScrollIndicator.view)
verticalScrollIndicator.view.superview?.bringSubviewToFront(verticalScrollIndicator.view)
}
}
private func reorderHeaderNodeToFront(_ headerNode: ListViewItemHeaderNode) {
headerNode.view.superview?.bringSubview(toFront: headerNode.view)
headerNode.view.superview?.bringSubviewToFront(headerNode.view)
if let itemHighlightOverlayBackground = self.itemHighlightOverlayBackground {
itemHighlightOverlayBackground.view.superview?.bringSubview(toFront: itemHighlightOverlayBackground.view)
itemHighlightOverlayBackground.view.superview?.bringSubviewToFront(itemHighlightOverlayBackground.view)
}
if let verticalScrollIndicator = self.verticalScrollIndicator {
verticalScrollIndicator.view.superview?.bringSubview(toFront: verticalScrollIndicator.view)
verticalScrollIndicator.view.superview?.bringSubviewToFront(verticalScrollIndicator.view)
}
}
@@ -3958,10 +3893,10 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
if let (_, frame) = accessibilityFocusedNode {
for itemNode in self.itemNodes {
if frame.intersects(itemNode.frame) {
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, itemNode.view)
UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: itemNode.view)
if let index = itemNode.index {
let scrollStatus = "Row \(index + 1) of \(self.items.count)"
UIAccessibilityPostNotification(UIAccessibilityPageScrolledNotification, scrollStatus)
UIAccessibility.post(notification: UIAccessibility.Notification.pageScrolled, argument: scrollStatus)
}
break
}
@@ -97,7 +97,7 @@ public let listViewAnimationCurveLinear: (CGFloat) -> CGFloat = { t in
}
#if os(iOS)
public func listViewAnimationCurveFromAnimationOptions(animationOptions: UIViewAnimationOptions) -> (CGFloat) -> CGFloat {
public func listViewAnimationCurveFromAnimationOptions(animationOptions: UIView.AnimationOptions) -> (CGFloat) -> CGFloat {
if animationOptions.rawValue == UInt(7 << 16) {
return listViewAnimationCurveSystem
} else {
@@ -112,7 +112,7 @@ private final class WindowRootViewController: UIViewController, UIViewController
self.extendedLayoutIncludesOpaqueBars = true
if #available(iOSApplicationExtension 11.0, *) {
self.voiceOverStatusObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name.UIAccessibilityVoiceOverStatusDidChange, object: nil, queue: OperationQueue.main, using: { [weak self] _ in
self.voiceOverStatusObserver = NotificationCenter.default.addObserver(forName: UIAccessibility.voiceOverStatusDidChangeNotification, object: nil, queue: OperationQueue.main, using: { [weak self] _ in
if let strongSelf = self {
strongSelf.updatePreviewingRegistration()
}
@@ -130,11 +130,11 @@ private final class WindowRootViewController: UIViewController, UIViewController
}
}
override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
override var preferredScreenEdgesDeferringSystemGestures: UIRectEdge {
return self.gestureEdges
}
override func prefersHomeIndicatorAutoHidden() -> Bool {
override var prefersHomeIndicatorAutoHidden: Bool {
return self.preferNavigationUIHidden
}
@@ -6,10 +6,10 @@ public class NavigationBackButtonNode: ASControlNode {
return UIFont.systemFont(ofSize: 17.0)
}
private func attributesForCurrentState() -> [NSAttributedStringKey : AnyObject] {
private func attributesForCurrentState() -> [NSAttributedString.Key : AnyObject] {
return [
NSAttributedStringKey.font: self.fontForCurrentState(),
NSAttributedStringKey.foregroundColor: self.isEnabled ? self.color : self.disabledColor
NSAttributedString.Key.font: self.fontForCurrentState(),
NSAttributedString.Key.foregroundColor: self.isEnabled ? self.color : self.disabledColor
]
}
@@ -137,7 +137,7 @@ public class NavigationBackButtonNode: ASControlNode {
let alpha: CGFloat = !self.isEnabled ? 1.0 : (highlighted ? 0.4 : 1.0)
if animated {
UIView.animate(withDuration: 0.3, delay: 0.0, options: UIViewAnimationOptions.beginFromCurrentState, animations: { () -> Void in
UIView.animate(withDuration: 0.3, delay: 0.0, options: UIView.AnimationOptions.beginFromCurrentState, animations: { () -> Void in
self.alpha = alpha
}, completion: nil)
}
@@ -334,7 +334,7 @@ open class NavigationBar: ASDisplayNode {
accessibilityElements.append(self.titleNode)
}
if let titleView = self.titleView, titleView.superview != nil {
titleView.accessibilityFrame = UIAccessibilityConvertFrameToScreenCoordinates(titleView.bounds, titleView)
titleView.accessibilityFrame = UIAccessibility.convertToScreenCoordinates(titleView.bounds, in: titleView)
accessibilityElements.append(titleView)
}
if self.rightButtonNode.supernode != nil {
@@ -672,7 +672,7 @@ open class NavigationBar: ASDisplayNode {
self.titleNode = ASTextNode()
self.titleNode.isAccessibilityElement = true
self.titleNode.accessibilityTraits = UIAccessibilityTraitHeader
self.titleNode.accessibilityTraits = .header
self.backButtonNode = NavigationButtonNode()
self.badgeNode = NavigationBarBadgeNode(fillColor: self.presentationData.theme.badgeBackgroundColor, strokeColor: self.presentationData.theme.badgeStrokeColor, textColor: self.presentationData.theme.badgeTextColor)
@@ -831,7 +831,7 @@ open class NavigationBar: ASDisplayNode {
leftTitleInset += backButtonSize.width + backButtonInset + 1.0
let topHitTestSlop = (nominalHeight - backButtonSize.height) * 0.5
self.backButtonNode.hitTestSlop = UIEdgeInsetsMake(-topHitTestSlop, -27.0, -topHitTestSlop, -8.0)
self.backButtonNode.hitTestSlop = UIEdgeInsets(top: -topHitTestSlop, left: -27.0, bottom: -topHitTestSlop, right: -8.0)
if let transitionState = self.transitionState {
let progress = transitionState.progress
@@ -10,10 +10,10 @@ private final class NavigationButtonItemNode: ASTextNode {
return self.bold ? UIFont.boldSystemFont(ofSize: 17.0) : UIFont.systemFont(ofSize: 17.0)
}
private func attributesForCurrentState() -> [NSAttributedStringKey : AnyObject] {
private func attributesForCurrentState() -> [NSAttributedString.Key: AnyObject] {
return [
NSAttributedStringKey.font: self.fontForCurrentState(),
NSAttributedStringKey.foregroundColor: self.isEnabled ? self.color : self.disabledColor
NSAttributedString.Key.font: self.fontForCurrentState(),
NSAttributedString.Key.foregroundColor: self.isEnabled ? self.color : self.disabledColor
]
}
@@ -144,7 +144,7 @@ private final class NavigationButtonItemNode: ASTextNode {
self.hitTestSlop = UIEdgeInsets(top: -16.0, left: -10.0, bottom: -16.0, right: -10.0)
self.displaysAsynchronously = false
self.accessibilityTraits = UIAccessibilityTraitButton
self.accessibilityTraits = .button
}
func updateLayout(_ constrainedSize: CGSize) -> CGSize {
@@ -296,7 +296,7 @@ open class NavigationController: UINavigationController, ContainableController,
self.controllerView.addSubview(self.controllerView.separatorView)
}
let navigationBackgroundFrame = CGRect(origin: CGPoint(x: masterData.0.maxX, y: 0.0), size: CGSize(width: lastControllerFrameAndLayout.0.width, height: (layout.statusBarHeight ?? 0.0) + 44.0))
//let navigationBackgroundFrame = CGRect(origin: CGPoint(x: masterData.0.maxX, y: 0.0), size: CGSize(width: lastControllerFrameAndLayout.0.width, height: (layout.statusBarHeight ?? 0.0) + 44.0))
if let backgroundDetailsMode = self.backgroundDetailsMode {
@@ -363,7 +363,7 @@ open class NavigationController: UINavigationController, ContainableController,
}
}
if let emptyDetailView = self.controllerView.emptyDetailView {
if let _ = self.controllerView.emptyDetailView {
// transition.updateFrame(view: navigationBackgroundView, frame: navigationBackgroundFrame)
// transition.updateFrame(view: navigationSeparatorView, frame: CGRect(origin: CGPoint(x: navigationBackgroundFrame.minX, y: navigationBackgroundFrame.maxY), size: CGSize(width: navigationBackgroundFrame.width, height: UIScreenPixel)))
// if let image = emptyDetailView.image {
@@ -796,7 +796,7 @@ open class NavigationController: UINavigationController, ContainableController,
@objc func panGesture(_ recognizer: UIPanGestureRecognizer) {
switch recognizer.state {
case UIGestureRecognizerState.began:
case .began:
guard let layout = self.validLayout else {
return
}
@@ -857,14 +857,14 @@ open class NavigationController: UINavigationController, ContainableController,
}
self.navigationTransitionCoordinator = navigationTransitionCoordinator
}
case UIGestureRecognizerState.changed:
case .changed:
if let navigationTransitionCoordinator = self.navigationTransitionCoordinator, !navigationTransitionCoordinator.animatingCompletion {
let translation = recognizer.translation(in: self.view).x
let progress = max(0.0, min(1.0, translation / self.view.frame.width))
navigationTransitionCoordinator.progress = progress
}
case UIGestureRecognizerState.ended:
case .ended:
if let navigationTransitionCoordinator = self.navigationTransitionCoordinator, !navigationTransitionCoordinator.animatingCompletion {
let velocity = recognizer.velocity(in: self.view).x
@@ -1205,7 +1205,7 @@ open class NavigationController: UINavigationController, ContainableController,
if flag {
controller.view.frame = strongSelf.view.bounds.offsetBy(dx: 0.0, dy: strongSelf.view.bounds.height)
strongSelf.view.addSubview(controller.view)
UIView.animate(withDuration: 0.3, delay: 0.0, options: UIViewAnimationOptions(rawValue: 7 << 16), animations: {
UIView.animate(withDuration: 0.3, delay: 0.0, options: UIView.AnimationOptions(rawValue: 7 << 16), animations: {
controller.view.frame = strongSelf.view.bounds
}, completion: { _ in
if let completion = completion {
@@ -1230,7 +1230,7 @@ open class NavigationController: UINavigationController, ContainableController,
override open func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
if let controller = self.presentedViewController {
if flag {
UIView.animate(withDuration: 0.3, delay: 0.0, options: UIViewAnimationOptions(rawValue: 7 << 16), animations: {
UIView.animate(withDuration: 0.3, delay: 0.0, options: UIView.AnimationOptions(rawValue: 7 << 16), animations: {
controller.view.frame = self.view.bounds.offsetBy(dx: 0.0, dy: self.view.bounds.height)
}, completion: { _ in
controller.view.removeFromSuperview()
@@ -39,9 +39,9 @@ public class NavigationTitleNode: ASDisplayNode {
}
private func setText(_ text: NSString) {
var titleAttributes = [NSAttributedStringKey : AnyObject]()
titleAttributes[NSAttributedStringKey.font] = UIFont.boldSystemFont(ofSize: 17.0)
titleAttributes[NSAttributedStringKey.foregroundColor] = self.color
var titleAttributes = [NSAttributedString.Key : AnyObject]()
titleAttributes[NSAttributedString.Key.font] = UIFont.boldSystemFont(ofSize: 17.0)
titleAttributes[NSAttributedString.Key.foregroundColor] = self.color
let titleString = NSAttributedString(string: text as String, attributes: titleAttributes)
self.label.attributedText = titleString
self.invalidateCalculatedLayout()
@@ -155,7 +155,7 @@ class NavigationTransitionCoordinator {
func animateCancel(_ completion: @escaping () -> ()) {
self.currentCompletion = completion
UIView.animate(withDuration: 0.1, delay: 0.0, options: UIViewAnimationOptions(), animations: { () -> Void in
UIView.animate(withDuration: 0.1, delay: 0.0, options: UIView.AnimationOptions(), animations: { () -> Void in
self.progress = 0.0
}) { (completed) -> Void in
switch self.transition {
@@ -235,13 +235,13 @@ class NavigationTransitionCoordinator {
}
if abs(velocity) < CGFloat.ulpOfOne && abs(self.progress) < CGFloat.ulpOfOne {
UIView.animate(withDuration: 0.5, delay: 0.0, options: UIViewAnimationOptions(rawValue: 7 << 16), animations: {
UIView.animate(withDuration: 0.5, delay: 0.0, options: UIView.AnimationOptions(rawValue: 7 << 16), animations: {
self.progress = 1.0
}, completion: { _ in
f()
})
} else {
UIView.animate(withDuration: Double(max(0.05, min(0.2, abs(distance / velocity)))), delay: 0.0, options: UIViewAnimationOptions(), animations: { () -> Void in
UIView.animate(withDuration: Double(max(0.05, min(0.2, abs(distance / velocity)))), delay: 0.0, options:UIView.AnimationOptions(), animations: { () -> Void in
self.progress = 1.0
}) { (completed) -> Void in
f()
@@ -76,7 +76,7 @@ final class PeekControllerMenuItemNode: HighlightTrackingButtonNode {
self.highligthedChanged = { [weak self] highlighted in
if let strongSelf = self {
if highlighted {
strongSelf.view.superview?.bringSubview(toFront: strongSelf.view)
strongSelf.view.superview?.bringSubviewToFront(strongSelf.view)
strongSelf.highlightedBackgroundNode.alpha = 1.0
} else {
strongSelf.highlightedBackgroundNode.alpha = 0.0
@@ -220,14 +220,14 @@ final class PeekControllerNode: ViewControllerTracingNode {
self.blurView.layer.animateAlpha(from: self.blurView.alpha, to: 0.0, duration: 0.25, removeOnCompletion: false)
let offset = CGPoint(x: rect.midX - self.containerNode.position.x, y: rect.midY - self.containerNode.position.y)
self.containerNode.layer.animatePosition(from: CGPoint(), to: offset, duration: 0.25, timingFunction: kCAMediaTimingFunctionEaseInEaseOut, removeOnCompletion: false, additive: true, force: true, completion: { _ in
self.containerNode.layer.animatePosition(from: CGPoint(), to: offset, duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false, additive: true, force: true, completion: { _ in
completion()
})
self.containerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false)
self.containerNode.layer.animateScale(from: 1.0, to: 0.1, duration: 0.25, removeOnCompletion: false)
if let topAccessoryNode = self.topAccessoryNode {
topAccessoryNode.layer.animatePosition(from: CGPoint(), to: offset, duration: 0.25, timingFunction: kCAMediaTimingFunctionEaseInEaseOut, removeOnCompletion: false, additive: true, force: true, completion: { _ in
topAccessoryNode.layer.animatePosition(from: CGPoint(), to: offset, duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false, additive: true, force: true, completion: { _ in
completion()
})
topAccessoryNode.layer.animateAlpha(from: topAccessoryNode.alpha, to: 0.0, duration: 0.2, removeOnCompletion: false)
@@ -235,7 +235,7 @@ final class PeekControllerNode: ViewControllerTracingNode {
}
if let menuNode = self.menuNode {
menuNode.layer.animatePosition(from: menuNode.position, to: CGPoint(x: menuNode.position.x, y: self.bounds.size.height + menuNode.bounds.size.height / 2.0), duration: 0.25, timingFunction: kCAMediaTimingFunctionEaseInEaseOut, removeOnCompletion: false)
menuNode.layer.animatePosition(from: menuNode.position, to: CGPoint(x: menuNode.position.x, y: self.bounds.size.height + menuNode.bounds.size.height / 2.0), duration: 0.25, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false)
}
}
@@ -307,7 +307,7 @@ public final class PresentationContext {
}
private func notifyAccessibilityScreenChanged() {
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil)
UIAccessibility.post(notification: UIAccessibility.Notification.screenChanged, argument: nil)
}
func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
+2 -2
View File
@@ -178,14 +178,14 @@ public final class StatusBar: ASDisplayNode {
self.inCallBackgroundNode.layer.backgroundColor = inCallBackgroundColor.cgColor
if animated {
self.inCallBackgroundNode.layer.animate(from: UIColor.clear.cgColor, to: inCallBackgroundColor.cgColor, keyPath: "backgroundColor", timingFunction: kCAMediaTimingFunctionEaseInEaseOut, duration: 0.3)
self.inCallBackgroundNode.layer.animate(from: UIColor.clear.cgColor, to: inCallBackgroundColor.cgColor, keyPath: "backgroundColor", timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, duration: 0.3)
}
} else {
self.inCallLabel.removeFromSupernode()
self.inCallBackgroundNode.layer.backgroundColor = UIColor.clear.cgColor
if animated {
self.inCallBackgroundNode.layer.animate(from: inCallBackgroundColor.cgColor, to: UIColor.clear.cgColor, keyPath: "backgroundColor", timingFunction: kCAMediaTimingFunctionEaseInEaseOut, duration: 0.3)
self.inCallBackgroundNode.layer.animate(from: inCallBackgroundColor.cgColor, to: UIColor.clear.cgColor, keyPath: "backgroundColor", timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, duration: 0.3)
}
}
}
@@ -61,7 +61,7 @@ private func displayHiddenAnimation() -> CAAnimation {
let animation = CABasicAnimation(keyPath: "transform.translation.y")
animation.fromValue = NSNumber(value: Float(-40.0))
animation.toValue = NSNumber(value: Float(-40.0))
animation.fillMode = kCAFillModeBoth
animation.fillMode = .both
animation.duration = 1.0
animation.speed = 0.0
animation.isAdditive = true
@@ -126,7 +126,7 @@ private class StatusBarItemNode: ASDisplayNode {
formatter?.locale = Locale.current
if let string = formatter?.string(from: Date()) {
let attributedString = NSAttributedString(string: string, attributes: [NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 12.0), NSAttributedStringKey.foregroundColor: color])
let attributedString = NSAttributedString(string: string, attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12.0), NSAttributedString.Key.foregroundColor: color])
let line = CTLineCreateWithAttributedString(attributedString)
@@ -482,7 +482,7 @@ class StatusBarProxyNode: ASDisplayNode {
self.timer = Timer(timeInterval: 5.0, target: StatusBarProxyNodeTimerTarget { [weak self] in
self?.updateItems()
}, selector: #selector(StatusBarProxyNodeTimerTarget.tick), userInfo: nil, repeats: true)
RunLoop.main.add(self.timer!, forMode: .commonModes)
RunLoop.main.add(self.timer!, forMode: .common)
} else {
self.timer?.invalidate()
self.timer = nil
@@ -233,10 +233,10 @@ open class TabBarController: ViewController {
self.tabBarControllerNode.tabBarNode.selectedIndex = self.selectedIndex
if let currentController = self.currentController {
currentController.willMove(toParentViewController: nil)
currentController.willMove(toParent: nil)
self.tabBarControllerNode.currentControllerNode = nil
currentController.removeFromParentViewController()
currentController.didMove(toParentViewController: nil)
currentController.removeFromParent()
currentController.didMove(toParent: nil)
self.currentController = nil
}
@@ -247,11 +247,11 @@ open class TabBarController: ViewController {
var displayNavigationBar = false
if let currentController = self.currentController {
currentController.willMove(toParentViewController: self)
currentController.willMove(toParent: self)
self.tabBarControllerNode.currentControllerNode = currentController.displayNode
currentController.navigationBar?.isHidden = true
self.addChildViewController(currentController)
currentController.didMove(toParentViewController: self)
self.addChild(currentController)
currentController.didMove(toParent: self)
currentController.navigationBar?.layoutSuspended = true
currentController.navigationItem.setTarget(self.navigationItem)
+4 -4
View File
@@ -10,7 +10,7 @@ import DisplayPrivate
private let separatorHeight: CGFloat = 1.0 / UIScreen.main.scale
private func tabBarItemImage(_ image: UIImage?, title: String, backgroundColor: UIColor, tintColor: UIColor, horizontal: Bool, imageMode: Bool) -> (UIImage, CGFloat) {
let font = horizontal ? Font.regular(13.0) : Font.medium(10.0)
let titleSize = (title as NSString).boundingRect(with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude), options: [.usesLineFragmentOrigin], attributes: [NSAttributedStringKey.font: font], context: nil).size
let titleSize = (title as NSString).boundingRect(with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude), options: [.usesLineFragmentOrigin], attributes: [NSAttributedString.Key.font: font], context: nil).size
let imageSize: CGSize
if let image = image {
@@ -76,9 +76,9 @@ private func tabBarItemImage(_ image: UIImage?, title: String, backgroundColor:
if !imageMode {
if horizontal {
(title as NSString).draw(at: CGPoint(x: imageSize.width + horizontalSpacing, y: floor((size.height - titleSize.height) / 2.0) - 2.0), withAttributes: [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: tintColor])
(title as NSString).draw(at: CGPoint(x: imageSize.width + horizontalSpacing, y: floor((size.height - titleSize.height) / 2.0) - 2.0), withAttributes: [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: tintColor])
} else {
(title as NSString).draw(at: CGPoint(x: floorToScreenPixels((size.width - titleSize.width) / 2.0), y: size.height - titleSize.height - 2.0), withAttributes: [NSAttributedStringKey.font: font, NSAttributedStringKey.foregroundColor: tintColor])
(title as NSString).draw(at: CGPoint(x: floorToScreenPixels((size.width - titleSize.width) / 2.0), y: size.height - titleSize.height - 2.0), withAttributes: [NSAttributedString.Key.font: font, NSAttributedString.Key.foregroundColor: tintColor])
}
}
@@ -143,7 +143,7 @@ private final class TabBarNodeContainer {
self.imageNode = imageNode
self.imageNode.isAccessibilityElement = true
self.imageNode.accessibilityTraits = UIAccessibilityTraitButton
self.imageNode.accessibilityTraits = .button
self.badgeContainerNode = ASDisplayNode()
self.badgeContainerNode.isUserInteractionEnabled = false
@@ -24,14 +24,14 @@ private class TapLongTapOrDoubleTapGestureRecognizerTimerTarget: NSObject {
}
}
enum TapLongTapOrDoubleTapGesture {
public enum TapLongTapOrDoubleTapGesture {
case tap
case doubleTap
case longTap
case hold
}
enum TapLongTapOrDoubleTapGestureRecognizerAction {
public enum TapLongTapOrDoubleTapGestureRecognizerAction {
case waitForDoubleTap
case waitForSingleTap
case waitForHold(timeout: Double, acceptTap: Bool)
@@ -44,12 +44,12 @@ public final class TapLongTapOrDoubleTapGestureRecognizer: UIGestureRecognizer,
private var tapCount: Int = 0
private var timer: Foundation.Timer?
private(set) var lastRecognizedGestureAndLocation: (TapLongTapOrDoubleTapGesture, CGPoint)?
public private(set) var lastRecognizedGestureAndLocation: (TapLongTapOrDoubleTapGesture, CGPoint)?
var tapActionAtPoint: ((CGPoint) -> TapLongTapOrDoubleTapGestureRecognizerAction)?
var highlight: ((CGPoint?) -> Void)?
public var tapActionAtPoint: ((CGPoint) -> TapLongTapOrDoubleTapGestureRecognizerAction)?
public var highlight: ((CGPoint?) -> Void)?
var hapticFeedback: HapticFeedback?
public var hapticFeedback: HapticFeedback?
private var highlightPoint: CGPoint?
@@ -156,13 +156,13 @@ public final class TapLongTapOrDoubleTapGestureRecognizer: UIGestureRecognizer,
self.timer?.invalidate()
let timer = Timer(timeInterval: 0.3, target: TapLongTapOrDoubleTapGestureRecognizerTimerTarget(target: self), selector: #selector(TapLongTapOrDoubleTapGestureRecognizerTimerTarget.longTapEvent), userInfo: nil, repeats: false)
self.timer = timer
RunLoop.main.add(timer, forMode: RunLoopMode.commonModes)
RunLoop.main.add(timer, forMode: .common)
case let .waitForHold(timeout, _):
self.hapticFeedback = HapticFeedback()
self.hapticFeedback?.prepareTap()
let timer = Timer(timeInterval: timeout, target: TapLongTapOrDoubleTapGestureRecognizerTimerTarget(target: self), selector: #selector(TapLongTapOrDoubleTapGestureRecognizerTimerTarget.holdEvent), userInfo: nil, repeats: false)
self.timer = timer
RunLoop.main.add(timer, forMode: RunLoopMode.commonModes)
RunLoop.main.add(timer, forMode: .common)
case .fail:
self.state = .failed
}
@@ -227,7 +227,7 @@ public final class TapLongTapOrDoubleTapGestureRecognizer: UIGestureRecognizer,
self.state = .began
let timer = Timer(timeInterval: 0.2, target: TapLongTapOrDoubleTapGestureRecognizerTimerTarget(target: self), selector: #selector(TapLongTapOrDoubleTapGestureRecognizerTimerTarget.tapEvent), userInfo: nil, repeats: false)
self.timer = timer
RunLoop.main.add(timer, forMode: RunLoopMode.commonModes)
RunLoop.main.add(timer, forMode: .common)
case let .waitForHold(_, acceptTap):
if let (touchLocation, _) = self.touchLocationAndTimestamp, acceptTap {
if self.state != .began {
@@ -124,7 +124,7 @@ public final class TextAlertContentNode: AlertContentNode {
private var validLayout: CGSize?
public var textAttributeAction: (NSAttributedStringKey, (Any) -> Void)? {
public var textAttributeAction: (NSAttributedString.Key, (Any) -> Void)? {
didSet {
if let (attribute, textAttributeAction) = self.textAttributeAction {
self.textNode.highlightAttributeAction = { attributes in
@@ -218,12 +218,12 @@ public final class TextAlertContentNode: AlertContentNode {
if let titleNode = self.titleNode, let attributedText = titleNode.attributedText {
let updatedText = NSMutableAttributedString(attributedString: attributedText)
updatedText.addAttribute(NSAttributedStringKey.foregroundColor, value: theme.primaryColor, range: NSRange(location: 0, length: updatedText.length))
updatedText.addAttribute(NSAttributedString.Key.foregroundColor, value: theme.primaryColor, range: NSRange(location: 0, length: updatedText.length))
titleNode.attributedText = updatedText
}
if let attributedText = self.textNode.attributedText {
let updatedText = NSMutableAttributedString(attributedString: attributedText)
updatedText.addAttribute(NSAttributedStringKey.foregroundColor, value: theme.primaryColor, range: NSRange(location: 0, length: updatedText.length))
updatedText.addAttribute(NSAttributedString.Key.foregroundColor, value: theme.primaryColor, range: NSRange(location: 0, length: updatedText.length))
self.textNode.attributedText = updatedText
}
+14 -14
View File
@@ -206,7 +206,7 @@ public final class TextNodeLayout: NSObject {
}
}
public func attributesAtPoint(_ point: CGPoint) -> (Int, [NSAttributedStringKey: Any])? {
public func attributesAtPoint(_ point: CGPoint) -> (Int, [NSAttributedString.Key: Any])? {
if let attributedString = self.attributedString {
let transformedPoint = CGPoint(x: point.x - self.insets.left, y: point.y - self.insets.top)
var lineIndex = -1
@@ -336,7 +336,7 @@ public final class TextNodeLayout: NSObject {
public func attributeSubstring(name: String, index: Int) -> String? {
if let attributedString = self.attributedString {
var range = NSRange()
let _ = attributedString.attribute(NSAttributedStringKey(rawValue: name), at: index, effectiveRange: &range)
let _ = attributedString.attribute(NSAttributedString.Key(rawValue: name), at: index, effectiveRange: &range)
if range.length != 0 {
return (attributedString.string as NSString).substring(with: range)
}
@@ -349,7 +349,7 @@ public final class TextNodeLayout: NSObject {
return []
}
var result: [(Any, CGRect)] = []
attributedString.enumerateAttribute(NSAttributedStringKey(rawValue: name), in: NSRange(location: 0, length: attributedString.length), options: []) { (value, range, _) in
attributedString.enumerateAttribute(NSAttributedString.Key(rawValue: name), in: NSRange(location: 0, length: attributedString.length), options: []) { (value, range, _) in
if let value = value, range.length != 0 {
var coveringRect = CGRect()
for line in self.lines {
@@ -390,7 +390,7 @@ public final class TextNodeLayout: NSObject {
public func lineAndAttributeRects(name: String, at index: Int) -> [(CGRect, CGRect)]? {
if let attributedString = self.attributedString {
var range = NSRange()
let _ = attributedString.attribute(NSAttributedStringKey(rawValue: name), at: index, effectiveRange: &range)
let _ = attributedString.attribute(NSAttributedString.Key(rawValue: name), at: index, effectiveRange: &range)
if range.length != 0 {
var rects: [(CGRect, CGRect)] = []
for line in self.lines {
@@ -468,7 +468,7 @@ private final class TextAccessibilityOverlayNodeView: UIView {
let element = AccessibilityAreaNode()
element.accessibilityLabel = value as? String ?? ""
element.frame = rect
element.accessibilityTraits = UIAccessibilityTraitLink
element.accessibilityTraits = .link
element.activate = { [weak self] in
self?.openUrl(value as? String ?? "")
return true
@@ -543,7 +543,7 @@ public class TextNode: ASDisplayNode {
self.clipsToBounds = false
}
public func attributesAtPoint(_ point: CGPoint) -> (Int, [NSAttributedStringKey: Any])? {
public func attributesAtPoint(_ point: CGPoint) -> (Int, [NSAttributedString.Key: Any])? {
if let cachedLayout = self.cachedLayout {
return cachedLayout.attributesAtPoint(point)
} else {
@@ -581,7 +581,7 @@ public class TextNode: ASDisplayNode {
let font: CTFont
if stringLength != 0 {
if let stringFont = attributedString.attribute(NSAttributedStringKey.font, at: 0, effectiveRange: nil) {
if let stringFont = attributedString.attribute(NSAttributedString.Key.font, at: 0, effectiveRange: nil) {
font = stringFont as! CTFont
} else {
font = defaultFont
@@ -686,9 +686,9 @@ public class TextNode: ASDisplayNode {
if CTLineGetTypographicBounds(originalLine, nil, nil, nil) - CTLineGetTrailingWhitespaceWidth(originalLine) < Double(constrainedSize.width) {
coreTextLine = originalLine
} else {
var truncationTokenAttributes: [NSAttributedStringKey : AnyObject] = [:]
truncationTokenAttributes[NSAttributedStringKey.font] = font
truncationTokenAttributes[NSAttributedStringKey(rawValue: kCTForegroundColorFromContextAttributeName as String)] = true as NSNumber
var truncationTokenAttributes: [NSAttributedString.Key : AnyObject] = [:]
truncationTokenAttributes[NSAttributedString.Key.font] = font
truncationTokenAttributes[NSAttributedString.Key(rawValue: kCTForegroundColorFromContextAttributeName as String)] = true as NSNumber
let tokenString = "\u{2026}"
let truncatedTokenString = NSAttributedString(string: tokenString, attributes: truncationTokenAttributes)
let truncationToken = CTLineCreateWithAttributedString(truncatedTokenString)
@@ -699,12 +699,12 @@ public class TextNode: ASDisplayNode {
var headIndent: CGFloat = 0.0
attributedString.enumerateAttributes(in: NSMakeRange(lineRange.location, lineRange.length), options: []) { attributes, range, _ in
if let _ = attributes[NSAttributedStringKey.strikethroughStyle] {
if let _ = attributes[NSAttributedString.Key.strikethroughStyle] {
let lowerX = floor(CTLineGetOffsetForStringIndex(coreTextLine, range.location, nil))
let upperX = ceil(CTLineGetOffsetForStringIndex(coreTextLine, range.location + range.length, nil))
let x = lowerX < upperX ? lowerX : upperX
strikethroughs.append(TextNodeStrikethrough(frame: CGRect(x: x, y: 0.0, width: abs(upperX - lowerX), height: fontLineHeight)))
} else if let paragraphStyle = attributes[NSAttributedStringKey.paragraphStyle] as? NSParagraphStyle {
} else if let paragraphStyle = attributes[NSAttributedString.Key.paragraphStyle] as? NSParagraphStyle {
headIndent = paragraphStyle.headIndent
}
@@ -744,12 +744,12 @@ public class TextNode: ASDisplayNode {
var headIndent: CGFloat = 0.0
attributedString.enumerateAttributes(in: NSMakeRange(lineRange.location, lineRange.length), options: []) { attributes, range, _ in
if let _ = attributes[NSAttributedStringKey.strikethroughStyle] {
if let _ = attributes[NSAttributedString.Key.strikethroughStyle] {
let lowerX = floor(CTLineGetOffsetForStringIndex(coreTextLine, range.location, nil))
let upperX = ceil(CTLineGetOffsetForStringIndex(coreTextLine, range.location + range.length, nil))
let x = lowerX < upperX ? lowerX : upperX
strikethroughs.append(TextNodeStrikethrough(frame: CGRect(x: x, y: 0.0, width: abs(upperX - lowerX), height: fontLineHeight)))
} else if let paragraphStyle = attributes[NSAttributedStringKey.paragraphStyle] as? NSParagraphStyle {
} else if let paragraphStyle = attributes[NSAttributedString.Key.paragraphStyle] as? NSParagraphStyle {
headIndent = paragraphStyle.headIndent
}
}
@@ -14,7 +14,7 @@ open class UITracingLayerView: UIView {
self.setNeedsLayout()
}
override open var autoresizingMask: UIViewAutoresizing {
override open var autoresizingMask: UIView.AutoresizingMask {
get {
return []
} set(value) {
@@ -39,6 +39,6 @@ class UniversalTapRecognizer: UITapGestureRecognizer {
}
}), selector: #selector(TimerTargetWrapper.timerEvent), userInfo: nil, repeats: false)
self.timer = timer
RunLoop.main.add(timer, forMode: .commonModes)
RunLoop.main.add(timer, forMode: .common)
}
}
@@ -109,7 +109,7 @@ open class ViewControllerPresentationArguments {
}
}
override open func prefersHomeIndicatorAutoHidden() -> Bool {
override open var prefersHomeIndicatorAutoHidden: Bool {
return self.preferNavigationUIHidden
}
+10 -10
View File
@@ -446,9 +446,9 @@ public class Window1 {
self.presentationContext.containerLayoutUpdated(containedLayoutForWindowLayout(self.windowLayout, hasOnScreenNavigation: self.hostView.hasOnScreenNavigation), transition: .immediate)
self.overlayPresentationContext.containerLayoutUpdated(containedLayoutForWindowLayout(self.windowLayout, hasOnScreenNavigation: self.hostView.hasOnScreenNavigation), transition: .immediate)
self.statusBarChangeObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name.UIApplicationWillChangeStatusBarFrame, object: nil, queue: OperationQueue.main, using: { [weak self] notification in
self.statusBarChangeObserver = NotificationCenter.default.addObserver(forName: UIApplication.willChangeStatusBarFrameNotification, object: nil, queue: OperationQueue.main, using: { [weak self] notification in
if let strongSelf = self {
let statusBarHeight: CGFloat = max(20.0, (notification.userInfo?[UIApplicationStatusBarFrameUserInfoKey] as? NSValue)?.cgRectValue.height ?? 20.0)
let statusBarHeight: CGFloat = max(20.0, (notification.userInfo?[UIApplication.statusBarFrameUserInfoKey] as? NSValue)?.cgRectValue.height ?? 20.0)
let transition: ContainedViewLayoutTransition = .animated(duration: 0.35, curve: .easeInOut)
strongSelf.updateLayout { $0.update(statusBarHeight: statusBarHeight, transition: transition, overrideTransition: false) }
@@ -460,11 +460,11 @@ public class Window1 {
return
}
let keyboardHeight = max(0.0, strongSelf.keyboardManager?.getCurrentKeyboardHeight() ?? 0.0)
var duration: Double = (notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0.0
var duration: Double = (notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0.0
if duration > Double.ulpOfOne {
duration = 0.5
}
let curve: UInt = (notification.userInfo?[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber)?.uintValue ?? 7
let curve: UInt = (notification.userInfo?[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber)?.uintValue ?? 7
let transitionCurve: ContainedViewLayoutTransitionCurve
if curve == 7 {
@@ -477,9 +477,9 @@ public class Window1 {
}
})
self.keyboardFrameChangeObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil, queue: nil, using: { [weak self] notification in
self.keyboardFrameChangeObserver = NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillChangeFrameNotification, object: nil, queue: nil, using: { [weak self] notification in
if let strongSelf = self {
let keyboardFrame: CGRect = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? CGRect()
let keyboardFrame: CGRect = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? CGRect()
let screenHeight: CGFloat
@@ -494,11 +494,11 @@ public class Window1 {
}
let keyboardHeight = max(0.0, screenHeight - keyboardFrame.minY)
var duration: Double = (notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0.0
var duration: Double = (notification.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0.0
if duration > Double.ulpOfOne {
duration = 0.5
}
let curve: UInt = (notification.userInfo?[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber)?.uintValue ?? 7
let curve: UInt = (notification.userInfo?[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber)?.uintValue ?? 7
let transitionCurve: ContainedViewLayoutTransitionCurve
if curve == 7 {
@@ -512,7 +512,7 @@ public class Window1 {
})
if #available(iOSApplicationExtension 11.0, *) {
self.keyboardTypeChangeObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name.UITextInputCurrentInputModeDidChange, object: nil, queue: OperationQueue.main, using: { [weak self] notification in
self.keyboardTypeChangeObserver = NotificationCenter.default.addObserver(forName: UITextInputMode.currentInputModeDidChangeNotification, object: nil, queue: OperationQueue.main, using: { [weak self] notification in
if let strongSelf = self, let initialInputHeight = strongSelf.windowLayout.inputHeight, let firstResponder = getFirstResponderAndAccessoryHeight(strongSelf.hostView.eventView).0 {
if firstResponder.textInputMode?.primaryLanguage != nil {
return
@@ -540,7 +540,7 @@ public class Window1 {
}
if #available(iOSApplicationExtension 11.0, *) {
self.voiceOverStatusObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name.UIAccessibilityVoiceOverStatusDidChange, object: nil, queue: OperationQueue.main, using: { [weak self] _ in
self.voiceOverStatusObserver = NotificationCenter.default.addObserver(forName: UIAccessibility.voiceOverStatusDidChangeNotification, object: nil, queue: OperationQueue.main, using: { [weak self] _ in
if let strongSelf = self {
strongSelf.updateLayout { $0.update(inVoiceOver: UIAccessibility.isVoiceOverRunning) }
}
@@ -102,6 +102,7 @@
D05CC3251B695B0700E235A3 /* NavigationBarProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = D05CC3231B695B0700E235A3 /* NavigationBarProxy.m */; };
D05CC3271B69725400E235A3 /* NavigationBackArrowLight@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D05CC3261B69725400E235A3 /* NavigationBackArrowLight@2x.png */; };
D05CC3291B69750D00E235A3 /* InteractiveTransitionGestureRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D05CC3281B69750D00E235A3 /* InteractiveTransitionGestureRecognizer.swift */; };
D060185F22F35E7400796784 /* ShakeAnimation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D060185E22F35E7400796784 /* ShakeAnimation.swift */; };
D06B76DB20592A97006E9EEA /* LayoutSizes.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06B76DA20592A97006E9EEA /* LayoutSizes.swift */; };
D06D37A220779C82009219B6 /* VolumeControlStatusBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06D37A120779C82009219B6 /* VolumeControlStatusBar.swift */; };
D06EE8451B7140FF00837186 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06EE8441B7140FF00837186 /* Font.swift */; };
@@ -281,6 +282,7 @@
D05CC3231B695B0700E235A3 /* NavigationBarProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NavigationBarProxy.m; sourceTree = "<group>"; };
D05CC3261B69725400E235A3 /* NavigationBackArrowLight@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "NavigationBackArrowLight@2x.png"; sourceTree = "<group>"; };
D05CC3281B69750D00E235A3 /* InteractiveTransitionGestureRecognizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InteractiveTransitionGestureRecognizer.swift; sourceTree = "<group>"; };
D060185E22F35E7400796784 /* ShakeAnimation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShakeAnimation.swift; sourceTree = "<group>"; };
D06B76DA20592A97006E9EEA /* LayoutSizes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutSizes.swift; sourceTree = "<group>"; };
D06D37A120779C82009219B6 /* VolumeControlStatusBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VolumeControlStatusBar.swift; sourceTree = "<group>"; };
D06EE8441B7140FF00837186 /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
@@ -586,6 +588,7 @@
D05CC3001B6955D500E235A3 /* Utils */ = {
isa = PBXGroup;
children = (
D060185E22F35E7400796784 /* ShakeAnimation.swift */,
D0750C7522B2934800BE5F6E /* ImageNode.swift */,
D0750C7222B2931900BE5F6E /* TransformImageArguments.swift */,
D0750C7122B2931900BE5F6E /* TransformImageNode.swift */,
@@ -985,6 +988,7 @@
D03AA4DD202DB1840056C405 /* PeekControllerGestureRecognizer.swift in Sources */,
D007019A2029CAE2006B9E34 /* TooltipControllerNode.swift in Sources */,
D05CC3291B69750D00E235A3 /* InteractiveTransitionGestureRecognizer.swift in Sources */,
D060185F22F35E7400796784 /* ShakeAnimation.swift in Sources */,
D077B8E91F4637040046D27A /* NavigationBarBadge.swift in Sources */,
D0CE67921F7DA11700FFB557 /* ActionSheetTheme.swift in Sources */,
D0A134642034DE580059716A /* TabBarTapRecognizer.swift in Sources */,
@@ -1108,7 +1112,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_REFLECTION_METADATA_LEVEL = none;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = DebugFork;
};
@@ -1240,7 +1244,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_REFLECTION_METADATA_LEVEL = none;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = DebugHockeyapp;
};
@@ -1269,7 +1273,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_REFLECTION_METADATA_LEVEL = none;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = ReleaseHockeyapp;
};
@@ -1370,7 +1374,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_REFLECTION_METADATA_LEVEL = none;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = DebugAppStore;
};
@@ -1452,7 +1456,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_REFLECTION_METADATA_LEVEL = none;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = ReleaseAppStore;
};
@@ -1534,7 +1538,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_REFLECTION_METADATA_LEVEL = none;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = ReleaseHockeyappInternal;
};
@@ -1624,7 +1628,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_REFLECTION_METADATA_LEVEL = none;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = DebugAppStoreLLC;
};
@@ -1706,7 +1710,7 @@
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_REFLECTION_METADATA_LEVEL = none;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = ReleaseAppStoreLLC;
};