mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 13:13:55 +00:00
Color improvements
This commit is contained in:
parent
f47a710fb9
commit
ceead276c4
@ -137,6 +137,8 @@ public final class PeerInfoCoverComponent: Component {
|
||||
|
||||
super.init(frame: frame)
|
||||
|
||||
self.clipsToBounds = true
|
||||
|
||||
self.addSubview(self.backgroundView)
|
||||
self.layer.addSublayer(self.backgroundGradientLayer)
|
||||
self.addSubview(self.avatarBackgroundPatternContainer)
|
||||
@ -235,14 +237,29 @@ public final class PeerInfoCoverComponent: Component {
|
||||
self.state = state
|
||||
|
||||
let backgroundColor: UIColor
|
||||
var secondaryBackgroundColor: UIColor
|
||||
let secondaryBackgroundColor: UIColor
|
||||
|
||||
let patternBackgroundColor: UIColor
|
||||
let secondaryPatternBackgroundColor: UIColor
|
||||
let useClearPatternColor: Bool
|
||||
|
||||
if let peer = component.peer, let colors = peer._asPeer().profileColor.flatMap({ component.context.peerNameColors.getProfile($0, dark: component.isDark) }) {
|
||||
|
||||
backgroundColor = colors.main
|
||||
secondaryBackgroundColor = colors.secondary ?? colors.main
|
||||
|
||||
patternBackgroundColor = backgroundColor
|
||||
secondaryPatternBackgroundColor = secondaryBackgroundColor
|
||||
|
||||
useClearPatternColor = false
|
||||
} else {
|
||||
backgroundColor = .clear
|
||||
secondaryBackgroundColor = .clear
|
||||
|
||||
patternBackgroundColor = component.isDark ? UIColor(white: 1.0, alpha: 0.2) : UIColor(white: 0.0, alpha: 0.2)
|
||||
secondaryPatternBackgroundColor = patternBackgroundColor
|
||||
|
||||
useClearPatternColor = true
|
||||
}
|
||||
|
||||
self.backgroundView.backgroundColor = secondaryBackgroundColor
|
||||
@ -276,7 +293,7 @@ public final class PeerInfoCoverComponent: Component {
|
||||
transition.setFrame(view: self.avatarBackgroundPatternView, frame: CGSize(width: 200.0, height: 200.0).centered(around: CGPoint()))
|
||||
|
||||
|
||||
let baseAvatarGradientAlpha: CGFloat = 0.8
|
||||
let baseAvatarGradientAlpha: CGFloat = 0.24
|
||||
let numSteps = 10
|
||||
self.avatarBackgroundGradientLayer.colors = (0 ..< 10).map { i in
|
||||
let step: CGFloat = 1.0 - CGFloat(i) / CGFloat(numSteps - 1)
|
||||
@ -329,9 +346,14 @@ public final class PeerInfoCoverComponent: Component {
|
||||
self.avatarPatternContentLayers.append(itemLayer)
|
||||
}
|
||||
|
||||
let gradientPosition: CGFloat = max(0.0, min(1.0, (avatarBackgroundPatternContainerFrame.midY + itemFrame.midY) / gradientHeight))
|
||||
let itemBackgroundColor: UIColor = secondaryBackgroundColor.mixedWith(backgroundColor, alpha: gradientPosition)
|
||||
let patternColor = UIColor(white: 0.0, alpha: component.isDark ? 0.2 : 0.2).blendOver(background: itemBackgroundColor)
|
||||
let patternColor: UIColor
|
||||
if useClearPatternColor {
|
||||
patternColor = patternBackgroundColor
|
||||
} else {
|
||||
let gradientPosition: CGFloat = max(0.0, min(1.0, (avatarBackgroundPatternContainerFrame.midY + itemFrame.midY) / gradientHeight))
|
||||
let itemBackgroundColor: UIColor = secondaryPatternBackgroundColor.mixedWith(patternBackgroundColor, alpha: gradientPosition)
|
||||
patternColor = UIColor(white: 0.0, alpha: component.isDark ? 0.2 : 0.2).blendOver(background: itemBackgroundColor)
|
||||
}
|
||||
|
||||
itemLayer.frame = itemFrame
|
||||
itemLayer.layerTintColor = patternColor.cgColor
|
||||
|
||||
@ -369,12 +369,12 @@ private func peerNameColorScreenEntries(
|
||||
entries.append(.backgroundEmoji(emojiContent, colors.main, false, false))
|
||||
}
|
||||
} else {
|
||||
if let emojiContent, profileColors != nil {
|
||||
if let emojiContent {
|
||||
var selectedItems = Set<MediaId>()
|
||||
if let selectedProfileEmojiId {
|
||||
selectedItems.insert(MediaId(namespace: Namespaces.Media.CloudFile, id: selectedProfileEmojiId))
|
||||
}
|
||||
let emojiContent = emojiContent.withSelectedItems(selectedItems).withCustomTintColor(profileColors?.main)
|
||||
let emojiContent = emojiContent.withSelectedItems(selectedItems).withCustomTintColor(profileColors?.main ?? presentationData.theme.list.itemSecondaryTextColor)
|
||||
|
||||
//TODO:localize
|
||||
entries.append(.backgroundEmojiHeader("ADD ICON TO PROFILE", (selectedProfileEmojiId != nil && selectedProfileEmojiId != 0) ? presentationData.strings.NameColor_BackgroundEmoji_Remove : nil))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user