no message

This commit is contained in:
Peter 2016-08-09 00:22:48 +03:00
parent 1fbd4941dc
commit 2e501affef
30 changed files with 159 additions and 133 deletions

View File

@ -64,7 +64,6 @@
D05CC3291B69750D00E235A3 /* InteractiveTransitionGestureRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D05CC3281B69750D00E235A3 /* InteractiveTransitionGestureRecognizer.swift */; };
D06EE8451B7140FF00837186 /* Font.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06EE8441B7140FF00837186 /* Font.swift */; };
D07921A91B6FC0C0005C23D9 /* KeyboardHostWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = D07921A81B6FC0C0005C23D9 /* KeyboardHostWindow.swift */; };
D07921AC1B6FC92B005C23D9 /* StatusBarHostWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = D07921AB1B6FC92B005C23D9 /* StatusBarHostWindow.swift */; };
D081229D1D19AA1C005F7395 /* ContainerViewLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = D081229C1D19AA1C005F7395 /* ContainerViewLayout.swift */; };
D08E903A1D24159200533158 /* ActionSheetItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D08E90391D24159200533158 /* ActionSheetItem.swift */; };
D08E903C1D2417E000533158 /* ActionSheetButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D08E903B1D2417E000533158 /* ActionSheetButtonItem.swift */; };
@ -172,7 +171,6 @@
D05CC3281B69750D00E235A3 /* InteractiveTransitionGestureRecognizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InteractiveTransitionGestureRecognizer.swift; sourceTree = "<group>"; };
D06EE8441B7140FF00837186 /* Font.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Font.swift; sourceTree = "<group>"; };
D07921A81B6FC0C0005C23D9 /* KeyboardHostWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyboardHostWindow.swift; sourceTree = "<group>"; };
D07921AB1B6FC92B005C23D9 /* StatusBarHostWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusBarHostWindow.swift; sourceTree = "<group>"; };
D081229C1D19AA1C005F7395 /* ContainerViewLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainerViewLayout.swift; sourceTree = "<group>"; };
D08E90391D24159200533158 /* ActionSheetItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionSheetItem.swift; sourceTree = "<group>"; };
D08E903B1D2417E000533158 /* ActionSheetButtonItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionSheetButtonItem.swift; sourceTree = "<group>"; };
@ -435,7 +433,6 @@
D07921AA1B6FC911005C23D9 /* Status Bar */ = {
isa = PBXGroup;
children = (
D07921AB1B6FC92B005C23D9 /* StatusBarHostWindow.swift */,
D0078A671C92B21400DF6D92 /* StatusBar.swift */,
D0B3671F1C94A53A00346D2E /* StatusBarProxyNode.swift */,
D03E7DFE1C96F7B400C07816 /* StatusBarManager.swift */,
@ -636,7 +633,6 @@
files = (
D08E903C1D2417E000533158 /* ActionSheetButtonItem.swift in Sources */,
D0E49C881B83A3580099E553 /* ImageCache.swift in Sources */,
D07921AC1B6FC92B005C23D9 /* StatusBarHostWindow.swift in Sources */,
D0078A681C92B21400DF6D92 /* StatusBar.swift in Sources */,
D05CC2F81B6955D000E235A3 /* UIViewController+Navigation.m in Sources */,
D02BDB021B6AC703008AFAD2 /* RuntimeUtils.swift in Sources */,

View File

@ -12,7 +12,7 @@
<key>DisplayTests.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>18</integer>
<integer>19</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>

View File

@ -26,7 +26,7 @@ class ASTransformLayer: CATransformLayer {
}
class ASTransformView: UIView {
override class func layerClass() -> AnyClass {
override class var layerClass: AnyClass {
return ASTransformLayer.self
}
}

View File

@ -17,6 +17,8 @@ public class ActionSheetButtonItem: ActionSheetItem {
}
public func node() -> ActionSheetItemNode {
return ActionSheetButtonNode(title: AttributedString(string: title, font: ActionSheetButtonNode.defaultFont, textColor: self.color == .accent ? UIColor(0x1195f2) : UIColor.red()), action: self.action)
let textColorIsAccent = self.color == ActionSheetButtonColor.accent
let textColor = textColorIsAccent ? UIColor(0x1195f2) : UIColor.red
return ActionSheetButtonNode(title: NSAttributedString(string: title, font: ActionSheetButtonNode.defaultFont, textColor: textColor), action: self.action)
}
}

View File

@ -10,7 +10,7 @@ public class ActionSheetButtonNode: ActionSheetItemNode {
private let label: UILabel
private var calculatedLabelSize: CGSize?
public init(title: AttributedString, action: () -> Void) {
public init(title: NSAttributedString, action: () -> Void) {
self.action = action
self.button = HighlightTrackingButton()

View File

@ -37,7 +37,7 @@ public class ActionSheetController: ViewController {
public func setItemGroups(_ groups: [ActionSheetItemGroup]) {
self.groups = groups
if self.isViewLoaded() {
if self.isViewLoaded {
self.actionSheetNode.setGroups(groups)
}
}

View File

@ -66,13 +66,13 @@ final class ActionSheetItemGroupNode: ASDisplayNode, UIScrollViewDelegate {
func updateItemNodes(_ nodes: [ActionSheetItemNode], leadingVisibleNodeCount: CGFloat = 1000.0) {
for node in self.itemNodes {
if !nodes.contains({ $0 === node }) {
if !nodes.contains(where: { $0 === node }) {
node.removeFromSupernode()
}
}
for node in nodes {
if !self.itemNodes.contains({ $0 === node }) {
if !self.itemNodes.contains(where: { $0 === node }) {
self.scrollView.addSubnode(node)
}
}

View File

@ -24,7 +24,7 @@ internal class BarButtonItemWrapper {
self.parentNode.addSubnode(self.buttonNode)
self.setEnabledListenerKey = barButtonItem.addSetEnabledListener({ [weak self] enabled in
self?.buttonNode.isEnabled = enabled.boolValue
self?.buttonNode.isEnabled = enabled
return
})

View File

@ -11,8 +11,8 @@ public struct Font {
}
}
public extension AttributedString {
convenience init(string: String, font: UIFont, textColor: UIColor = UIColor.black()) {
public extension NSAttributedString {
convenience init(string: String, font: UIFont, textColor: UIColor = UIColor.black) {
self.init(string: string, attributes: [NSFontAttributeName: font, NSForegroundColorAttributeName as String: textColor])
}
}

View File

@ -2,7 +2,7 @@ import Foundation
import UIKit
let deviceColorSpace = CGColorSpaceCreateDeviceRGB()
let deviceScale = UIScreen.main().scale
let deviceScale = UIScreen.main.scale
public func generateImage(_ size: CGSize, pixelGenerator: (CGSize, UnsafeMutablePointer<Int8>) -> Void) -> UIImage? {
let scale = deviceScale
@ -50,7 +50,7 @@ public func generateImage(_ size: CGSize, contextGenerator: (CGSize, CGContext)
return nil
}
context.scale(x: scale, y: scale)
context.scaleBy(x: scale, y: scale)
contextGenerator(size, context)
@ -73,7 +73,7 @@ public func generateFilledCircleImage(radius: CGFloat, color: UIColor?, backgrou
if let color = color {
context.setFillColor(color.cgColor)
} else {
context.setFillColor(UIColor.clear().cgColor)
context.setFillColor(UIColor.clear.cgColor)
context.setBlendMode(.copy)
}
context.fillEllipse(in: CGRect(origin: CGPoint(), size: size))
@ -110,28 +110,28 @@ public class DrawingContext {
public func withContext(_ f: @noescape(CGContext) -> ()) {
if self._context == nil {
if let c = CGContext(data: bytes, width: Int(scaledSize.width), height: Int(scaledSize.height), bitsPerComponent: 8, bytesPerRow: bytesPerRow, space: deviceColorSpace, bitmapInfo: self.bitmapInfo.rawValue) {
c.scale(x: scale, y: scale)
c.scaleBy(x: scale, y: scale)
self._context = c
}
}
if let _context = self._context {
_context.translate(x: self.size.width / 2.0, y: self.size.height / 2.0)
_context.scale(x: 1.0, y: -1.0)
_context.translate(x: -self.size.width / 2.0, y: -self.size.height / 2.0)
_context.translateBy(x: self.size.width / 2.0, y: self.size.height / 2.0)
_context.scaleBy(x: 1.0, y: -1.0)
_context.translateBy(x: -self.size.width / 2.0, y: -self.size.height / 2.0)
f(_context)
_context.translate(x: self.size.width / 2.0, y: self.size.height / 2.0)
_context.scale(x: 1.0, y: -1.0)
_context.translate(x: -self.size.width / 2.0, y: -self.size.height / 2.0)
_context.translateBy(x: self.size.width / 2.0, y: self.size.height / 2.0)
_context.scaleBy(x: 1.0, y: -1.0)
_context.translateBy(x: -self.size.width / 2.0, y: -self.size.height / 2.0)
}
}
public func withFlippedContext(_ f: @noescape(CGContext) -> ()) {
if self._context == nil {
if let c = CGContext(data: bytes, width: Int(scaledSize.width), height: Int(scaledSize.height), bitsPerComponent: 8, bytesPerRow: bytesPerRow, space: deviceColorSpace, bitmapInfo: self.bitmapInfo.rawValue) {
c.scale(x: scale, y: scale)
c.scaleBy(x: scale, y: scale)
self._context = c
}
}
@ -177,7 +177,7 @@ public class DrawingContext {
let colorValue = pixel.pointee
return UIColor(UInt32(colorValue))
} else {
return UIColor.clear()
return UIColor.clear
}
}
@ -231,7 +231,7 @@ public class DrawingContext {
}
}
public enum ParsingError: ErrorProtocol {
public enum ParsingError: Error {
case Generic
}

View File

@ -323,7 +323,7 @@ private struct ListViewState {
var maxY: CGFloat = 0.0
for i in 0 ..< self.nodes.count {
var frame = self.nodes[i].frame
frame.offsetInPlace(dx: 0.0, dy: offset)
frame = frame.offsetBy(dx: 0.0, dy: offset)
self.nodes[i].frame = frame
minY = min(minY, frame.minY)
@ -338,7 +338,7 @@ private struct ListViewState {
if abs(additionalOffset) > CGFloat(FLT_EPSILON) {
for i in 0 ..< self.nodes.count {
var frame = self.nodes[i].frame
frame.offsetInPlace(dx: 0.0, dy: additionalOffset)
frame = frame.offsetBy(dx: 0.0, dy: additionalOffset)
self.nodes[i].frame = frame
}
}
@ -356,7 +356,7 @@ private struct ListViewState {
if abs(offset) > CGFloat(FLT_EPSILON) {
for i in 0 ..< self.nodes.count {
var frame = self.nodes[i].frame
frame.offsetInPlace(dx: 0.0, dy: offset)
frame = frame.offsetBy(dx: 0.0, dy: offset)
self.nodes[i].frame = frame
}
}
@ -882,7 +882,7 @@ private final class ListViewBackingLayer: CALayer {
private final class ListViewBackingView: UIView {
weak var target: ASDisplayNode?
override class func layerClass() -> AnyClass {
override class var layerClass: AnyClass {
return ListViewBackingLayer.self
}
@ -1464,12 +1464,12 @@ public final class ListView: ASDisplayNode, UIScrollViewDelegate {
}
state.fixScrollPostition(self.items.count)
let sortedDeleteIndices = deleteIndices.sorted(isOrderedBefore: {$0.index < $1.index})
let sortedDeleteIndices = deleteIndices.sorted(by: {$0.index < $1.index})
for deleteItem in sortedDeleteIndices.reversed() {
self.items.remove(at: deleteItem.index)
}
let sortedIndicesAndItems = insertIndicesAndItems.sorted(isOrderedBefore: { $0.index < $1.index })
let sortedIndicesAndItems = insertIndicesAndItems.sorted(by: { $0.index < $1.index })
if self.items.count == 0 {
if sortedIndicesAndItems[0].index != 0 {
fatalError("deleteAndInsertItems: invalid insert into empty list")

View File

@ -27,7 +27,7 @@ struct ListViewItemSpring {
}
private class ListViewItemView: UIView {
override class func layerClass() -> AnyClass {
override class var layerClass: AnyClass {
return ASTransformLayer.self
}
}

View File

@ -9,7 +9,7 @@ public class NavigationBackButtonNode: ASControlNode {
private func attributesForCurrentState() -> [String : AnyObject] {
return [
NSFontAttributeName: self.fontForCurrentState(),
NSForegroundColorAttributeName: self.isEnabled ? self.color : UIColor.gray()
NSForegroundColorAttributeName: self.isEnabled ? self.color : UIColor.gray
]
}
@ -25,14 +25,14 @@ public class NavigationBackButtonNode: ASControlNode {
}
set(value) {
self._text = value
self.label.attributedString = AttributedString(string: text, attributes: self.attributesForCurrentState())
self.label.attributedString = NSAttributedString(string: text, attributes: self.attributesForCurrentState())
self.invalidateCalculatedLayout()
}
}
var color: UIColor = UIColor(0x1195f2) {
didSet {
self.label.attributedString = AttributedString(string: self._text, attributes: self.attributesForCurrentState())
self.label.attributedString = NSAttributedString(string: self._text, attributes: self.attributesForCurrentState())
}
}

View File

@ -32,10 +32,10 @@ private func backArrowImage(color: UIColor) -> UIImage? {
}
public class NavigationBar: ASDisplayNode {
public var foregroundColor: UIColor = UIColor.black() {
public var foregroundColor: UIColor = UIColor.black {
didSet {
if let title = self.title {
self.titleNode.attributedText = AttributedString(string: title, font: Font.medium(17.0), textColor: self.foregroundColor)
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.medium(17.0), textColor: self.foregroundColor)
}
}
}
@ -66,6 +66,7 @@ public class NavigationBar: ASDisplayNode {
private let clippingNode: ASDisplayNode
private var itemTitleListenerKey: Int?
private var itemTitleViewListenerKey: Int?
private var itemLeftButtonListenerKey: Int?
private var _item: UINavigationItem?
var item: UINavigationItem? {
@ -94,6 +95,13 @@ public class NavigationBar: ASDisplayNode {
}
}
self.titleView = item.titleView
self.itemTitleViewListenerKey = item.addSetTitleViewListener { [weak self] titleView in
if let strongSelf = self {
strongSelf.titleView = titleView
}
}
self.itemLeftButtonListenerKey = item.addSetLeftBarButtonItemListener { [weak self] _, _ in
if let strongSelf = self {
strongSelf.updateLeftButton()
@ -111,7 +119,7 @@ public class NavigationBar: ASDisplayNode {
private var title: String? {
didSet {
if let title = self.title {
self.titleNode.attributedText = AttributedString(string: title, font: Font.medium(17.0), textColor: self.foregroundColor)
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.medium(17.0), textColor: self.foregroundColor)
if self.titleNode.supernode == nil {
self.clippingNode.addSubnode(self.titleNode)
}
@ -123,6 +131,22 @@ public class NavigationBar: ASDisplayNode {
self.setNeedsLayout()
}
}
private var titleView: UIView? {
didSet {
if let oldValue = oldValue {
oldValue.removeFromSuperview()
}
if let titleView = self.titleView {
self.clippingNode.view.addSubview(titleView)
}
self.invalidateCalculatedLayout()
self.setNeedsLayout()
}
}
private let titleNode: ASTextNode
var previousItemListenerKey: Int?
@ -414,13 +438,18 @@ public class NavigationBar: ASDisplayNode {
}
}
if let titleView = self.titleView {
let titleViewSize = CGSize(width: max(1.0, size.width - leftTitleInset - leftTitleInset), height: nominalHeight)
titleView.frame = CGRect(origin: CGPoint(x: leftTitleInset, y: contentVerticalOrigin), size: titleViewSize)
}
//self.effectView.frame = self.bounds
}
public func makeTransitionTitleNode(foregroundColor: UIColor) -> ASDisplayNode? {
if let title = self.title {
let node = ASTextNode()
node.attributedText = AttributedString(string: title, font: Font.medium(17.0), textColor: foregroundColor)
node.attributedText = NSAttributedString(string: title, font: Font.medium(17.0), textColor: foregroundColor)
return node
} else {
return nil

View File

@ -9,7 +9,7 @@ public class NavigationButtonNode: ASTextNode {
private func attributesForCurrentState() -> [String : AnyObject] {
return [
NSFontAttributeName: self.fontForCurrentState(),
NSForegroundColorAttributeName: self.isEnabled ? self.color : UIColor.gray()
NSForegroundColorAttributeName: self.isEnabled ? self.color : UIColor.gray
]
}
@ -21,14 +21,14 @@ public class NavigationButtonNode: ASTextNode {
set(value) {
_text = value
self.attributedString = AttributedString(string: text, attributes: self.attributesForCurrentState())
self.attributedString = NSAttributedString(string: text, attributes: self.attributesForCurrentState())
}
}
public var color: UIColor = UIColor(0x1195f2) {
didSet {
if let text = self._text {
self.attributedString = AttributedString(string: text, attributes: self.attributesForCurrentState())
self.attributedString = NSAttributedString(string: text, attributes: self.attributesForCurrentState())
}
}
}
@ -42,7 +42,7 @@ public class NavigationButtonNode: ASTextNode {
if _bold != value {
_bold = value
self.attributedString = AttributedString(string: text, attributes: self.attributesForCurrentState())
self.attributedString = NSAttributedString(string: text, attributes: self.attributesForCurrentState())
}
}
}
@ -129,7 +129,7 @@ public class NavigationButtonNode: ASTextNode {
if self.isEnabled != value {
super.isEnabled = value
self.attributedString = AttributedString(string: text, attributes: self.attributesForCurrentState())
self.attributedString = NSAttributedString(string: text, attributes: self.attributesForCurrentState())
}
}
}

View File

@ -4,7 +4,7 @@ import AsyncDisplayKit
import SwiftSignalKit
private class NavigationControllerView: UIView {
override class func layerClass() -> AnyClass {
override class var layerClass: AnyClass {
return CATracingLayer.self
}
}
@ -60,7 +60,7 @@ public class NavigationController: NavigationControllerProxy, ContainableControl
}
public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
if !self.isViewLoaded() {
if !self.isViewLoaded {
self.loadView()
}
self.containerLayout = layout
@ -253,7 +253,7 @@ public class NavigationController: NavigationControllerProxy, ContainableControl
}
if animated && self.viewControllers.count != 0 && viewControllers.count != 0 && self.viewControllers.last! !== viewControllers.last! {
if self.viewControllers.contains({ $0 === viewControllers.last }) {
if self.viewControllers.contains(where: { $0 === viewControllers.last }) {
let bottomController = viewControllers.last! as UIViewController
let topController = self.viewControllers.last! as UIViewController
@ -323,7 +323,7 @@ public class NavigationController: NavigationControllerProxy, ContainableControl
})
}
} else {
if let topController = self.viewControllers.last where topController.isViewLoaded() {
if let topController = self.viewControllers.last where topController.isViewLoaded {
topController.navigation_setNavigationController(nil)
topController.view.removeFromSuperview()
}

View File

@ -15,7 +15,7 @@ public class NavigationTitleNode: ASDisplayNode {
}
}
public var color: UIColor = UIColor.black() {
public var color: UIColor = UIColor.black {
didSet {
self.setText(self._text)
}
@ -42,7 +42,7 @@ public class NavigationTitleNode: ASDisplayNode {
var titleAttributes = [String : AnyObject]()
titleAttributes[NSFontAttributeName] = UIFont.boldSystemFont(ofSize: 17.0)
titleAttributes[NSForegroundColorAttributeName] = self.color
let titleString = AttributedString(string: text as String, attributes: titleAttributes)
let titleString = NSAttributedString(string: text as String, attributes: titleAttributes)
self.label.attributedString = titleString
self.invalidateCalculatedLayout()
}

View File

@ -8,7 +8,7 @@ enum NavigationTransition {
private let shadowWidth: CGFloat = 16.0
private func generateShadow() -> UIImage? {
return UIImage(named: "NavigationShadow", in: Bundle(for: NavigationBackButtonNode.self), compatibleWith: nil)?.precomposed().resizableImage(withCapInsets: UIEdgeInsetsZero, resizingMode: .tile)
return UIImage(named: "NavigationShadow", in: Bundle(for: NavigationBackButtonNode.self), compatibleWith: nil)?.precomposed().resizableImage(withCapInsets: UIEdgeInsets(), resizingMode: .tile)
}
private let shadowImage = generateShadow()
@ -51,7 +51,7 @@ class NavigationTransitionCoordinator {
self.topNavigationBar = topNavigationBar
self.bottomNavigationBar = bottomNavigationBar
self.dimView = UIView()
self.dimView.backgroundColor = UIColor.black()
self.dimView.backgroundColor = UIColor.black
self.shadowView = UIImageView(image: shadowImage)
if let topNavigationBar = topNavigationBar, bottomNavigationBar = bottomNavigationBar {

View File

@ -46,7 +46,7 @@ final class PresentationContext {
self.presentationDisposables.add(controllerReady.start(next: { [weak self] _ in
if let strongSelf = self {
if strongSelf.controllers.contains({ $0 === controller }) {
if strongSelf.controllers.contains(where: { $0 === controller }) {
return
}
@ -131,7 +131,7 @@ final class PresentationContext {
func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
for controller in self.controllers {
if controller.isViewLoaded() {
if controller.isViewLoaded {
if let result = controller.view.hitTest(point, with: event) {
return result
}

View File

@ -2,7 +2,7 @@ import Foundation
import UIKit
private let systemVersion = { () -> (Int, Int) in
let string = UIDevice.current().systemVersion as NSString
let string = UIDevice.current.systemVersion as NSString
var minor = 0
let range = string.range(of: ".")
if range.location != NSNotFound {

View File

@ -1,29 +0,0 @@
import Foundation
import UIKit
private class StatusBarHostWindowController: UIViewController {
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.default
}
override func prefersStatusBarHidden() -> Bool {
return false
}
override func shouldAutorotate() -> Bool {
return true
}
}
public class StatusBarHostWindow: UIWindow {
public init() {
super.init(frame: CGRect())
self.windowLevel = 10000.0
self.rootViewController = StatusBarHostWindowController()
}
required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}

View File

@ -31,7 +31,7 @@ private func optimizeMappedSurface(_ surface: MappedStatusBarSurface) -> MappedS
return surface
}
}
let size = UIApplication.shared().statusBarFrame.size
let size = UIApplication.shared.statusBarFrame.size
return MappedStatusBarSurface(statusBars: [MappedStatusBar(style: surface.statusBars[0].style, frame: CGRect(origin: CGPoint(x: 0.0, y: surface.statusBars[0].frame.origin.y), size: size), statusBar: nil)], surface: surface.surface)
} else {
return surface
@ -124,7 +124,7 @@ class StatusBarManager {
for surface in previousSurfaces {
for statusBar in surface.statusBars {
if !visibleStatusBars.contains({$0 === statusBar}) {
if !visibleStatusBars.contains(where: {$0 === statusBar}) {
statusBar.removeProxyNode()
}
}
@ -132,7 +132,7 @@ class StatusBarManager {
for surface in self.surfaces {
for statusBar in surface.statusBars {
if !visibleStatusBars.contains({$0 === statusBar}) {
if !visibleStatusBars.contains(where: {$0 === statusBar}) {
statusBar.removeProxyNode()
}
}
@ -144,8 +144,8 @@ class StatusBarManager {
if let globalStatusBar = globalStatusBar {
let statusBarStyle: UIStatusBarStyle = globalStatusBar.0 == .Black ? .default : .lightContent
if UIApplication.shared().statusBarStyle != statusBarStyle {
UIApplication.shared().setStatusBarStyle(statusBarStyle, animated: false)
if UIApplication.shared.statusBarStyle != statusBarStyle {
UIApplication.shared.setStatusBarStyle(statusBarStyle, animated: false)
}
StatusBarUtils.statusBarWindow()!.alpha = globalStatusBar.1
} else {

View File

@ -43,16 +43,16 @@ private class StatusBarItemNode: ASDisplayNode {
if let contents = sublayer.contents where CFGetTypeID(contents) == CGImage.typeID {
let image = contents as! CGImage
context.withFlippedContext { c in
c.translate(x: origin.x, y: origin.y)
c.translateBy(x: origin.x, y: origin.y)
c.draw(in: CGRect(origin: CGPoint(), size: context.size), image: image)
c.translate(x: -origin.x, y: -origin.y)
c.translateBy(x: -origin.x, y: -origin.y)
}
} else {
context.withContext { c in
UIGraphicsPushContext(c)
c.translate(x: origin.x, y: origin.y)
c.translateBy(x: origin.x, y: origin.y)
sublayer.render(in: c)
c.translate(x: -origin.x, y: -origin.y)
c.translateBy(x: -origin.x, y: -origin.y)
UIGraphicsPopContext()
}
}

View File

@ -1,41 +1,41 @@
import UIKit
final class SystemContainedControllerTransitionCoordinator:NSObject, UIViewControllerTransitionCoordinator {
public func isAnimated() -> Bool {
public var isAnimated: Bool {
return false
}
public func presentationStyle() -> UIModalPresentationStyle {
public var presentationStyle: UIModalPresentationStyle {
return .fullScreen
}
public func initiallyInteractive() -> Bool {
public var initiallyInteractive: Bool {
return false
}
public let isInterruptible: Bool = false
public func isInteractive() -> Bool {
public var isInteractive: Bool {
return false
}
public func isCancelled() -> Bool {
public var isCancelled: Bool {
return false
}
public func transitionDuration() -> TimeInterval {
public var transitionDuration: TimeInterval {
return 0.6
}
public func percentComplete() -> CGFloat {
public var percentComplete: CGFloat {
return 0.0
}
public func completionVelocity() -> CGFloat {
public var completionVelocity: CGFloat {
return 0.0
}
public func completionCurve() -> UIViewAnimationCurve {
public var completionCurve: UIViewAnimationCurve {
return .easeInOut
}
@ -47,11 +47,11 @@ final class SystemContainedControllerTransitionCoordinator:NSObject, UIViewContr
return nil
}
public func containerView() -> UIView {
public var containerView: UIView {
return UIView()
}
public func targetTransform() -> CGAffineTransform {
public var targetTransform: CGAffineTransform {
return CGAffineTransform.identity
}

View File

@ -2,7 +2,7 @@ import Foundation
import UIKit
import AsyncDisplayKit
private let separatorHeight: CGFloat = 1.0 / UIScreen.main().scale
private let separatorHeight: CGFloat = 1.0 / UIScreen.main.scale
private func tabBarItemImage(_ image: UIImage?, title: String, tintColor: UIColor) -> UIImage {
let font = Font.regular(10.0)
let titleSize = (title as NSString).boundingRect(with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude), options: [.usesLineFragmentOrigin], attributes: [NSFontAttributeName: font], context: nil).size
@ -24,10 +24,10 @@ private func tabBarItemImage(_ image: UIImage?, title: String, tintColor: UIColo
if let image = image {
let imageRect = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - imageSize.width) / 2.0), y: 0.0), size: imageSize)
context.saveGState()
context.translate(x: imageRect.midX, y: imageRect.midY)
context.scale(x: 1.0, y: -1.0)
context.translate(x: -imageRect.midX, y: -imageRect.midY)
context.clipToMask(imageRect, mask: image.cgImage!)
context.translateBy(x: imageRect.midX, y: imageRect.midY)
context.scaleBy(x: 1.0, y: -1.0)
context.translateBy(x: -imageRect.midX, y: -imageRect.midY)
context.clip(to: imageRect, mask: image.cgImage!)
context.setFillColor(tintColor.cgColor)
context.fill(imageRect)
context.restoreGState()
@ -140,7 +140,8 @@ class TabBarNode: ASDisplayNode {
let node = self.tabBarNodes[i]
node.measure(CGSize(width: internalWidth, height: size.height))
node.frame = CGRect(origin: CGPoint(x: floor(leftNodeOriginX + CGFloat(i) * distanceBetweenNodes - node.calculatedSize.width / 2.0), y: 4.0), size: node.calculatedSize)
let originX = floor(leftNodeOriginX + CGFloat(i) * distanceBetweenNodes - node.calculatedSize.width / 2.0)
node.frame = CGRect(origin: CGPoint(x: originX, y: 4.0), size: node.calculatedSize)
}
}
}

View File

@ -26,7 +26,7 @@ private func dumpLayers(_ layer: CALayer, indent: String = "") {
}
}
public let UIScreenScale = UIScreen.main().scale
public let UIScreenScale = UIScreen.main.scale
public func floorToScreenPixels(_ value: CGFloat) -> CGFloat {
return floor(value * UIScreenScale) / UIScreenScale
}
@ -96,7 +96,7 @@ public extension UIImage {
self.draw(at: CGPoint())
let result = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
if !UIEdgeInsetsEqualToEdgeInsets(self.capInsets, UIEdgeInsetsZero) {
if !UIEdgeInsetsEqualToEdgeInsets(self.capInsets, UIEdgeInsets()) {
return result.resizableImage(withCapInsets: self.capInsets, resizingMode: self.resizingMode)
}
return result

View File

@ -1,12 +1,15 @@
#import <UIKit/UIKit.h>
typedef void (^UINavigationItemSetTitleListener)(NSString *);
typedef void (^UINavigationItemSetTitleViewListener)(UIView *);
typedef void (^UINavigationItemSetBarButtonItemListener)(UIBarButtonItem *, BOOL);
@interface UINavigationItem (Proxy)
- (NSInteger)addSetTitleListener:(UINavigationItemSetTitleListener)listener;
- (void)removeSetTitleListener:(NSInteger)key;
- (NSInteger)addSetTitleViewListener:(UINavigationItemSetTitleViewListener)listener;
- (void)removeSetTitleViewListener:(NSInteger)key;
- (NSInteger)addSetLeftBarButtonItemListener:(UINavigationItemSetBarButtonItemListener)listener;
- (void)removeSetLeftBarButtonItemListener:(NSInteger)key;
- (NSInteger)addSetRightBarButtonItemListener:(UINavigationItemSetBarButtonItemListener)listener;

View File

@ -4,6 +4,7 @@
#import "RuntimeUtils.h"
static const void *setTitleListenerBagKey = &setTitleListenerBagKey;
static const void *setTitleViewListenerBagKey = &setTitleViewListenerBagKey;
static const void *setLeftBarButtonItemListenerBagKey = &setLeftBarButtonItemListenerBagKey;
static const void *setRightBarButtonItemListenerBagKey = &setRightBarButtonItemListenerBagKey;
@ -15,6 +16,7 @@ static const void *setRightBarButtonItemListenerBagKey = &setRightBarButtonItemL
dispatch_once(&onceToken, ^
{
[RuntimeUtils swizzleInstanceMethodOfClass:[UINavigationItem class] currentSelector:@selector(setTitle:) newSelector:@selector(_ac91f40f_setTitle:)];
[RuntimeUtils swizzleInstanceMethodOfClass:[UINavigationItem class] currentSelector:@selector(setTitleView:) newSelector:@selector(_ac91f40f_setTitleView:)];
[RuntimeUtils swizzleInstanceMethodOfClass:[UINavigationItem class] currentSelector:@selector(setLeftBarButtonItem:) newSelector:@selector(_ac91f40f_setLeftBarButtonItem:animated:)];
[RuntimeUtils swizzleInstanceMethodOfClass:[UINavigationItem class] currentSelector:@selector(setRightBarButtonItem:) newSelector:@selector(_ac91f40f_setRightBarButtonItem:animated:)];
});
@ -24,18 +26,25 @@ static const void *setRightBarButtonItemListenerBagKey = &setRightBarButtonItemL
{
[self _ac91f40f_setTitle:title];
[(NSBag *)[self associatedObjectForKey:setTitleListenerBagKey] enumerateItems:^(UINavigationItemSetTitleListener listener)
{
[(NSBag *)[self associatedObjectForKey:setTitleListenerBagKey] enumerateItems:^(UINavigationItemSetTitleListener listener) {
listener(title);
}];
}
- (void)_ac91f40f_setTitleView:(UIView *)titleView
{
[self _ac91f40f_setTitleView:titleView];
[(NSBag *)[self associatedObjectForKey:setTitleViewListenerBagKey] enumerateItems:^(UINavigationItemSetTitleViewListener listener) {
listener(titleView);
}];
}
- (void)_ac91f40f_setLeftBarButtonItem:(UIBarButtonItem *)leftBarButtonItem animated:(BOOL)animated
{
[self _ac91f40f_setLeftBarButtonItem:leftBarButtonItem animated:animated];
[(NSBag *)[self associatedObjectForKey:setLeftBarButtonItemListenerBagKey] enumerateItems:^(UINavigationItemSetBarButtonItemListener listener)
{
[(NSBag *)[self associatedObjectForKey:setLeftBarButtonItemListenerBagKey] enumerateItems:^(UINavigationItemSetBarButtonItemListener listener) {
listener(leftBarButtonItem, animated);
}];
}
@ -44,8 +53,7 @@ static const void *setRightBarButtonItemListenerBagKey = &setRightBarButtonItemL
{
[self _ac91f40f_setRightBarButtonItem:rightBarButtonItem animated:animated];
[(NSBag *)[self associatedObjectForKey:setRightBarButtonItemListenerBagKey] enumerateItems:^(UINavigationItemSetBarButtonItemListener listener)
{
[(NSBag *)[self associatedObjectForKey:setRightBarButtonItemListenerBagKey] enumerateItems:^(UINavigationItemSetBarButtonItemListener listener) {
listener(rightBarButtonItem, animated);
}];
}
@ -66,6 +74,22 @@ static const void *setRightBarButtonItemListenerBagKey = &setRightBarButtonItemL
[(NSBag *)[self associatedObjectForKey:setTitleListenerBagKey] removeItem:key];
}
- (NSInteger)addSetTitleViewListener:(UINavigationItemSetTitleViewListener)listener
{
NSBag *bag = [self associatedObjectForKey:setTitleViewListenerBagKey];
if (bag == nil)
{
bag = [[NSBag alloc] init];
[self setAssociatedObject:bag forKey:setTitleViewListenerBagKey];
}
return [bag addItem:[listener copy]];
}
- (void)removeSetTitleViewListener:(NSInteger)key
{
[(NSBag *)[self associatedObjectForKey:setTitleViewListenerBagKey] removeItem:key];
}
- (NSInteger)addSetLeftBarButtonItemListener:(UINavigationItemSetBarButtonItemListener)listener
{
NSBag *bag = [self associatedObjectForKey:setLeftBarButtonItemListenerBagKey];

View File

@ -43,7 +43,7 @@ import SwiftSignalKit
private var scrollToTopView: ScrollToTopView?
public var scrollToTop: (() -> Void)? {
didSet {
if self.isViewLoaded() {
if self.isViewLoaded {
self.updateScrollToTopView()
}
}
@ -92,7 +92,7 @@ import SwiftSignalKit
public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
self.containerLayout = layout
if !self.isViewLoaded() {
if !self.isViewLoaded {
self.loadView()
}
self.view.frame = CGRect(origin: self.view.frame.origin, size: layout.size)
@ -133,7 +133,7 @@ import SwiftSignalKit
}
public func requestLayout(transition: ContainedViewLayoutTransition) {
if self.isViewLoaded() {
if self.isViewLoaded {
self.containerLayoutUpdated(self.containerLayout, transition: transition)
}
}

View File

@ -2,11 +2,11 @@ import Foundation
import AsyncDisplayKit
private class WindowRootViewController: UIViewController {
override func preferredStatusBarStyle() -> UIStatusBarStyle {
override var preferredStatusBarStyle: UIStatusBarStyle {
return .default
}
override func prefersStatusBarHidden() -> Bool {
override var prefersStatusBarHidden: Bool {
return false
}
}
@ -84,8 +84,8 @@ private struct UpdatingLayout {
}
}
private let orientationChangeDuration: Double = UIDevice.current().userInterfaceIdiom == .pad ? 0.4 : 0.3
private let statusBarHiddenInLandscape: Bool = UIDevice.current().userInterfaceIdiom == .phone
private let orientationChangeDuration: Double = UIDevice.current.userInterfaceIdiom == .pad ? 0.4 : 0.3
private let statusBarHiddenInLandscape: Bool = UIDevice.current.userInterfaceIdiom == .phone
private func containedLayoutForWindowLayout(_ layout: WindowLayout) -> ContainerViewLayout {
return ContainerViewLayout(size: layout.size, intrinsicInsets: UIEdgeInsets(), statusBarHeight: layout.statusBarHeight, inputHeight: layout.inputHeight)
@ -108,12 +108,12 @@ public class Window: UIWindow {
private var statusBarHidden = false
public convenience init() {
self.init(frame: UIScreen.main().bounds)
self.init(frame: UIScreen.main.bounds)
}
public override init(frame: CGRect) {
self.statusBarManager = StatusBarManager()
self.windowLayout = WindowLayout(size: frame.size, statusBarHeight: UIApplication.shared().statusBarFrame.size.height, inputHeight: 0.0)
self.windowLayout = WindowLayout(size: frame.size, statusBarHeight: UIApplication.shared.statusBarFrame.size.height, inputHeight: 0.0)
self.presentationContext = PresentationContext()
super.init(frame: frame)
@ -129,7 +129,7 @@ public class Window: UIWindow {
self.statusBarChangeObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name.UIApplicationWillChangeStatusBarFrame, 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?[UIApplicationStatusBarFrameUserInfoKey] 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) }
@ -138,8 +138,8 @@ public class Window: UIWindow {
self.keyboardFrameChangeObserver = NotificationCenter.default.addObserver(forName: NSNotification.Name.UIKeyboardWillChangeFrame, object: nil, queue: nil, using: { [weak self] notification in
if let strongSelf = self {
let keyboardFrame: CGRect = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue() ?? CGRect()
let keyboardHeight = max(0.0, UIScreen.main().bounds.size.height - keyboardFrame.minY)
let keyboardFrame: CGRect = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? CGRect()
let keyboardHeight = max(0.0, UIScreen.main.bounds.size.height - keyboardFrame.minY)
var duration: Double = (notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0.0
if duration > DBL_EPSILON {
duration = 0.5
@ -316,7 +316,7 @@ public class Window: UIWindow {
if let updatingLayout = self.updatingLayout {
self.updatingLayout = nil
if updatingLayout.layout != self.windowLayout {
var statusBarHeight = UIApplication.shared().statusBarFrame.size.height
var statusBarHeight = UIApplication.shared.statusBarFrame.size.height
var statusBarWasHidden = self.statusBarHidden
if statusBarHiddenInLandscape && updatingLayout.layout.size.width > updatingLayout.layout.size.height {
statusBarHeight = 0.0