diff --git a/submodules/Components/ReactionButtonListComponent/Sources/ReactionButtonListComponent.swift b/submodules/Components/ReactionButtonListComponent/Sources/ReactionButtonListComponent.swift index bf81f82aa3..011398bc0e 100644 --- a/submodules/Components/ReactionButtonListComponent/Sources/ReactionButtonListComponent.swift +++ b/submodules/Components/ReactionButtonListComponent/Sources/ReactionButtonListComponent.swift @@ -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() - 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() + for reaction in reactions { validIds.insert(reaction.reaction.value) var avatarPeers = reaction.peers diff --git a/submodules/DebugSettingsUI/Sources/DebugController.swift b/submodules/DebugSettingsUI/Sources/DebugController.swift index 51bfc59ee5..0db2b467cb 100644 --- a/submodules/DebugSettingsUI/Sources/DebugController.swift +++ b/submodules/DebugSettingsUI/Sources/DebugController.swift @@ -102,7 +102,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { case playlistPlayback(Bool) case enableQuickReactionSwitch(Bool) case disableReloginTokens(Bool) - case voiceConference + case liveStreamV2(Bool) case preferredVideoCodec(Int, String, String?, Bool) case disableVideoAspectScaling(Bool) case enableNetworkFramework(Bool) @@ -127,7 +127,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { return DebugControllerSection.web.rawValue case .keepChatNavigationStack, .skipReadHistory, .dustEffect, .crashOnSlowQueries, .crashOnMemoryPressure: return DebugControllerSection.experiments.rawValue - case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .storiesExperiment, .storiesJpegExperiment, .playlistPlayback, .enableQuickReactionSwitch, .voiceConference, .experimentalCompatibility, .enableDebugDataDisplay, .acceleratedStickers, .browserExperiment, .localTranscription, .enableReactionOverrides, .restorePurchases, .disableReloginTokens: + case .clearTips, .resetNotifications, .crash, .fillLocalSavedMessageCache, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .resetTagHoles, .reindexUnread, .resetCacheIndex, .reindexCache, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .storiesExperiment, .storiesJpegExperiment, .playlistPlayback, .enableQuickReactionSwitch, .experimentalCompatibility, .enableDebugDataDisplay, .acceleratedStickers, .browserExperiment, .localTranscription, .enableReactionOverrides, .restorePurchases, .disableReloginTokens, .liveStreamV2: return DebugControllerSection.experiments.rawValue case .logTranslationRecognition, .resetTranslationStates: return DebugControllerSection.translation.rawValue @@ -240,7 +240,7 @@ private enum DebugControllerEntry: ItemListNodeEntry { return 49 case .enableQuickReactionSwitch: return 50 - case .voiceConference: + case .liveStreamV2: return 51 case let .preferredVideoCodec(index, _, _, _): return 52 + index @@ -1312,11 +1312,15 @@ private enum DebugControllerEntry: ItemListNodeEntry { }) }).start() }) - case .voiceConference: - return ItemListDisclosureItem(presentationData: presentationData, title: "Voice Conference (Test)", label: "", sectionId: self.section, style: .blocks, action: { - guard let _ = arguments.context else { - return - } + case let .liveStreamV2(value): + return ItemListSwitchItem(presentationData: presentationData, title: "Live Stream V2", value: value, sectionId: self.section, style: .blocks, updated: { value in + let _ = arguments.sharedContext.accountManager.transaction ({ transaction in + transaction.updateSharedData(ApplicationSpecificSharedDataKeys.experimentalUISettings, { settings in + var settings = settings?.get(ExperimentalUISettings.self) ?? ExperimentalUISettings.defaultSettings + settings.liveStreamV2 = value + return PreferencesEntry(settings) + }) + }).start() }) case let .preferredVideoCodec(_, title, value, isSelected): return ItemListCheckboxItem(presentationData: presentationData, title: title, style: .right, checked: isSelected, zeroSeparatorInsets: false, sectionId: self.section, action: { @@ -1468,6 +1472,7 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present } entries.append(.playlistPlayback(experimentalSettings.playlistPlayback)) entries.append(.enableQuickReactionSwitch(!experimentalSettings.disableQuickReaction)) + entries.append(.liveStreamV2(experimentalSettings.liveStreamV2)) } let codecs: [(String, String?)] = [ diff --git a/submodules/ReactionSelectionNode/Sources/ReactionSelectionNode.swift b/submodules/ReactionSelectionNode/Sources/ReactionSelectionNode.swift index 9140f9745a..4bd8a3b79d 100644 --- a/submodules/ReactionSelectionNode/Sources/ReactionSelectionNode.swift +++ b/submodules/ReactionSelectionNode/Sources/ReactionSelectionNode.swift @@ -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) diff --git a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift index e80e972eba..284f939f91 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift @@ -1637,7 +1637,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { if let current = self.genericCallContext { genericCallContext = current } else { - if self.isStream, !"".isEmpty { + if self.isStream, self.accountContext.sharedContext.immediateExperimentalUISettings.liveStreamV2 { genericCallContext = .mediaStream(WrappedMediaStreamingContext(rejoinNeeded: { [weak self] in Queue.mainQueue().async { guard let strongSelf = self else { diff --git a/submodules/TelegramCore/Sources/ApiUtils/ReactionsMessageAttribute.swift b/submodules/TelegramCore/Sources/ApiUtils/ReactionsMessageAttribute.swift index cb98e12f44..63b3d8b66e 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/ReactionsMessageAttribute.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/ReactionsMessageAttribute.swift @@ -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]) { diff --git a/submodules/TelegramCore/Sources/Authorization.swift b/submodules/TelegramCore/Sources/Authorization.swift index ee429ff014..31875955eb 100644 --- a/submodules/TelegramCore/Sources/Authorization.swift +++ b/submodules/TelegramCore/Sources/Authorization.swift @@ -365,7 +365,7 @@ public func sendAuthorizationCode(accountManager: AccountManager 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) ) diff --git a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift index fb7f905772..2f71522c77 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift @@ -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 ) diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index 591e5e131b..a5e38bb28f 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -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 ) diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift index 439f7b0b53..051a246935 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageDateAndStatusNode/Sources/ChatMessageDateAndStatusNode.swift @@ -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, diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift index bc1f7ca0a1..c0c186521c 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageReactionsFooterContentNode/Sources/ChatMessageReactionsFooterContentNode.swift @@ -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, diff --git a/submodules/TelegramUI/Components/Chat/TopMessageReactions/Sources/TopMessageReactions.swift b/submodules/TelegramUI/Components/Chat/TopMessageReactions/Sources/TopMessageReactions.swift index 080aeb97a6..c43d7117dd 100644 --- a/submodules/TelegramUI/Components/Chat/TopMessageReactions/Sources/TopMessageReactions.swift +++ b/submodules/TelegramUI/Components/Chat/TopMessageReactions/Sources/TopMessageReactions.swift @@ -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() + #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): diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index d8ce813d31..b734ce065b 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -532,7 +532,7 @@ public final class SharedAccountContextImpl: SharedAccountContext { sortIndex = sortOrder.order } else if case let .backupData(backupDataValue) = attribute { backupData = backupDataValue.data - } else if case .supportUserInfo = attribute { + } else if case .supportUserInfo = attribute, !"".isEmpty { isSupportUser = true } } diff --git a/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift b/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift index 644d2a270a..c545871ff9 100644 --- a/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift +++ b/submodules/TelegramUIPreferences/Sources/ExperimentalUISettings.swift @@ -57,6 +57,7 @@ public struct ExperimentalUISettings: Codable, Equatable { public var callV2: Bool public var allowWebViewInspection: Bool public var disableReloginTokens: Bool + public var liveStreamV2: Bool public static var defaultSettings: ExperimentalUISettings { return ExperimentalUISettings( @@ -91,7 +92,8 @@ public struct ExperimentalUISettings: Codable, Equatable { dustEffect: false, callV2: false, allowWebViewInspection: false, - disableReloginTokens: false + disableReloginTokens: false, + liveStreamV2: false ) } @@ -127,7 +129,8 @@ public struct ExperimentalUISettings: Codable, Equatable { dustEffect: Bool, callV2: Bool, allowWebViewInspection: Bool, - disableReloginTokens: Bool + disableReloginTokens: Bool, + liveStreamV2: Bool ) { self.keepChatNavigationStack = keepChatNavigationStack self.skipReadHistory = skipReadHistory @@ -161,6 +164,7 @@ public struct ExperimentalUISettings: Codable, Equatable { self.callV2 = callV2 self.allowWebViewInspection = allowWebViewInspection self.disableReloginTokens = disableReloginTokens + self.liveStreamV2 = liveStreamV2 } public init(from decoder: Decoder) throws { @@ -198,6 +202,7 @@ public struct ExperimentalUISettings: Codable, Equatable { self.callV2 = try container.decodeIfPresent(Bool.self, forKey: "callV2") ?? false self.allowWebViewInspection = try container.decodeIfPresent(Bool.self, forKey: "allowWebViewInspection") ?? false self.disableReloginTokens = try container.decodeIfPresent(Bool.self, forKey: "disableReloginTokens") ?? false + self.liveStreamV2 = try container.decodeIfPresent(Bool.self, forKey: "liveStreamV2") ?? false } public func encode(to encoder: Encoder) throws { @@ -235,6 +240,7 @@ public struct ExperimentalUISettings: Codable, Equatable { try container.encode(self.callV2, forKey: "callV2") try container.encode(self.allowWebViewInspection, forKey: "allowWebViewInspection") try container.encode(self.disableReloginTokens, forKey: "disableReloginTokens") + try container.encode(self.liveStreamV2, forKey: "liveStreamV2") } } diff --git a/submodules/TelegramVoip/Sources/GroupCallContext.swift b/submodules/TelegramVoip/Sources/GroupCallContext.swift index 636ac67d45..ac4f0b7f7b 100644 --- a/submodules/TelegramVoip/Sources/GroupCallContext.swift +++ b/submodules/TelegramVoip/Sources/GroupCallContext.swift @@ -57,7 +57,7 @@ final class NetworkBroadcastPartSource: BroadcastPartSource { private var dataSource: AudioBroadcastDataSource? #if DEBUG - private let debugDumpDirectory: EngineTempBox.Directory? + private var debugDumpDirectory: EngineTempBox.Directory? #endif init(queue: Queue, engine: TelegramEngine, callId: Int64, accessHash: Int64, isExternalStream: Bool) { @@ -67,8 +67,8 @@ final class NetworkBroadcastPartSource: BroadcastPartSource { self.accessHash = accessHash self.isExternalStream = isExternalStream - #if DEBUG && true - self.debugDumpDirectory = EngineTempBox.shared.tempDirectory() + #if DEBUG + //self.debugDumpDirectory = EngineTempBox.shared.tempDirectory() #endif } diff --git a/submodules/TelegramVoip/Sources/LiveStreamController.swift b/submodules/TelegramVoip/Sources/LiveStreamController.swift deleted file mode 100644 index 2d3f4150d8..0000000000 --- a/submodules/TelegramVoip/Sources/LiveStreamController.swift +++ /dev/null @@ -1,10 +0,0 @@ -import Foundation -import SwiftSignalKit -import TgVoipWebrtc -import TelegramCore - -public final class LiveStreamController { - public init(network: Network) { - - } -}