From fe72fde9dc58b9b0a23a78d29cd4f4d7390d9caa Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 26 Jul 2022 00:31:00 +0200 Subject: [PATCH 1/3] Trigger build --- Random.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Random.txt b/Random.txt index 34c2b34b5c..c53f77a5ec 100644 --- a/Random.txt +++ b/Random.txt @@ -1 +1 @@ -462c8b20925f8d3f87f0ab82d25d9c2a +91204a26a271ccb13c9732b161e1aa0f From 4d1f0a057fd46e9915508e951f030ad5d04af7a8 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 26 Jul 2022 01:35:24 +0200 Subject: [PATCH 2/3] Disable effects in dark theme --- .../Sources/PresentationThemeCodable.swift | 2 +- .../Sources/EmojiPagerContentComponent.swift | 38 +++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index d04b76ed88..3263541e8c 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -1643,7 +1643,7 @@ extension PresentationThemeInputMediaPanel: Codable { panelIconColor: try decodeColor(values, .panelIcon), panelHighlightedIconBackgroundColor: try decodeColor(values, .panelHighlightedIconBg), panelHighlightedIconColor: panelHighlightedIconColor, - panelContentVibrantOverlayColor: try decodeColor(values, .panelContentVibrantOverlay, fallbackKey: "\(codingPath).panelIcon"), + panelContentVibrantOverlayColor: try decodeColor(values, .panelContentVibrantOverlay, fallbackKey: "\(codingPath).stickersSectionText"), stickersBackgroundColor: try decodeColor(values, .stickersBg), stickersSectionTextColor: try decodeColor(values, .stickersSectionText), stickersSearchBackgroundColor: try decodeColor(values, .stickersSearchBg), diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift index a6a4aede8f..9d9093aba7 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift @@ -586,6 +586,8 @@ private final class GroupHeaderLayer: UIView { themeUpdated = true } + let needsVibrancy = !theme.overallDarkAppearance + let textOffsetY: CGFloat if hasTopSeparator { textOffsetY = 9.0 @@ -668,6 +670,7 @@ private final class GroupHeaderLayer: UIView { UIGraphicsPopContext() })?.cgImage + self.tintTextLayer.isHidden = !needsVibrancy self.currentTextLayout = (title, color, textConstrainedWidth, textSize) } @@ -709,6 +712,7 @@ private final class GroupHeaderLayer: UIView { if let image = PresentationResourcesChat.chatEntityKeyboardLock(theme, color: .white) { tintLockIconLayer.contents = image.cgImage tintLockIconLayer.frame = lockIconLayer.frame + tintLockIconLayer.isHidden = !needsVibrancy } else { tintLockIconLayer.contents = nil } @@ -774,6 +778,7 @@ private final class GroupHeaderLayer: UIView { self.tintSubtitleLayer = tintSubtitleLayer self.tintContentLayer.addSublayer(tintSubtitleLayer) } + tintSubtitleLayer.isHidden = !needsVibrancy if let updateTintSubtitleContents = updateTintSubtitleContents { tintSubtitleLayer.contents = updateTintSubtitleContents.cgImage @@ -813,6 +818,8 @@ private final class GroupHeaderLayer: UIView { self.tintContentLayer.addSublayer(tintClearIconLayer) } + tintClearIconLayer.isHidden = !needsVibrancy + var clearSize = clearIconLayer.bounds.size if updateImage, let image = PresentationResourcesChat.chatInputMediaPanelGridDismissImage(theme, color: theme.chat.inputMediaPanel.panelContentVibrantOverlayColor) { clearSize = image.size @@ -895,6 +902,8 @@ private final class GroupHeaderLayer: UIView { } tintSeparatorLayer.backgroundColor = UIColor.white.cgColor tintSeparatorLayer.frame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: size.width, height: UIScreenPixel)) + + tintSeparatorLayer.isHidden = !needsVibrancy } else { if let separatorLayer = self.separatorLayer { self.separatorLayer = separatorLayer @@ -3672,18 +3681,25 @@ public final class EmojiPagerContentComponent: Component { return } - if self.vibrancyEffectView == nil { - let style: UIBlurEffect.Style - style = .extraLight - let blurEffect = UIBlurEffect(style: style) - let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect) - let vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect) - self.vibrancyEffectView = vibrancyEffectView - self.backgroundView.addSubview(vibrancyEffectView) - for subview in vibrancyEffectView.subviews { - let _ = subview + if keyboardChildEnvironment.theme.overallDarkAppearance { + if let vibrancyEffectView = self.vibrancyEffectView { + self.vibrancyEffectView = nil + vibrancyEffectView.removeFromSuperview() + } + } else { + if self.vibrancyEffectView == nil { + let style: UIBlurEffect.Style + style = .extraLight + let blurEffect = UIBlurEffect(style: style) + let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect) + let vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect) + self.vibrancyEffectView = vibrancyEffectView + self.backgroundView.addSubview(vibrancyEffectView) + for subview in vibrancyEffectView.subviews { + let _ = subview + } + vibrancyEffectView.contentView.addSubview(self.mirrorContentScrollView) } - vibrancyEffectView.contentView.addSubview(self.mirrorContentScrollView) } self.backgroundView.updateColor(color: keyboardChildEnvironment.theme.chat.inputMediaPanel.backgroundColor, enableBlur: true, forceKeepBlur: false, transition: transition.containedViewLayoutTransition) From c39f8ebd81fc2b5166e3aaadce4128a7636a6e81 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 26 Jul 2022 01:48:52 +0200 Subject: [PATCH 3/3] Fix layout --- .../Sources/EmojiPagerContentComponent.swift | 7 ++++++- .../Sources/EntityKeyboardBottomPanelComponent.swift | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift index 9d9093aba7..348cc977a8 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift @@ -1592,7 +1592,12 @@ public final class EmojiPagerContentComponent: Component { self.itemsPerRow = max(minItemsPerRow, Int((itemHorizontalSpace + minSpacing) / (self.nativeItemSize + minSpacing))) - self.visibleItemSize = self.nativeItemSize + //self.itemsPerRow * x + minSpacing * (x - 1) = itemHorizontalSpace + //self.itemsPerRow * x + minSpacing * (self.itemsPerRow - 1) = itemHorizontalSpace + //x = (itemHorizontalSpace - minSpacing * (self.itemsPerRow - 1)) / self.itemsPerRow + let proposedItemSize = floor((itemHorizontalSpace - minSpacing * (CGFloat(self.itemsPerRow) - 1.0)) / CGFloat(self.itemsPerRow)) + + self.visibleItemSize = proposedItemSize < self.nativeItemSize ? proposedItemSize : self.nativeItemSize self.horizontalSpacing = floorToScreenPixels((itemHorizontalSpace - self.visibleItemSize * CGFloat(self.itemsPerRow)) / CGFloat(self.itemsPerRow - 1)) diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardBottomPanelComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardBottomPanelComponent.swift index 5cc31d874b..fde1c16782 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardBottomPanelComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EntityKeyboardBottomPanelComponent.swift @@ -186,6 +186,13 @@ final class EntityKeyboardBottomPanelComponent: Component { let intrinsicHeight: CGFloat = 34.0 let height = intrinsicHeight + component.containerInsets.bottom + let accessoryButtonOffset: CGFloat + if component.containerInsets.bottom > 0.0 { + accessoryButtonOffset = 2.0 + } else { + accessoryButtonOffset = -2.0 + } + let panelEnvironment = environment[PagerComponentPanelEnvironment.self].value let activeContentId = panelEnvironment.activeContentId @@ -217,7 +224,7 @@ final class EntityKeyboardBottomPanelComponent: Component { environment: {}, containerSize: CGSize(width: .greatestFiniteMagnitude, height: intrinsicHeight) ) - leftAccessoryButtonTransition.setFrame(view: leftAccessoryButton.view, frame: CGRect(origin: CGPoint(x: component.containerInsets.left + 2.0, y: 2.0), size: leftAccessoryButtonSize)) + leftAccessoryButtonTransition.setFrame(view: leftAccessoryButton.view, frame: CGRect(origin: CGPoint(x: component.containerInsets.left + 2.0, y: accessoryButtonOffset), size: leftAccessoryButtonSize)) } else { self.leftAccessoryButton = nil } @@ -269,7 +276,7 @@ final class EntityKeyboardBottomPanelComponent: Component { environment: {}, containerSize: CGSize(width: .greatestFiniteMagnitude, height: intrinsicHeight) ) - rightAccessoryButtonTransition.setFrame(view: rightAccessoryButton.view, frame: CGRect(origin: CGPoint(x: availableSize.width - component.containerInsets.right - 2.0 - rightAccessoryButtonSize.width, y: 2.0), size: rightAccessoryButtonSize)) + rightAccessoryButtonTransition.setFrame(view: rightAccessoryButton.view, frame: CGRect(origin: CGPoint(x: availableSize.width - component.containerInsets.right - 2.0 - rightAccessoryButtonSize.width, y: accessoryButtonOffset), size: rightAccessoryButtonSize)) } else { self.rightAccessoryButton = nil }