From 0e938a6bb80f884e80279044ff52ac9bb5e585b8 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 15 Jun 2021 21:34:17 +0400 Subject: [PATCH 01/13] Don't load unnecessary pattern image --- .../Sources/Themes/ThemePreviewControllerNode.swift | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift index 56332a965f..7f57328d53 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift @@ -202,7 +202,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate { self.wallpaperNode.update(wallpaper: self.wallpaper) self.wallpaperNode.updateBubbleTheme(bubbleTheme: self.previewTheme, bubbleCorners: self.presentationData.chatBubbleCorners) - + self.remoteChatBackgroundNode.imageUpdated = { [weak self] image in if let strongSelf = self, strongSelf.blurredNode.supernode != nil { var image = image @@ -250,14 +250,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate { let signal: Signal<(TransformImageArguments) -> DrawingContext?, NoError> let fileReference = FileMediaReference.standalone(media: file.file) if wallpaper.isPattern { - signal = patternWallpaperImage(account: context.account, accountManager: context.sharedContext.accountManager, representations: convertedRepresentations, mode: .screen, autoFetchFullSize: false) - |> mapToSignal { value -> Signal<(TransformImageArguments) -> DrawingContext?, NoError> in - if let value = value { - return .single(value) - } else { - return .complete() - } - } + signal = .complete() } else { signal = .complete() } From b908426ef5af615e640a23b4f75bda7cf52b48c7 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 15 Jun 2021 22:05:01 +0400 Subject: [PATCH 02/13] Request thumbnail instead of medium for screencasts --- submodules/TelegramCallsUI/Sources/VoiceChatController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index 155055c10d..0a6f808027 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -4930,7 +4930,7 @@ public final class VoiceChatController: ViewController { requestedVideoChannels.append(videoChannel) } if member.peer.id != self.callState?.myPeerId { - if var presentationChannel = member.requestedPresentationVideoChannel(minQuality: .thumbnail, maxQuality: .medium) { + if var presentationChannel = member.requestedPresentationVideoChannel(minQuality: .thumbnail, maxQuality: .thumbnail) { if self.effectiveSpeaker?.1 == presentationChannel.endpointId { presentationChannel.minQuality = .full presentationChannel.maxQuality = .full From 06926e3c34bac742cfd10c23061699dec216a63d Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 15 Jun 2021 22:06:41 +0400 Subject: [PATCH 03/13] Update tgcalls --- submodules/TgVoipWebrtc/tgcalls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index 10e208f6f3..4c98c768ca 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit 10e208f6f35eaa4a8ef6bb95e58b704178e8affd +Subproject commit 4c98c768ca0969cfcebf6da3e585c6760960fe0b From 9da1b9566f2b092740877c0456116170fdc05764 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 15 Jun 2021 23:09:10 +0400 Subject: [PATCH 04/13] If no pattern available, proceed with opening screens --- .../Sources/WallpaperBackgroundNode.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift index f03f178342..b953b79c18 100644 --- a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift +++ b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift @@ -531,6 +531,8 @@ public final class WallpaperBackgroundNode: ASDisplayNode { } else { strongSelf._isReady.set(true) } + } else { + strongSelf._isReady.set(true) } })) } From bac8b1efea0eb35c5b4bd1ad09c556bd02a89633 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 15 Jun 2021 23:36:35 +0400 Subject: [PATCH 05/13] Fix tinted night preview --- .../Sources/Themes/ThemeSettingsController.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift index 32ac152296..38414fe459 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift @@ -844,7 +844,14 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The if let accentColor = accentColor, case let .theme(themeReference) = accentColor { theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference) } else { - theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: generalThemeReference, accentColor: accentColor?.accentColor, bubbleColors: accentColor?.customBubbleColors, wallpaper: accentColor?.wallpaper) + var wallpaperGradientColors: [UInt32]? + switch accentColor { + case let .accentColor(value): + wallpaperGradientColors = value.baseColor.wallpaperGradientColors + default: + break + } + theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: generalThemeReference, accentColor: accentColor?.accentColor, bubbleColors: accentColor?.customBubbleColors, wallpaper: accentColor?.wallpaper, wallpaperGradientColors: wallpaperGradientColors) } effectiveWallpaper = theme?.chat.defaultWallpaper ?? .builtin(WallpaperSettings()) } From 94abbecdd64f99f5cf34827cd6b143e9728c7a5a Mon Sep 17 00:00:00 2001 From: Ali <> Date: Tue, 15 Jun 2021 23:43:43 +0400 Subject: [PATCH 06/13] Support semi-transparent gradients --- .../Sources/PresentationThemeEssentialGraphics.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift index 9fe6a0d9be..b898ce12f1 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeEssentialGraphics.swift @@ -206,6 +206,7 @@ public final class PrincipalThemeEssentialGraphics { } if let incomingGradientColors = incomingGradientColors { self.incomingBubbleGradientImage = generateImage(CGSize(width: 1.0, height: 512.0), opaque: true, scale: 1.0, rotatedContext: { size, context in + context.clear(CGRect(origin: CGPoint(), size: size)) var locations: [CGFloat] = [0.0, 1.0] let colors = [incomingGradientColors.0.cgColor, incomingGradientColors.1.cgColor] as NSArray @@ -224,6 +225,7 @@ public final class PrincipalThemeEssentialGraphics { } if let outgoingGradientColors = outgoingGradientColors { self.outgoingBubbleGradientImage = generateImage(CGSize(width: 1.0, height: 512.0), opaque: true, scale: 1.0, rotatedContext: { size, context in + context.clear(CGRect(origin: CGPoint(), size: size)) var locations: [CGFloat] = [0.0, 1.0] let colors = [outgoingGradientColors.0.cgColor, outgoingGradientColors.1.cgColor] as NSArray From 91d88e63a312db211f18205f73f2d6ca0ae126ad Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 16 Jun 2021 00:35:58 +0400 Subject: [PATCH 07/13] Adjust blurs --- .../Sources/SoftwareGradientBackground.swift | 74 ++++++++++--------- .../DefaultDarkPresentationTheme.swift | 4 +- .../DefaultDarkTintedPresentationTheme.swift | 23 +++--- submodules/WallpaperBackgroundNode/BUILD | 1 + .../Sources/WallpaperBackgroundNode.swift | 47 ++++++++++-- 5 files changed, 96 insertions(+), 53 deletions(-) diff --git a/submodules/GradientBackground/Sources/SoftwareGradientBackground.swift b/submodules/GradientBackground/Sources/SoftwareGradientBackground.swift index 81366c7efb..df02af0f17 100644 --- a/submodules/GradientBackground/Sources/SoftwareGradientBackground.swift +++ b/submodules/GradientBackground/Sources/SoftwareGradientBackground.swift @@ -32,6 +32,45 @@ private func interpolatePoints(_ point1: CGPoint, _ point2: CGPoint, at factor: return CGPoint(x: interpolateFloat(point1.x, point2.x, at: factor), y: interpolateFloat(point1.y, point2.y, at: factor)) } +public func adjustSaturationInContext(context: DrawingContext, saturation: CGFloat) { + var buffer = vImage_Buffer() + buffer.data = context.bytes + buffer.width = UInt(context.size.width * context.scale) + buffer.height = UInt(context.size.height * context.scale) + buffer.rowBytes = context.bytesPerRow + + let divisor: Int32 = 0x1000 + + let rwgt: CGFloat = 0.3086 + let gwgt: CGFloat = 0.6094 + let bwgt: CGFloat = 0.0820 + + let adjustSaturation = saturation + + let a = (1.0 - adjustSaturation) * rwgt + adjustSaturation + let b = (1.0 - adjustSaturation) * rwgt + let c = (1.0 - adjustSaturation) * rwgt + let d = (1.0 - adjustSaturation) * gwgt + let e = (1.0 - adjustSaturation) * gwgt + adjustSaturation + let f = (1.0 - adjustSaturation) * gwgt + let g = (1.0 - adjustSaturation) * bwgt + let h = (1.0 - adjustSaturation) * bwgt + let i = (1.0 - adjustSaturation) * bwgt + adjustSaturation + + let satMatrix: [CGFloat] = [ + a, b, c, 0, + d, e, f, 0, + g, h, i, 0, + 0, 0, 0, 1 + ] + + var matrix: [Int16] = satMatrix.map { value in + return Int16(value * CGFloat(divisor)) + } + + vImageMatrixMultiply_ARGB8888(&buffer, &buffer, &matrix, divisor, nil, nil, vImage_Flags(kvImageDoNotTile)) +} + private func generateGradient(size: CGSize, colors: [UIColor], positions: [CGPoint], adjustSaturation: CGFloat = 1.0) -> UIImage { let width = Int(size.width) let height = Int(size.height) @@ -116,40 +155,7 @@ private func generateGradient(size: CGSize, colors: [UIColor], positions: [CGPoi } if abs(adjustSaturation - 1.0) > .ulpOfOne { - var buffer = vImage_Buffer() - buffer.data = context.bytes - buffer.width = UInt(width) - buffer.height = UInt(height) - buffer.rowBytes = context.bytesPerRow - - let divisor: Int32 = 0x1000 - - let rwgt: CGFloat = 0.3086 - let gwgt: CGFloat = 0.6094 - let bwgt: CGFloat = 0.0820 - - let a = (1.0 - adjustSaturation) * rwgt + adjustSaturation - let b = (1.0 - adjustSaturation) * rwgt - let c = (1.0 - adjustSaturation) * rwgt - let d = (1.0 - adjustSaturation) * gwgt - let e = (1.0 - adjustSaturation) * gwgt + adjustSaturation - let f = (1.0 - adjustSaturation) * gwgt - let g = (1.0 - adjustSaturation) * bwgt - let h = (1.0 - adjustSaturation) * bwgt - let i = (1.0 - adjustSaturation) * bwgt + adjustSaturation - - let satMatrix: [CGFloat] = [ - a, b, c, 0, - d, e, f, 0, - g, h, i, 0, - 0, 0, 0, 1 - ] - - var matrix: [Int16] = satMatrix.map { value in - return Int16(value * CGFloat(divisor)) - } - - vImageMatrixMultiply_ARGB8888(&buffer, &buffer, &matrix, divisor, nil, nil, vImage_Flags(kvImageDoNotTile)) + adjustSaturationInContext(context: context, saturation: adjustSaturation) } return context.generateImage()! diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift index 2d1e85c97e..520b5050f9 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift @@ -404,9 +404,11 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati unpinnedArchiveAvatarColor: PresentationThemeArchiveAvatarColors(backgroundColors: PresentationThemeGradientColors(topColor: UIColor(rgb: 0x666666), bottomColor: UIColor(rgb: 0x666666)), foregroundColor: UIColor(rgb: 0x000000)), onlineDotColor: UIColor(rgb: 0x4cc91f) ) + + let incomingBubbleAlpha: CGFloat = 0.9 let message = PresentationThemeChatMessage( - incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1D1D1D, alpha: 0.9), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1D1D1D, alpha: 0.9), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628), shadow: nil)), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), accentControlDisabledColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.4), mediaControlInnerBackgroundColor: UIColor(rgb: 0x262628), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff, alpha: 0.12), separator: UIColor(rgb: 0x000000), bar: UIColor(rgb: 0xffffff), barIconForeground: .clear, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)), + incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1D1D1D, alpha: incomingBubbleAlpha), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1D1D1D, alpha: incomingBubbleAlpha), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628), shadow: nil)), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), accentControlDisabledColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.4), mediaControlInnerBackgroundColor: UIColor(rgb: 0x262628), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff, alpha: 0.12), separator: UIColor(rgb: 0x000000), bar: UIColor(rgb: 0xffffff), barIconForeground: .clear, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)), outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x313131), gradientFill: UIColor(rgb: 0x313131), highlightedFill: UIColor(rgb: 0x464646), stroke: UIColor(rgb: 0x313131), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x313131), gradientFill: UIColor(rgb: 0x313131), highlightedFill: UIColor(rgb: 0x464646), stroke: UIColor(rgb: 0x313131), shadow: nil)), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), accentControlDisabledColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaControlInnerBackgroundColor: UIColor(rgb: 0x313131), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xffffff), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff).withAlphaComponent(0.12), separator: UIColor(rgb: 0xffffff, alpha: 0.5), bar: UIColor(rgb: 0xffffff), barIconForeground: .clear, barPositive: UIColor(rgb: 0xffffff), barNegative: UIColor(rgb: 0xffffff)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)), freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f), shadow: nil)), infoPrimaryTextColor: UIColor(rgb: 0xffffff), diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift index 800f4781ec..82523549b0 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift @@ -92,7 +92,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme passcode = passcode.withUpdated(backgroundColors: passcode.backgroundColors.withUpdated(topColor: accentColor?.withMultiplied(hue: 1.049, saturation: 0.573, brightness: 0.47), bottomColor: additionalBackgroundColor), buttonColor: mainBackgroundColor) rootController = rootController.withUpdated( tabBar: rootController.tabBar.withUpdated( - backgroundColor: mainBackgroundColor, + backgroundColor: mainBackgroundColor?.withAlphaComponent(0.9), separatorColor: mainSeparatorColor, iconColor: mainForegroundColor, selectedIconColor: accentColor, @@ -105,7 +105,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme secondaryTextColor: mainSecondaryColor, controlColor: mainSecondaryColor, accentTextColor: accentColor, - blurredBackgroundColor: mainBackgroundColor, + blurredBackgroundColor: mainBackgroundColor?.withAlphaComponent(0.9), opaqueBackgroundColor: mainBackgroundColor, separatorColor: mainSeparatorColor, segmentedBackgroundColor: mainInputColor, @@ -270,6 +270,8 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme highlightedIncomingBubbleColor = accentColor?.withMultiplied(hue: 1.03, saturation: 0.463, brightness: 0.29) highlightedOutgoingBubbleColor = outgoingBubbleFillColor?.withMultiplied(hue: 1.019, saturation: 0.609, brightness: 0.63) } + + let incomingFillColor = mainBackgroundColor?.withMultipliedAlpha(0.9) chat = chat.withUpdated( defaultWallpaper: defaultWallpaper, @@ -277,14 +279,14 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme incoming: chat.message.incoming.withUpdated( bubble: chat.message.incoming.bubble.withUpdated( withWallpaper: chat.message.outgoing.bubble.withWallpaper.withUpdated( - fill: mainBackgroundColor, - gradientFill: mainBackgroundColor, + fill: incomingFillColor, + gradientFill: incomingFillColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor ), withoutWallpaper: chat.message.outgoing.bubble.withoutWallpaper.withUpdated( - fill: mainBackgroundColor, - gradientFill: mainBackgroundColor, + fill: incomingFillColor, + gradientFill: incomingFillColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor ) @@ -385,7 +387,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme unreadBarStrokeColor: mainBackgroundColor ), inputPanel: chat.inputPanel.withUpdated( - panelBackgroundColor: mainBackgroundColor, + panelBackgroundColor: mainBackgroundColor?.withAlphaComponent(0.9), panelSeparatorColor: mainSeparatorColor, panelControlAccentColor: accentColor, panelControlColor: mainSecondaryTextColor?.withAlphaComponent(0.5), @@ -420,7 +422,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme buttonHighlightedStrokeColor: accentColor?.withMultiplied(hue: 1.019, saturation: 0.39, brightness: 0.07) ), historyNavigation: chat.historyNavigation.withUpdated( - fillColor: mainBackgroundColor, + fillColor: mainBackgroundColor?.withAlphaComponent(0.9), strokeColor: mainSeparatorColor, foregroundColor: mainSecondaryTextColor?.withAlphaComponent(0.5), badgeBackgroundColor: accentColor, @@ -509,7 +511,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres secondaryTextColor: mainSecondaryColor, controlColor: mainSecondaryColor, accentTextColor: accentColor, - blurredBackgroundColor: mainBackgroundColor, + blurredBackgroundColor: mainBackgroundColor.withAlphaComponent(0.9), opaqueBackgroundColor: mainBackgroundColor, separatorColor: mainSeparatorColor, badgeBackgroundColor: UIColor(rgb: 0xef5b5b), @@ -665,9 +667,10 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres ) let buttonStrokeColor = accentColor.withMultiplied(hue: 1.014, saturation: 0.56, brightness: 0.64).withAlphaComponent(0.15) + let incomingFillColor = mainBackgroundColor.withMultipliedAlpha(0.9) let message = PresentationThemeChatMessage( - incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil)), primaryTextColor: .white, secondaryTextColor: mainSecondaryTextColor.withAlphaComponent(0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: UIColor(rgb: 0xff6767), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: accentColor, accentControlColor: accentColor, accentControlDisabledColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.5), mediaControlInnerBackgroundColor: mainBackgroundColor, pendingActivityColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileTitleColor: accentColor, fileDescriptionColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileDurationColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23), polls: PresentationThemeChatBubblePolls(radioButton: accentColor.withMultiplied(hue: 0.995, saturation: 0.317, brightness: 0.51), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: mainSeparatorColor, bar: accentColor, barIconForeground: .white, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: accentColor.withAlphaComponent(0.2), textSelectionKnobColor: accentColor), + incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: incomingFillColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: incomingFillColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil)), primaryTextColor: .white, secondaryTextColor: mainSecondaryTextColor.withAlphaComponent(0.5), linkTextColor: accentColor, linkHighlightColor: accentColor.withAlphaComponent(0.5), scamColor: UIColor(rgb: 0xff6767), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: accentColor, accentControlColor: accentColor, accentControlDisabledColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaActiveControlColor: accentColor, mediaInactiveControlColor: accentColor.withAlphaComponent(0.5), mediaControlInnerBackgroundColor: mainBackgroundColor, pendingActivityColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileTitleColor: accentColor, fileDescriptionColor: mainSecondaryTextColor.withAlphaComponent(0.5), fileDurationColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.585, brightness: 0.23), polls: PresentationThemeChatBubblePolls(radioButton: accentColor.withMultiplied(hue: 0.995, saturation: 0.317, brightness: 0.51), radioProgress: accentColor, highlight: accentColor.withAlphaComponent(0.12), separator: mainSeparatorColor, bar: accentColor, barIconForeground: .white, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: accentColor.withAlphaComponent(0.2), textSelectionKnobColor: accentColor), outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: highlightedOutgoingBubbleColor, stroke: outgoingBubbleFillColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: outgoingBubbleFillColor, gradientFill: outgoingBubbleFillGradientColor, highlightedFill: highlightedOutgoingBubbleColor, stroke: outgoingBubbleFillColor, shadow: nil)), primaryTextColor: outgoingPrimaryTextColor, secondaryTextColor: outgoingSecondaryTextColor, linkTextColor: outgoingLinkTextColor, linkHighlightColor: UIColor.white.withAlphaComponent(0.5), scamColor: outgoingScamColor, textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: outgoingPrimaryTextColor, accentControlColor: outgoingPrimaryTextColor, accentControlDisabledColor: mainSecondaryTextColor.withAlphaComponent(0.5), mediaActiveControlColor: outgoingPrimaryTextColor, mediaInactiveControlColor: outgoingSecondaryTextColor, mediaControlInnerBackgroundColor: outgoingBubbleFillColor, pendingActivityColor: outgoingSecondaryTextColor, fileTitleColor: outgoingPrimaryTextColor, fileDescriptionColor: outgoingSecondaryTextColor, fileDurationColor: outgoingSecondaryTextColor, mediaPlaceholderColor: accentColor.withMultiplied(hue: 1.019, saturation: 0.804, brightness: 0.51), polls: PresentationThemeChatBubblePolls(radioButton: outgoingPrimaryTextColor, radioProgress: accentColor.withMultiplied(hue: 0.99, saturation: 0.56, brightness: 1.0), highlight: accentColor.withMultiplied(hue: 0.99, saturation: 0.56, brightness: 1.0).withAlphaComponent(0.12), separator: mainSeparatorColor, bar: outgoingPrimaryTextColor, barIconForeground: .clear, barPositive: outgoingPrimaryTextColor, barNegative: outgoingPrimaryTextColor), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: additionalBackgroundColor.withAlphaComponent(0.5), withoutWallpaper: additionalBackgroundColor.withAlphaComponent(0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: buttonStrokeColor), actionButtonsTextColor: PresentationThemeVariableColor(color: .white), textSelectionColor: UIColor.white.withAlphaComponent(0.2), textSelectionKnobColor: UIColor.white), freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: mainBackgroundColor, highlightedFill: highlightedIncomingBubbleColor, stroke: mainBackgroundColor, shadow: nil)), infoPrimaryTextColor: UIColor(rgb: 0xffffff), diff --git a/submodules/WallpaperBackgroundNode/BUILD b/submodules/WallpaperBackgroundNode/BUILD index 016c37baab..65b2180e3e 100644 --- a/submodules/WallpaperBackgroundNode/BUILD +++ b/submodules/WallpaperBackgroundNode/BUILD @@ -19,6 +19,7 @@ swift_library( "//submodules/AccountContext:AccountContext", "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", "//submodules/WallpaperResources:WallpaperResources", + "//submodules/FastBlur:FastBlur", ], visibility = [ "//visibility:public", diff --git a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift index b953b79c18..f31444712a 100644 --- a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift +++ b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift @@ -10,9 +10,25 @@ import AccountContext import SwiftSignalKit import WallpaperResources import Postbox +import FastBlur private let motionAmount: CGFloat = 32.0 +private func generateBlurredContents(image: UIImage) -> UIImage? { + let size = image.size.aspectFitted(CGSize(width: 64.0, height: 64.0)) + let context = DrawingContext(size: size, scale: 1.0, premultiplied: true, opaque: true, clear: false) + context.withFlippedContext { c in + c.draw(image.cgImage!, in: CGRect(origin: CGPoint(), size: size)) + } + + telegramFastBlurMore(Int32(context.size.width), Int32(context.size.height), Int32(context.bytesPerRow), context.bytes) + telegramFastBlurMore(Int32(context.size.width), Int32(context.size.height), Int32(context.bytesPerRow), context.bytes) + + adjustSaturationInContext(context: context, saturation: 1.7) + + return context.generateImage() +} + public final class WallpaperBackgroundNode: ASDisplayNode { public final class BubbleBackgroundNode: ASDisplayNode { public enum BubbleType { @@ -98,11 +114,8 @@ public final class WallpaperBackgroundNode: ASDisplayNode { var hasComplexGradient = false switch wallpaper { - case let .file(_, _, _, _, isPattern, _, _, _, settings): + case let .file(_, _, _, _, _, _, _, _, settings): hasComplexGradient = settings.colors.count >= 3 - if !isPattern { - needsCleanBackground = false - } case let .gradient(_, colors, _): hasComplexGradient = colors.count >= 3 default: @@ -127,8 +140,13 @@ public final class WallpaperBackgroundNode: ASDisplayNode { cleanWallpaperNode.frame = self.bounds self.insertSubnode(cleanWallpaperNode, at: 0) } - self.cleanWallpaperNode?.contents = backgroundNode.contentNode.contents - self.cleanWallpaperNode?.backgroundColor = backgroundNode.contentNode.backgroundColor + if let blurredBackgroundContents = backgroundNode.blurredBackgroundContents { + self.cleanWallpaperNode?.contents = blurredBackgroundContents.cgImage + self.cleanWallpaperNode?.backgroundColor = backgroundNode.contentNode.backgroundColor + } else { + self.cleanWallpaperNode?.contents = backgroundNode.contentNode.contents + self.cleanWallpaperNode?.backgroundColor = backgroundNode.contentNode.backgroundColor + } } else { if let cleanWallpaperNode = self.cleanWallpaperNode { self.cleanWallpaperNode = nil @@ -242,6 +260,8 @@ public final class WallpaperBackgroundNode: ASDisplayNode { private let useSharedAnimationPhase: Bool private let contentNode: ASDisplayNode + private var blurredBackgroundContents: UIImage? + private var gradientBackgroundNode: GradientBackgroundNode? private let patternImageNode: ASImageNode @@ -404,6 +424,7 @@ public final class WallpaperBackgroundNode: ASDisplayNode { self.contentNode.backgroundColor = nil self.contentNode.contents = nil + self.blurredBackgroundContents = nil self.motionEnabled = false self.wallpaperDisposable.set(nil) } else { @@ -417,7 +438,7 @@ public final class WallpaperBackgroundNode: ASDisplayNode { if gradientColors.count >= 2 { self.contentNode.backgroundColor = nil - self.contentNode.contents = generateImage(CGSize(width: 100.0, height: 200.0), rotatedContext: { size, context in + let image = generateImage(CGSize(width: 100.0, height: 200.0), rotatedContext: { size, context in let gradientColors = [UIColor(rgb: gradientColors[0]).cgColor, UIColor(rgb: gradientColors[1]).cgColor] as CFArray var locations: [CGFloat] = [0.0, 1.0] @@ -429,22 +450,27 @@ public final class WallpaperBackgroundNode: ASDisplayNode { context.translateBy(x: -size.width / 2.0, y: -size.height / 2.0) context.drawLinearGradient(gradient, start: CGPoint(x: 0.0, y: 0.0), end: CGPoint(x: 0.0, y: size.height), options: [.drawsBeforeStartLocation, .drawsAfterEndLocation]) - })?.cgImage + }) + self.contentNode.contents = image?.cgImage + self.blurredBackgroundContents = image self.wallpaperDisposable.set(nil) } else if gradientColors.count >= 1 { self.contentNode.backgroundColor = UIColor(rgb: gradientColors[0]) self.contentNode.contents = nil + self.blurredBackgroundContents = nil self.wallpaperDisposable.set(nil) } else { self.contentNode.backgroundColor = .white if let image = chatControllerBackgroundImage(theme: nil, wallpaper: wallpaper, mediaBox: self.context.sharedContext.accountManager.mediaBox, knockoutMode: false) { self.contentNode.contents = image.cgImage + self.blurredBackgroundContents = generateBlurredContents(image: image) self.wallpaperDisposable.set(nil) Queue.mainQueue().justDispatch { self._isReady.set(true) } } else if let image = chatControllerBackgroundImage(theme: nil, wallpaper: wallpaper, mediaBox: self.context.account.postbox.mediaBox, knockoutMode: false) { self.contentNode.contents = image.cgImage + self.blurredBackgroundContents = generateBlurredContents(image: image) self.wallpaperDisposable.set(nil) Queue.mainQueue().justDispatch { self._isReady.set(true) @@ -456,6 +482,11 @@ public final class WallpaperBackgroundNode: ASDisplayNode { return } strongSelf.contentNode.contents = image?.0?.cgImage + if let image = image?.0 { + strongSelf.blurredBackgroundContents = generateBlurredContents(image: image) + } else { + strongSelf.blurredBackgroundContents = nil + } strongSelf._isReady.set(true) })) } From 24115d3043ed93816284b53a2f435cb36db2936f Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 16 Jun 2021 00:57:45 +0400 Subject: [PATCH 08/13] Filter repeated patterns --- .../Sources/Themes/WallpaperPatternPanelNode.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift index 5819a342a5..c760f1f31e 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift @@ -9,6 +9,7 @@ import TelegramPresentationData import LegacyComponents import AccountContext import MergeLists +import Postbox private let itemSize = CGSize(width: 88.0, height: 88.0) private let inset: CGFloat = 12.0 @@ -267,12 +268,18 @@ final class WallpaperPatternPanelNode: ASDisplayNode { self.addSubnode(self.titleNode) self.addSubnode(self.labelNode) - self.disposable = ((telegramWallpapers(postbox: context.account.postbox, network: context.account.network) - |> map { wallpapers in + |> map { wallpapers -> [TelegramWallpaper] in + var existingIds = Set() + return wallpapers.filter { wallpaper in if case let .file(file) = wallpaper, wallpaper.isPattern, file.file.mimeType != "image/webp" { - return true + if existingIds.contains(file.file.fileId) { + return false + } else { + existingIds.insert(file.file.fileId) + return true + } } else { return false } From 90c95a5ae508e662cdf40ef80ea0f2e16d591566 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 16 Jun 2021 01:02:46 +0400 Subject: [PATCH 09/13] Apply updated wallpaper --- .../SettingsUI/Sources/Themes/ThemeAccentColorController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift index 8fc8684128..fd3900bcf3 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift @@ -247,7 +247,7 @@ final class ThemeAccentColorController: ViewController { baseTheme = .classic } - let wallpaper = state.initialWallpaper ?? coloredWallpaper + let wallpaper = coloredWallpaper ?? state.initialWallpaper let settings = TelegramThemeSettings(baseTheme: baseTheme, accentColor: state.accentColor, messageColors: state.messagesColors, wallpaper: wallpaper) let baseThemeReference = PresentationThemeReference.builtin(PresentationBuiltinThemeReference(baseTheme: baseTheme)) From fa8df3fcfa7396cbd2eaf38fb74327a9f44fffaa Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 16 Jun 2021 01:10:54 +0400 Subject: [PATCH 10/13] Fix default tinted theme --- .../Sources/DefaultDarkTintedPresentationTheme.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift index 82523549b0..9d35c1c9e0 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift @@ -757,7 +757,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres ) let chat = PresentationThemeChat( - defaultWallpaper: .color(accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18).argb), + defaultWallpaper: .file(id: 0, accessHash: 0, isCreator: false, isDefault: true, isPattern: true, isDark: false, slug: "fqv01SQemVIBAAAApND8LDRUhRU", file: TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: 36542425), partialReference: nil, resource: WallpaperDataResource(slug: "fqv01SQemVIBAAAApND8LDRUhRU"), previewRepresentations: [TelegramMediaImageRepresentation(dimensions: PixelDimensions(width: 600, height: 800), resource: WallpaperDataResource(slug: "fqv01SQemVIBAAAApND8LDRUhRU"), progressiveSizes: [], immediateThumbnailData: nil)], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "image/tgv", size: nil, attributes: []), settings: WallpaperSettings(colors: [0x1b2836, 0x121a22, 0x1b2836, 0x121a22], intensity: 50)), message: message, serviceMessage: serviceMessage, inputPanel: inputPanel, From c80bc87fea656a7653c46c1daa140e8c05c5214d Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 16 Jun 2021 01:28:52 +0400 Subject: [PATCH 11/13] Fix default night colors --- .../SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift | 3 +++ .../Sources/DefaultDarkPresentationTheme.swift | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift index c760f1f31e..dc8cb7abad 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift @@ -274,6 +274,9 @@ final class WallpaperPatternPanelNode: ASDisplayNode { return wallpapers.filter { wallpaper in if case let .file(file) = wallpaper, wallpaper.isPattern, file.file.mimeType != "image/webp" { + if file.id == 0 { + return true + } if existingIds.contains(file.file.fileId) { return false } else { diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift index 520b5050f9..9a4ff2f07e 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift @@ -409,7 +409,7 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati let message = PresentationThemeChatMessage( incoming: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1D1D1D, alpha: incomingBubbleAlpha), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1D1D1D, alpha: incomingBubbleAlpha), highlightedFill: UIColor(rgb: 0x353539), stroke: UIColor(rgb: 0x262628), shadow: nil)), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), accentControlDisabledColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.4), mediaControlInnerBackgroundColor: UIColor(rgb: 0x262628), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x1f1f1f).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0x737373), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff, alpha: 0.12), separator: UIColor(rgb: 0x000000), bar: UIColor(rgb: 0xffffff), barIconForeground: .clear, barPositive: UIColor(rgb: 0x00A700), barNegative: UIColor(rgb: 0xFE3824)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)), - outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x313131), gradientFill: UIColor(rgb: 0x313131), highlightedFill: UIColor(rgb: 0x464646), stroke: UIColor(rgb: 0x313131), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x313131), gradientFill: UIColor(rgb: 0x313131), highlightedFill: UIColor(rgb: 0x464646), stroke: UIColor(rgb: 0x313131), shadow: nil)), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), accentControlDisabledColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaControlInnerBackgroundColor: UIColor(rgb: 0x313131), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xffffff), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff).withAlphaComponent(0.12), separator: UIColor(rgb: 0xffffff, alpha: 0.5), bar: UIColor(rgb: 0xffffff), barIconForeground: .clear, barPositive: UIColor(rgb: 0xffffff), barNegative: UIColor(rgb: 0xffffff)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)), + outgoing: PresentationThemePartedColors(bubble: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x61BCF9), gradientFill: UIColor(rgb: 0x007AFF), highlightedFill: UIColor(rgb: 0x61BCF9), stroke: .clear, shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x61BCF9), gradientFill: UIColor(rgb: 0x007AFF), highlightedFill: UIColor(rgb: 0x61BCF9), stroke: .clear, shadow: nil)), primaryTextColor: UIColor(rgb: 0xffffff), secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), linkTextColor: UIColor(rgb: 0xffffff), linkHighlightColor: UIColor(rgb: 0xffffff, alpha: 0.5), scamColor: UIColor(rgb: 0xeb5545), textHighlightColor: UIColor(rgb: 0xf5c038), accentTextColor: UIColor(rgb: 0xffffff), accentControlColor: UIColor(rgb: 0xffffff), accentControlDisabledColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaActiveControlColor: UIColor(rgb: 0xffffff), mediaInactiveControlColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaControlInnerBackgroundColor: UIColor(rgb: 0x313131), pendingActivityColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileTitleColor: UIColor(rgb: 0xffffff), fileDescriptionColor: UIColor(rgb: 0xffffff, alpha: 0.5), fileDurationColor: UIColor(rgb: 0xffffff, alpha: 0.5), mediaPlaceholderColor: UIColor(rgb: 0x313131).mixedWith(UIColor(rgb: 0xffffff), alpha: 0.05), polls: PresentationThemeChatBubblePolls(radioButton: UIColor(rgb: 0xffffff), radioProgress: UIColor(rgb: 0xffffff), highlight: UIColor(rgb: 0xffffff).withAlphaComponent(0.12), separator: UIColor(rgb: 0xffffff, alpha: 0.5), bar: UIColor(rgb: 0xffffff), barIconForeground: .clear, barPositive: UIColor(rgb: 0xffffff), barNegative: UIColor(rgb: 0xffffff)), actionButtonsFillColor: PresentationThemeVariableColor(withWallpaper: UIColor(rgb: 0x000000, alpha: 0.5), withoutWallpaper: UIColor(rgb: 0x000000, alpha: 0.5)), actionButtonsStrokeColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xb2b2b2, alpha: 0.18)), actionButtonsTextColor: PresentationThemeVariableColor(color: UIColor(rgb: 0xffffff)), textSelectionColor: UIColor(rgb: 0xffffff, alpha: 0.2), textSelectionKnobColor: UIColor(rgb: 0xffffff)), freeform: PresentationThemeBubbleColor(withWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f), shadow: nil), withoutWallpaper: PresentationThemeBubbleColorComponents(fill: UIColor(rgb: 0x1f1f1f), highlightedFill: UIColor(rgb: 0x2a2a2a), stroke: UIColor(rgb: 0x1f1f1f), shadow: nil)), infoPrimaryTextColor: UIColor(rgb: 0xffffff), infoLinkTextColor: UIColor(rgb: 0xffffff), From 9561771c5f1d3c72d67006ec57bfbd1a698dc2ee Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 16 Jun 2021 12:36:08 +0400 Subject: [PATCH 12/13] Adjust inverted pattern presentation --- .../Sources/DefaultDayPresentationTheme.swift | 6 ++++++ .../Sources/WallpaperBackgroundNode.swift | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift index 073e5dc584..4d6bb7998f 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift @@ -20,6 +20,12 @@ public func dateFillNeedsBlur(theme: PresentationTheme, wallpaper: TelegramWallp return false } else if case .color = wallpaper { return false + } else if case let .file(_, _, _, _, isPattern, _, _, _, settings) = wallpaper { + if isPattern, let intensity = settings.intensity, intensity < 0 { + return false + } else { + return true + } } else { return true } diff --git a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift index f31444712a..794a687508 100644 --- a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift +++ b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift @@ -112,10 +112,14 @@ public final class WallpaperBackgroundNode: ASDisplayNode { needsCleanBackground = true } + var isInvertedGradient = false var hasComplexGradient = false switch wallpaper { case let .file(_, _, _, _, _, _, _, _, settings): hasComplexGradient = settings.colors.count >= 3 + if let intensity = settings.intensity, intensity < 0 { + isInvertedGradient = true + } case let .gradient(_, colors, _): hasComplexGradient = colors.count >= 3 default: @@ -125,6 +129,15 @@ public final class WallpaperBackgroundNode: ASDisplayNode { var needsGradientBackground = false var needsWallpaperBackground = false + if isInvertedGradient { + switch self.bubbleType { + case .free: + needsCleanBackground = false + case .incoming, .outgoing: + break + } + } + if needsCleanBackground { if hasComplexGradient { needsGradientBackground = backgroundNode.gradientBackgroundNode != nil From 654b9003e660c04f58207aafb55c0cfa398ce6fd Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 16 Jun 2021 12:39:43 +0400 Subject: [PATCH 13/13] Dismiss keyboard on color panel hide --- .../Sources/Themes/ThemeAccentColorControllerNode.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift index 3ae912fd42..6d8bb52b92 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift @@ -619,6 +619,12 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate } let colorPanelCollapsed = self.state.colorPanelCollapsed + + if colorPanelCollapsed != previousState.colorPanelCollapsed { + Queue.mainQueue().justDispatch { + self.colorPanelNode.view.endEditing(true) + } + } if (previousState.patternWallpaper != nil) != (self.state.patternWallpaper != nil) { self.patternButtonNode.setSelected(self.state.patternWallpaper != nil, animated: animated)