mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Name color improvements
This commit is contained in:
parent
08b76943c2
commit
7cb8f9739b
@ -1281,10 +1281,10 @@ public class PeerNameColors: Equatable {
|
|||||||
var colors = PeerNameColors.defaultSingleColors
|
var colors = PeerNameColors.defaultSingleColors
|
||||||
var darkColors: [Int32: Colors] = [:]
|
var darkColors: [Int32: Colors] = [:]
|
||||||
|
|
||||||
if let peerColors = data["peer_colors"] as? [String: [Double]] {
|
if let peerColors = data["peer_colors"] as? [String: [String]] {
|
||||||
for (key, values) in peerColors {
|
for (key, values) in peerColors {
|
||||||
if let index = Int32(key) {
|
if let index = Int32(key) {
|
||||||
let colorsArray = values.map { UIColor(rgb: UInt32($0)) }
|
let colorsArray = values.compactMap { UIColor(hexString: $0) }
|
||||||
if let colorValues = Colors(colors: colorsArray) {
|
if let colorValues = Colors(colors: colorsArray) {
|
||||||
colors[index] = colorValues
|
colors[index] = colorValues
|
||||||
}
|
}
|
||||||
@ -1292,10 +1292,10 @@ public class PeerNameColors: Equatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let darkPeerColors = data["dark_peer_colors"] as? [String: [Double]] {
|
if let darkPeerColors = data["dark_peer_colors"] as? [String: [String]] {
|
||||||
for (key, values) in darkPeerColors {
|
for (key, values) in darkPeerColors {
|
||||||
if let index = Int32(key) {
|
if let index = Int32(key) {
|
||||||
let colorsArray = values.map { UIColor(rgb: UInt32($0)) }
|
let colorsArray = values.compactMap { UIColor(hexString: $0) }
|
||||||
if let colorValues = Colors(colors: colorsArray) {
|
if let colorValues = Colors(colors: colorsArray) {
|
||||||
darkColors[index] = colorValues
|
darkColors[index] = colorValues
|
||||||
}
|
}
|
||||||
|
@ -339,10 +339,15 @@ public final class ChatPresentationInterfaceState: Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public struct AccountPeerColor: Equatable {
|
public struct AccountPeerColor: Equatable {
|
||||||
public var isDashed: Bool
|
public enum Style {
|
||||||
|
case solid
|
||||||
|
case doubleDashed
|
||||||
|
case tripleDashed
|
||||||
|
}
|
||||||
|
public var style: Style
|
||||||
|
|
||||||
public init(isDashed: Bool) {
|
public init(style: Style) {
|
||||||
self.isDashed = isDashed
|
self.style = style
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
|
|||||||
quote: ChatInputTextView.Theme.Quote(
|
quote: ChatInputTextView.Theme.Quote(
|
||||||
background: mainColor.withMultipliedAlpha(0.1),
|
background: mainColor.withMultipliedAlpha(0.1),
|
||||||
foreground: mainColor,
|
foreground: mainColor,
|
||||||
isDashed: textInputView.theme?.quote.isDashed == true
|
lineStyle: textInputView.theme?.quote.lineStyle ?? .solid
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -259,18 +259,23 @@ private final class ChatInputTextContainer: NSTextContainer {
|
|||||||
public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDelegate, NSTextStorageDelegate {
|
public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDelegate, NSTextStorageDelegate {
|
||||||
public final class Theme: Equatable {
|
public final class Theme: Equatable {
|
||||||
public final class Quote: Equatable {
|
public final class Quote: Equatable {
|
||||||
|
public enum LineStyle {
|
||||||
|
case solid
|
||||||
|
case doubleDashed
|
||||||
|
case tripleDashed
|
||||||
|
}
|
||||||
public let background: UIColor
|
public let background: UIColor
|
||||||
public let foreground: UIColor
|
public let foreground: UIColor
|
||||||
public let isDashed: Bool
|
public let lineStyle: LineStyle
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
background: UIColor,
|
background: UIColor,
|
||||||
foreground: UIColor,
|
foreground: UIColor,
|
||||||
isDashed: Bool
|
lineStyle: LineStyle
|
||||||
) {
|
) {
|
||||||
self.background = background
|
self.background = background
|
||||||
self.foreground = foreground
|
self.foreground = foreground
|
||||||
self.isDashed = isDashed
|
self.lineStyle = lineStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func ==(lhs: Quote, rhs: Quote) -> Bool {
|
public static func ==(lhs: Quote, rhs: Quote) -> Bool {
|
||||||
@ -280,7 +285,7 @@ public final class ChatInputTextView: ChatInputTextViewImpl, NSLayoutManagerDele
|
|||||||
if !lhs.foreground.isEqual(rhs.foreground) {
|
if !lhs.foreground.isEqual(rhs.foreground) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if lhs.isDashed != rhs.isDashed {
|
if lhs.lineStyle != rhs.lineStyle {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -763,8 +768,8 @@ private final class QuoteBackgroundView: UIView {
|
|||||||
self.backgroundView.update(
|
self.backgroundView.update(
|
||||||
size: size,
|
size: size,
|
||||||
primaryColor: theme.foreground,
|
primaryColor: theme.foreground,
|
||||||
secondaryColor: theme.isDashed ? .clear : nil,
|
secondaryColor: theme.lineStyle != .solid ? .clear : nil,
|
||||||
thirdColor: nil,
|
thirdColor: theme.lineStyle == .tripleDashed ? .clear : nil,
|
||||||
pattern: nil,
|
pattern: nil,
|
||||||
animation: .None
|
animation: .None
|
||||||
)
|
)
|
||||||
|
@ -222,6 +222,9 @@ public class ChatMessageReplyInfoNode: ASDisplayNode {
|
|||||||
if dashSecondaryColor != nil {
|
if dashSecondaryColor != nil {
|
||||||
secondaryColor = .clear
|
secondaryColor = .clear
|
||||||
}
|
}
|
||||||
|
if dashTertiaryColor != nil {
|
||||||
|
tertiaryColor = .clear
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dustColor = incoming ? arguments.presentationData.theme.theme.chat.message.incoming.secondaryTextColor : arguments.presentationData.theme.theme.chat.message.outgoing.secondaryTextColor
|
dustColor = incoming ? arguments.presentationData.theme.theme.chat.message.incoming.secondaryTextColor : arguments.presentationData.theme.theme.chat.message.outgoing.secondaryTextColor
|
||||||
case .standalone:
|
case .standalone:
|
||||||
@ -230,6 +233,9 @@ public class ChatMessageReplyInfoNode: ASDisplayNode {
|
|||||||
if dashSecondaryColor != nil {
|
if dashSecondaryColor != nil {
|
||||||
secondaryColor = .clear
|
secondaryColor = .clear
|
||||||
}
|
}
|
||||||
|
if dashTertiaryColor != nil {
|
||||||
|
tertiaryColor = .clear
|
||||||
|
}
|
||||||
|
|
||||||
mainColor = serviceMessageColorComponents(chatTheme: arguments.presentationData.theme.theme.chat, wallpaper: arguments.presentationData.theme.wallpaper).primaryText
|
mainColor = serviceMessageColorComponents(chatTheme: arguments.presentationData.theme.theme.chat, wallpaper: arguments.presentationData.theme.wallpaper).primaryText
|
||||||
dustColor = titleColor
|
dustColor = titleColor
|
||||||
|
@ -93,24 +93,26 @@ private let dashBackgroundTemplateImage: UIImage = {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
private func generateDashTemplateImage(isMonochrome: Bool, isTriple: Bool) -> UIImage {
|
private func generateDashTemplateImage(isMonochrome: Bool, isTriple: Bool) -> UIImage {
|
||||||
return generateImage(CGSize(width: radius * 2.0, height: isTriple ? 27.0 : 18.0), rotatedContext: { size, context in
|
return generateImage(CGSize(width: radius * 2.0, height: 18.0), rotatedContext: { size, context in
|
||||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||||
context.setFillColor(UIColor.white.cgColor)
|
context.setFillColor(UIColor.white.cgColor)
|
||||||
|
|
||||||
let dashOffset: CGFloat
|
let dashOffset: CGFloat
|
||||||
if isTriple {
|
if isTriple {
|
||||||
dashOffset = 0.0
|
dashOffset = isMonochrome ? -2.0 : 0.0
|
||||||
} else {
|
} else {
|
||||||
dashOffset = isMonochrome ? -4.0 : 5.0
|
dashOffset = isMonochrome ? -4.0 : 5.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let dashHeight: CGFloat = isTriple ? 6.0 : 9.0
|
||||||
|
|
||||||
context.translateBy(x: 0.0, y: dashOffset)
|
context.translateBy(x: 0.0, y: dashOffset)
|
||||||
|
|
||||||
for _ in 0 ..< 2 {
|
for _ in 0 ..< 2 {
|
||||||
context.move(to: CGPoint(x: 0.0, y: 3.0))
|
context.move(to: CGPoint(x: 0.0, y: 3.0))
|
||||||
context.addLine(to: CGPoint(x: lineWidth, y: 0.0))
|
context.addLine(to: CGPoint(x: lineWidth, y: 0.0))
|
||||||
context.addLine(to: CGPoint(x: lineWidth, y: 9.0))
|
context.addLine(to: CGPoint(x: lineWidth, y: dashHeight))
|
||||||
context.addLine(to: CGPoint(x: 0.0, y: 9.0 + 3.0))
|
context.addLine(to: CGPoint(x: 0.0, y: dashHeight + 3.0))
|
||||||
context.closePath()
|
context.closePath()
|
||||||
context.fillPath()
|
context.fillPath()
|
||||||
|
|
||||||
@ -133,6 +135,10 @@ private let dashMonochromeTemplateImage: UIImage = {
|
|||||||
return generateDashTemplateImage(isMonochrome: true, isTriple: false)
|
return generateDashTemplateImage(isMonochrome: true, isTriple: false)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
private let dashMonochromeTripleTemplateImage: UIImage = {
|
||||||
|
return generateDashTemplateImage(isMonochrome: true, isTriple: true)
|
||||||
|
}()
|
||||||
|
|
||||||
private func generateGradient(gradientWidth: CGFloat, baseAlpha: CGFloat) -> UIImage {
|
private func generateGradient(gradientWidth: CGFloat, baseAlpha: CGFloat) -> UIImage {
|
||||||
return generateImage(CGSize(width: gradientWidth, height: 16.0), opaque: false, scale: 1.0, rotatedContext: { size, context in
|
return generateImage(CGSize(width: gradientWidth, height: 16.0), opaque: false, scale: 1.0, rotatedContext: { size, context in
|
||||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||||
@ -334,9 +340,13 @@ private final class LineView: UIView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let templateImage: UIImage
|
let templateImage: UIImage
|
||||||
|
let monochromeTemplateImage: UIImage
|
||||||
|
|
||||||
if let thirdColor {
|
if let thirdColor {
|
||||||
let thirdDashBackgroundFrame = CGRect(origin: CGPoint(x: 0.0, y: -9.0), size: CGSize(width: radius * 2.0, height: size.height + 18.0))
|
let thirdDashBackgroundFrame = CGRect(origin: CGPoint(x: 0.0, y: -12.0), size: CGSize(width: radius * 2.0, height: size.height + 18.0))
|
||||||
templateImage = dashOpaqueTripleTemplateImage
|
templateImage = dashOpaqueTripleTemplateImage
|
||||||
|
monochromeTemplateImage = dashMonochromeTripleTemplateImage
|
||||||
|
|
||||||
let dashThirdBackgroundView: UIImageView
|
let dashThirdBackgroundView: UIImageView
|
||||||
if let current = self.dashThirdBackgroundView {
|
if let current = self.dashThirdBackgroundView {
|
||||||
dashThirdBackgroundView = current
|
dashThirdBackgroundView = current
|
||||||
@ -350,15 +360,18 @@ private final class LineView: UIView {
|
|||||||
dashThirdBackgroundView.frame = thirdDashBackgroundFrame
|
dashThirdBackgroundView.frame = thirdDashBackgroundFrame
|
||||||
}
|
}
|
||||||
|
|
||||||
if secondaryColor.alpha == 0.0 {
|
if thirdColor.alpha == 0.0 {
|
||||||
dashThirdBackgroundView.image = templateImage
|
dashThirdBackgroundView.alpha = 0.4
|
||||||
dashThirdBackgroundView.tintColor = thirdColor
|
dashThirdBackgroundView.image = monochromeTemplateImage
|
||||||
|
dashThirdBackgroundView.tintColor = primaryColor
|
||||||
} else {
|
} else {
|
||||||
|
dashThirdBackgroundView.alpha = 1.0
|
||||||
dashThirdBackgroundView.image = templateImage
|
dashThirdBackgroundView.image = templateImage
|
||||||
dashThirdBackgroundView.tintColor = thirdColor
|
dashThirdBackgroundView.tintColor = thirdColor
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
templateImage = dashOpaqueTemplateImage
|
templateImage = dashOpaqueTemplateImage
|
||||||
|
monochromeTemplateImage = dashMonochromeTemplateImage
|
||||||
if let dashThirdBackgroundView = self.dashThirdBackgroundView {
|
if let dashThirdBackgroundView = self.dashThirdBackgroundView {
|
||||||
self.dashThirdBackgroundView = nil
|
self.dashThirdBackgroundView = nil
|
||||||
dashThirdBackgroundView.removeFromSuperview()
|
dashThirdBackgroundView.removeFromSuperview()
|
||||||
@ -367,7 +380,7 @@ private final class LineView: UIView {
|
|||||||
|
|
||||||
if secondaryColor.alpha == 0.0 {
|
if secondaryColor.alpha == 0.0 {
|
||||||
self.backgroundView.alpha = 0.2
|
self.backgroundView.alpha = 0.2
|
||||||
dashBackgroundView.image = dashMonochromeTemplateImage
|
dashBackgroundView.image = monochromeTemplateImage
|
||||||
dashBackgroundView.tintColor = primaryColor
|
dashBackgroundView.tintColor = primaryColor
|
||||||
} else {
|
} else {
|
||||||
self.backgroundView.alpha = 1.0
|
self.backgroundView.alpha = 1.0
|
||||||
|
@ -5109,8 +5109,15 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
let isPremium = peerView.peers[peerView.peerId]?.isPremium ?? false
|
let isPremium = peerView.peers[peerView.peerId]?.isPremium ?? false
|
||||||
var accountPeerColor: ChatPresentationInterfaceState.AccountPeerColor?
|
var accountPeerColor: ChatPresentationInterfaceState.AccountPeerColor?
|
||||||
if let nameColor = peerView.peers[peerView.peerId]?.nameColor, strongSelf.context.peerNameColors.get(nameColor).secondary != nil {
|
if let nameColor = peerView.peers[peerView.peerId]?.nameColor {
|
||||||
accountPeerColor = ChatPresentationInterfaceState.AccountPeerColor(isDashed: true)
|
let colors = strongSelf.context.peerNameColors.get(nameColor)
|
||||||
|
var style: ChatPresentationInterfaceState.AccountPeerColor.Style = .solid
|
||||||
|
if colors.tertiary != nil {
|
||||||
|
style = .tripleDashed
|
||||||
|
} else if colors.secondary != nil {
|
||||||
|
style = .doubleDashed
|
||||||
|
}
|
||||||
|
accountPeerColor = ChatPresentationInterfaceState.AccountPeerColor(style: style)
|
||||||
}
|
}
|
||||||
strongSelf.updateChatPresentationInterfaceState(animated: false, interactive: false, { state in
|
strongSelf.updateChatPresentationInterfaceState(animated: false, interactive: false, { state in
|
||||||
return state.updatedIsPremium(isPremium).updatedAccountPeerColor(accountPeerColor)
|
return state.updatedIsPremium(isPremium).updatedAccountPeerColor(accountPeerColor)
|
||||||
|
@ -1045,11 +1045,22 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
|||||||
var baseFontSize: CGFloat = 17.0
|
var baseFontSize: CGFloat = 17.0
|
||||||
var keyboardAppearance: UIKeyboardAppearance = UIKeyboardAppearance.default
|
var keyboardAppearance: UIKeyboardAppearance = UIKeyboardAppearance.default
|
||||||
if let presentationInterfaceState = self.presentationInterfaceState {
|
if let presentationInterfaceState = self.presentationInterfaceState {
|
||||||
|
var lineStyle: ChatInputTextView.Theme.Quote.LineStyle = .solid
|
||||||
|
if let accountPeerColor = presentationInterfaceState.accountPeerColor {
|
||||||
|
switch accountPeerColor.style {
|
||||||
|
case .solid:
|
||||||
|
lineStyle = .solid
|
||||||
|
case .doubleDashed:
|
||||||
|
lineStyle = .doubleDashed
|
||||||
|
case .tripleDashed:
|
||||||
|
lineStyle = .tripleDashed
|
||||||
|
}
|
||||||
|
}
|
||||||
textInputNode.textView.theme = ChatInputTextView.Theme(
|
textInputNode.textView.theme = ChatInputTextView.Theme(
|
||||||
quote: ChatInputTextView.Theme.Quote(
|
quote: ChatInputTextView.Theme.Quote(
|
||||||
background: presentationInterfaceState.theme.list.itemAccentColor.withMultipliedAlpha(presentationInterfaceState.theme.overallDarkAppearance ? 0.2 : 0.1),
|
background: presentationInterfaceState.theme.list.itemAccentColor.withMultipliedAlpha(presentationInterfaceState.theme.overallDarkAppearance ? 0.2 : 0.1),
|
||||||
foreground: presentationInterfaceState.theme.list.itemAccentColor,
|
foreground: presentationInterfaceState.theme.list.itemAccentColor,
|
||||||
isDashed: presentationInterfaceState.accountPeerColor?.isDashed == true
|
lineStyle: lineStyle
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1628,11 +1639,22 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let textInputNode = self.textInputNode {
|
if let textInputNode = self.textInputNode {
|
||||||
|
var lineStyle: ChatInputTextView.Theme.Quote.LineStyle = .solid
|
||||||
|
if let accountPeerColor = interfaceState.accountPeerColor {
|
||||||
|
switch accountPeerColor.style {
|
||||||
|
case .solid:
|
||||||
|
lineStyle = .solid
|
||||||
|
case .doubleDashed:
|
||||||
|
lineStyle = .doubleDashed
|
||||||
|
case .tripleDashed:
|
||||||
|
lineStyle = .tripleDashed
|
||||||
|
}
|
||||||
|
}
|
||||||
textInputNode.textView.theme = ChatInputTextView.Theme(
|
textInputNode.textView.theme = ChatInputTextView.Theme(
|
||||||
quote: ChatInputTextView.Theme.Quote(
|
quote: ChatInputTextView.Theme.Quote(
|
||||||
background: interfaceState.theme.list.itemAccentColor.withMultipliedAlpha(interfaceState.theme.overallDarkAppearance ? 0.2 : 0.1),
|
background: interfaceState.theme.list.itemAccentColor.withMultipliedAlpha(interfaceState.theme.overallDarkAppearance ? 0.2 : 0.1),
|
||||||
foreground: interfaceState.theme.list.itemAccentColor,
|
foreground: interfaceState.theme.list.itemAccentColor,
|
||||||
isDashed: interfaceState.accountPeerColor?.isDashed == true
|
lineStyle: lineStyle
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user