diff --git a/submodules/CloudData/Sources/CloudData.swift b/submodules/CloudData/Sources/CloudData.swift index 30c7709800..04f1df80be 100644 --- a/submodules/CloudData/Sources/CloudData.swift +++ b/submodules/CloudData/Sources/CloudData.swift @@ -12,6 +12,10 @@ private enum FetchError { @available(iOS 10.0, *) private func fetchRawData(prefix: String) -> Signal { return Signal { subscriber in + #if targetEnvironment(simulator) + return EmptyDisposable + #endif + let container = CKContainer.default() let publicDatabase = container.database(with: .public) let recordId = CKRecord.ID(recordName: "emergency-datacenter-\(prefix)") diff --git a/submodules/Display/Source/UIKitUtils.swift b/submodules/Display/Source/UIKitUtils.swift index bb506e410b..3bbcda2c9b 100644 --- a/submodules/Display/Source/UIKitUtils.swift +++ b/submodules/Display/Source/UIKitUtils.swift @@ -201,6 +201,44 @@ public extension UIColor { return self } + func blitOver(_ other: UIColor, alpha: CGFloat) -> UIColor { + let alpha = min(1.0, max(0.0, alpha)) + let oneMinusAlpha = 1.0 - alpha + + var r1: CGFloat = 0.0 + var r2: CGFloat = 0.0 + var g1: CGFloat = 0.0 + var g2: CGFloat = 0.0 + var b1: CGFloat = 0.0 + var b2: CGFloat = 0.0 + var a1: CGFloat = 0.0 + var a2: CGFloat = 0.0 + if self.getRed(&r1, green: &g1, blue: &b1, alpha: &a1) && + other.getRed(&r2, green: &g2, blue: &b2, alpha: &a2) + { + let resultingAlpha = max(0.0, min(1.0, alpha * a1)) + let oneMinusResultingAlpha = 1.0 - resultingAlpha + + let r = r1 * resultingAlpha + r2 * oneMinusResultingAlpha + let g = g1 * resultingAlpha + g2 * oneMinusResultingAlpha + let b = b1 * resultingAlpha + b2 * oneMinusResultingAlpha + let a: CGFloat = 1.0 + return UIColor(red: r, green: g, blue: b, alpha: a) + } + return self + } + + func withMultipliedAlpha(_ alpha: CGFloat) -> UIColor { + var r1: CGFloat = 0.0 + var g1: CGFloat = 0.0 + var b1: CGFloat = 0.0 + var a1: CGFloat = 0.0 + if self.getRed(&r1, green: &g1, blue: &b1, alpha: &a1) { + return UIColor(red: r1, green: g1, blue: b1, alpha: max(0.0, min(1.0, a1 * alpha))) + } + return self + } + func interpolateTo(_ color: UIColor, fraction: CGFloat) -> UIColor? { let f = min(max(0, fraction), 1) diff --git a/submodules/ShimmerEffect/Sources/ShimmerEffect.swift b/submodules/ShimmerEffect/Sources/ShimmerEffect.swift index 329098c6c5..3157a60c1a 100644 --- a/submodules/ShimmerEffect/Sources/ShimmerEffect.swift +++ b/submodules/ShimmerEffect/Sources/ShimmerEffect.swift @@ -52,7 +52,8 @@ private final class ShimmerEffectForegroundNode: ASDisplayNode { self.currentBackgroundColor = backgroundColor self.currentForegroundColor = foregroundColor - self.imageNode.image = generateImage(CGSize(width: 4.0, height: 320.0), opaque: true, scale: 1.0, rotatedContext: { size, context in + self.imageNode.image = generateImage(CGSize(width: 16.0, height: 320.0), opaque: false, scale: 1.0, rotatedContext: { size, context in + context.clear(CGRect(origin: CGPoint(), size: size)) context.setFillColor(backgroundColor.cgColor) context.fill(CGRect(origin: CGPoint(), size: size)) diff --git a/submodules/TelegramUI/Sources/ChatMediaInputGifPane.swift b/submodules/TelegramUI/Sources/ChatMediaInputGifPane.swift index ab06c54cf0..5b70c31711 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputGifPane.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputGifPane.swift @@ -141,6 +141,9 @@ final class ChatMediaInputGifPane: ChatMediaInputPane, UIScrollViewDelegate { func setMode(mode: ChatMediaInputGifMode) { if self.mode == mode { + if let multiplexedNode = self.multiplexedNode { + multiplexedNode.scrollNode.view.setContentOffset(CGPoint(), animated: true) + } return } self.mode = mode diff --git a/submodules/TelegramUI/Sources/ChatMediaInputNode.swift b/submodules/TelegramUI/Sources/ChatMediaInputNode.swift index 582ecf6b2c..5de56553cb 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputNode.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputNode.swift @@ -217,9 +217,7 @@ func chatMediaInputPanelEntries(view: ItemCollectionsView, savedStickers: Ordere return entries } -private let reactions: [String] = ["👍", "👎", "😍", "😂", "😯", "😕", "😢", "😡", "💪", "👏", "🙈", "😒"] - -func chatMediaInputPanelGifModeEntries(theme: PresentationTheme) -> [ChatMediaInputPanelEntry] { +func chatMediaInputPanelGifModeEntries(theme: PresentationTheme, reactions: [String]) -> [ChatMediaInputPanelEntry] { var entries: [ChatMediaInputPanelEntry] = [] entries.append(.stickersMode(theme)) entries.append(.savedGifs(theme)) @@ -827,10 +825,27 @@ final class ChatMediaInputNode: ChatInputNode { }) self.trendingInteraction = trendingInteraction + let preferencesViewKey: PostboxViewKey = .preferences(keys: Set([PreferencesKeys.appConfiguration])) + let reactions: Signal<[String], NoError> = context.account.postbox.combinedView(keys: [preferencesViewKey]) + |> map { views -> [String] in + let defaultReactions: [String] = ["👍", "👎", "😍", "😂", "😯", "😕", "😢", "😡", "💪", "👏", "🙈", "😒"] + guard let view = views.views[preferencesViewKey] as? PreferencesView else { + return defaultReactions + } + guard let appConfiguration = view.values[PreferencesKeys.appConfiguration] as? AppConfiguration else { + return defaultReactions + } + guard let data = appConfiguration.data, let emojis = data["gif_search_emojies"] as? [String] else { + return defaultReactions + } + return emojis + } + |> distinctUntilChanged + let previousView = Atomic(value: nil) let transitionQueue = Queue() - let transitions = combineLatest(queue: transitionQueue, itemCollectionsView, peerSpecificPack, context.account.viewTracker.featuredStickerPacks(), self.themeAndStringsPromise.get()) - |> map { viewAndUpdate, peerSpecificPack, trendingPacks, themeAndStrings -> (ItemCollectionsView, ChatMediaInputPanelTransition, ChatMediaInputPanelTransition, Bool, ChatMediaInputGridTransition, Bool) in + let transitions = combineLatest(queue: transitionQueue, itemCollectionsView, peerSpecificPack, context.account.viewTracker.featuredStickerPacks(), self.themeAndStringsPromise.get(), reactions) + |> map { viewAndUpdate, peerSpecificPack, trendingPacks, themeAndStrings, reactions -> (ItemCollectionsView, ChatMediaInputPanelTransition, ChatMediaInputPanelTransition, Bool, ChatMediaInputGridTransition, Bool) in let (view, viewUpdate) = viewAndUpdate let previous = previousView.swap(view) var update = viewUpdate @@ -866,7 +881,7 @@ final class ChatMediaInputNode: ChatInputNode { } let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, hasUnreadTrending: hasUnreadTrending, theme: theme) - let gifPaneEntries = chatMediaInputPanelGifModeEntries(theme: theme) + let gifPaneEntries = chatMediaInputPanelGifModeEntries(theme: theme, reactions: reactions) var gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, strings: strings, theme: theme) if view.higher == nil { diff --git a/submodules/TelegramUI/Sources/ChatMediaInputStickerGridItem.swift b/submodules/TelegramUI/Sources/ChatMediaInputStickerGridItem.swift index c4f85c3c39..09783cb095 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputStickerGridItem.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputStickerGridItem.swift @@ -312,7 +312,7 @@ final class ChatMediaInputStickerGridItemNode: GridItemNode { placeholderNode.frame = CGRect(origin: CGPoint(), size: size) let theme = item.theme - placeholderNode.update(backgroundColor: theme.chat.inputMediaPanel.stickersBackgroundColor, foregroundColor: theme.chat.inputMediaPanel.stickersSectionTextColor.mixedWith(theme.chat.inputMediaPanel.stickersBackgroundColor, alpha: 0.9), shimmeringColor: theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.3), shapes: [.roundedRect(rect: placeholderFrame, cornerRadius: 10.0)], size: bounds.size) + placeholderNode.update(backgroundColor: theme.chat.inputMediaPanel.stickersBackgroundColor, foregroundColor: theme.chat.inputMediaPanel.stickersSectionTextColor.blitOver(theme.chat.inputMediaPanel.stickersBackgroundColor, alpha: 0.1), shimmeringColor: theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.3), shapes: [.roundedRect(rect: placeholderFrame, cornerRadius: 10.0)], size: bounds.size) } } diff --git a/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift b/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift index 8494e605d0..c54b0f880c 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputStickerPackItem.swift @@ -247,7 +247,7 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode { if let placeholderImageNode = self.placeholderImageNode { if placeholderImageNode.image == nil { - placeholderImageNode.image = generateStretchableFilledCircleImage(diameter: 10.0, color: theme.chat.inputMediaPanel.panelHighlightedIconBackgroundColor.mixedWith(.clear, alpha: 0.6)) + placeholderImageNode.image = generateStretchableFilledCircleImage(diameter: 10.0, color: theme.chat.inputMediaPanel.panelHighlightedIconBackgroundColor.withMultipliedAlpha(0.3)) } let size = boundingSize let imageSize = boundingImageSize @@ -261,7 +261,7 @@ final class ChatMediaInputStickerPackItemNode: ListViewItemNode { let placeholderFrame = CGRect(origin: CGPoint(x: floor((boundingSize.width - imageSize.width) / 2.0) + verticalOffset, y: floor((boundingSize.height - imageSize.height) / 2.0)), size: imageSize) placeholderNode.frame = CGRect(origin: CGPoint(), size: size) - placeholderNode.update(backgroundColor: theme.chat.inputPanel.panelBackgroundColor, foregroundColor: theme.chat.inputMediaPanel.panelHighlightedIconBackgroundColor.mixedWith(theme.chat.inputPanel.panelBackgroundColor, alpha: 0.8), shimmeringColor: theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.3), shapes: [.roundedRect(rect: placeholderFrame, cornerRadius: 5.0)], size: bounds.size) + placeholderNode.update(backgroundColor: theme.chat.inputPanel.panelBackgroundColor, foregroundColor: theme.chat.inputMediaPanel.stickersSectionTextColor.blitOver(theme.chat.inputPanel.panelBackgroundColor, alpha: 0.4), shimmeringColor: theme.chat.inputMediaPanel.panelHighlightedIconBackgroundColor.withMultipliedAlpha(0.2), shapes: [.roundedRect(rect: placeholderFrame, cornerRadius: 5.0)], size: bounds.size) } self.updateIsHighlighted() diff --git a/submodules/TelegramUI/Sources/MultiplexedVideoNode.swift b/submodules/TelegramUI/Sources/MultiplexedVideoNode.swift index e9a237d4e9..d74302010e 100644 --- a/submodules/TelegramUI/Sources/MultiplexedVideoNode.swift +++ b/submodules/TelegramUI/Sources/MultiplexedVideoNode.swift @@ -30,7 +30,7 @@ final class MultiplexedVideoPlaceholderNode: ASDisplayNode { } self.effectNode.frame = CGRect(origin: CGPoint(), size: size) - self.effectNode.update(backgroundColor: theme.chat.inputPanel.panelBackgroundColor, foregroundColor: theme.chat.inputMediaPanel.stickersSectionTextColor.mixedWith(theme.chat.inputPanel.panelBackgroundColor, alpha: 0.72), shimmeringColor: theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.3), shapes: [.rect(rect: CGRect(origin: CGPoint(), size: size))], size: bounds.size) + self.effectNode.update(backgroundColor: theme.chat.inputMediaPanel.stickersBackgroundColor, foregroundColor: theme.chat.inputMediaPanel.stickersSectionTextColor.blitOver(theme.chat.inputMediaPanel.stickersBackgroundColor, alpha: 0.2), shimmeringColor: theme.list.itemBlocksBackgroundColor.withAlphaComponent(0.3), shapes: [.rect(rect: CGRect(origin: CGPoint(), size: size))], size: bounds.size) } func updateAbsoluteRect(_ absoluteRect: CGRect, within containerSize: CGSize) {