diff --git a/Display/DeviceMetrics.swift b/Display/DeviceMetrics.swift index 01354976ec..84d1d66206 100644 --- a/Display/DeviceMetrics.swift +++ b/Display/DeviceMetrics.swift @@ -104,7 +104,7 @@ enum DeviceMetrics { case .iPhone4, .iPhone5: return 37.0 case .iPhone6, .iPhoneX: - return 42.0 + return 44.0 case .iPhone6Plus: return 42.0 case .iPhoneXSMax: diff --git a/Display/ListViewItemHeader.swift b/Display/ListViewItemHeader.swift index db5a74e35f..a11585bc50 100644 --- a/Display/ListViewItemHeader.swift +++ b/Display/ListViewItemHeader.swift @@ -20,7 +20,7 @@ public protocol ListViewItemHeader: class { open class ListViewItemHeaderNode: ASDisplayNode { private final var spring: ListViewItemSpring? - let wantsScrollDynamics: Bool + open private(set) var wantsScrollDynamics: Bool let isRotated: Bool final private(set) var internalStickLocationDistanceFactor: CGFloat = 0.0 final var internalStickLocationDistance: CGFloat = 0.0 diff --git a/Display/ListViewItemNode.swift b/Display/ListViewItemNode.swift index 1b41f683a4..05e4eda19b 100644 --- a/Display/ListViewItemNode.swift +++ b/Display/ListViewItemNode.swift @@ -94,7 +94,7 @@ open class ListViewItemNode: ASDisplayNode { private final var spring: ListViewItemSpring? private final var animations: [(String, ListViewAnimation)] = [] - final let wantsScrollDynamics: Bool + open private(set) var wantsScrollDynamics: Bool public final var wantsTrailingItemSpaceUpdates: Bool = false @@ -178,14 +178,10 @@ open class ListViewItemNode: ASDisplayNode { } public init(layerBacked: Bool, dynamicBounce: Bool = true, rotated: Bool = false, seeThrough: Bool = false) { - if true { - if dynamicBounce { - self.spring = ListViewItemSpring(stiffness: -280.0, damping: -24.0, mass: 0.85) - } - self.wantsScrollDynamics = dynamicBounce - } else { - self.wantsScrollDynamics = false + if dynamicBounce { + self.spring = ListViewItemSpring(stiffness: -280.0, damping: -24.0, mass: 0.85) } + self.wantsScrollDynamics = dynamicBounce self.rotated = rotated @@ -198,7 +194,7 @@ open class ListViewItemNode: ASDisplayNode { } else { super.init() - self.setViewBlock({ + self.setViewBlock({ return CASeeThroughTracingView() }) } diff --git a/Display/NavigationBackButtonNode.swift b/Display/NavigationBackButtonNode.swift index 8b81086c1a..393ba98db8 100644 --- a/Display/NavigationBackButtonNode.swift +++ b/Display/NavigationBackButtonNode.swift @@ -9,7 +9,7 @@ public class NavigationBackButtonNode: ASControlNode { private func attributesForCurrentState() -> [NSAttributedStringKey : AnyObject] { return [ NSAttributedStringKey.font: self.fontForCurrentState(), - NSAttributedStringKey.foregroundColor: self.isEnabled ? self.color : UIColor.gray + NSAttributedStringKey.foregroundColor: self.isEnabled ? self.color : self.disabledColor ] } @@ -36,6 +36,12 @@ public class NavigationBackButtonNode: ASControlNode { } } + public var disabledColor: UIColor = UIColor(rgb: 0xd0d0d0) { + didSet { + self.label.attributedText = NSAttributedString(string: self._text, attributes: self.attributesForCurrentState()) + } + } + private var touchCount = 0 var pressed: () -> () = {} diff --git a/Display/NavigationBar.swift b/Display/NavigationBar.swift index 905c1de1e5..61931c9b67 100644 --- a/Display/NavigationBar.swift +++ b/Display/NavigationBar.swift @@ -16,6 +16,7 @@ public final class NavigationBarTheme { } public let buttonColor: UIColor + public let disabledButtonColor: UIColor public let primaryTextColor: UIColor public let backgroundColor: UIColor public let separatorColor: UIColor @@ -23,8 +24,9 @@ public final class NavigationBarTheme { public let badgeStrokeColor: UIColor public let badgeTextColor: UIColor - public init(buttonColor: UIColor, primaryTextColor: UIColor, backgroundColor: UIColor, separatorColor: UIColor, badgeBackgroundColor: UIColor, badgeStrokeColor: UIColor, badgeTextColor: UIColor) { + public init(buttonColor: UIColor, disabledButtonColor: UIColor, primaryTextColor: UIColor, backgroundColor: UIColor, separatorColor: UIColor, badgeBackgroundColor: UIColor, badgeStrokeColor: UIColor, badgeTextColor: UIColor) { self.buttonColor = buttonColor + self.disabledButtonColor = disabledButtonColor self.primaryTextColor = primaryTextColor self.backgroundColor = backgroundColor self.separatorColor = separatorColor @@ -34,7 +36,7 @@ public final class NavigationBarTheme { } public func withUpdatedSeparatorColor(_ color: UIColor) -> NavigationBarTheme { - return NavigationBarTheme(buttonColor: self.buttonColor, primaryTextColor: self.primaryTextColor, backgroundColor: self.backgroundColor, separatorColor: color, badgeBackgroundColor: self.badgeBackgroundColor, badgeStrokeColor: self.badgeStrokeColor, badgeTextColor: self.badgeTextColor) + return NavigationBarTheme(buttonColor: self.buttonColor, disabledButtonColor: self.disabledButtonColor, primaryTextColor: self.primaryTextColor, backgroundColor: self.backgroundColor, separatorColor: color, badgeBackgroundColor: self.badgeBackgroundColor, badgeStrokeColor: self.badgeStrokeColor, badgeTextColor: self.badgeTextColor) } } @@ -606,8 +608,11 @@ open class NavigationBar: ASDisplayNode { self.clippingNode.clipsToBounds = true self.backButtonNode.color = self.presentationData.theme.buttonColor + self.backButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor self.leftButtonNode.color = self.presentationData.theme.buttonColor + self.leftButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor self.rightButtonNode.color = self.presentationData.theme.buttonColor + self.rightButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor self.backButtonArrow.image = backArrowImage(color: self.presentationData.theme.buttonColor) if let title = self.title { self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(17.0), textColor: self.presentationData.theme.primaryTextColor) @@ -676,8 +681,11 @@ open class NavigationBar: ASDisplayNode { self.backgroundColor = self.presentationData.theme.backgroundColor self.backButtonNode.color = self.presentationData.theme.buttonColor + self.backButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor self.leftButtonNode.color = self.presentationData.theme.buttonColor + self.leftButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor self.rightButtonNode.color = self.presentationData.theme.buttonColor + self.rightButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor self.backButtonArrow.image = backArrowImage(color: self.presentationData.theme.buttonColor) if let title = self.title { self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(17.0), textColor: self.presentationData.theme.primaryTextColor) diff --git a/Display/NavigationButtonNode.swift b/Display/NavigationButtonNode.swift index b6a74ce8b6..a56663fcc3 100644 --- a/Display/NavigationButtonNode.swift +++ b/Display/NavigationButtonNode.swift @@ -9,7 +9,7 @@ private final class NavigationButtonItemNode: ASTextNode { private func attributesForCurrentState() -> [NSAttributedStringKey : AnyObject] { return [ NSAttributedStringKey.font: self.fontForCurrentState(), - NSAttributedStringKey.foregroundColor: self.isEnabled ? self.color : UIColor.gray + NSAttributedStringKey.foregroundColor: self.isEnabled ? self.color : self.disabledColor ] } @@ -93,6 +93,14 @@ private final class NavigationButtonItemNode: ASTextNode { } } + public var disabledColor: UIColor = UIColor(rgb: 0xd0d0d0) { + didSet { + if let text = self._text { + self.attributedText = NSAttributedString(string: text, attributes: self.attributesForCurrentState()) + } + } + } + private var _bold: Bool = false public var bold: Bool { get { @@ -229,6 +237,16 @@ final class NavigationButtonNode: ASDisplayNode { } } + public var disabledColor: UIColor = UIColor(rgb: 0xd0d0d0) { + didSet { + if !self.disabledColor.isEqual(oldValue) { + for node in self.nodes { + node.disabledColor = self.disabledColor + } + } + } + } + override init() { super.init() }