Stars reaction test [skip ci]

This commit is contained in:
Isaac 2024-06-27 14:39:09 +02:00
parent d65df43cb5
commit ad1ddf65c0
12 changed files with 326 additions and 72 deletions

View File

@ -20,6 +20,25 @@ private let tagImage: UIImage? = {
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/ReactionTagBackground"), color: .white)?.stretchableImage(withLeftCapWidth: 8, topCapHeight: 15)
}()
private final class StarsButtonEffectLayer: SimpleLayer {
override init() {
super.init()
self.backgroundColor = UIColor.blue.withAlphaComponent(0.2).cgColor
}
override init(layer: Any) {
super.init(layer: layer)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func update(size: CGSize) {
}
}
public final class ReactionIconView: PortalSourceView {
private var animationLayer: InlineStickerItemLayer?
@ -705,14 +724,27 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView {
}
}
let backgroundColors = ReactionButtonAsyncNode.ContainerButtonNode.Colors(
background: spec.component.chosenOrder != nil ? spec.component.colors.selectedBackground : spec.component.colors.deselectedBackground,
foreground: spec.component.chosenOrder != nil ? spec.component.colors.selectedForeground : spec.component.colors.deselectedForeground,
extractedBackground: spec.component.colors.extractedBackground,
extractedForeground: spec.component.colors.extractedForeground,
extractedSelectedForeground: spec.component.colors.extractedSelectedForeground,
isSelected: spec.component.chosenOrder != nil
)
let backgroundColors: ReactionButtonAsyncNode.ContainerButtonNode.Colors
if case .custom(MessageReaction.starsReactionId) = spec.component.reaction.value {
backgroundColors = ReactionButtonAsyncNode.ContainerButtonNode.Colors(
background: spec.component.chosenOrder != nil ? spec.component.colors.selectedStarsBackground : spec.component.colors.deselectedStarsBackground,
foreground: spec.component.chosenOrder != nil ? spec.component.colors.selectedStarsForeground : spec.component.colors.deselectedStarsForeground,
extractedBackground: spec.component.chosenOrder != nil ? spec.component.colors.selectedStarsBackground : spec.component.colors.deselectedStarsBackground,
extractedForeground: spec.component.chosenOrder != nil ? spec.component.colors.selectedStarsForeground : spec.component.colors.deselectedStarsForeground,
extractedSelectedForeground: spec.component.colors.extractedSelectedForeground,
isSelected: spec.component.chosenOrder != nil
)
} else {
backgroundColors = ReactionButtonAsyncNode.ContainerButtonNode.Colors(
background: spec.component.chosenOrder != nil ? spec.component.colors.selectedBackground : spec.component.colors.deselectedBackground,
foreground: spec.component.chosenOrder != nil ? spec.component.colors.selectedForeground : spec.component.colors.deselectedForeground,
extractedBackground: spec.component.colors.extractedBackground,
extractedForeground: spec.component.colors.extractedForeground,
extractedSelectedForeground: spec.component.colors.extractedSelectedForeground,
isSelected: spec.component.chosenOrder != nil
)
}
var backgroundCounter: ReactionButtonAsyncNode.ContainerButtonNode.Counter?
if let counterLayout = counterLayout {
backgroundCounter = ReactionButtonAsyncNode.ContainerButtonNode.Counter(
@ -743,6 +775,7 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView {
public let containerView: ContextExtractedContentContainingView
private let buttonNode: ContainerButtonNode
private var starsEffectLayer: StarsButtonEffectLayer?
public var iconView: ReactionIconView?
private var avatarsView: AnimatedAvatarSetView?
@ -838,6 +871,29 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView {
self.containerView.contentRect = CGRect(origin: CGPoint(), size: layout.size)
animation.animator.updateFrame(layer: self.buttonNode.layer, frame: CGRect(origin: CGPoint(), size: layout.size), completion: nil)
if case .custom(MessageReaction.starsReactionId) = layout.spec.component.reaction.value {
let starsEffectLayer: StarsButtonEffectLayer
if let current = self.starsEffectLayer {
starsEffectLayer = current
} else {
starsEffectLayer = StarsButtonEffectLayer()
self.starsEffectLayer = starsEffectLayer
if let iconView = self.iconView {
self.buttonNode.layer.insertSublayer(starsEffectLayer, below: iconView.layer)
} else {
self.buttonNode.layer.insertSublayer(starsEffectLayer, at: 0)
}
}
let starsEffectLayerFrame = CGRect(origin: CGPoint(), size: layout.size)
animation.animator.updateFrame(layer: starsEffectLayer, frame: starsEffectLayerFrame, completion: nil)
starsEffectLayer.update(size: starsEffectLayerFrame.size)
} else {
if let starsEffectLayer = self.starsEffectLayer {
self.starsEffectLayer = nil
starsEffectLayer.removeFromSuperlayer()
}
}
self.buttonNode.update(layout: layout.backgroundLayout)
if let iconView = self.iconView {
@ -878,65 +934,6 @@ public final class ReactionButtonAsyncNode: ContextControllerSourceView {
transition: animation.transition
)
}
/*if self.layout?.spec.component.reaction != layout.spec.component.reaction {
if let file = layout.spec.component.reaction.centerAnimation {
if let image = ReactionImageCache.shared.get(reaction: layout.spec.component.reaction.value) {
iconView.imageView.image = image
} else {
self.iconImageDisposable.set((reactionStaticImage(context: layout.spec.component.context, animation: file, pixelSize: CGSize(width: 32.0 * UIScreenScale, height: 32.0 * UIScreenScale), queue: sharedReactionStaticImage)
|> filter { data in
return data.isComplete
}
|> take(1)
|> map { data -> UIImage? in
if data.isComplete, let dataValue = try? Data(contentsOf: URL(fileURLWithPath: data.path)) {
if let image = UIImage(data: dataValue) {
return image.precomposed()
} else {
print("Could not decode image")
}
} else {
print("Incomplete data")
}
return nil
}
|> deliverOnMainQueue).start(next: { [weak self] image in
guard let strongSelf = self else {
return
}
if let image = image {
strongSelf.iconView?.imageView.image = image
ReactionImageCache.shared.put(reaction: layout.spec.component.reaction.value, image: image)
}
}))
}
} else if let legacyIcon = layout.spec.component.reaction.legacyIcon {
self.iconImageDisposable.set((layout.spec.component.context.account.postbox.mediaBox.resourceData(legacyIcon.resource)
|> deliverOn(Queue.concurrentDefaultQueue())
|> map { data -> UIImage? in
if data.complete, let dataValue = try? Data(contentsOf: URL(fileURLWithPath: data.path)) {
if let image = WebP.convert(fromWebP: dataValue) {
if #available(iOS 15.0, iOSApplicationExtension 15.0, *) {
return image.preparingForDisplay()
} else {
return image.precomposed()
}
}
}
return nil
}
|> deliverOnMainQueue).start(next: { [weak self] image in
guard let strongSelf = self else {
return
}
strongSelf.iconView?.imageView.image = image
}))
}
}*/
}
if !layout.spec.component.avatarPeers.isEmpty {
@ -1041,6 +1038,10 @@ public final class ReactionButtonComponent: Equatable {
public var selectedBackground: UInt32
public var deselectedForeground: UInt32
public var selectedForeground: UInt32
public var deselectedStarsBackground: UInt32
public var selectedStarsBackground: UInt32
public var deselectedStarsForeground: UInt32
public var selectedStarsForeground: UInt32
public var extractedBackground: UInt32
public var extractedForeground: UInt32
public var extractedSelectedForeground: UInt32
@ -1052,6 +1053,10 @@ public final class ReactionButtonComponent: Equatable {
selectedBackground: UInt32,
deselectedForeground: UInt32,
selectedForeground: UInt32,
deselectedStarsBackground: UInt32,
selectedStarsBackground: UInt32,
deselectedStarsForeground: UInt32,
selectedStarsForeground: UInt32,
extractedBackground: UInt32,
extractedForeground: UInt32,
extractedSelectedForeground: UInt32,
@ -1062,6 +1067,10 @@ public final class ReactionButtonComponent: Equatable {
self.selectedBackground = selectedBackground
self.deselectedForeground = deselectedForeground
self.selectedForeground = selectedForeground
self.deselectedStarsBackground = deselectedStarsBackground
self.selectedStarsBackground = selectedStarsBackground
self.deselectedStarsForeground = deselectedStarsForeground
self.selectedStarsForeground = selectedStarsForeground
self.extractedBackground = extractedBackground
self.extractedForeground = extractedForeground
self.extractedSelectedForeground = extractedSelectedForeground
@ -1243,8 +1252,7 @@ public final class ReactionButtonsAsyncLayoutContainer {
var items: [Result.Item] = []
var applyItems: [(key: MessageReaction.Reaction, size: CGSize, apply: (_ animation: ListViewItemUpdateAnimation, _ arguments: Arguments) -> ReactionNodePool.Item)] = []
var validIds = Set<MessageReaction.Reaction>()
for reaction in reactions.sorted(by: { lhs, rhs in
var reactions = reactions.sorted(by: { lhs, rhs in
var lhsCount = lhs.count
if lhs.chosenOrder != nil {
lhsCount -= 1
@ -1268,7 +1276,22 @@ public final class ReactionButtonsAsyncLayoutContainer {
}
return false
})
if let index = reactions.firstIndex(where: {
if case .custom(MessageReaction.starsReactionId) = $0.reaction.value {
return true
} else {
return false
}
}) {
let value = reactions[index]
reactions.remove(at: index)
reactions.insert(value, at: 0)
}
var validIds = Set<MessageReaction.Reaction>()
for reaction in reactions {
validIds.insert(reaction.reaction.value)
var avatarPeers = reaction.peers

View File

@ -56,6 +56,25 @@ protocol ReactionItemNode: ASDisplayNode {
private let lockedBackgroundImage: UIImage = generateFilledCircleImage(diameter: 16.0, color: .white)!.withRenderingMode(.alwaysTemplate)
private let lockedBadgeIcon: UIImage? = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Media/PanelBadgeLock"), color: .white)
private final class StarsReactionEffectLayer: SimpleLayer {
override init() {
super.init()
self.backgroundColor = UIColor.blue.withAlphaComponent(0.2).cgColor
}
override init(layer: Any) {
super.init(layer: layer)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func update(size: CGSize) {
}
}
public final class ReactionNode: ASDisplayNode, ReactionItemNode {
let context: AccountContext
let theme: PresentationTheme
@ -69,6 +88,8 @@ public final class ReactionNode: ASDisplayNode, ReactionItemNode {
let selectionTintView: UIView?
let selectionView: UIView?
private var starsEffectLayer: StarsReactionEffectLayer?
private var animateInAnimationNode: AnimatedStickerNode?
private var staticAnimationPlaceholderView: UIImageView?
private let staticAnimationNode: AnimatedStickerNode
@ -129,6 +150,12 @@ public final class ReactionNode: ASDisplayNode, ReactionItemNode {
super.init()
if case .custom(MessageReaction.starsReactionId) = item.reaction.rawValue {
let starsEffectLayer = StarsReactionEffectLayer()
self.starsEffectLayer = starsEffectLayer
self.layer.addSublayer(starsEffectLayer)
}
if item.stillAnimation.isCustomTemplateEmoji {
if let animationNode = self.staticAnimationNode as? DefaultAnimatedStickerNodeImpl {
animationNode.dynamicColor = theme.chat.inputPanel.panelControlAccentColor
@ -232,6 +259,11 @@ public final class ReactionNode: ASDisplayNode, ReactionItemNode {
public func updateLayout(size: CGSize, isExpanded: Bool, largeExpanded: Bool, isPreviewing: Bool, transition: ContainedViewLayoutTransition) {
let intrinsicSize = size
if let starsEffectLayer = self.starsEffectLayer {
transition.updateFrame(layer: starsEffectLayer, frame: CGRect(origin: CGPoint(), size: size))
starsEffectLayer.update(size: size)
}
let animationSize = self.item.stillAnimation.dimensions?.cgSize ?? CGSize(width: 512.0, height: 512.0)
var animationDisplaySize = animationSize.aspectFitted(intrinsicSize)

View File

@ -94,7 +94,26 @@ public func mergedMessageReactionsAndPeers(accountPeerId: EnginePeer.Id, account
}
}
return (attribute.reactions, recentPeers)
#if DEBUG
var reactions = attribute.reactions
if "".isEmpty {
if let index = reactions.firstIndex(where: {
if case .custom(MessageReaction.starsReactionId) = $0.value {
return true
} else {
return false
}
}) {
let value = reactions[index]
reactions.remove(at: index)
reactions.insert(value, at: 0)
} else {
reactions.insert(MessageReaction(value: .custom(MessageReaction.starsReactionId), count: 1000000, chosenOrder: nil), at: 0)
}
}
#endif
return (reactions, recentPeers)
}
private func mergeReactions(reactions: [MessageReaction], recentPeers: [ReactionsMessageAttribute.RecentPeer], pending: [PendingReactionsMessageAttribute.PendingReaction], accountPeerId: PeerId) -> ([MessageReaction], [ReactionsMessageAttribute.RecentPeer]) {

View File

@ -3,6 +3,8 @@ import Postbox
import TelegramApi
public struct MessageReaction: Equatable, PostboxCoding, Codable {
public static let starsReactionId: Int64 = 5435957248314579621
public enum Reaction: Hashable, Comparable, Codable, PostboxCoding {
case builtin(String)
case custom(Int64)

View File

@ -531,6 +531,10 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
),
@ -543,6 +547,10 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
)
@ -561,6 +569,10 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
),
@ -573,6 +585,10 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
)
@ -588,6 +604,10 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
),
@ -600,6 +620,10 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
)

View File

@ -744,6 +744,10 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
reactionInactiveForeground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionActiveBackground: accentColor,
reactionActiveForeground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
),
@ -756,6 +760,10 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
reactionInactiveForeground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionActiveBackground: accentColor,
reactionActiveForeground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
)
@ -772,6 +780,10 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
),
@ -784,6 +796,10 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff, alpha: 1.0),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
)
@ -799,6 +815,10 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: accentColor,
reactionActiveForeground: UIColor(rgb: 0xffffff),
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
),
@ -811,6 +831,10 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: accentColor,
reactionActiveForeground: UIColor(rgb: 0xffffff),
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1),
reactionActiveMediaPlaceholder: UIColor(rgb: 0x000000, alpha: 0.1)
)

View File

@ -16,7 +16,11 @@ public func selectDateFillStaticColor(theme: PresentationTheme, wallpaper: Teleg
}
}
public func selectReactionFillStaticColor(theme: PresentationTheme, wallpaper: TelegramWallpaper) -> UIColor {
public func selectReactionFillStaticColor(theme: PresentationTheme, wallpaper: TelegramWallpaper, isStars: Bool = false) -> UIColor {
if isStars {
return theme.chat.message.freeform.withoutWallpaper.reactionStarsInactiveBackground
}
if case .color = wallpaper {
return theme.chat.message.freeform.withoutWallpaper.reactionInactiveBackground
} else if theme.overallDarkAppearance {
@ -594,6 +598,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: defaultDayAccentColor,
reactionActiveBackground: defaultDayAccentColor,
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
),
@ -606,6 +614,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: defaultDayAccentColor,
reactionActiveBackground: defaultDayAccentColor,
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
)
@ -641,6 +653,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: UIColor(rgb: 0x3fc33b),
reactionActiveBackground: UIColor(rgb: 0x3fc33b),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
),
@ -653,6 +669,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: UIColor(rgb: 0x3fc33b),
reactionActiveBackground: UIColor(rgb: 0x3fc33b),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
)
@ -690,6 +710,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff, alpha: 0.8),
reactionActiveForeground: UIColor(white: 0.0, alpha: 0.1),
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
),
@ -702,6 +726,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff, alpha: 0.8),
reactionActiveForeground: UIColor(white: 0.0, alpha: 0.1),
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
)
@ -734,6 +762,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: defaultDayAccentColor,
reactionActiveBackground: defaultDayAccentColor,
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
),
@ -746,6 +778,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: defaultDayAccentColor,
reactionActiveBackground: defaultDayAccentColor,
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
)
@ -784,6 +820,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
),
@ -796,6 +836,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: UIColor(rgb: 0xffffff),
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
)
@ -833,6 +877,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: defaultDayAccentColor,
reactionActiveBackground: defaultDayAccentColor,
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
),
@ -845,6 +893,10 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
reactionInactiveForeground: defaultDayAccentColor,
reactionActiveBackground: defaultDayAccentColor,
reactionActiveForeground: .clear,
reactionStarsInactiveBackground: UIColor(rgb: 0xFEF1D4, alpha: 1.0),
reactionStarsInactiveForeground: UIColor(rgb: 0xD3720A),
reactionStarsActiveBackground: UIColor(rgb: 0xD3720A, alpha: 1.0),
reactionStarsActiveForeground: .clear,
reactionInactiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2),
reactionActiveMediaPlaceholder: UIColor(rgb: 0xffffff, alpha: 0.2)
)

