mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +00:00
Custom theme eaccent color improvements
This commit is contained in:
parent
97535aa1ff
commit
852b328878
@ -8,9 +8,10 @@ public final class PageControlNode: ASDisplayNode {
|
|||||||
public var dotColor: UIColor {
|
public var dotColor: UIColor {
|
||||||
didSet {
|
didSet {
|
||||||
if !oldValue.isEqual(self.dotColor) {
|
if !oldValue.isEqual(self.dotColor) {
|
||||||
|
let oldImage = self.normalDotImage
|
||||||
self.normalDotImage = generateFilledCircleImage(diameter: dotSize, color: self.dotColor)!
|
self.normalDotImage = generateFilledCircleImage(diameter: dotSize, color: self.dotColor)!
|
||||||
for dotNode in self.dotNodes {
|
for dotNode in self.dotNodes {
|
||||||
if dotNode === oldValue {
|
if dotNode.image === oldImage {
|
||||||
dotNode.image = self.normalDotImage
|
dotNode.image = self.normalDotImage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,9 +21,10 @@ public final class PageControlNode: ASDisplayNode {
|
|||||||
public var inactiveDotColor: UIColor {
|
public var inactiveDotColor: UIColor {
|
||||||
didSet {
|
didSet {
|
||||||
if !oldValue.isEqual(self.inactiveDotColor) {
|
if !oldValue.isEqual(self.inactiveDotColor) {
|
||||||
|
let oldImage = self.inactiveDotImage
|
||||||
self.inactiveDotImage = generateFilledCircleImage(diameter: dotSize, color: self.inactiveDotColor)!
|
self.inactiveDotImage = generateFilledCircleImage(diameter: dotSize, color: self.inactiveDotColor)!
|
||||||
for dotNode in self.dotNodes {
|
for dotNode in self.dotNodes {
|
||||||
if dotNode === oldValue {
|
if dotNode.image === oldImage {
|
||||||
dotNode.image = self.inactiveDotImage
|
dotNode.image = self.inactiveDotImage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,6 +109,19 @@ public extension UIColor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var lightness: CGFloat {
|
||||||
|
var red: CGFloat = 0.0
|
||||||
|
var green: CGFloat = 0.0
|
||||||
|
var blue: CGFloat = 0.0
|
||||||
|
if self.getRed(&red, green: &green, blue: &blue, alpha: nil) {
|
||||||
|
return 0.2126 * red + 0.7152 * green + 0.0722 * blue
|
||||||
|
} else if self.getWhite(&red, alpha: nil) {
|
||||||
|
return red
|
||||||
|
} else {
|
||||||
|
return 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func withMultipliedBrightnessBy(_ factor: CGFloat) -> UIColor {
|
func withMultipliedBrightnessBy(_ factor: CGFloat) -> UIColor {
|
||||||
var hue: CGFloat = 0.0
|
var hue: CGFloat = 0.0
|
||||||
var saturation: CGFloat = 0.0
|
var saturation: CGFloat = 0.0
|
||||||
|
|||||||
@ -13,18 +13,44 @@ private func makeDarkPresentationTheme(accentColor: UIColor, baseColor: Presenta
|
|||||||
let outgoingBubbleHighlightedFillColor: UIColor
|
let outgoingBubbleHighlightedFillColor: UIColor
|
||||||
let outgoingScamColor: UIColor
|
let outgoingScamColor: UIColor
|
||||||
|
|
||||||
|
let outgoingPrimaryTextColor: UIColor
|
||||||
|
let outgoingSecondaryTextColor: UIColor
|
||||||
|
let outgoingLinkTextColor: UIColor
|
||||||
|
let outgoingCheckColor: UIColor
|
||||||
|
|
||||||
if accentColor.rgb == UIColor.white.rgb {
|
if accentColor.rgb == UIColor.white.rgb {
|
||||||
badgeFillColor = .white
|
badgeFillColor = .white
|
||||||
badgeTextColor = .black
|
badgeTextColor = .black
|
||||||
outgoingBubbleFillColor = UIColor(rgb: 0x313131)
|
outgoingBubbleFillColor = UIColor(rgb: 0x313131)
|
||||||
outgoingBubbleHighlightedFillColor = UIColor(rgb: 0x464646)
|
outgoingBubbleHighlightedFillColor = UIColor(rgb: 0x464646)
|
||||||
outgoingScamColor = destructiveColor
|
outgoingScamColor = destructiveColor
|
||||||
|
|
||||||
|
outgoingPrimaryTextColor = .white
|
||||||
|
outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.5)
|
||||||
|
outgoingLinkTextColor = .white
|
||||||
|
outgoingCheckColor = UIColor(rgb: 0xffffff, alpha: 0.5)
|
||||||
} else {
|
} else {
|
||||||
badgeFillColor = destructiveColor
|
badgeFillColor = destructiveColor
|
||||||
badgeTextColor = .white
|
badgeTextColor = .white
|
||||||
outgoingBubbleFillColor = accentColor
|
outgoingBubbleFillColor = accentColor
|
||||||
outgoingBubbleHighlightedFillColor = accentColor.withMultipliedBrightnessBy(1.421)
|
outgoingBubbleHighlightedFillColor = accentColor.withMultipliedBrightnessBy(1.421)
|
||||||
|
|
||||||
|
|
||||||
|
if accentColor.lightness > 0.72 {
|
||||||
|
outgoingScamColor = .black
|
||||||
|
|
||||||
|
outgoingPrimaryTextColor = .black
|
||||||
|
outgoingSecondaryTextColor = UIColor(rgb: 0x000000, alpha: 0.5)
|
||||||
|
outgoingLinkTextColor = .black
|
||||||
|
outgoingCheckColor = UIColor(rgb: 0x000000, alpha: 0.5)
|
||||||
|
} else {
|
||||||
outgoingScamColor = .white
|
outgoingScamColor = .white
|
||||||
|
|
||||||
|
outgoingPrimaryTextColor = .white
|
||||||
|
outgoingSecondaryTextColor = UIColor(rgb: 0xffffff, alpha: 0.5)
|
||||||
|
outgoingLinkTextColor = .white
|
||||||
|
outgoingCheckColor = UIColor(rgb: 0xffffff, alpha: 0.5)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let rootTabBar = PresentationThemeRootTabBar(
|
let rootTabBar = PresentationThemeRootTabBar(
|
||||||
@ -176,11 +202,11 @@ private func makeDarkPresentationTheme(accentColor: UIColor, baseColor: Presenta
|
|||||||
|
|
||||||
let message = PresentationThemeChatMessage(
|
let message = PresentationThemeChatMessage(
|
||||||
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628))), primaryTextColor: .white, secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: destructiveColor, textHighlightColor: UIColor(rgb: 0xffe438), accentTextColor: accentColor, accentControlColor: accentColor, mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.4), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: accentColor, fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(.white, alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: UIColor(rgb: 0x000000), bar: accentColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff))),
|
incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x262628), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628))), primaryTextColor: .white, secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: destructiveColor, textHighlightColor: UIColor(rgb: 0xffe438), accentTextColor: accentColor, accentControlColor: accentColor, mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.4), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: accentColor, fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(.white, alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: UIColor(rgb: 0x000000), bar: accentColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff))),
|
||||||
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, highlightedFill: outgoingBubbleHighlightedFillColor, stroke: outgoingBubbleFillColor), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, highlightedFill: outgoingBubbleHighlightedFillColor, stroke: outgoingBubbleFillColor)), primaryTextColor: .white, secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: .white, linkHighlightColor: UIColor.white.withAlphaComponent(0.5), scamColor: outgoingScamColor, textHighlightColor: UIColor(rgb: 0xffe438), accentTextColor: .white, accentControlColor: .white, mediaActiveControlColor: .white, mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.3), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: .white, fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(.white, alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: .white, radioProgress: .white, highlight: UIColor(white: 1.0, alpha: 0.12), separator: UIColor(white: 1.0, alpha: 0.3), bar: .white), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff))),
|
outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, highlightedFill: outgoingBubbleHighlightedFillColor, stroke: outgoingBubbleFillColor), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, highlightedFill: outgoingBubbleHighlightedFillColor, stroke: outgoingBubbleFillColor)), primaryTextColor: outgoingPrimaryTextColor, secondaryTextColor: outgoingSecondaryTextColor, linkTextColor: outgoingLinkTextColor, linkHighlightColor: UIColor.white.withAlphaComponent(0.5), scamColor: outgoingScamColor, textHighlightColor: UIColor(rgb: 0xffe438), accentTextColor: .white, accentControlColor: .white, mediaActiveControlColor: .white, mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.3), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: .white, fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(.white, alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: .white, radioProgress: .white, highlight: UIColor(white: 1.0, alpha: 0.12), separator: UIColor(white: 1.0, alpha: 0.3), bar: .white), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff))),
|
||||||
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f))),
|
freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f)), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f))),
|
||||||
infoPrimaryTextColor: .white,
|
infoPrimaryTextColor: .white,
|
||||||
infoLinkTextColor: accentColor,
|
infoLinkTextColor: accentColor,
|
||||||
outgoingCheckColor: .white,
|
outgoingCheckColor: outgoingCheckColor,
|
||||||
mediaDateAndStatusFillColor: UIColor(white: 0.0, alpha: 0.5),
|
mediaDateAndStatusFillColor: UIColor(white: 0.0, alpha: 0.5),
|
||||||
mediaDateAndStatusTextColor: .white,
|
mediaDateAndStatusTextColor: .white,
|
||||||
shareButtonFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)),
|
shareButtonFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)),
|
||||||
|
|||||||
@ -8,13 +8,11 @@ private func makeDefaultDayPresentationTheme(accentColor: UIColor, serviceBackgr
|
|||||||
let constructiveColor: UIColor = UIColor(rgb: 0x00c900)
|
let constructiveColor: UIColor = UIColor(rgb: 0x00c900)
|
||||||
let secretColor: UIColor = UIColor(rgb: 0x00b12c)
|
let secretColor: UIColor = UIColor(rgb: 0x00b12c)
|
||||||
|
|
||||||
let accentColorHSV = accentColor.hsv
|
|
||||||
|
|
||||||
let outgoingPrimaryTextColor: UIColor
|
let outgoingPrimaryTextColor: UIColor
|
||||||
let outgoingSecondaryTextColor: UIColor
|
let outgoingSecondaryTextColor: UIColor
|
||||||
let outgoingLinkTextColor: UIColor
|
let outgoingLinkTextColor: UIColor
|
||||||
let outgoingCheckColor: UIColor
|
let outgoingCheckColor: UIColor
|
||||||
if accentColorHSV.2 > 0.83 {
|
if accentColor.lightness > 0.72 {
|
||||||
outgoingPrimaryTextColor = .black
|
outgoingPrimaryTextColor = .black
|
||||||
outgoingSecondaryTextColor = UIColor(rgb: 0x000000, alpha: 0.6)
|
outgoingSecondaryTextColor = UIColor(rgb: 0x000000, alpha: 0.6)
|
||||||
outgoingLinkTextColor = .black
|
outgoingLinkTextColor = .black
|
||||||
|
|||||||
@ -5831,7 +5831,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if case let .peer(peerId) = self.chatLocation, let messageId = messageLocation.messageId, (messageId.peerId != peerId && !forceInCurrentChat) || self.presentationInterfaceState.isScheduledMessages {
|
if case let .peer(peerId) = self.chatLocation, let messageId = messageLocation.messageId, (messageId.peerId != peerId && !forceInCurrentChat) || (self.presentationInterfaceState.isScheduledMessages && messageId.id != 0) {
|
||||||
if let navigationController = self.navigationController as? NavigationController {
|
if let navigationController = self.navigationController as? NavigationController {
|
||||||
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(messageId.peerId), messageId: messageId, keepStack: .always))
|
self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: self.context, chatLocation: .peer(messageId.peerId), messageId: messageId, keepStack: .always))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,6 +117,7 @@ private final class ActionSheetItemNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc private func buttonPressed() {
|
@objc private func buttonPressed() {
|
||||||
|
self.buttonNode.isUserInteractionEnabled = false
|
||||||
self.action()
|
self.action()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -613,6 +614,7 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc private func sendButtonPressed() {
|
@objc private func sendButtonPressed() {
|
||||||
|
self.sendButtonNode.isUserInteractionEnabled = false
|
||||||
self.send?()
|
self.send?()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user