mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-16 19:30:29 +00:00
Customizable color for disabled navigation bar buttons
This commit is contained in:
parent
2e9350d717
commit
b3a1027822
@ -104,7 +104,7 @@ enum DeviceMetrics {
|
|||||||
case .iPhone4, .iPhone5:
|
case .iPhone4, .iPhone5:
|
||||||
return 37.0
|
return 37.0
|
||||||
case .iPhone6, .iPhoneX:
|
case .iPhone6, .iPhoneX:
|
||||||
return 42.0
|
return 44.0
|
||||||
case .iPhone6Plus:
|
case .iPhone6Plus:
|
||||||
return 42.0
|
return 42.0
|
||||||
case .iPhoneXSMax:
|
case .iPhoneXSMax:
|
||||||
|
|||||||
@ -20,7 +20,7 @@ public protocol ListViewItemHeader: class {
|
|||||||
|
|
||||||
open class ListViewItemHeaderNode: ASDisplayNode {
|
open class ListViewItemHeaderNode: ASDisplayNode {
|
||||||
private final var spring: ListViewItemSpring?
|
private final var spring: ListViewItemSpring?
|
||||||
let wantsScrollDynamics: Bool
|
open private(set) var wantsScrollDynamics: Bool
|
||||||
let isRotated: Bool
|
let isRotated: Bool
|
||||||
final private(set) var internalStickLocationDistanceFactor: CGFloat = 0.0
|
final private(set) var internalStickLocationDistanceFactor: CGFloat = 0.0
|
||||||
final var internalStickLocationDistance: CGFloat = 0.0
|
final var internalStickLocationDistance: CGFloat = 0.0
|
||||||
|
|||||||
@ -94,7 +94,7 @@ open class ListViewItemNode: ASDisplayNode {
|
|||||||
private final var spring: ListViewItemSpring?
|
private final var spring: ListViewItemSpring?
|
||||||
private final var animations: [(String, ListViewAnimation)] = []
|
private final var animations: [(String, ListViewAnimation)] = []
|
||||||
|
|
||||||
final let wantsScrollDynamics: Bool
|
open private(set) var wantsScrollDynamics: Bool
|
||||||
|
|
||||||
public final var wantsTrailingItemSpaceUpdates: Bool = false
|
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) {
|
public init(layerBacked: Bool, dynamicBounce: Bool = true, rotated: Bool = false, seeThrough: Bool = false) {
|
||||||
if true {
|
if dynamicBounce {
|
||||||
if dynamicBounce {
|
self.spring = ListViewItemSpring(stiffness: -280.0, damping: -24.0, mass: 0.85)
|
||||||
self.spring = ListViewItemSpring(stiffness: -280.0, damping: -24.0, mass: 0.85)
|
|
||||||
}
|
|
||||||
self.wantsScrollDynamics = dynamicBounce
|
|
||||||
} else {
|
|
||||||
self.wantsScrollDynamics = false
|
|
||||||
}
|
}
|
||||||
|
self.wantsScrollDynamics = dynamicBounce
|
||||||
|
|
||||||
self.rotated = rotated
|
self.rotated = rotated
|
||||||
|
|
||||||
@ -198,7 +194,7 @@ open class ListViewItemNode: ASDisplayNode {
|
|||||||
} else {
|
} else {
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
self.setViewBlock({
|
self.setViewBlock({
|
||||||
return CASeeThroughTracingView()
|
return CASeeThroughTracingView()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ public class NavigationBackButtonNode: ASControlNode {
|
|||||||
private func attributesForCurrentState() -> [NSAttributedStringKey : AnyObject] {
|
private func attributesForCurrentState() -> [NSAttributedStringKey : AnyObject] {
|
||||||
return [
|
return [
|
||||||
NSAttributedStringKey.font: self.fontForCurrentState(),
|
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
|
private var touchCount = 0
|
||||||
var pressed: () -> () = {}
|
var pressed: () -> () = {}
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ public final class NavigationBarTheme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public let buttonColor: UIColor
|
public let buttonColor: UIColor
|
||||||
|
public let disabledButtonColor: UIColor
|
||||||
public let primaryTextColor: UIColor
|
public let primaryTextColor: UIColor
|
||||||
public let backgroundColor: UIColor
|
public let backgroundColor: UIColor
|
||||||
public let separatorColor: UIColor
|
public let separatorColor: UIColor
|
||||||
@ -23,8 +24,9 @@ public final class NavigationBarTheme {
|
|||||||
public let badgeStrokeColor: UIColor
|
public let badgeStrokeColor: UIColor
|
||||||
public let badgeTextColor: 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.buttonColor = buttonColor
|
||||||
|
self.disabledButtonColor = disabledButtonColor
|
||||||
self.primaryTextColor = primaryTextColor
|
self.primaryTextColor = primaryTextColor
|
||||||
self.backgroundColor = backgroundColor
|
self.backgroundColor = backgroundColor
|
||||||
self.separatorColor = separatorColor
|
self.separatorColor = separatorColor
|
||||||
@ -34,7 +36,7 @@ public final class NavigationBarTheme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func withUpdatedSeparatorColor(_ color: UIColor) -> 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.clippingNode.clipsToBounds = true
|
||||||
|
|
||||||
self.backButtonNode.color = self.presentationData.theme.buttonColor
|
self.backButtonNode.color = self.presentationData.theme.buttonColor
|
||||||
|
self.backButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor
|
||||||
self.leftButtonNode.color = self.presentationData.theme.buttonColor
|
self.leftButtonNode.color = self.presentationData.theme.buttonColor
|
||||||
|
self.leftButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor
|
||||||
self.rightButtonNode.color = self.presentationData.theme.buttonColor
|
self.rightButtonNode.color = self.presentationData.theme.buttonColor
|
||||||
|
self.rightButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor
|
||||||
self.backButtonArrow.image = backArrowImage(color: self.presentationData.theme.buttonColor)
|
self.backButtonArrow.image = backArrowImage(color: self.presentationData.theme.buttonColor)
|
||||||
if let title = self.title {
|
if let title = self.title {
|
||||||
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(17.0), textColor: self.presentationData.theme.primaryTextColor)
|
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.backgroundColor = self.presentationData.theme.backgroundColor
|
||||||
|
|
||||||
self.backButtonNode.color = self.presentationData.theme.buttonColor
|
self.backButtonNode.color = self.presentationData.theme.buttonColor
|
||||||
|
self.backButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor
|
||||||
self.leftButtonNode.color = self.presentationData.theme.buttonColor
|
self.leftButtonNode.color = self.presentationData.theme.buttonColor
|
||||||
|
self.leftButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor
|
||||||
self.rightButtonNode.color = self.presentationData.theme.buttonColor
|
self.rightButtonNode.color = self.presentationData.theme.buttonColor
|
||||||
|
self.rightButtonNode.disabledColor = self.presentationData.theme.disabledButtonColor
|
||||||
self.backButtonArrow.image = backArrowImage(color: self.presentationData.theme.buttonColor)
|
self.backButtonArrow.image = backArrowImage(color: self.presentationData.theme.buttonColor)
|
||||||
if let title = self.title {
|
if let title = self.title {
|
||||||
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(17.0), textColor: self.presentationData.theme.primaryTextColor)
|
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.semibold(17.0), textColor: self.presentationData.theme.primaryTextColor)
|
||||||
|
|||||||
@ -9,7 +9,7 @@ private final class NavigationButtonItemNode: ASTextNode {
|
|||||||
private func attributesForCurrentState() -> [NSAttributedStringKey : AnyObject] {
|
private func attributesForCurrentState() -> [NSAttributedStringKey : AnyObject] {
|
||||||
return [
|
return [
|
||||||
NSAttributedStringKey.font: self.fontForCurrentState(),
|
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
|
private var _bold: Bool = false
|
||||||
public var bold: Bool {
|
public var bold: Bool {
|
||||||
get {
|
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() {
|
override init() {
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user