Various fixes

This commit is contained in:
Ilya Laktyushin 2025-09-25 23:19:21 +04:00
parent 596e04468e
commit 85f8bde398
7 changed files with 34 additions and 13 deletions

View file

@ -374,7 +374,7 @@ private func themeSettingsControllerEntries(presentationData: PresentationData,
if accountPeer._asPeer().hasCustomNameColor {
authorName = accountPeer.displayTitle(strings: strings, displayOrder: presentationData.nameDisplayOrder)
}
profileColor = accountPeer.profileColor
profileColor = accountPeer.effectiveProfileColor
} else {
nameColor = .preset(.blue)
profileColor = nil

View file

@ -543,6 +543,10 @@ public extension EnginePeer {
return self._asPeer().profileColor
}
var effectiveProfileColor: PeerNameColor? {
return self._asPeer().effectiveProfileColor
}
var emojiStatus: PeerEmojiStatus? {
return self._asPeer().emojiStatus
}

View file

@ -342,6 +342,23 @@ public extension Peer {
}
}
var effectiveProfileColor: PeerNameColor? {
switch self.emojiStatus?.content {
case let .starGift(_, _, _, _, _, _, outerColor, _, _):
return PeerNameColor.other(outerColor)
default:
break
}
switch self {
case let user as TelegramUser:
return user.profileColor
case let channel as TelegramChannel:
return channel.profileColor
default:
return nil
}
}
var hasCustomNameColor: Bool {
let defaultNameColor = PeerNameColor(rawValue: Int32(self.id.id._internalGetInt64Value() % 7))
if self.nameColor != .preset(defaultNameColor) {

View file

@ -581,7 +581,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
hasBackground = true
} else if let peer {
backgroundCoverSubject = .peer(EnginePeer(peer))
if peer.profileColor != nil {
if peer.effectiveProfileColor != nil {
hasBackground = true
}
} else {
@ -660,11 +660,11 @@ final class PeerInfoHeaderNode: ASDisplayNode {
let headerBackgroundColor: UIColor = presentationData.theme.list.blocksBackgroundColor
let regularNavigationContentsAccentColor: UIColor = peer?.profileColor != nil ? .white : presentationData.theme.list.itemAccentColor
let regularNavigationContentsAccentColor: UIColor = peer?.effectiveProfileColor != nil ? .white : presentationData.theme.list.itemAccentColor
let collapsedHeaderNavigationContentsAccentColor = presentationData.theme.list.itemAccentColor
let expandedAvatarNavigationContentsAccentColor: UIColor = .white
let regularNavigationContentsPrimaryColor: UIColor = peer?.profileColor != nil ? .white : presentationData.theme.list.itemPrimaryTextColor
let regularNavigationContentsPrimaryColor: UIColor = peer?.effectiveProfileColor != nil ? .white : presentationData.theme.list.itemPrimaryTextColor
let collapsedHeaderNavigationContentsPrimaryColor = presentationData.theme.list.itemPrimaryTextColor
let expandedAvatarNavigationContentsPrimaryColor: UIColor = .white
@ -676,7 +676,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
let collapsedHeaderButtonBackgroundColor: UIColor = .clear
let expandedAvatarHeaderButtonBackgroundColor: UIColor = UIColor(white: 1.0, alpha: 0.1)
let regularContentButtonForegroundColor: UIColor = peer?.profileColor != nil ? UIColor.white : presentationData.theme.list.itemAccentColor
let regularContentButtonForegroundColor: UIColor = peer?.effectiveProfileColor != nil ? UIColor.white : presentationData.theme.list.itemAccentColor
let collapsedHeaderContentButtonForegroundColor = presentationData.theme.list.itemAccentColor
let expandedAvatarContentButtonForegroundColor: UIColor = .white
@ -697,7 +697,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
regularHeaderButtonBackgroundColor = baseButtonBackgroundColor.blendOver(background: secondaryColor.mixedWith(mainColor, alpha: 0.1))
hasCoverColor = true
} else if let profileColor = peer?.profileColor {
} else if let profileColor = peer?.effectiveProfileColor {
let backgroundColors = self.context.peerNameColors.getProfile(profileColor, dark: presentationData.theme.overallDarkAppearance)
regularNavigationContentsSecondaryColor = UIColor(white: 1.0, alpha: 0.6).blitOver(backgroundColors.main.withMultiplied(hue: 1.0, saturation: 2.2, brightness: 1.5), alpha: 1.0)
@ -899,7 +899,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
let patternColor = UIColor(rgb: UInt32(bitPattern: patternColorValue))
ratingBorderColor = patternColor.withAlphaComponent(0.1).blendOver(background: backgroundColor).mixedWith(.clear, alpha: effectiveTransitionFraction)
ratingForegroundColor = ratingBorderColor.mixedWith(presentationData.theme.list.itemCheckColors.foregroundColor, alpha: effectiveTransitionFraction)
} else if let profileColor = peer?.profileColor {
} else if let profileColor = peer?.effectiveProfileColor {
ratingBackgroundColor = UIColor(white: 1.0, alpha: 1.0).mixedWith(presentationData.theme.list.itemCheckColors.fillColor, alpha: effectiveTransitionFraction)
let backgroundColors = self.context.peerNameColors.getProfile(profileColor, dark: presentationData.theme.overallDarkAppearance)

View file

@ -1225,7 +1225,7 @@ private func settingsEditingItems(data: PeerInfoScreenData?, state: PeerInfoStat
}
colors.append(nameColors)
}
if let profileColor = peer.profileColor.flatMap({ context.peerNameColors.getProfile($0, dark: presentationData.theme.overallDarkAppearance, subject: .palette) }) {
if let profileColor = peer.effectiveProfileColor.flatMap({ context.peerNameColors.getProfile($0, dark: presentationData.theme.overallDarkAppearance, subject: .palette) }) {
colors.append(profileColor)
}
let colorImage = generateSettingsMenuPeerColorsLabelIcon(colors: colors)
@ -12547,7 +12547,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
let edgeEffectHeight: CGFloat = layout.intrinsicInsets.bottom
let edgeEffectFrame = CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - edgeEffectHeight), size: CGSize(width: layout.size.width, height: edgeEffectHeight))
transition.updateFrame(view: self.edgeEffectView, frame: edgeEffectFrame)
self.edgeEffectView.update(content: self.presentationData.theme.list.blocksBackgroundColor, isInverted: false, rect: edgeEffectFrame, edge: .bottom, edgeSize: edgeEffectFrame.height, containerSize: layout.size, transition: ComponentTransition(transition))
self.edgeEffectView.update(content: self.presentationData.theme.list.blocksBackgroundColor, rect: edgeEffectFrame, edge: .bottom, edgeSize: edgeEffectFrame.height, transition: ComponentTransition(transition))
}
let sectionSpacing: CGFloat = 24.0

View file

@ -372,12 +372,12 @@ final class ChannelAppearanceScreenComponent: Component {
let profileColor: PeerNameColor?
if case let .some(value) = self.updatedPeerProfileColor {
profileColor = value
} else if let peerProfileColor = peer.profileColor {
} else if let peerProfileColor = peer.effectiveProfileColor {
profileColor = peerProfileColor
} else {
profileColor = nil
}
if profileColor != peer.profileColor {
if profileColor != peer.effectiveProfileColor {
changes.insert(.profileColor)
}

View file

@ -326,7 +326,7 @@ final class PeerNameColorProfilePreviewItemNode: ListViewItemNode {
let statusColor: UIColor
if let status = item.peer?.emojiStatus, case .starGift = status.content {
statusColor = .white
} else if let peer = item.peer, peer.profileColor != nil {
} else if let peer = item.peer, peer.effectiveProfileColor != nil {
statusColor = .white
} else {
statusColor = item.theme.list.itemCheckColors.fillColor
@ -357,7 +357,7 @@ final class PeerNameColorProfilePreviewItemNode: ListViewItemNode {
backgroundColor = UIColor(rgb: UInt32(bitPattern: outerColor))
subtitleColor = UIColor(white: 1.0, alpha: 0.6).blitOver(backgroundColor.withMultiplied(hue: 1.0, saturation: 2.2, brightness: 1.5), alpha: 1.0)
particleColor = .white
} else if let peer = item.peer, let profileColor = peer.profileColor {
} else if let peer = item.peer, let profileColor = peer.effectiveProfileColor {
titleColor = .white
backgroundColor = item.context.peerNameColors.getProfile(profileColor).main
subtitleColor = UIColor(white: 1.0, alpha: 0.6).blitOver(backgroundColor.withMultiplied(hue: 1.0, saturation: 2.2, brightness: 1.5), alpha: 1.0)