From 9f9ce2b850d1b33a81acbd0b30897b8d3c3d945d Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 21 Sep 2021 18:48:35 +0300 Subject: [PATCH 1/3] Fix send button icon in white dark theme --- .../Sources/ComponentsThemes.swift | 14 ++++++++++++++ .../Resources/PresentationResourcesChat.swift | 6 +++--- .../Sources/ChatTextInputActionButtonsNode.swift | 4 +++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift b/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift index 96c0501443..ccc7a13c8c 100644 --- a/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift +++ b/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift @@ -117,3 +117,17 @@ public extension NavigationControllerTheme { self.init(statusBar: navigationStatusBar, navigationBar: NavigationBarTheme(rootControllerTheme: presentationTheme), emptyAreaColor: presentationTheme.chatList.backgroundColor) } } + +public extension PresentationThemeBubbleColorComponents { + var hasSingleFillColor: Bool { + if self.fill.count == 1 { + return true + } + for i in 0 ..< self.fill.count - 1 { + if self.fill[i].argb != self.fill[i + 1].argb { + return false + } + } + return true + } +} diff --git a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift index 652ebaee1a..21990f7bec 100644 --- a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift +++ b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift @@ -433,7 +433,7 @@ public struct PresentationResourcesChat { return generateImage(CGSize(width: 33.0, height: 33.0), rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) let color: UIColor - if [.day, .night].contains(theme.referenceTheme.baseTheme) && theme.chat.message.outgoing.bubble.withWallpaper.fill.count > 1 { + if [.day, .night].contains(theme.referenceTheme.baseTheme) && !theme.chat.message.outgoing.bubble.withWallpaper.hasSingleFillColor { color = .white } else { color = theme.chat.inputPanel.actionControlForegroundColor @@ -470,7 +470,7 @@ public struct PresentationResourcesChat { return generateImage(CGSize(width: 33.0, height: 33.0), rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) let color: UIColor - if [.day, .night].contains(theme.referenceTheme.baseTheme) && theme.chat.message.outgoing.bubble.withWallpaper.fill.count > 1 { + if [.day, .night].contains(theme.referenceTheme.baseTheme) && !theme.chat.message.outgoing.bubble.withWallpaper.hasSingleFillColor { color = .white } else { color = theme.chat.inputPanel.actionControlForegroundColor @@ -515,7 +515,7 @@ public struct PresentationResourcesChat { context.translateBy(x: -imageRect.midX, y: -imageRect.midY) let color: UIColor - if [.day, .night].contains(theme.referenceTheme.baseTheme) && theme.chat.message.outgoing.bubble.withWallpaper.fill.count > 1 { + if [.day, .night].contains(theme.referenceTheme.baseTheme) && !theme.chat.message.outgoing.bubble.withWallpaper.hasSingleFillColor { color = .white } else { color = theme.chat.inputPanel.actionControlForegroundColor diff --git a/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift b/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift index 20c23bd685..1509557639 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift @@ -42,6 +42,8 @@ final class ChatTextInputActionButtonsNode: ASDisplayNode { self.micButton = ChatTextInputMediaRecordingButton(theme: theme, strings: strings, presentController: presentController) self.sendContainerNode = ASDisplayNode() + self.sendContainerNode.layer.allowsGroupOpacity = true + self.backgroundNode = ASDisplayNode() self.backgroundNode.backgroundColor = theme.chat.inputPanel.actionControlFillColor self.backgroundNode.clipsToBounds = true @@ -112,7 +114,7 @@ final class ChatTextInputActionButtonsNode: ASDisplayNode { self.backgroundNode.backgroundColor = theme.chat.inputPanel.actionControlFillColor - if [.day, .night].contains(theme.referenceTheme.baseTheme) && theme.chat.message.outgoing.bubble.withWallpaper.fill.count > 1 { + if [.day, .night].contains(theme.referenceTheme.baseTheme) && !theme.chat.message.outgoing.bubble.withWallpaper.hasSingleFillColor { self.backdropNode.isHidden = false } else { self.backdropNode.isHidden = true From 9aa4256dbf51dea6137788aee242667226bc9690 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 21 Sep 2021 20:28:40 +0300 Subject: [PATCH 2/3] Various Fixes --- .../Sources/VoiceChatController.swift | 5 +++++ submodules/TelegramUI/Sources/ChatController.swift | 12 ++++++++++++ .../Sources/ChatInterfaceInputContexts.swift | 2 +- .../TelegramUI/Sources/ChatThemeScreen.swift | 14 +++++++++++--- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index f2a5171029..2dc45059bc 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -1995,12 +1995,17 @@ public final class VoiceChatController: ViewController { } strongSelf.participantsNode.isHidden = !isLivestream + let hadPeer = strongSelf.peer != nil strongSelf.peer = peer strongSelf.currentTitleIsCustom = title != nil strongSelf.currentTitle = title ?? peer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder) strongSelf.updateTitle(transition: .immediate) strongSelf.titleNode.isRecording = isRecording + + if strongSelf.isScheduling && !hadPeer { + strongSelf.updateScheduleButtonTitle() + } } if !strongSelf.didSetDataReady { strongSelf.didSetDataReady = true diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 9601003efa..e8ee0a53ce 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -3401,6 +3401,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if !cachedGroupData.botInfos.isEmpty { hasBots = true } + let botCommands = cachedGroupData.botInfos.reduce(into: [], { result, info in + result.append(contentsOf: info.botInfo.commands) + }) + if !botCommands.isEmpty { + hasBotCommands = true + } if case let .known(value) = cachedGroupData.autoremoveTimeout { autoremoveTimeout = value?.effectiveValue } @@ -3409,6 +3415,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if !cachedChannelData.botInfos.isEmpty { hasBots = true } + let botCommands = cachedChannelData.botInfos.reduce(into: [], { result, info in + result.append(contentsOf: info.botInfo.commands) + }) + if !botCommands.isEmpty { + hasBotCommands = true + } } if case let .known(value) = cachedChannelData.autoremoveTimeout { autoremoveTimeout = value?.effectiveValue diff --git a/submodules/TelegramUI/Sources/ChatInterfaceInputContexts.swift b/submodules/TelegramUI/Sources/ChatInterfaceInputContexts.swift index 31eeb06242..fdc6118485 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceInputContexts.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceInputContexts.swift @@ -311,7 +311,7 @@ func inputTextPanelStateForChatPresentationInterfaceState(_ chatPresentationInte stickersEnabled = false } } - if chatPresentationInterfaceState.hasBots { + if chatPresentationInterfaceState.hasBots && chatPresentationInterfaceState.hasBotCommands { accessoryItems.append(.commands) } accessoryItems.append(.stickers(stickersEnabled)) diff --git a/submodules/TelegramUI/Sources/ChatThemeScreen.swift b/submodules/TelegramUI/Sources/ChatThemeScreen.swift index 43f8c64dc5..f69128b307 100644 --- a/submodules/TelegramUI/Sources/ChatThemeScreen.swift +++ b/submodules/TelegramUI/Sources/ChatThemeScreen.swift @@ -165,7 +165,7 @@ private struct ThemeSettingsThemeItemNodeTransition { private func ensureThemeVisible(listNode: ListView, emoticon: String?, animated: Bool) -> Bool { var resultNode: ThemeSettingsThemeItemIconNode? -// var previousNode: ThemeSettingsThemeItemIconNode? + var previousNode: ThemeSettingsThemeItemIconNode? var nextNode: ThemeSettingsThemeItemIconNode? listNode.forEachItemNode { node in guard let node = node as? ThemeSettingsThemeItemIconNode else { @@ -175,14 +175,22 @@ private func ensureThemeVisible(listNode: ListView, emoticon: String?, animated: if node.item?.emoticon == emoticon { resultNode = node } else { -// previousNode = node + previousNode = node } } else if nextNode == nil { nextNode = node } } if let resultNode = resultNode { - listNode.ensureItemNodeVisible(resultNode, animated: animated, overflow: 57.0) + var nodeToEnsure = resultNode + if case let .visible(resultVisibility) = resultNode.visibility, resultVisibility == 1.0 { + if let previousNode = previousNode, case let .visible(previousVisibility) = previousNode.visibility, previousVisibility < 0.5 { + nodeToEnsure = previousNode + } else if let nextNode = nextNode, case let .visible(nextVisibility) = nextNode.visibility, nextVisibility < 0.5 { + nodeToEnsure = nextNode + } + } + listNode.ensureItemNodeVisible(nodeToEnsure, animated: animated, overflow: 57.0) return true } else { return false From b57632c6702af4413e6bc39f197db9d99de9e704 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 22 Sep 2021 00:08:47 +0300 Subject: [PATCH 3/3] Various Fixes --- .../Sources/ChatItemGalleryFooterContentNode.swift | 13 +++++++++---- .../ShareController/Sources/ShareController.swift | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift index 208f1af5e9..670d8c3af9 100644 --- a/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift +++ b/submodules/GalleryUI/Sources/ChatItemGalleryFooterContentNode.swift @@ -587,8 +587,12 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } else if let media = media as? TelegramMediaFile, !media.isAnimated { for attribute in media.attributes { switch attribute { - case .Video: - canFullscreen = true + case let .Video(_, dimensions, _): + if dimensions.height > 0 { + if CGFloat(dimensions.width) / CGFloat(dimensions.height) > 1.33 { + canFullscreen = true + } + } default: break } @@ -1114,7 +1118,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } var preferredAction = ShareControllerPreferredAction.default - var actionCompletionText: String = "" + var actionCompletionText: String? if let generalMessageContentKind = generalMessageContentKind { switch generalMessageContentKind { case .image: @@ -1164,6 +1168,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll } else if let image = content.image { subject = .media(.webPage(webPage: WebpageReference(webpage), media: image)) preferredAction = .saveToCameraRoll + actionCompletionText = strongSelf.presentationData.strings.Gallery_ImageSaved } } } else if let file = m as? TelegramMediaFile { @@ -1185,7 +1190,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll self?.interacting?(false) } shareController.actionCompleted = { [weak self] in - if let strongSelf = self { + if let strongSelf = self, let actionCompletionText = actionCompletionText { let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 } strongSelf.controllerInteraction?.presentController(UndoOverlayController(presentationData: presentationData, content: .mediaSaved(text: actionCompletionText), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), nil) } diff --git a/submodules/ShareController/Sources/ShareController.swift b/submodules/ShareController/Sources/ShareController.swift index e917287c86..19c3b9effb 100644 --- a/submodules/ShareController/Sources/ShareController.swift +++ b/submodules/ShareController/Sources/ShareController.swift @@ -892,7 +892,7 @@ public final class ShareController: ViewController { } else { context = self.sharedContext.makeTempAccountContext(account: self.currentAccount) } - self.controllerNode.transitionToProgressWithValue(signal: SaveToCameraRoll.saveToCameraRoll(context: context, postbox: context.account.postbox, mediaReference: mediaReference) |> map(Optional.init)) + self.controllerNode.transitionToProgressWithValue(signal: SaveToCameraRoll.saveToCameraRoll(context: context, postbox: context.account.postbox, mediaReference: mediaReference) |> map(Optional.init), dismissImmediately: true) } private func switchToAccount(account: Account, animateIn: Bool) {