Merge commit 'b57632c6702af4413e6bc39f197db9d99de9e704'

This commit is contained in:
Ali 2021-09-22 01:56:54 +03:00
commit cfba93ccbf
9 changed files with 59 additions and 13 deletions

View File

@ -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)
}

View File

@ -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) {

View File

@ -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

View File

@ -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
}
}

View File

@ -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

View File

@ -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

View File

@ -311,7 +311,7 @@ func inputTextPanelStateForChatPresentationInterfaceState(_ chatPresentationInte
stickersEnabled = false
}
}
if chatPresentationInterfaceState.hasBots {
if chatPresentationInterfaceState.hasBots && chatPresentationInterfaceState.hasBotCommands {
accessoryItems.append(.commands)
}
accessoryItems.append(.stickers(stickersEnabled))

View File

@ -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

View File

@ -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