View File

@ -783,6 +783,10 @@ public final class PresentationThemeBubbleColorComponents {
public let reactionInactiveForeground: UIColor
public let reactionActiveBackground: UIColor
public let reactionActiveForeground: UIColor
public let reactionStarsInactiveBackground: UIColor
public let reactionStarsInactiveForeground: UIColor
public let reactionStarsActiveBackground: UIColor
public let reactionStarsActiveForeground: UIColor
public let reactionInactiveMediaPlaceholder: UIColor
public let reactionActiveMediaPlaceholder: UIColor
@ -795,6 +799,10 @@ public final class PresentationThemeBubbleColorComponents {
reactionInactiveForeground: UIColor,
reactionActiveBackground: UIColor,
reactionActiveForeground: UIColor,
reactionStarsInactiveBackground: UIColor,
reactionStarsInactiveForeground: UIColor,
reactionStarsActiveBackground: UIColor,
reactionStarsActiveForeground: UIColor,
reactionInactiveMediaPlaceholder: UIColor,
reactionActiveMediaPlaceholder: UIColor
) {
@ -806,6 +814,10 @@ public final class PresentationThemeBubbleColorComponents {
self.reactionInactiveForeground = reactionInactiveForeground
self.reactionActiveBackground = reactionActiveBackground
self.reactionActiveForeground = reactionActiveForeground
self.reactionStarsInactiveBackground = reactionStarsInactiveBackground
self.reactionStarsInactiveForeground = reactionStarsInactiveForeground
self.reactionStarsActiveBackground = reactionStarsActiveBackground
self.reactionStarsActiveForeground = reactionStarsActiveForeground
self.reactionInactiveMediaPlaceholder = reactionInactiveMediaPlaceholder
self.reactionActiveMediaPlaceholder = reactionActiveMediaPlaceholder
}
@ -818,6 +830,10 @@ public final class PresentationThemeBubbleColorComponents {
reactionInactiveForeground: UIColor? = nil,
reactionActiveBackground: UIColor? = nil,
reactionActiveForeground: UIColor? = nil,
reactionStarsInactiveBackground: UIColor? = nil,
reactionStarsInactiveForeground: UIColor? = nil,
reactionStarsActiveBackground: UIColor? = nil,
reactionStarsActiveForeground: UIColor? = nil,
reactionInactiveMediaPlaceholder: UIColor? = nil,
reactionActiveMediaPlaceholder: UIColor? = nil
) -> PresentationThemeBubbleColorComponents {
@ -830,6 +846,10 @@ public final class PresentationThemeBubbleColorComponents {
reactionInactiveForeground: reactionInactiveForeground ?? self.reactionInactiveForeground,
reactionActiveBackground: reactionActiveBackground ?? self.reactionActiveBackground,
reactionActiveForeground: reactionActiveForeground ?? self.reactionActiveForeground,
reactionStarsInactiveBackground: reactionStarsInactiveBackground ?? self.reactionStarsInactiveBackground,
reactionStarsInactiveForeground: reactionStarsInactiveForeground ?? self.reactionStarsInactiveForeground,
reactionStarsActiveBackground: reactionStarsActiveBackground ?? self.reactionStarsActiveBackground,
reactionStarsActiveForeground: reactionStarsActiveForeground ?? self.reactionStarsActiveForeground,
reactionInactiveMediaPlaceholder: reactionInactiveMediaPlaceholder ?? self.reactionInactiveMediaPlaceholder,
reactionActiveMediaPlaceholder: reactionActiveMediaPlaceholder ?? self.reactionActiveMediaPlaceholder
)

View File

@ -1206,6 +1206,10 @@ extension PresentationThemeBubbleColorComponents: Codable {
reactionInactiveForeground: reactionInactiveForeground,
reactionActiveBackground: reactionActiveBackground,
reactionActiveForeground: reactionActiveForeground,
reactionStarsInactiveBackground: reactionInactiveBackground,
reactionStarsInactiveForeground: reactionInactiveForeground,
reactionStarsActiveBackground: reactionActiveBackground,
reactionStarsActiveForeground: reactionActiveForeground,
reactionInactiveMediaPlaceholder: reactionInactiveMediaPlaceholder,
reactionActiveMediaPlaceholder: reactionActiveMediaPlaceholder
)

View File

@ -356,6 +356,10 @@ public class ChatMessageDateAndStatusNode: ASDisplayNode {
selectedBackground: themeColors.reactionActiveBackground.argb,
deselectedForeground: themeColors.reactionInactiveForeground.argb,
selectedForeground: themeColors.reactionActiveForeground.argb,
deselectedStarsBackground: themeColors.reactionStarsInactiveBackground.argb,
selectedStarsBackground: themeColors.reactionStarsActiveBackground.argb,
deselectedStarsForeground: themeColors.reactionStarsInactiveForeground.argb,
selectedStarsForeground: themeColors.reactionStarsActiveForeground.argb,
extractedBackground: arguments.presentationData.theme.theme.contextMenu.backgroundColor.argb,
extractedForeground: arguments.presentationData.theme.theme.contextMenu.primaryColor.argb,
extractedSelectedForeground: arguments.presentationData.theme.theme.overallDarkAppearance ? themeColors.reactionActiveForeground.argb : arguments.presentationData.theme.theme.list.itemCheckColors.foregroundColor.argb,
@ -370,6 +374,10 @@ public class ChatMessageDateAndStatusNode: ASDisplayNode {
selectedBackground: themeColors.reactionActiveBackground.argb,
deselectedForeground: themeColors.reactionInactiveForeground.argb,
selectedForeground: themeColors.reactionActiveForeground.argb,
deselectedStarsBackground: themeColors.reactionStarsInactiveBackground.argb,
selectedStarsBackground: themeColors.reactionStarsActiveBackground.argb,
deselectedStarsForeground: themeColors.reactionStarsInactiveForeground.argb,
selectedStarsForeground: themeColors.reactionStarsActiveForeground.argb,
extractedBackground: arguments.presentationData.theme.theme.contextMenu.backgroundColor.argb,
extractedForeground: arguments.presentationData.theme.theme.contextMenu.primaryColor.argb,
extractedSelectedForeground: arguments.presentationData.theme.theme.overallDarkAppearance ? themeColors.reactionActiveForeground.argb : arguments.presentationData.theme.theme.list.itemCheckColors.foregroundColor.argb,

View File

@ -77,6 +77,10 @@ public final class MessageReactionButtonsNode: ASDisplayNode {
selectedBackground: themeColors.reactionActiveBackground.argb,
deselectedForeground: themeColors.reactionInactiveForeground.argb,
selectedForeground: themeColors.reactionActiveForeground.argb,
deselectedStarsBackground: themeColors.reactionStarsInactiveBackground.argb,
selectedStarsBackground: themeColors.reactionStarsActiveBackground.argb,
deselectedStarsForeground: themeColors.reactionStarsInactiveForeground.argb,
selectedStarsForeground: themeColors.reactionStarsActiveForeground.argb,
extractedBackground: presentationData.theme.theme.contextMenu.backgroundColor.argb,
extractedForeground: presentationData.theme.theme.contextMenu.primaryColor.argb,
extractedSelectedForeground: presentationData.theme.theme.overallDarkAppearance ? themeColors.reactionActiveForeground.argb : presentationData.theme.theme.list.itemCheckColors.foregroundColor.argb,
@ -90,6 +94,10 @@ public final class MessageReactionButtonsNode: ASDisplayNode {
selectedBackground: themeColors.reactionActiveBackground.argb,
deselectedForeground: themeColors.reactionInactiveForeground.argb,
selectedForeground: themeColors.reactionActiveForeground.argb,
deselectedStarsBackground: themeColors.reactionStarsInactiveBackground.argb,
selectedStarsBackground: themeColors.reactionStarsActiveBackground.argb,
deselectedStarsForeground: themeColors.reactionStarsInactiveForeground.argb,
selectedStarsForeground: themeColors.reactionStarsActiveForeground.argb,
extractedBackground: presentationData.theme.theme.contextMenu.backgroundColor.argb,
extractedForeground: presentationData.theme.theme.contextMenu.primaryColor.argb,
extractedSelectedForeground: presentationData.theme.theme.overallDarkAppearance ? themeColors.reactionActiveForeground.argb : presentationData.theme.theme.list.itemCheckColors.foregroundColor.argb,
@ -108,6 +116,10 @@ public final class MessageReactionButtonsNode: ASDisplayNode {
selectedBackground: themeColors.reactionActiveBackground.argb,
deselectedForeground: themeColors.reactionInactiveForeground.argb,
selectedForeground: themeColors.reactionActiveForeground.argb,
deselectedStarsBackground: selectReactionFillStaticColor(theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper, isStars: true).argb,
selectedStarsBackground: themeColors.reactionStarsActiveBackground.argb,
deselectedStarsForeground: themeColors.reactionStarsInactiveForeground.argb,
selectedStarsForeground: themeColors.reactionStarsActiveForeground.argb,
extractedBackground: presentationData.theme.theme.contextMenu.backgroundColor.argb,
extractedForeground: presentationData.theme.theme.contextMenu.primaryColor.argb,
extractedSelectedForeground: presentationData.theme.theme.contextMenu.primaryColor.argb,

View File

@ -255,7 +255,15 @@ public func topMessageReactions(context: AccountContext, message: Message, subPe
guard let allowedReactions = allowedReactions else {
return .single(nil)
}
if case let .set(reactions) = allowedReactions {
#if DEBUG
var reactions = reactions
if "".isEmpty {
reactions.insert(.custom(MessageReaction.starsReactionId))
}
#endif
return context.engine.stickers.resolveInlineStickers(fileIds: reactions.compactMap { item -> Int64? in
switch item {
case .builtin:
@ -265,10 +273,17 @@ public func topMessageReactions(context: AccountContext, message: Message, subPe
}
})
|> map { files -> (reactions: AllowedReactions, files: [Int64: TelegramMediaFile]) in
return (allowedReactions, files)
return (.set(reactions), files)
}
} else {
#if DEBUG
return context.engine.stickers.resolveInlineStickers(fileIds: [MessageReaction.starsReactionId])
|> map { files -> (reactions: AllowedReactions, files: [Int64: TelegramMediaFile]) in
return (allowedReactions, files)
}
#else
return .single((allowedReactions, [:]))
#endif
}
}
@ -286,6 +301,25 @@ public func topMessageReactions(context: AccountContext, message: Message, subPe
var result: [ReactionItem] = []
var existingIds = Set<MessageReaction.Reaction>()
#if DEBUG
if "".isEmpty {
if let file = allowedReactionsAndFiles.files[MessageReaction.starsReactionId] {
existingIds.insert(.custom(MessageReaction.starsReactionId))
result.append(ReactionItem(
reaction: ReactionItem.Reaction(rawValue: .custom(file.fileId.id)),
appearAnimation: file,
stillAnimation: file,
listAnimation: file,
largeListAnimation: file,
applicationAnimation: nil,
largeApplicationAnimation: nil,
isCustom: true
))
}
}
#endif
for topReaction in topReactions {
switch topReaction.content {
case let .builtin(value):