diff --git a/submodules/AsyncDisplayKit/Source/ASEditableTextNode.mm b/submodules/AsyncDisplayKit/Source/ASEditableTextNode.mm index cf7fd8bd2d..fdd08f0929 100644 --- a/submodules/AsyncDisplayKit/Source/ASEditableTextNode.mm +++ b/submodules/AsyncDisplayKit/Source/ASEditableTextNode.mm @@ -733,9 +733,6 @@ range.location = range.location + range.length - 1; range.length = 1; [self.textView scrollRangeToVisible:range]; - - CGPoint bottomOffset = CGPointMake(0, self.textView.contentSize.height - self.textView.bounds.size.height); - //[self.textView setContentOffset:bottomOffset animated:NO]; } #pragma mark - Keyboard diff --git a/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift b/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift index 884fd4f68a..0f128abe6a 100644 --- a/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift +++ b/submodules/BotPaymentsUI/Sources/BotCheckoutControllerNode.swift @@ -585,7 +585,7 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz } self.actionButtonPanelNode = ASDisplayNode() - self.actionButtonPanelNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.backgroundColor + self.actionButtonPanelNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.opaqueBackgroundColor self.actionButtonPanelSeparator = ASDisplayNode() self.actionButtonPanelSeparator.backgroundColor = self.presentationData.theme.rootController.navigationBar.separatorColor diff --git a/submodules/BotPaymentsUI/Sources/BotReceiptControllerNode.swift b/submodules/BotPaymentsUI/Sources/BotReceiptControllerNode.swift index dbffb11746..5a038bfb0c 100644 --- a/submodules/BotPaymentsUI/Sources/BotReceiptControllerNode.swift +++ b/submodules/BotPaymentsUI/Sources/BotReceiptControllerNode.swift @@ -296,7 +296,7 @@ final class BotReceiptControllerNode: ItemListControllerNode { } self.actionButtonPanelNode = ASDisplayNode() - self.actionButtonPanelNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.backgroundColor + self.actionButtonPanelNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.opaqueBackgroundColor self.actionButtonPanelSeparator = ASDisplayNode() self.actionButtonPanelSeparator.backgroundColor = self.presentationData.theme.rootController.navigationBar.separatorColor diff --git a/submodules/CallListUI/Sources/CallListControllerNode.swift b/submodules/CallListUI/Sources/CallListControllerNode.swift index 52a77c4730..0640d5ed22 100644 --- a/submodules/CallListUI/Sources/CallListControllerNode.swift +++ b/submodules/CallListUI/Sources/CallListControllerNode.swift @@ -226,7 +226,7 @@ final class CallListControllerNode: ASDisplayNode { self.openInfo = openInfo self.emptyStateUpdated = emptyStateUpdated - self.currentState = CallListNodeState(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: presentationData.dateTimeFormat, disableAnimations: presentationData.disableAnimations, editing: false, messageIdWithRevealedOptions: nil) + self.currentState = CallListNodeState(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: presentationData.dateTimeFormat, disableAnimations: true, editing: false, messageIdWithRevealedOptions: nil) self.statePromise = ValuePromise(self.currentState, ignoreRepeated: true) self.listNode = ListView() @@ -633,7 +633,7 @@ final class CallListControllerNode: ASDisplayNode { } func updateThemeAndStrings(presentationData: PresentationData) { - if presentationData.theme !== self.currentState.presentationData.theme || presentationData.strings !== self.currentState.presentationData.strings || presentationData.disableAnimations != self.currentState.disableAnimations { + if presentationData.theme !== self.currentState.presentationData.theme || presentationData.strings !== self.currentState.presentationData.strings { self.presentationData = presentationData self.leftOverlayNode.backgroundColor = presentationData.theme.list.blocksBackgroundColor @@ -652,7 +652,7 @@ final class CallListControllerNode: ASDisplayNode { self.updateEmptyPlaceholder(theme: presentationData.theme, strings: presentationData.strings, type: self.currentLocationAndType.type, isHidden: self.emptyTextNode.alpha.isZero) self.updateState { - return $0.withUpdatedPresentationData(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: presentationData.dateTimeFormat, disableAnimations: presentationData.disableAnimations) + return $0.withUpdatedPresentationData(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: presentationData.dateTimeFormat, disableAnimations: true) } self.listNode.forEachItemHeaderNode({ itemHeaderNode in diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 5cb9fd7fbf..04f07dcc1a 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -186,7 +186,6 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController title = filter.title } else if self.groupId == .root { title = self.presentationData.strings.DialogList_Title - self.navigationBar?.item = nil } else { title = self.presentationData.strings.ChatList_ArchivedChatsTitle } diff --git a/submodules/ChatListUI/Sources/ChatListControllerNode.swift b/submodules/ChatListUI/Sources/ChatListControllerNode.swift index da0b82118f..2a36dc0b26 100644 --- a/submodules/ChatListUI/Sources/ChatListControllerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListControllerNode.swift @@ -275,7 +275,7 @@ private final class ChatListContainerItemNode: ASDisplayNode { self.becameEmpty = becameEmpty self.emptyAction = emptyAction - self.listNode = ChatListNode(context: context, groupId: groupId, chatListFilter: filter, previewing: previewing, fillPreloadItems: controlsHistoryPreload, mode: .chatList, theme: presentationData.theme, fontSize: presentationData.listsFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations) + self.listNode = ChatListNode(context: context, groupId: groupId, chatListFilter: filter, previewing: previewing, fillPreloadItems: controlsHistoryPreload, mode: .chatList, theme: presentationData.theme, fontSize: presentationData.listsFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true) super.init() @@ -372,7 +372,7 @@ private final class ChatListContainerItemNode: ASDisplayNode { return presentationData.strings.VoiceOver_ScrollStatus(row, count).0 } - self.listNode.updateThemeAndStrings(theme: presentationData.theme, fontSize: presentationData.listsFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations) + self.listNode.updateThemeAndStrings(theme: presentationData.theme, fontSize: presentationData.listsFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true) self.emptyNode?.updateThemeAndStrings(theme: presentationData.theme, strings: presentationData.strings) } diff --git a/submodules/ChatListUI/Sources/ChatListSearchFiltersContainerNode.swift b/submodules/ChatListUI/Sources/ChatListSearchFiltersContainerNode.swift index 2224d24af0..c3dab73e8a 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchFiltersContainerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchFiltersContainerNode.swift @@ -211,7 +211,7 @@ final class ChatListSearchFiltersContainerNode: ASDisplayNode { let previousContentWidth = self.scrollNode.view.contentSize.width if self.currentParams?.presentationData.theme !== presentationData.theme { - self.backgroundColor = presentationData.theme.rootController.navigationBar.backgroundColor + self.backgroundColor = presentationData.theme.rootController.navigationBar.opaqueBackgroundColor self.selectedLineNode.image = generateImage(CGSize(width: 5.0, height: 3.0), rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) context.setFillColor(presentationData.theme.list.itemAccentColor.cgColor) diff --git a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift index cbb766ae94..37b6fb3053 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift @@ -515,7 +515,7 @@ public enum ChatListSearchEntry: Comparable, Identifiable { let header = ChatListSearchItemHeader(type: .messages, theme: presentationData.theme, strings: presentationData.strings, actionTitle: nil, action: nil) let selection: ChatHistoryMessageSelection = selected.flatMap { .selectable(selected: $0) } ?? .none if let tagMask = tagMask, tagMask != .photoOrVideo { - return ListMessageItem(presentationData: ChatPresentationData(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: .builtin(nil, WallpaperSettings())), fontSize: presentationData.fontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations, largeEmoji: false, chatBubbleCorners: PresentationChatBubbleCorners(mainRadius: 0.0, auxiliaryRadius: 0.0, mergeBubbleCorners: false)), context: context, chatLocation: .peer(peer.peerId), interaction: listInteraction, message: message, selection: selection, displayHeader: enableHeaders && !displayCustomHeader, customHeader: nil, hintIsLink: tagMask == .webPage, isGlobalSearchResult: true) + return ListMessageItem(presentationData: ChatPresentationData(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: .builtin(nil, WallpaperSettings())), fontSize: presentationData.fontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true, largeEmoji: false, chatBubbleCorners: PresentationChatBubbleCorners(mainRadius: 0.0, auxiliaryRadius: 0.0, mergeBubbleCorners: false)), context: context, chatLocation: .peer(peer.peerId), interaction: listInteraction, message: message, selection: selection, displayHeader: enableHeaders && !displayCustomHeader, customHeader: nil, hintIsLink: tagMask == .webPage, isGlobalSearchResult: true) } else { return ChatListItem(presentationData: presentationData, context: context, peerGroupId: .root, filterData: nil, index: ChatListIndex(pinningIndex: nil, messageIndex: message.index), content: .peer(messages: [message], peer: peer, combinedReadState: readState, isRemovedFromTotalUnreadCount: false, presence: nil, summaryInfo: ChatListMessageTagSummaryInfo(), embeddedState: nil, inputActivities: nil, promoInfo: nil, ignoreUnreadBadge: true, displayAsMessage: false, hasFailedMessages: false), editing: false, hasActiveRevealControls: false, selected: false, header: tagMask == nil ? header : nil, enableContextActions: false, hiddenOffset: false, interaction: interaction) } @@ -737,7 +737,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { let presentationData = context.sharedContext.currentPresentationData.with { $0 } self.presentationData = presentationData - self.presentationDataPromise.set(.single(ChatListPresentationData(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: self.presentationData.disableAnimations))) + self.presentationDataPromise.set(.single(ChatListPresentationData(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: true))) self.searchStatePromise.set(self.searchStateValue) self.selectedMessages = interaction.getSelectedMessageIds() @@ -1502,7 +1502,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { |> deliverOnMainQueue).start(next: { [weak self] presentationData in if let strongSelf = self { strongSelf.presentationData = presentationData - strongSelf.presentationDataPromise.set(.single(ChatListPresentationData(theme: presentationData.theme, fontSize: presentationData.listsFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations))) + strongSelf.presentationDataPromise.set(.single(ChatListPresentationData(theme: presentationData.theme, fontSize: presentationData.listsFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true))) strongSelf.listNode.forEachItemHeaderNode({ itemHeaderNode in if let itemHeaderNode = itemHeaderNode as? ChatListSearchItemHeaderNode { diff --git a/submodules/ChatListUI/Sources/ChatListSearchMessageSelectionPanelNode.swift b/submodules/ChatListUI/Sources/ChatListSearchMessageSelectionPanelNode.swift index d126d37553..765d79ab65 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchMessageSelectionPanelNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchMessageSelectionPanelNode.swift @@ -121,7 +121,7 @@ final class ChatListSearchMessageSelectionPanelNode: ASDisplayNode { if presentationData.theme !== self.theme { self.theme = presentationData.theme - self.backgroundNode.backgroundColor = presentationData.theme.rootController.navigationBar.backgroundColor + self.backgroundNode.backgroundColor = presentationData.theme.rootController.navigationBar.opaqueBackgroundColor self.separatorNode.backgroundColor = presentationData.theme.rootController.navigationBar.separatorColor self.deleteButton.setImage(generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Accessory Panels/MessageSelectionTrash"), color: presentationData.theme.chat.inputPanel.panelControlAccentColor), for: [.normal]) diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index f86624bf5b..b12a6f3461 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -875,7 +875,7 @@ public final class ChatListNode: ListView { let removingPeerId = currentRemovingPeerId.with { $0 } - var disableAnimations = state.presentationData.disableAnimations + var disableAnimations = true if previousState.editing != state.editing { disableAnimations = false } else { @@ -1332,7 +1332,7 @@ public final class ChatListNode: ListView { } public func updateThemeAndStrings(theme: PresentationTheme, fontSize: PresentationFontSize, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, nameSortOrder: PresentationPersonNameOrder, nameDisplayOrder: PresentationPersonNameOrder, disableAnimations: Bool) { - if theme !== self.currentState.presentationData.theme || strings !== self.currentState.presentationData.strings || dateTimeFormat != self.currentState.presentationData.dateTimeFormat || disableAnimations != self.currentState.presentationData.disableAnimations { + if theme !== self.currentState.presentationData.theme || strings !== self.currentState.presentationData.strings || dateTimeFormat != self.currentState.presentationData.dateTimeFormat { self.theme = theme if self.keepTopItemOverscrollBackground != nil { self.keepTopItemOverscrollBackground = ListViewKeepTopItemOverscrollBackground(color: theme.chatList.pinnedItemBackgroundColor, direction: true) diff --git a/submodules/ContactListUI/Sources/ContactListNode.swift b/submodules/ContactListUI/Sources/ContactListNode.swift index a24a0fa1b4..c6c6b9ffa6 100644 --- a/submodules/ContactListUI/Sources/ContactListNode.swift +++ b/submodules/ContactListUI/Sources/ContactListNode.swift @@ -884,7 +884,7 @@ public final class ContactListNode: ASDisplayNode { self.presentationData = presentationData self.listNode = ListView() - self.listNode.dynamicBounceEnabled = !self.presentationData.disableAnimations + self.listNode.dynamicBounceEnabled = false self.listNode.accessibilityPageScrolledString = { row, count in return presentationData.strings.VoiceOver_ScrollStatus(row, count).0 } @@ -1338,8 +1338,6 @@ public final class ContactListNode: ASDisplayNode { animation = .insertion } else if hadPermissionInfo != hasPermissionInfo { animation = .insertion - } else if let previous = previous, !presentationData.disableAnimations, (entries.count - previous.count) < 20 { - animation = .default } else { animation = .none } @@ -1366,11 +1364,10 @@ public final class ContactListNode: ASDisplayNode { if let strongSelf = self { let previousTheme = strongSelf.presentationData.theme let previousStrings = strongSelf.presentationData.strings - let previousDisableAnimations = strongSelf.presentationData.disableAnimations strongSelf.presentationData = presentationData - if previousTheme !== presentationData.theme || previousStrings !== presentationData.strings || previousDisableAnimations != presentationData.disableAnimations { + if previousTheme !== presentationData.theme || previousStrings !== presentationData.strings { strongSelf.backgroundColor = presentationData.theme.chatList.backgroundColor strongSelf.listNode.verticalScrollIndicatorColor = presentationData.theme.list.scrollIndicatorColor strongSelf.presentationDataPromise.set(.single(presentationData)) @@ -1385,7 +1382,7 @@ public final class ContactListNode: ASDisplayNode { strongSelf.authorizationNode.isHidden = authorizationPreviousHidden strongSelf.addSubnode(strongSelf.authorizationNode) - strongSelf.listNode.dynamicBounceEnabled = !presentationData.disableAnimations + strongSelf.listNode.dynamicBounceEnabled = false strongSelf.listNode.forEachAccessoryItemNode({ accessoryItemNode in if let accessoryItemNode = accessoryItemNode as? ContactsSectionHeaderAccessoryItemNode { diff --git a/submodules/ContactListUI/Sources/InviteContactsCountPanelNode.swift b/submodules/ContactListUI/Sources/InviteContactsCountPanelNode.swift index 47d68ed1af..2abe674765 100644 --- a/submodules/ContactListUI/Sources/InviteContactsCountPanelNode.swift +++ b/submodules/ContactListUI/Sources/InviteContactsCountPanelNode.swift @@ -37,7 +37,7 @@ final class InviteContactsCountPanelNode: ASDisplayNode { super.init() - self.backgroundColor = theme.rootController.navigationBar.backgroundColor + self.backgroundColor = theme.rootController.navigationBar.opaqueBackgroundColor self.addSubnode(self.button) self.addSubnode(self.separatorNode) diff --git a/submodules/Display/Source/ListViewTransactionQueue.swift b/submodules/Display/Source/ListViewTransactionQueue.swift index a790dc1e82..af78b3f10e 100644 --- a/submodules/Display/Source/ListViewTransactionQueue.swift +++ b/submodules/Display/Source/ListViewTransactionQueue.swift @@ -32,6 +32,8 @@ public final class ListViewTransactionQueue { } } }) + } else { + assert(true) } } diff --git a/submodules/Display/Source/NavigationBar.swift b/submodules/Display/Source/NavigationBar.swift index a79e95683d..701965ae0b 100644 --- a/submodules/Display/Source/NavigationBar.swift +++ b/submodules/Display/Source/NavigationBar.swift @@ -132,6 +132,8 @@ public final class NavigationBackgroundNode: ASDisplayNode { private var effectView: UIVisualEffectView? private let backgroundNode: ASDisplayNode + private var validLayout: (CGSize, CGFloat)? + public init(color: UIColor, enableBlur: Bool = true) { self._color = .clear self.enableBlur = enableBlur @@ -183,7 +185,11 @@ public final class NavigationBackgroundNode: ASDisplayNode { } } - effectView.frame = self.bounds + if let (size, cornerRadius) = self.validLayout { + effectView.frame = CGRect(origin: CGPoint(), size: size) + ContainedViewLayoutTransition.immediate.updateCornerRadius(layer: effectView.layer, cornerRadius: cornerRadius) + effectView.clipsToBounds = !cornerRadius.isZero + } self.effectView = effectView self.view.insertSubview(effectView, at: 0) } @@ -204,7 +210,7 @@ public final class NavigationBackgroundNode: ASDisplayNode { self.updateBackgroundBlur(forceKeepBlur: forceKeepBlur) } - public func update(size: CGSize, transition: ContainedViewLayoutTransition) { + public func update(size: CGSize, cornerRadius: CGFloat = 0.0, transition: ContainedViewLayoutTransition) { let contentFrame = CGRect(origin: CGPoint(), size: size) transition.updateFrame(node: self.backgroundNode, frame: contentFrame) if let effectView = self.effectView, effectView.frame != contentFrame { @@ -215,6 +221,12 @@ public final class NavigationBackgroundNode: ASDisplayNode { } } } + + transition.updateCornerRadius(node: self.backgroundNode, cornerRadius: cornerRadius) + if let effectView = self.effectView { + transition.updateCornerRadius(layer: effectView.layer, cornerRadius: cornerRadius) + effectView.clipsToBounds = !cornerRadius.isZero + } } } @@ -828,7 +840,7 @@ open class NavigationBar: ASDisplayNode { } self.stripeNode.backgroundColor = self.presentationData.theme.separatorColor - self.backgroundNode = NavigationBackgroundNode(color: self.presentationData.theme.backgroundColor) + self.backgroundNode = NavigationBackgroundNode(color: self.presentationData.theme.backgroundColor, enableBlur: self.presentationData.theme.enableBackgroundBlur) self.additionalContentNode = SparseNode() super.init() @@ -962,7 +974,7 @@ open class NavigationBar: ASDisplayNode { expansionHeight = contentNode.height let additionalExpansionHeight: CGFloat = self.secondaryContentNode != nil && appearsHidden ? NavigationBar.defaultSecondaryContentHeight : 0.0 - contentNodeFrame = CGRect(origin: CGPoint(x: 0.0, y: size.height - additionalContentHeight - expansionHeight - apparentAdditionalHeight - additionalExpansionHeight), size: CGSize(width: size.width, height: expansionHeight)) + contentNodeFrame = CGRect(origin: CGPoint(x: 0.0, y: size.height - (appearsHidden ? 0.0 : additionalContentHeight) - expansionHeight - apparentAdditionalHeight - additionalExpansionHeight), size: CGSize(width: size.width, height: expansionHeight)) if appearsHidden { if self.secondaryContentNode != nil { contentNodeFrame.origin.y += NavigationBar.defaultSecondaryContentHeight diff --git a/submodules/Display/Source/TextNode.swift b/submodules/Display/Source/TextNode.swift index e010783205..6df461f382 100644 --- a/submodules/Display/Source/TextNode.swift +++ b/submodules/Display/Source/TextNode.swift @@ -242,6 +242,14 @@ public final class TextNodeLayout: NSObject { return 0.0 } } + + public var trailingLineIsRTL: Bool { + if let lastLine = self.lines.last { + return lastLine.isRTL + } else { + return false + } + } public func attributesAtPoint(_ point: CGPoint, orNearest: Bool) -> (Int, [NSAttributedString.Key: Any])? { if let attributedString = self.attributedString { diff --git a/submodules/HashtagSearchUI/Sources/HashtagSearchController.swift b/submodules/HashtagSearchUI/Sources/HashtagSearchController.swift index 693401351e..034972000f 100644 --- a/submodules/HashtagSearchUI/Sources/HashtagSearchController.swift +++ b/submodules/HashtagSearchUI/Sources/HashtagSearchController.swift @@ -40,7 +40,7 @@ public final class HashtagSearchController: TelegramBaseController { self.title = query self.navigationItem.backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Back, style: .plain, target: nil, action: nil) - let chatListPresentationData = ChatListPresentationData(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: self.presentationData.disableAnimations) + let chatListPresentationData = ChatListPresentationData(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: true) let location: SearchMessagesLocation = .general(tags: nil, minDate: nil, maxDate: nil) let search = context.engine.messages.searchMessages(location: location, query: query, state: nil) @@ -115,17 +115,37 @@ public final class HashtagSearchController: TelegramBaseController { } override public func loadDisplayNode() { - self.displayNode = HashtagSearchControllerNode(context: self.context, peer: self.peer, query: self.query, theme: self.presentationData.theme, strings: self.presentationData.strings, navigationController: self.navigationController as? NavigationController) + self.displayNode = HashtagSearchControllerNode(context: self.context, peer: self.peer, query: self.query, theme: self.presentationData.theme, strings: self.presentationData.strings, navigationBar: self.navigationBar, navigationController: self.navigationController as? NavigationController) if let chatController = self.controllerNode.chatController { chatController.parentController = self } self.displayNodeDidLoad() } + + private var suspendNavigationBarLayout: Bool = false + private var suspendedNavigationBarLayout: ContainerViewLayout? + private var additionalNavigationBarBackgroundHeight: CGFloat = 0.0 + + override public func updateNavigationBarLayout(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { + if self.suspendNavigationBarLayout { + self.suspendedNavigationBarLayout = layout + return + } + self.applyNavigationBarLayout(layout, navigationLayout: self.navigationLayout(layout: layout), additionalBackgroundHeight: self.additionalNavigationBarBackgroundHeight, transition: transition) + } override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { + self.suspendNavigationBarLayout = true + super.containerLayoutUpdated(layout, transition: transition) - self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, transition: transition) + self.additionalNavigationBarBackgroundHeight = self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, transition: transition) + + self.suspendNavigationBarLayout = false + if let suspendedNavigationBarLayout = self.suspendedNavigationBarLayout { + self.suspendedNavigationBarLayout = suspendedNavigationBarLayout + self.applyNavigationBarLayout(suspendedNavigationBarLayout, navigationLayout: self.navigationLayout(layout: layout), additionalBackgroundHeight: self.additionalNavigationBarBackgroundHeight, transition: transition) + } } } diff --git a/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift b/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift index fe178a5bab..b7b0f16a86 100644 --- a/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift +++ b/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift @@ -10,12 +10,14 @@ import ChatListUI import SegmentedControlNode final class HashtagSearchControllerNode: ASDisplayNode { - private let toolbarBackgroundNode: ASDisplayNode + private let navigationBar: NavigationBar? + + private let toolbarBackgroundNode: NavigationBackgroundNode private let toolbarSeparatorNode: ASDisplayNode private let segmentedControlNode: SegmentedControlNode let listNode: ListView - var chatController: ChatController? + let chatController: ChatController? private let context: AccountContext private let query: String @@ -24,9 +26,9 @@ final class HashtagSearchControllerNode: ASDisplayNode { private var enqueuedTransitions: [(ChatListSearchContainerTransition, Bool)] = [] private var hasValidLayout = false - var navigationBar: NavigationBar? - - init(context: AccountContext, peer: Peer?, query: String, theme: PresentationTheme, strings: PresentationStrings, navigationController: NavigationController?) { + init(context: AccountContext, peer: Peer?, query: String, theme: PresentationTheme, strings: PresentationStrings, navigationBar: NavigationBar?, navigationController: NavigationController?) { + self.navigationBar = navigationBar + self.context = context self.query = query self.listNode = ListView() @@ -34,8 +36,7 @@ final class HashtagSearchControllerNode: ASDisplayNode { return strings.VoiceOver_ScrollStatus(row, count).0 } - self.toolbarBackgroundNode = ASDisplayNode() - self.toolbarBackgroundNode.backgroundColor = theme.rootController.navigationBar.backgroundColor + self.toolbarBackgroundNode = NavigationBackgroundNode(color: theme.rootController.navigationBar.blurredBackgroundColor) self.toolbarSeparatorNode = ASDisplayNode() self.toolbarSeparatorNode.backgroundColor = theme.rootController.navigationBar.separatorColor @@ -102,13 +103,13 @@ final class HashtagSearchControllerNode: ASDisplayNode { } } - func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) { + func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) -> CGFloat { self.containerLayout = (layout, navigationBarHeight) - if self.chatController != nil && self.toolbarBackgroundNode.supernode == nil { - self.addSubnode(self.toolbarBackgroundNode) - self.addSubnode(self.toolbarSeparatorNode) - self.addSubnode(self.segmentedControlNode) + if self.chatController != nil && self.toolbarSeparatorNode.supernode == nil { + //self.addSubnode(self.toolbarBackgroundNode) + self.navigationBar?.additionalContentNode.addSubnode(self.toolbarSeparatorNode) + self.navigationBar?.additionalContentNode.addSubnode(self.segmentedControlNode) } var insets = layout.insets(options: [.input]) @@ -118,10 +119,11 @@ final class HashtagSearchControllerNode: ASDisplayNode { let panelY: CGFloat = insets.top - UIScreenPixel - 4.0 transition.updateFrame(node: self.toolbarBackgroundNode, frame: CGRect(origin: CGPoint(x: 0.0, y: panelY), size: CGSize(width: layout.size.width, height: toolbarHeight))) - transition.updateFrame(node: self.toolbarSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: panelY + toolbarHeight), size: CGSize(width: layout.size.width, height: UIScreenPixel))) + self.toolbarBackgroundNode.update(size: self.toolbarBackgroundNode.bounds.size, transition: transition) + transition.updateFrame(node: self.toolbarSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: panelY), size: CGSize(width: layout.size.width, height: UIScreenPixel))) let controlSize = self.segmentedControlNode.updateLayout(.stretchToFill(width: layout.size.width - 14.0 * 2.0), transition: transition) - transition.updateFrame(node: self.segmentedControlNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - controlSize.width) / 2.0), y: panelY + floor((toolbarHeight - controlSize.height) / 2.0)), size: controlSize)) + transition.updateFrame(node: self.segmentedControlNode, frame: CGRect(origin: CGPoint(x: floor((layout.size.width - controlSize.width) / 2.0), y: panelY + 2.0 + floor((toolbarHeight - controlSize.height) / 2.0)), size: controlSize)) if let chatController = self.chatController { insets.top += toolbarHeight - 4.0 @@ -152,5 +154,11 @@ final class HashtagSearchControllerNode: ASDisplayNode { self.dequeueTransition() } } + + if self.chatController != nil { + return toolbarHeight + } else { + return 0.0 + } } } diff --git a/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift b/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift index 404f42cc07..510a599157 100644 --- a/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift +++ b/submodules/ItemListPeerItem/Sources/ItemListPeerItem.swift @@ -1408,7 +1408,7 @@ public final class ItemListPeerItemHeaderNode: ListViewItemHeaderNode, ItemListH self.backgroundNode.backgroundColor = theme.list.blocksBackgroundColor self.snappedBackgroundNode = ASDisplayNode() - self.snappedBackgroundNode.backgroundColor = theme.rootController.navigationBar.backgroundColor + self.snappedBackgroundNode.backgroundColor = theme.rootController.navigationBar.opaqueBackgroundColor self.snappedBackgroundNode.alpha = 0.0 self.separatorNode = ASDisplayNode() @@ -1467,7 +1467,7 @@ public final class ItemListPeerItemHeaderNode: ListViewItemHeaderNode, ItemListH self.theme = theme self.backgroundNode.backgroundColor = theme.list.blocksBackgroundColor - self.snappedBackgroundNode.backgroundColor = theme.rootController.navigationBar.backgroundColor + self.snappedBackgroundNode.backgroundColor = theme.rootController.navigationBar.opaqueBackgroundColor self.separatorNode.backgroundColor = theme.list.itemBlocksSeparatorColor let titleFont = Font.regular(13.0) diff --git a/submodules/LegacyUI/Sources/TelegramInitializeLegacyComponents.swift b/submodules/LegacyUI/Sources/TelegramInitializeLegacyComponents.swift index e67f8afd4f..a9bc6176eb 100644 --- a/submodules/LegacyUI/Sources/TelegramInitializeLegacyComponents.swift +++ b/submodules/LegacyUI/Sources/TelegramInitializeLegacyComponents.swift @@ -263,7 +263,7 @@ private final class LegacyComponentsGlobalsProviderImpl: NSObject, LegacyCompone theme = defaultPresentationTheme } let barTheme = theme.rootController.navigationBar - return TGNavigationBarPallete(backgroundColor: barTheme.backgroundColor, separatorColor: barTheme.separatorColor, titleColor: barTheme.primaryTextColor, tintColor: barTheme.accentTextColor) + return TGNavigationBarPallete(backgroundColor: barTheme.opaqueBackgroundColor, separatorColor: barTheme.separatorColor, titleColor: barTheme.primaryTextColor, tintColor: barTheme.accentTextColor) } func menuSheetPallete() -> TGMenuSheetPallete! { @@ -308,7 +308,7 @@ private final class LegacyComponentsGlobalsProviderImpl: NSObject, LegacyCompone let navigationBar = presentationTheme.rootController.navigationBar let tabBar = presentationTheme.rootController.tabBar - return TGMediaAssetsPallete(dark: presentationTheme.overallDarkAppearance, backgroundColor: theme.plainBackgroundColor, selectionColor: theme.itemHighlightedBackgroundColor, separatorColor: theme.itemPlainSeparatorColor, textColor: theme.itemPrimaryTextColor, secondaryTextColor: theme.controlSecondaryColor, accentColor: theme.itemAccentColor, destructiveColor: theme.itemDestructiveColor, barBackgroundColor: tabBar.backgroundColor, barSeparatorColor: tabBar.separatorColor, navigationTitleColor: navigationBar.primaryTextColor, badge: generateStretchableFilledCircleImage(diameter: 22.0, color: navigationBar.accentTextColor), badgeTextColor: navigationBar.backgroundColor, sendIconImage: PresentationResourcesChat.chatInputPanelSendButtonImage(presentationTheme), doneIconImage: PresentationResourcesChat.chatInputPanelApplyButtonImage(presentationTheme), maybeAccentColor: navigationBar.accentTextColor) + return TGMediaAssetsPallete(dark: presentationTheme.overallDarkAppearance, backgroundColor: theme.plainBackgroundColor, selectionColor: theme.itemHighlightedBackgroundColor, separatorColor: theme.itemPlainSeparatorColor, textColor: theme.itemPrimaryTextColor, secondaryTextColor: theme.controlSecondaryColor, accentColor: theme.itemAccentColor, destructiveColor: theme.itemDestructiveColor, barBackgroundColor: tabBar.backgroundColor, barSeparatorColor: tabBar.separatorColor, navigationTitleColor: navigationBar.primaryTextColor, badge: generateStretchableFilledCircleImage(diameter: 22.0, color: navigationBar.accentTextColor), badgeTextColor: navigationBar.opaqueBackgroundColor, sendIconImage: PresentationResourcesChat.chatInputPanelSendButtonImage(presentationTheme), doneIconImage: PresentationResourcesChat.chatInputPanelApplyButtonImage(presentationTheme), maybeAccentColor: navigationBar.accentTextColor) } func checkButtonPallete() -> TGCheckButtonPallete! { diff --git a/submodules/LocationUI/Sources/LocationMapHeaderNode.swift b/submodules/LocationUI/Sources/LocationMapHeaderNode.swift index 50b7f715c1..e267dedc67 100644 --- a/submodules/LocationUI/Sources/LocationMapHeaderNode.swift +++ b/submodules/LocationUI/Sources/LocationMapHeaderNode.swift @@ -15,7 +15,7 @@ private func generateBackgroundImage(theme: PresentationTheme) -> UIImage? { context.clear(CGRect(origin: CGPoint(), size: size)) context.setShadow(offset: CGSize(), blur: 10.0, color: UIColor(rgb: 0x000000, alpha: 0.2).cgColor) - context.setFillColor(theme.rootController.navigationBar.backgroundColor.cgColor) + context.setFillColor(theme.rootController.navigationBar.opaqueBackgroundColor.cgColor) let path = UIBezierPath(roundedRect: CGRect(origin: CGPoint(x: panelInset, y: panelInset), size: CGSize(width: cornerRadius * 2.0, height: cornerRadius * 2.0)), cornerRadius: cornerRadius) context.addPath(path.cgPath) context.fillPath() diff --git a/submodules/LocationUI/Sources/LocationOptionsNode.swift b/submodules/LocationUI/Sources/LocationOptionsNode.swift index 9aee841c66..950f0df748 100644 --- a/submodules/LocationUI/Sources/LocationOptionsNode.swift +++ b/submodules/LocationUI/Sources/LocationOptionsNode.swift @@ -19,7 +19,7 @@ final class LocationOptionsNode: ASDisplayNode { self.presentationData = presentationData self.backgroundNode = ASDisplayNode() - self.backgroundNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.backgroundColor + self.backgroundNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.opaqueBackgroundColor self.separatorNode = ASDisplayNode() self.separatorNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.separatorColor @@ -47,7 +47,7 @@ final class LocationOptionsNode: ASDisplayNode { func updatePresentationData(_ presentationData: PresentationData) { self.presentationData = presentationData - self.backgroundNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.backgroundColor + self.backgroundNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.opaqueBackgroundColor self.separatorNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.separatorColor self.segmentedControlNode.updateTheme(SegmentedControlTheme(theme: self.presentationData.theme)) } diff --git a/submodules/MessageReactionListUI/Sources/MessageReactionListController.swift b/submodules/MessageReactionListUI/Sources/MessageReactionListController.swift index 94374463e3..ba463333d1 100644 --- a/submodules/MessageReactionListUI/Sources/MessageReactionListController.swift +++ b/submodules/MessageReactionListUI/Sources/MessageReactionListController.swift @@ -175,7 +175,7 @@ private final class MessageReactionListControllerNode: ViewControllerTracingNode self.contentHeaderContainerBackgroundNode.displayWithoutProcessing = true self.contentHeaderContainerBackgroundNode.image = generateImage(CGSize(width: 10.0, height: 10.0), rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) - context.setFillColor(presentationData.theme.rootController.navigationBar.backgroundColor.cgColor) + context.setFillColor(presentationData.theme.rootController.navigationBar.opaqueBackgroundColor.cgColor) context.fillEllipse(in: CGRect(origin: CGPoint(), size: size)) context.fill(CGRect(origin: CGPoint(x: 0.0, y: size.height / 2.0), size: CGSize(width: size.width, height: size.height / 2.0))) })?.stretchableImage(withLeftCapWidth: 5, topCapHeight: 5) diff --git a/submodules/PassportUI/Sources/SecureIdAuthAcceptNode.swift b/submodules/PassportUI/Sources/SecureIdAuthAcceptNode.swift index 4ea08bef1c..376c52ec14 100644 --- a/submodules/PassportUI/Sources/SecureIdAuthAcceptNode.swift +++ b/submodules/PassportUI/Sources/SecureIdAuthAcceptNode.swift @@ -45,7 +45,7 @@ final class SecureIdAuthAcceptNode: ASDisplayNode { super.init() - self.backgroundColor = theme.rootController.navigationBar.backgroundColor + self.backgroundColor = theme.rootController.navigationBar.opaqueBackgroundColor self.addSubnode(self.separatorNode) self.addSubnode(self.buttonBackgroundNode) diff --git a/submodules/PasswordSetupUI/Sources/TwoFactorAuthDataInputScreen.swift b/submodules/PasswordSetupUI/Sources/TwoFactorAuthDataInputScreen.swift index aa7100dcd0..08dc3a8e7f 100644 --- a/submodules/PasswordSetupUI/Sources/TwoFactorAuthDataInputScreen.swift +++ b/submodules/PasswordSetupUI/Sources/TwoFactorAuthDataInputScreen.swift @@ -686,7 +686,7 @@ private final class TwoFactorDataInputScreenNode: ViewControllerTracingNode, UIS self.resendCodeAction = resendCodeAction self.navigationBackgroundNode = ASDisplayNode() - self.navigationBackgroundNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.backgroundColor + self.navigationBackgroundNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.opaqueBackgroundColor self.navigationBackgroundNode.alpha = 0.0 self.navigationSeparatorNode = ASDisplayNode() self.navigationSeparatorNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.separatorColor diff --git a/submodules/PeerInfoUI/Sources/OldChannelsController.swift b/submodules/PeerInfoUI/Sources/OldChannelsController.swift index 19ef901616..4da1e82f73 100644 --- a/submodules/PeerInfoUI/Sources/OldChannelsController.swift +++ b/submodules/PeerInfoUI/Sources/OldChannelsController.swift @@ -221,7 +221,7 @@ private final class OldChannelsActionPanelNode: ASDisplayNode { super.init() - self.backgroundColor = presentationData.theme.rootController.navigationBar.backgroundColor + self.backgroundColor = presentationData.theme.rootController.navigationBar.opaqueBackgroundColor self.addSubnode(self.separatorNode) self.addSubnode(self.buttonNode) @@ -233,7 +233,7 @@ private final class OldChannelsActionPanelNode: ASDisplayNode { func updatePresentationData(_ presentationData: ItemListPresentationData) { self.separatorNode.backgroundColor = presentationData.theme.rootController.navigationBar.separatorColor - self.backgroundColor = presentationData.theme.rootController.navigationBar.backgroundColor + self.backgroundColor = presentationData.theme.rootController.navigationBar.opaqueBackgroundColor } func updateLayout(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) -> CGFloat { diff --git a/submodules/SearchBarNode/Sources/SearchBarNode.swift b/submodules/SearchBarNode/Sources/SearchBarNode.swift index b3ce398a96..6f6c447077 100644 --- a/submodules/SearchBarNode/Sources/SearchBarNode.swift +++ b/submodules/SearchBarNode/Sources/SearchBarNode.swift @@ -620,8 +620,8 @@ public final class SearchBarNodeTheme: Equatable { } public init(theme: PresentationTheme, hasBackground: Bool = true, hasSeparator: Bool = true) { - self.background = hasBackground ? theme.rootController.navigationBar.backgroundColor : .clear - self.separator = hasSeparator ? theme.rootController.navigationBar.separatorColor : theme.rootController.navigationBar.backgroundColor + self.background = hasBackground ? theme.rootController.navigationBar.blurredBackgroundColor : .clear + self.separator = hasSeparator ? theme.rootController.navigationBar.separatorColor : theme.rootController.navigationBar.blurredBackgroundColor self.inputFill = theme.rootController.navigationSearchBar.inputFillColor self.placeholder = theme.rootController.navigationSearchBar.inputPlaceholderTextColor self.primaryText = theme.rootController.navigationSearchBar.inputTextColor diff --git a/submodules/SearchUI/Sources/NavigationBarSearchContentNode.swift b/submodules/SearchUI/Sources/NavigationBarSearchContentNode.swift index 6c1ab5d9be..a0945ea8e0 100644 --- a/submodules/SearchUI/Sources/NavigationBarSearchContentNode.swift +++ b/submodules/SearchUI/Sources/NavigationBarSearchContentNode.swift @@ -41,7 +41,7 @@ public class NavigationBarSearchContentNode: NavigationBarContentNode { self.placeholder = placeholder self.placeholderNode.accessibilityLabel = placeholder if let disabledOverlay = self.disabledOverlay { - disabledOverlay.backgroundColor = theme.rootController.navigationBar.backgroundColor.withAlphaComponent(0.5) + disabledOverlay.backgroundColor = theme.rootController.navigationBar.opaqueBackgroundColor.withAlphaComponent(0.5) } if let validLayout = self.validLayout { self.updatePlaceholder(self.expansionProgress, size: validLayout.0, leftInset: validLayout.1, rightInset: validLayout.2, transition: .immediate) @@ -98,7 +98,7 @@ public class NavigationBarSearchContentNode: NavigationBarContentNode { } } if let disabledOverlay = self.disabledOverlay { - disabledOverlay.backgroundColor = self.theme?.rootController.navigationBar.backgroundColor.withAlphaComponent(0.4) + disabledOverlay.backgroundColor = self.theme?.rootController.navigationBar.opaqueBackgroundColor.withAlphaComponent(0.4) var disabledOverlayFrame = self.placeholderNode.frame if let searchBarHeight = self.placeholderHeight { @@ -130,7 +130,7 @@ public class NavigationBarSearchContentNode: NavigationBarContentNode { let overscrollProgress = max(0.0, max(0.0, self.expansionProgress - 1.0 + fraction) / fraction - visibleProgress) let searchBarNodeLayout = self.placeholderNode.asyncLayout() - let (searchBarHeight, searchBarApply) = searchBarNodeLayout(NSAttributedString(string: self.placeholder, font: searchBarFont, textColor: self.theme?.rootController.navigationSearchBar.inputPlaceholderTextColor ?? UIColor(rgb: 0x8e8e93)), CGSize(width: baseWidth, height: fieldHeight), visibleProgress, self.theme?.rootController.navigationSearchBar.inputPlaceholderTextColor ?? UIColor(rgb: 0x8e8e93), self.theme?.rootController.navigationSearchBar.inputFillColor ?? .clear, self.theme?.rootController.navigationBar.backgroundColor ?? .clear, transition) + let (searchBarHeight, searchBarApply) = searchBarNodeLayout(NSAttributedString(string: self.placeholder, font: searchBarFont, textColor: self.theme?.rootController.navigationSearchBar.inputPlaceholderTextColor ?? UIColor(rgb: 0x8e8e93)), CGSize(width: baseWidth, height: fieldHeight), visibleProgress, self.theme?.rootController.navigationSearchBar.inputPlaceholderTextColor ?? UIColor(rgb: 0x8e8e93), self.theme?.rootController.navigationSearchBar.inputFillColor ?? .clear, self.theme?.rootController.navigationBar.opaqueBackgroundColor ?? .clear, transition) searchBarApply() let searchBarFrame = CGRect(origin: CGPoint(x: padding + leftInset, y: 8.0 + overscrollProgress * fieldHeight), size: CGSize(width: baseWidth, height: fieldHeight)) diff --git a/submodules/SettingsUI/Sources/BubbleSettings/BubbleSettingsController.swift b/submodules/SettingsUI/Sources/BubbleSettings/BubbleSettingsController.swift index 7cbf65a1f8..4cbb2f731e 100644 --- a/submodules/SettingsUI/Sources/BubbleSettings/BubbleSettingsController.swift +++ b/submodules/SettingsUI/Sources/BubbleSettings/BubbleSettingsController.swift @@ -63,7 +63,7 @@ private final class BubbleSettingsControllerNode: ASDisplayNode, UIScrollViewDel self.scrollNode = ASScrollNode() - self.chatBackgroundNode = WallpaperBackgroundNode() + self.chatBackgroundNode = WallpaperBackgroundNode(context: context) self.chatBackgroundNode.displaysAsynchronously = false self.messagesContainerNode = ASDisplayNode() diff --git a/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceController.swift b/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceController.swift index 8dc5f78b0d..3b10fd385c 100644 --- a/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceController.swift +++ b/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceController.swift @@ -36,7 +36,7 @@ public class TermsOfServiceControllerTheme { public extension TermsOfServiceControllerTheme { convenience init(presentationTheme: PresentationTheme) { - self.init(statusBarStyle: presentationTheme.rootController.statusBarStyle.style, navigationBackground: presentationTheme.rootController.navigationBar.backgroundColor, navigationSeparator: presentationTheme.rootController.navigationBar.separatorColor, listBackground: presentationTheme.list.blocksBackgroundColor, itemBackground: presentationTheme.list.itemBlocksBackgroundColor, itemSeparator: presentationTheme.list.itemBlocksSeparatorColor, primary: presentationTheme.list.itemPrimaryTextColor, accent: presentationTheme.list.itemAccentColor, disabled: presentationTheme.rootController.navigationBar.disabledButtonColor) + self.init(statusBarStyle: presentationTheme.rootController.statusBarStyle.style, navigationBackground: presentationTheme.rootController.navigationBar.opaqueBackgroundColor, navigationSeparator: presentationTheme.rootController.navigationBar.separatorColor, listBackground: presentationTheme.list.blocksBackgroundColor, itemBackground: presentationTheme.list.itemBlocksBackgroundColor, itemSeparator: presentationTheme.list.itemBlocksSeparatorColor, primary: presentationTheme.list.itemPrimaryTextColor, accent: presentationTheme.list.itemAccentColor, disabled: presentationTheme.rootController.navigationBar.disabledButtonColor) } } diff --git a/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceControllerNode.swift b/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceControllerNode.swift index 6871c9e3da..5a75ca945e 100644 --- a/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceControllerNode.swift +++ b/submodules/SettingsUI/Sources/Terms of Service/TermsOfServiceControllerNode.swift @@ -79,7 +79,7 @@ final class TermsOfServiceControllerNode: ViewControllerTracingNode { super.init() self.backgroundColor = self.presentationData.theme.list.blocksBackgroundColor - self.toolbarNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.backgroundColor + self.toolbarNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.opaqueBackgroundColor self.toolbarSeparatorNode.backgroundColor = self.presentationData.theme.rootController.navigationBar.separatorColor self.contentBackgroundNode.backgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor diff --git a/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionController.swift b/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionController.swift index c8cee23e4d..a611646bfe 100644 --- a/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionController.swift +++ b/submodules/SettingsUI/Sources/Text Size/TextSizeSelectionController.swift @@ -75,7 +75,7 @@ private final class TextSizeSelectionControllerNode: ASDisplayNode, UIScrollView self.pageControlNode = PageControlNode(dotSpacing: 7.0, dotColor: .white, inactiveDotColor: UIColor.white.withAlphaComponent(0.4)) self.chatListBackgroundNode = ASDisplayNode() - self.chatBackgroundNode = WallpaperBackgroundNode() + self.chatBackgroundNode = WallpaperBackgroundNode(context: context) self.chatBackgroundNode.displaysAsynchronously = false self.messagesContainerNode = ASDisplayNode() diff --git a/submodules/SettingsUI/Sources/Themes/EditThemeController.swift b/submodules/SettingsUI/Sources/Themes/EditThemeController.swift index 2b93ad1da8..1adc11460b 100644 --- a/submodules/SettingsUI/Sources/Themes/EditThemeController.swift +++ b/submodules/SettingsUI/Sources/Themes/EditThemeController.swift @@ -556,7 +556,7 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers themeSpecificChatWallpapers[themeReference.index] = nil - return PresentationThemeSettings(theme: themeReference, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations) + return PresentationThemeSettings(theme: themeReference, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, reduceMotion: current.reduceMotion) }) |> deliverOnMainQueue).start(completed: { if !hasCustomFile { saveThemeTemplateFile(state.title, themeResource, { @@ -590,7 +590,7 @@ public func editThemeController(context: AccountContext, mode: EditThemeControll var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers themeSpecificChatWallpapers[themeReference.index] = nil - return PresentationThemeSettings(theme: themeReference, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations) + return PresentationThemeSettings(theme: themeReference, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, reduceMotion: current.reduceMotion) }) |> deliverOnMainQueue).start(completed: { if let themeResource = themeResource, !hasCustomFile { saveThemeTemplateFile(state.title, themeResource, { diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift index 2b742f81d8..9860c35054 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorController.swift @@ -276,7 +276,7 @@ final class ThemeAccentColorController: ViewController { var themeSpecificAccentColors = current.themeSpecificAccentColors themeSpecificAccentColors[baseThemeReference.index] = PresentationThemeAccentColor(themeIndex: themeReference.index) - return PresentationThemeSettings(theme: updatedTheme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: updatedAutomaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations) + return PresentationThemeSettings(theme: updatedTheme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: updatedAutomaticThemeSwitchSetting, largeEmoji: current.largeEmoji, reduceMotion: current.reduceMotion) }) |> castError(CreateThemeError.self) } else { @@ -305,7 +305,7 @@ final class ThemeAccentColorController: ViewController { var themeSpecificAccentColors = current.themeSpecificAccentColors themeSpecificAccentColors[baseThemeReference.index] = PresentationThemeAccentColor(themeIndex: themeReference.index) - return PresentationThemeSettings(theme: updatedTheme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: updatedAutomaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations) + return PresentationThemeSettings(theme: updatedTheme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: updatedAutomaticThemeSwitchSetting, largeEmoji: current.largeEmoji, reduceMotion: current.reduceMotion) }) |> castError(CreateThemeError.self) } else { diff --git a/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift index e5221be5ff..67f959881d 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemePreviewControllerNode.swift @@ -103,7 +103,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate { self.messagesContainerNode.clipsToBounds = true self.messagesContainerNode.transform = CATransform3DMakeScale(1.0, -1.0, 1.0) - self.instantChatBackgroundNode = WallpaperBackgroundNode() + self.instantChatBackgroundNode = WallpaperBackgroundNode(context: context) self.instantChatBackgroundNode.displaysAsynchronously = false let wallpaper = initialWallpaper ?? previewTheme.chat.defaultWallpaper diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift index 006fb4b353..9a9b1ea3b5 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsChatPreviewItem.swift @@ -96,7 +96,7 @@ class ThemeSettingsChatPreviewItem: ListViewItem, ItemListItem { } class ThemeSettingsChatPreviewItemNode: ListViewItemNode { - private let backgroundNode: WallpaperBackgroundNode + private var backgroundNode: WallpaperBackgroundNode? private let topStripeNode: ASDisplayNode private let bottomStripeNode: ASDisplayNode private let maskNode: ASImageNode @@ -110,8 +110,6 @@ class ThemeSettingsChatPreviewItemNode: ListViewItemNode { private let disposable = MetaDisposable() init() { - self.backgroundNode = WallpaperBackgroundNode() - self.topStripeNode = ASDisplayNode() self.topStripeNode.isLayerBacked = true @@ -221,32 +219,35 @@ class ThemeSettingsChatPreviewItemNode: ListViewItemNode { node.updateFrame(CGRect(origin: CGPoint(x: 0.0, y: topOffset), size: node.frame.size), within: layoutSize) topOffset += node.frame.size.height } + + if strongSelf.backgroundNode == nil { + let backgroundNode = WallpaperBackgroundNode(context: item.context) + strongSelf.backgroundNode = backgroundNode + strongSelf.insertSubnode(backgroundNode, at: 0) + } if let updatedBackgroundSignal = updatedBackgroundSignal { strongSelf.disposable.set((updatedBackgroundSignal |> deliverOnMainQueue).start(next: { [weak self] image in - if let strongSelf = self, let (image, final) = image { + if let strongSelf = self, let (image, final) = image, let backgroundNode = strongSelf.backgroundNode { if final && !strongSelf.finalImage { let tempLayer = CALayer() - tempLayer.frame = strongSelf.backgroundNode.bounds - tempLayer.contentsGravity = strongSelf.backgroundNode.layer.contentsGravity + tempLayer.frame = backgroundNode.bounds + tempLayer.contentsGravity = backgroundNode.layer.contentsGravity tempLayer.contents = strongSelf.contents strongSelf.layer.addSublayer(tempLayer) tempLayer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15, removeOnCompletion: false, completion: { [weak tempLayer] _ in tempLayer?.removeFromSuperlayer() }) } - strongSelf.backgroundNode.image = image + backgroundNode.image = image strongSelf.finalImage = final } })) } strongSelf.topStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor strongSelf.bottomStripeNode.backgroundColor = item.theme.list.itemBlocksSeparatorColor - - if strongSelf.backgroundNode.supernode == nil { - strongSelf.insertSubnode(strongSelf.backgroundNode, at: 0) - } + if strongSelf.topStripeNode.supernode == nil { strongSelf.insertSubnode(strongSelf.topStripeNode, at: 1) } @@ -283,9 +284,11 @@ class ThemeSettingsChatPreviewItemNode: ListViewItemNode { strongSelf.maskNode.image = hasCorners ? PresentationResourcesItemList.cornersImage(item.theme, top: hasTopCorners, bottom: hasBottomCorners) : nil let backgroundFrame = CGRect(origin: CGPoint(x: 0.0, y: -min(insets.top, separatorHeight)), size: CGSize(width: params.width, height: contentSize.height + min(insets.top, separatorHeight) + min(insets.bottom, separatorHeight))) - strongSelf.backgroundNode.frame = backgroundFrame.insetBy(dx: 0.0, dy: -100.0) - strongSelf.backgroundNode.update(wallpaper: item.wallpaper) - strongSelf.backgroundNode.updateLayout(size: strongSelf.backgroundNode.bounds.size, transition: .immediate) + if let backgroundNode = strongSelf.backgroundNode { + backgroundNode.frame = backgroundFrame.insetBy(dx: 0.0, dy: -100.0) + backgroundNode.update(wallpaper: item.wallpaper) + backgroundNode.updateLayout(size: backgroundNode.bounds.size, transition: .immediate) + } strongSelf.maskNode.frame = backgroundFrame.insetBy(dx: params.leftInset, dy: 0.0) strongSelf.topStripeNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -min(insets.top, separatorHeight)), size: CGSize(width: layoutSize.width, height: separatorHeight)) strongSelf.bottomStripeNode.frame = CGRect(origin: CGPoint(x: bottomStripeInset, y: contentSize.height + bottomStripeOffset), size: CGSize(width: layoutSize.width - bottomStripeInset, height: separatorHeight)) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift index 526a95a9b5..df7b0508c6 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsController.swift @@ -522,7 +522,7 @@ private func themeSettingsControllerEntries(presentationData: PresentationData, entries.append(.otherHeader(presentationData.theme, strings.Appearance_Other.uppercased())) entries.append(.largeEmoji(presentationData.theme, strings.Appearance_LargeEmoji, presentationData.largeEmoji)) - entries.append(.animations(presentationData.theme, strings.Appearance_ReduceMotion, presentationData.disableAnimations)) + entries.append(.animations(presentationData.theme, strings.Appearance_ReduceMotion, presentationData.reduceMotion)) entries.append(.animationsInfo(presentationData.theme, strings.Appearance_ReduceMotionInfo)) return entries @@ -598,9 +598,9 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The let _ = updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in return current.withUpdatedLargeEmoji(largeEmoji) }).start() - }, disableAnimations: { disableAnimations in + }, disableAnimations: { reduceMotion in let _ = updatePresentationThemeSettingsInteractively(accountManager: context.sharedContext.accountManager, { current in - return current.withUpdatedDisableAnimations(disableAnimations) + return current.withUpdatedReduceMotion(reduceMotion) }).start() }, selectAppIcon: { name in currentAppIconName.set(name) @@ -1016,17 +1016,10 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The presentInGlobalOverlayImpl?(contextController, nil) }) }) - - let previousThemeReference = Atomic(value: nil) - let previousAccentColor = Atomic(value: nil) - + let signal = combineLatest(queue: .mainQueue(), context.sharedContext.presentationData, context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.presentationThemeSettings]), cloudThemes.get(), availableAppIcons, currentAppIconName.get(), removedThemeIndexesPromise.get()) |> map { presentationData, sharedData, cloudThemes, availableAppIcons, currentAppIconName, removedThemeIndexes -> (ItemListControllerState, (ItemListNodeState, Any)) in let settings = (sharedData.entries[ApplicationSpecificSharedDataKeys.presentationThemeSettings] as? PresentationThemeSettings) ?? PresentationThemeSettings.defaultSettings - - let dateTimeFormat = presentationData.dateTimeFormat - let largeEmoji = presentationData.largeEmoji - let disableAnimations = presentationData.disableAnimations let themeReference: PresentationThemeReference if presentationData.autoNightModeTriggered { @@ -1035,8 +1028,6 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The themeReference = settings.theme } - let accentColor = settings.themeSpecificAccentColors[themeReference.index] - let rightNavigationButton = ItemListNavigationButton(content: .icon(.add), style: .regular, enabled: true, action: { moreImpl?() }) @@ -1304,7 +1295,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The } } - return PresentationThemeSettings(theme: updatedTheme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: updatedAutomaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations) + return PresentationThemeSettings(theme: updatedTheme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: updatedAutomaticThemeSwitchSetting, largeEmoji: current.largeEmoji, reduceMotion: current.reduceMotion) }).start() presentCrossfadeControllerImpl?(true) diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift index b1efed722d..e3587f6838 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperColorPanelNode.swift @@ -966,4 +966,11 @@ final class WallpaperColorPanelNode: ASDisplayNode { return updated }) } + + override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { + if let result = super.hitTest(point, with: event) { + return result + } + return nil + } } diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift index b7973c446b..e7b2785ee7 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift @@ -102,7 +102,7 @@ class WallpaperGalleryControllerNode: GalleryControllerNode { override func didLoad() { super.didLoad() - self.view.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(self.longPressGesture(_:)))) + //self.view.addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(self.longPressGesture(_:)))) } @objc private func longPressGesture(_ recognizer: UILongPressGestureRecognizer) { @@ -199,7 +199,8 @@ public class WallpaperGalleryController: ViewController { private var toolbarNode: WallpaperGalleryToolbarNode? private var patternPanelNode: WallpaperPatternPanelNode? private var colorsPanelNode: WallpaperColorPanelNode? - + + private var patternInitialWallpaper: TelegramWallpaper? private var patternPanelEnabled = false private var colorsPanelEnabled = false @@ -341,6 +342,17 @@ public class WallpaperGalleryController: ViewController { } return GalleryPagerTransaction(deleteItems: [], insertItems: [], updateItems: updateItems, focusOnItem: self.galleryNode.pager.centralItemNode()?.index, synchronous: false) } + + private func updateCurrentEntryTransaction(entry: WallpaperGalleryEntry, arguments: WallpaperGalleryItemArguments) -> GalleryPagerTransaction { + var updateItems: [GalleryPagerUpdateItem] = [] + for index in 0 ..< self.entries.count { + if index == self.centralEntryIndex { + let item = GalleryPagerUpdateItem(index: index, previousIndex: index, item: WallpaperGalleryItem(context: self.context, index: index, entry: entry, arguments: arguments, source: self.source)) + updateItems.append(item) + } + } + return GalleryPagerTransaction(deleteItems: [], insertItems: [], updateItems: updateItems, focusOnItem: self.galleryNode.pager.centralItemNode()?.index, synchronous: false) + } override public func loadDisplayNode() { let controllerInteraction = GalleryControllerInteraction(presentController: { [weak self] controller, arguments in @@ -432,7 +444,7 @@ public class WallpaperGalleryController: ViewController { let completion: (TelegramWallpaper) -> Void = { wallpaper in let baseSettings = wallpaper.settings - let updatedSettings = WallpaperSettings(blur: options.contains(.blur), motion: options.contains(.motion), color: baseSettings?.color, bottomColor: baseSettings?.bottomColor, intensity: baseSettings?.intensity) + let updatedSettings = WallpaperSettings(blur: options.contains(.blur), motion: options.contains(.motion), color: baseSettings?.color, bottomColor: baseSettings?.bottomColor, additionalColors: baseSettings?.additionalColors ?? [], intensity: baseSettings?.intensity) let wallpaper = wallpaper.withUpdatedSettings(updatedSettings) let autoNightModeTriggered = strongSelf.presentationData.autoNightModeTriggered @@ -597,14 +609,22 @@ public class WallpaperGalleryController: ViewController { node.action = { [weak self] in self?.actionPressed() } - node.requestPatternPanel = { [weak self] enabled in + node.requestPatternPanel = { [weak self] enabled, initialWallpaper in if let strongSelf = self, let (layout, _) = strongSelf.validLayout { + strongSelf.colorsPanelEnabled = false + + strongSelf.patternInitialWallpaper = enabled ? initialWallpaper : nil strongSelf.patternPanelEnabled = enabled strongSelf.galleryNode.scrollView.isScrollEnabled = !enabled if enabled { strongSelf.patternPanelNode?.didAppear() } else { - strongSelf.updateEntries(pattern: .color(0), preview: false) + switch initialWallpaper { + case .color: + strongSelf.updateEntries(pattern: .color(0), preview: false) + default: + break + } } strongSelf.containerLayoutUpdated(layout, transition: .animated(duration: 0.3, curve: .spring)) } @@ -612,6 +632,7 @@ public class WallpaperGalleryController: ViewController { node.requestColorsPanel = { [weak self] colors in if let strongSelf = self, let (layout, _) = strongSelf.validLayout { + strongSelf.patternPanelEnabled = false strongSelf.colorsPanelEnabled = colors != nil strongSelf.galleryNode.scrollView.isScrollEnabled = colors == nil if let colors = colors { @@ -671,6 +692,25 @@ public class WallpaperGalleryController: ViewController { self.galleryNode.pager.transaction(self.updateTransaction(entries: entries, arguments: WallpaperGalleryItemArguments(colorPreview: preview, isColorsList: false, patternEnabled: self.patternPanelEnabled))) } + + private func updateEntries(wallpaper: TelegramWallpaper, preview: Bool = false) { + guard self.validLayout != nil, let centralEntryIndex = self.galleryNode.pager.centralItemNode()?.index else { + return + } + + var entries = self.entries + var currentEntry = entries[centralEntryIndex] + switch currentEntry { + case .wallpaper: + currentEntry = .wallpaper(wallpaper, nil) + default: + break + } + entries[centralEntryIndex] = currentEntry + self.entries = entries + + self.galleryNode.pager.transaction(self.updateCurrentEntryTransaction(entry: currentEntry, arguments: WallpaperGalleryItemArguments(colorPreview: preview, isColorsList: false, patternEnabled: self.patternPanelEnabled))) + } private func updateEntries(pattern: TelegramWallpaper?, intensity: Int32? = nil, preview: Bool = false) { var updatedEntries: [WallpaperGalleryEntry] = [] @@ -715,8 +755,6 @@ public class WallpaperGalleryController: ViewController { self.toolbarNode!.updateLayout(size: CGSize(width: layout.size.width, height: 49.0), layout: layout, transition: transition) var bottomInset = layout.intrinsicInsets.bottom + 49.0 - let standardInputHeight = layout.deviceMetrics.keyboardHeight(inLandscape: false) - let height = max(standardInputHeight, layout.inputHeight ?? 0.0) - bottomInset + 47.0 let currentPatternPanelNode: WallpaperPatternPanelNode if let patternPanelNode = self.patternPanelNode { @@ -724,8 +762,22 @@ public class WallpaperGalleryController: ViewController { } else { let patternPanelNode = WallpaperPatternPanelNode(context: self.context, theme: presentationData.theme, strings: presentationData.strings) patternPanelNode.patternChanged = { [weak self] pattern, intensity, preview in - if let strongSelf = self, strongSelf.validLayout != nil { - strongSelf.updateEntries(pattern: pattern, intensity: intensity, preview: preview) + if let strongSelf = self, strongSelf.validLayout != nil, let patternInitialWallpaper = strongSelf.patternInitialWallpaper { + switch patternInitialWallpaper { + case .color: + strongSelf.updateEntries(pattern: pattern, intensity: intensity, preview: preview) + case let .builtin(gradient, _): + if let pattern = pattern, case let .file(file) = pattern { + var gradientColors = gradient?.colors ?? defaultBuiltinWallpaperGradientColors.map({ $0.rgb }) + + let newSettings = WallpaperSettings(blur: false, motion: false, color: gradientColors[0], bottomColor: gradientColors[1], additionalColors: Array(gradientColors.dropFirst(2)), intensity: intensity) + let newWallpaper = TelegramWallpaper.file(id: file.id, accessHash: file.accessHash, isCreator: file.isCreator, isDefault: file.isDefault, isPattern: pattern.isPattern, isDark: file.isDark, slug: file.slug, file: file.file, settings: newSettings) + + strongSelf.updateEntries(wallpaper: newWallpaper, preview: preview) + } + default: + break + } } } patternPanelNode.backgroundColors = self.presentationData.theme.overallDarkAppearance ? (self.presentationData.theme.list.blocksBackgroundColor, nil, nil) : nil @@ -747,10 +799,19 @@ public class WallpaperGalleryController: ViewController { guard let strongSelf = self else { return } - guard let centralItemNode = strongSelf.galleryNode.pager.centralItemNode() as? WallpaperGalleryItemNode else { + guard let entry = strongSelf.currentEntry(), case let .wallpaper(currentWallpaper, _) = entry else { return } - centralItemNode.updateColors(colors: colors) + + var wallpaper: TelegramWallpaper = .builtin(TelegramWallpaper.Gradient(colors: colors.map { + $0.rgb + }), WallpaperSettings(blur: false, motion: false, color: nil, bottomColor: nil, intensity: nil, rotation: nil)) + + if case .file = currentWallpaper { + wallpaper = currentWallpaper.withUpdatedSettings(WallpaperSettings(blur: false, motion: false, color: colors[0].rgb, bottomColor: colors[1].rgb, additionalColors: colors.dropFirst(2).map({ $0.rgb }), intensity: nil, rotation: nil)) + } + + strongSelf.updateEntries(wallpaper: wallpaper) } } diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift index b37958f817..0955ca888b 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift @@ -114,13 +114,13 @@ final class WallpaperGalleryItemNode: GalleryItemNode { let status = Promise(.Local) let actionButton = Promise(nil) var action: (() -> Void)? - var requestPatternPanel: ((Bool) -> Void)? + var requestPatternPanel: ((Bool, TelegramWallpaper) -> Void)? var requestColorsPanel: (([UIColor]?) -> Void)? private var validLayout: (ContainerViewLayout, CGFloat)? private var validOffset: CGFloat? - private var gradientColors: [UIColor]? + private var initialWallpaper: TelegramWallpaper? init(context: AccountContext) { self.context = context @@ -129,7 +129,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { self.wrapperNode = ASDisplayNode() self.imageNode = TransformImageNode() self.imageNode.contentAnimations = .subsequentUpdates - self.nativeNode = WallpaperBackgroundNode() + self.nativeNode = WallpaperBackgroundNode(context: context) self.cropNode = WallpaperCropNode() self.statusNode = RadialStatusNode(backgroundNodeColor: UIColor(white: 0.0, alpha: 0.6)) self.statusNode.frame = CGRect(x: 0.0, y: 0.0, width: progressDiameter, height: progressDiameter) @@ -222,18 +222,6 @@ final class WallpaperGalleryItemNode: GalleryItemNode { return nil } } - - func updateColors(colors: [UIColor]) { - if self.gradientColors == nil { - return - } - self.gradientColors = colors - self.nativeNode.update(wallpaper: .builtin(TelegramWallpaper.Gradient(colors: colors.map { - $0.rgb - }), WallpaperSettings(blur: false, motion: false, color: nil, bottomColor: nil, intensity: nil, rotation: nil))) - - self.colorsButtonNode.colors = colors - } override func ready() -> Signal { return self._ready.get() @@ -283,16 +271,32 @@ final class WallpaperGalleryItemNode: GalleryItemNode { let progressAction = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode(color: presentationData.theme.rootController.navigationBar.accentTextColor)) var isBlurrable = true + + switch entry { + case let .wallpaper(wallpaper, _): + if case .builtin = wallpaper { + self.nativeNode.isHidden = false + self.nativeNode.update(wallpaper: wallpaper) + } else if case let .file(_, _, _, _, isPattern, _, _, _, settings) = wallpaper, isPattern, !settings.additionalColors.isEmpty { + self.nativeNode.isHidden = false + self.nativeNode.update(wallpaper: wallpaper) + } else { + self.nativeNode.isHidden = true + } + default: + self.nativeNode.isHidden = true + } switch entry { case let .wallpaper(wallpaper, message): + self.initialWallpaper = wallpaper + switch wallpaper { case let .builtin(gradient, _): - if self.gradientColors == nil { - self.gradientColors = gradient?.colors.map({ color in - return UIColor(rgb: color) - }) ?? defaultBuiltinWallpaperGradientColors - } + let gradientColors = self.calculateGradientColors() ?? defaultBuiltinWallpaperGradientColors + + self.colorsButtonNode.colors = gradientColors + displaySize = CGSize(width: 1308.0, height: 2688.0).fitted(CGSize(width: 1280.0, height: 1280.0)).dividedByScreenScale().integralFloor contentSize = displaySize signal = settingsBuiltinWallpaperImage(account: self.context.account) @@ -322,6 +326,10 @@ final class WallpaperGalleryItemNode: GalleryItemNode { colorSignal = chatServiceBackgroundColor(wallpaper: wallpaper, mediaBox: self.context.account.postbox.mediaBox) isBlurrable = false case let .file(file): + let gradientColors = self.calculateGradientColors() ?? defaultBuiltinWallpaperGradientColors + + self.colorsButtonNode.colors = gradientColors + let dimensions = file.file.dimensions ?? PixelDimensions(width: 2000, height: 4000) contentSize = dimensions.cgSize displaySize = dimensions.cgSize.dividedByScreenScale().integralFloor @@ -372,8 +380,12 @@ final class WallpaperGalleryItemNode: GalleryItemNode { } self.colorPreview = self.arguments.colorPreview - - signal = patternWallpaperImage(account: self.context.account, accountManager: self.context.sharedContext.accountManager, representations: convertedRepresentations, mode: .screen, autoFetchFullSize: true) + + if !file.settings.additionalColors.isEmpty { + signal = .single({ _ in nil }) + } else { + signal = patternWallpaperImage(account: self.context.account, accountManager: self.context.sharedContext.accountManager, representations: convertedRepresentations, mode: .screen, autoFetchFullSize: true) + } colorSignal = chatServiceBackgroundColor(wallpaper: wallpaper, mediaBox: self.context.account.postbox.mediaBox) isBlurrable = false @@ -532,18 +544,6 @@ final class WallpaperGalleryItemNode: GalleryItemNode { } else { self.imageNode.contentMode = .scaleToFill } - - switch entry { - case let .wallpaper(wallpaper, _): - if case .builtin = wallpaper { - self.nativeNode.isHidden = false - self.nativeNode.update(wallpaper: wallpaper) - } else { - self.nativeNode.isHidden = true - } - default: - self.nativeNode.isHidden = true - } self.imageNode.setSignal(signal, dispatchOnDisplayLink: false) self.imageNode.asyncLayout()(TransformImageArguments(corners: ImageCorners(), imageSize: displaySize, boundingSize: displaySize, intrinsicInsets: UIEdgeInsets(), custom: patternArguments))() @@ -658,7 +658,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { } var colors: [UInt32]? { - return self.gradientColors?.map({ $0.rgb }) + return self.calculateGradientColors()?.map({ $0.rgb }) } @objc func toggleBlur() { @@ -728,14 +728,49 @@ final class WallpaperGalleryItemNode: GalleryItemNode { } @objc private func togglePattern() { + guard let initialWallpaper = self.initialWallpaper else { + return + } + let value = !self.patternButtonNode.isSelected self.patternButtonNode.setSelected(value, animated: false) - self.requestPatternPanel?(value) + self.requestPatternPanel?(value, initialWallpaper) + } + + func calculateGradientColors() -> [UIColor]? { + guard let entry = self.entry else { + return nil + } + switch entry { + case let .wallpaper(wallpaper, _): + switch wallpaper { + case let .builtin(gradient, _): + let gradientColors = gradient?.colors.map({ color in + return UIColor(rgb: color) + }) ?? defaultBuiltinWallpaperGradientColors + return gradientColors + case let .file(_, _, _, _, _, _, _, _, settings): + if let topColor = settings.color, let bottomColor = settings.bottomColor, settings.additionalColors.count == 2 { + return [ + UIColor(rgb: topColor), + UIColor(rgb: bottomColor), + UIColor(rgb: settings.additionalColors[0]), + UIColor(rgb: settings.additionalColors[1]) + ] + } else { + return nil + } + default: + return nil + } + default: + return nil + } } @objc private func toggleColors() { - guard let currentGradientColors = self.gradientColors else { + guard let currentGradientColors = self.calculateGradientColors() else { return } let value = !self.colorsButtonNode.isSelected @@ -862,17 +897,15 @@ final class WallpaperGalleryItemNode: GalleryItemNode { case let .wallpaper(wallpaper, _): switch wallpaper { case let .builtin(gradient, _): - self.colorsButtonNode.colors = self.gradientColors + self.colorsButtonNode.colors = self.calculateGradientColors() + + motionAlpha = 0.0 + patternAlpha = 1.0 + + patternFrame = leftButtonFrame.offsetBy(dx: -centerOffset, dy: 0.0) + colorsFrame = colorsFrame.offsetBy(dx: centerOffset, dy: 0.0) + playAlpha = 1.0 - motionAlpha = 1.0 - if self.motionButtonNode.isSelected { - motionFrame = leftButtonFrame.offsetBy(dx: -centerOffset, dy: 0.0) - colorsFrame = colorsFrame.offsetBy(dx: centerOffset, dy: 0.0) - playAlpha = 1.0 - } else { - motionFrame = leftButtonFrame - playAlpha = 0.0 - } colorsAlpha = 1.0 case .color: patternAlpha = 1.0 @@ -889,20 +922,33 @@ final class WallpaperGalleryItemNode: GalleryItemNode { case .gradient: motionAlpha = 1.0 case let .file(file): - if wallpaper.isPattern { - motionAlpha = 1.0 - if self.arguments.isColorsList { - patternAlpha = 1.0 - if self.patternButtonNode.isSelected { - patternFrame = leftButtonFrame + if !file.settings.additionalColors.isEmpty { + self.colorsButtonNode.colors = self.calculateGradientColors() + + motionAlpha = 0.0 + patternAlpha = 1.0 + + patternFrame = leftButtonFrame.offsetBy(dx: -centerOffset, dy: 0.0) + colorsFrame = colorsFrame.offsetBy(dx: centerOffset, dy: 0.0) + playAlpha = 1.0 + + colorsAlpha = 1.0 + } else { + if wallpaper.isPattern { + motionAlpha = 1.0 + if self.arguments.isColorsList { + patternAlpha = 1.0 + if self.patternButtonNode.isSelected { + patternFrame = leftButtonFrame + } + motionFrame = rightButtonFrame } + } else { + blurAlpha = 1.0 + blurFrame = leftButtonFrame + motionAlpha = 1.0 motionFrame = rightButtonFrame } - } else { - blurAlpha = 1.0 - blurFrame = leftButtonFrame - motionAlpha = 1.0 - motionFrame = rightButtonFrame } } } diff --git a/submodules/ShareController/Sources/ShareController.swift b/submodules/ShareController/Sources/ShareController.swift index ea65b9cebb..0f794a6893 100644 --- a/submodules/ShareController/Sources/ShareController.swift +++ b/submodules/ShareController/Sources/ShareController.swift @@ -985,7 +985,7 @@ final class MessageStoryRenderer { self.containerNode = ASDisplayNode() - self.instantChatBackgroundNode = WallpaperBackgroundNode() + self.instantChatBackgroundNode = WallpaperBackgroundNode(context: context) self.instantChatBackgroundNode.displaysAsynchronously = false self.instantChatBackgroundNode.image = chatControllerBackgroundImage(theme: self.presentationData.theme, wallpaper: self.presentationData.chatWallpaper, mediaBox: context.sharedContext.accountManager.mediaBox, knockoutMode: context.sharedContext.immediateExperimentalUISettings.knockoutWallpaper) diff --git a/submodules/SyncCore/Sources/TelegramWallpaper.swift b/submodules/SyncCore/Sources/TelegramWallpaper.swift index 9cc301caa2..350b2a0b9b 100644 --- a/submodules/SyncCore/Sources/TelegramWallpaper.swift +++ b/submodules/SyncCore/Sources/TelegramWallpaper.swift @@ -5,14 +5,16 @@ public struct WallpaperSettings: PostboxCoding, Equatable { public var motion: Bool public var color: UInt32? public var bottomColor: UInt32? + public var additionalColors: [UInt32] public var intensity: Int32? public var rotation: Int32? - public init(blur: Bool = false, motion: Bool = false, color: UInt32? = nil, bottomColor: UInt32? = nil, intensity: Int32? = nil, rotation: Int32? = nil) { + public init(blur: Bool = false, motion: Bool = false, color: UInt32? = nil, bottomColor: UInt32? = nil, additionalColors: [UInt32] = [], intensity: Int32? = nil, rotation: Int32? = nil) { self.blur = blur self.motion = motion self.color = color self.bottomColor = bottomColor + self.additionalColors = additionalColors self.intensity = intensity self.rotation = rotation } @@ -22,6 +24,7 @@ public struct WallpaperSettings: PostboxCoding, Equatable { self.motion = decoder.decodeInt32ForKey("m", orElse: 0) != 0 self.color = decoder.decodeOptionalInt32ForKey("c").flatMap { UInt32(bitPattern: $0) } self.bottomColor = decoder.decodeOptionalInt32ForKey("bc").flatMap { UInt32(bitPattern: $0) } + self.additionalColors = decoder.decodeInt32ArrayForKey("additionalColors").map { UInt32(bitPattern: $0) } self.intensity = decoder.decodeOptionalInt32ForKey("i") self.rotation = decoder.decodeOptionalInt32ForKey("r") } @@ -39,6 +42,7 @@ public struct WallpaperSettings: PostboxCoding, Equatable { } else { encoder.encodeNil(forKey: "bc") } + encoder.encodeInt32Array(self.additionalColors.map(Int32.init(bitPattern:)), forKey: "additionalColors") if let intensity = self.intensity { encoder.encodeInt32(intensity, forKey: "i") } else { @@ -64,6 +68,9 @@ public struct WallpaperSettings: PostboxCoding, Equatable { if lhs.bottomColor != rhs.bottomColor { return false } + if lhs.additionalColors != rhs.additionalColors { + return false + } if lhs.intensity != rhs.intensity { return false } diff --git a/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift b/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift index 5b54602285..2816162c63 100644 --- a/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift +++ b/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift @@ -226,7 +226,7 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi self.rightMaskNode = ASImageNode() self.rightMaskNode.contentMode = .scaleToFill - let maskImage = generateMaskImage(color: self.theme.rootController.navigationBar.backgroundColor) + let maskImage = generateMaskImage(color: self.theme.rootController.navigationBar.opaqueBackgroundColor) self.leftMaskNode.image = maskImage self.rightMaskNode.image = maskImage @@ -355,7 +355,7 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi self.nameDisplayOrder = presentationData.nameDisplayOrder self.dateTimeFormat = presentationData.dateTimeFormat - let maskImage = generateMaskImage(color: self.theme.rootController.navigationBar.backgroundColor) + let maskImage = generateMaskImage(color: self.theme.rootController.navigationBar.opaqueBackgroundColor) self.leftMaskNode.image = maskImage self.rightMaskNode.image = maskImage diff --git a/submodules/TelegramPresentationData/Sources/ChatPresentationData.swift b/submodules/TelegramPresentationData/Sources/ChatPresentationData.swift index 614ea5416e..4ed273afbf 100644 --- a/submodules/TelegramPresentationData/Sources/ChatPresentationData.swift +++ b/submodules/TelegramPresentationData/Sources/ChatPresentationData.swift @@ -66,6 +66,6 @@ public final class ChatPresentationData { extension ChatPresentationData { public convenience init(presentationData: PresentationData) { - self.init(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper), fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations, largeEmoji: presentationData.largeEmoji, chatBubbleCorners: presentationData.chatBubbleCorners) + self.init(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper), fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true, largeEmoji: presentationData.largeEmoji, chatBubbleCorners: presentationData.chatBubbleCorners) } } diff --git a/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift b/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift index 89c256b65c..0168febaff 100644 --- a/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift +++ b/submodules/TelegramPresentationData/Sources/ComponentsThemes.swift @@ -47,7 +47,7 @@ public extension TabBarControllerTheme { public extension NavigationBarTheme { convenience init(rootControllerTheme: PresentationTheme, enableBackgroundBlur: Bool = true, hideBackground: Bool = false, hideBadge: Bool = false) { let theme = rootControllerTheme.rootController.navigationBar - self.init(buttonColor: theme.buttonColor, disabledButtonColor: theme.disabledButtonColor, primaryTextColor: theme.primaryTextColor, backgroundColor: hideBackground ? .clear : theme.backgroundColor, enableBackgroundBlur: enableBackgroundBlur, separatorColor: hideBackground ? .clear : theme.separatorColor, badgeBackgroundColor: hideBadge ? .clear : theme.badgeBackgroundColor, badgeStrokeColor: hideBadge ? .clear : theme.badgeStrokeColor, badgeTextColor: hideBadge ? .clear : theme.badgeTextColor) + self.init(buttonColor: theme.buttonColor, disabledButtonColor: theme.disabledButtonColor, primaryTextColor: theme.primaryTextColor, backgroundColor: hideBackground ? .clear : theme.blurredBackgroundColor, enableBackgroundBlur: enableBackgroundBlur, separatorColor: hideBackground ? .clear : theme.separatorColor, badgeBackgroundColor: hideBadge ? .clear : theme.badgeBackgroundColor, badgeStrokeColor: hideBadge ? .clear : theme.badgeStrokeColor, badgeTextColor: hideBadge ? .clear : theme.badgeTextColor) } } diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift index 947be27426..75a09651db 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift @@ -238,7 +238,8 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati secondaryTextColor: UIColor(rgb: 0xffffff, alpha: 0.5), controlColor: UIColor(rgb: 0x767676), accentTextColor: UIColor(rgb: 0xffffff), - backgroundColor: UIColor(rgb: 0x1d1d1d, alpha: 0.94), + blurredBackgroundColor: UIColor(rgb: 0x1d1d1d, alpha: 0.9), + opaqueBackgroundColor: UIColor(rgb: 0x1d1d1d).mixedWith(UIColor(rgb: 0x000000), alpha: 0.1), separatorColor: UIColor(rgb: 0x3d3d40), badgeBackgroundColor: UIColor(rgb: 0xffffff), badgeStrokeColor: UIColor(rgb: 0x1c1c1d), @@ -252,7 +253,7 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati ) let rootTabBar = PresentationThemeRootTabBar( - backgroundColor: rootNavigationBar.backgroundColor, + backgroundColor: rootNavigationBar.blurredBackgroundColor, separatorColor: UIColor(rgb: 0x3d3d40), iconColor: UIColor(rgb: 0x828282), selectedIconColor: UIColor(rgb: 0xffffff), @@ -439,7 +440,7 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati ) let inputPanel = PresentationThemeChatInputPanel( - panelBackgroundColor: rootNavigationBar.backgroundColor, + panelBackgroundColor: rootNavigationBar.blurredBackgroundColor, panelBackgroundColorNoWallpaper: UIColor(rgb: 0x000000, alpha: 0.94), panelSeparatorColor: UIColor(rgb: 0x3d3d40), panelControlAccentColor: UIColor(rgb: 0xffffff), diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift index b6e84f35f3..c28cbefddf 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkTintedPresentationTheme.swift @@ -100,7 +100,8 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme secondaryTextColor: mainSecondaryColor, controlColor: mainSecondaryColor, accentTextColor: accentColor, - backgroundColor: mainBackgroundColor, + blurredBackgroundColor: mainBackgroundColor, + opaqueBackgroundColor: mainBackgroundColor, separatorColor: mainSeparatorColor, segmentedBackgroundColor: mainInputColor, segmentedForegroundColor: mainBackgroundColor, @@ -503,7 +504,8 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres secondaryTextColor: mainSecondaryColor, controlColor: mainSecondaryColor, accentTextColor: accentColor, - backgroundColor: mainBackgroundColor, + blurredBackgroundColor: mainBackgroundColor, + opaqueBackgroundColor: mainBackgroundColor, separatorColor: mainSeparatorColor, badgeBackgroundColor: UIColor(rgb: 0xef5b5b), badgeStrokeColor: UIColor(rgb: 0xef5b5b), @@ -781,7 +783,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres let contextMenu = PresentationThemeContextMenu( dimColor: UIColor(rgb: 0x000000, alpha: 0.6), - backgroundColor: rootNavigationBar.backgroundColor.withAlphaComponent(0.78), + backgroundColor: rootNavigationBar.opaqueBackgroundColor.withAlphaComponent(0.78), itemSeparatorColor: UIColor(rgb: 0xffffff, alpha: 0.15), sectionSeparatorColor: UIColor(rgb: 0x000000, alpha: 0.2), itemBackgroundColor: UIColor(rgb: 0x000000, alpha: 0.0), diff --git a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift index 7a2cbbb96c..b3f0d3c0f9 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDayPresentationTheme.swift @@ -345,7 +345,8 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio secondaryTextColor: UIColor(rgb: 0x787878), controlColor: UIColor(rgb: 0x7e8791), accentTextColor: UIColor(rgb: 0x007ee5), - backgroundColor: UIColor(rgb: 0xf7f7f7, alpha: 0.86), + blurredBackgroundColor: UIColor(rgb: 0xf7f7f7, alpha: 0.86), + opaqueBackgroundColor: UIColor(rgb: 0xf7f7f7).mixedWith(.white, alpha: 0.14), separatorColor: UIColor(rgb: 0xc8c7cc), badgeBackgroundColor: UIColor(rgb: 0xff3b30), badgeStrokeColor: UIColor(rgb: 0xff3b30), @@ -359,7 +360,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio ) let rootTabBar = PresentationThemeRootTabBar( - backgroundColor: rootNavigationBar.backgroundColor, + backgroundColor: rootNavigationBar.blurredBackgroundColor, separatorColor: UIColor(rgb: 0xa3a3a3), iconColor: UIColor(rgb: 0x959595), selectedIconColor: UIColor(rgb: 0x007ee5), @@ -660,8 +661,8 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio ) let inputPanel = PresentationThemeChatInputPanel( - panelBackgroundColor: rootNavigationBar.backgroundColor, - panelBackgroundColorNoWallpaper: rootNavigationBar.backgroundColor, + panelBackgroundColor: rootNavigationBar.blurredBackgroundColor, + panelBackgroundColorNoWallpaper: rootNavigationBar.blurredBackgroundColor, panelSeparatorColor: UIColor(rgb: 0xb2b2b2), panelControlAccentColor: UIColor(rgb: 0x007ee5), panelControlColor: UIColor(rgb: 0x858e99), diff --git a/submodules/TelegramPresentationData/Sources/PresentationData.swift b/submodules/TelegramPresentationData/Sources/PresentationData.swift index 486b75f56b..05513dc704 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationData.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationData.swift @@ -86,10 +86,10 @@ public final class PresentationData: Equatable { public let dateTimeFormat: PresentationDateTimeFormat public let nameDisplayOrder: PresentationPersonNameOrder public let nameSortOrder: PresentationPersonNameOrder - public let disableAnimations: Bool + public let reduceMotion: Bool public let largeEmoji: Bool - public init(strings: PresentationStrings, theme: PresentationTheme, autoNightModeTriggered: Bool, chatWallpaper: TelegramWallpaper, chatFontSize: PresentationFontSize, chatBubbleCorners: PresentationChatBubbleCorners, listsFontSize: PresentationFontSize, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, nameSortOrder: PresentationPersonNameOrder, disableAnimations: Bool, largeEmoji: Bool) { + public init(strings: PresentationStrings, theme: PresentationTheme, autoNightModeTriggered: Bool, chatWallpaper: TelegramWallpaper, chatFontSize: PresentationFontSize, chatBubbleCorners: PresentationChatBubbleCorners, listsFontSize: PresentationFontSize, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, nameSortOrder: PresentationPersonNameOrder, reduceMotion: Bool, largeEmoji: Bool) { self.strings = strings self.theme = theme self.autoNightModeTriggered = autoNightModeTriggered @@ -100,16 +100,16 @@ public final class PresentationData: Equatable { self.dateTimeFormat = dateTimeFormat self.nameDisplayOrder = nameDisplayOrder self.nameSortOrder = nameSortOrder - self.disableAnimations = disableAnimations + self.reduceMotion = reduceMotion self.largeEmoji = largeEmoji } public func withUpdated(theme: PresentationTheme) -> PresentationData { - return PresentationData(strings: self.strings, theme: theme, autoNightModeTriggered: self.autoNightModeTriggered, chatWallpaper: self.chatWallpaper, chatFontSize: self.chatFontSize, chatBubbleCorners: self.chatBubbleCorners, listsFontSize: self.listsFontSize, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, nameSortOrder: self.nameSortOrder, disableAnimations: self.disableAnimations, largeEmoji: self.largeEmoji) + return PresentationData(strings: self.strings, theme: theme, autoNightModeTriggered: self.autoNightModeTriggered, chatWallpaper: self.chatWallpaper, chatFontSize: self.chatFontSize, chatBubbleCorners: self.chatBubbleCorners, listsFontSize: self.listsFontSize, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, nameSortOrder: self.nameSortOrder, reduceMotion: self.reduceMotion, largeEmoji: self.largeEmoji) } public static func ==(lhs: PresentationData, rhs: PresentationData) -> Bool { - return lhs.strings === rhs.strings && lhs.theme === rhs.theme && lhs.autoNightModeTriggered == rhs.autoNightModeTriggered && lhs.chatWallpaper == rhs.chatWallpaper && lhs.chatFontSize == rhs.chatFontSize && lhs.chatBubbleCorners == rhs.chatBubbleCorners && lhs.listsFontSize == rhs.listsFontSize && lhs.dateTimeFormat == rhs.dateTimeFormat && lhs.disableAnimations == rhs.disableAnimations && lhs.largeEmoji == rhs.largeEmoji + return lhs.strings === rhs.strings && lhs.theme === rhs.theme && lhs.autoNightModeTriggered == rhs.autoNightModeTriggered && lhs.chatWallpaper == rhs.chatWallpaper && lhs.chatFontSize == rhs.chatFontSize && lhs.chatBubbleCorners == rhs.chatBubbleCorners && lhs.listsFontSize == rhs.listsFontSize && lhs.dateTimeFormat == rhs.dateTimeFormat && lhs.reduceMotion == rhs.reduceMotion && lhs.largeEmoji == rhs.largeEmoji } } @@ -311,7 +311,7 @@ public func currentPresentationDataAndSettings(accountManager: AccountManager, s let chatBubbleCorners = PresentationChatBubbleCorners(mainRadius: CGFloat(themeSettings.chatBubbleSettings.mainRadius), auxiliaryRadius: CGFloat(themeSettings.chatBubbleSettings.auxiliaryRadius), mergeBubbleCorners: themeSettings.chatBubbleSettings.mergeBubbleCorners) - return InitialPresentationDataAndSettings(presentationData: PresentationData(strings: stringsValue, theme: theme, autoNightModeTriggered: autoNightModeTriggered, chatWallpaper: effectiveChatWallpaper, chatFontSize: chatFontSize, chatBubbleCorners: chatBubbleCorners, listsFontSize: listsFontSize, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, nameSortOrder: nameSortOrder, disableAnimations: themeSettings.disableAnimations, largeEmoji: themeSettings.largeEmoji), automaticMediaDownloadSettings: automaticMediaDownloadSettings, autodownloadSettings: autodownloadSettings, callListSettings: callListSettings, inAppNotificationSettings: inAppNotificationSettings, mediaInputSettings: mediaInputSettings, experimentalUISettings: experimentalUISettings) + return InitialPresentationDataAndSettings(presentationData: PresentationData(strings: stringsValue, theme: theme, autoNightModeTriggered: autoNightModeTriggered, chatWallpaper: effectiveChatWallpaper, chatFontSize: chatFontSize, chatBubbleCorners: chatBubbleCorners, listsFontSize: listsFontSize, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, nameSortOrder: nameSortOrder, reduceMotion: themeSettings.reduceMotion, largeEmoji: themeSettings.largeEmoji), automaticMediaDownloadSettings: automaticMediaDownloadSettings, autodownloadSettings: autodownloadSettings, callListSettings: callListSettings, inAppNotificationSettings: inAppNotificationSettings, mediaInputSettings: mediaInputSettings, experimentalUISettings: experimentalUISettings) } } @@ -646,7 +646,7 @@ public func updatedPresentationData(accountManager: AccountManager, applicationI let chatBubbleCorners = PresentationChatBubbleCorners(mainRadius: CGFloat(themeSettings.chatBubbleSettings.mainRadius), auxiliaryRadius: CGFloat(themeSettings.chatBubbleSettings.auxiliaryRadius), mergeBubbleCorners: themeSettings.chatBubbleSettings.mergeBubbleCorners) - return PresentationData(strings: stringsValue, theme: themeValue, autoNightModeTriggered: autoNightModeTriggered, chatWallpaper: effectiveChatWallpaper, chatFontSize: chatFontSize, chatBubbleCorners: chatBubbleCorners, listsFontSize: listsFontSize, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, nameSortOrder: nameSortOrder, disableAnimations: themeSettings.disableAnimations, largeEmoji: themeSettings.largeEmoji) + return PresentationData(strings: stringsValue, theme: themeValue, autoNightModeTriggered: autoNightModeTriggered, chatWallpaper: effectiveChatWallpaper, chatFontSize: chatFontSize, chatBubbleCorners: chatBubbleCorners, listsFontSize: listsFontSize, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, nameSortOrder: nameSortOrder, reduceMotion: themeSettings.reduceMotion, largeEmoji: themeSettings.largeEmoji) } } else { return .complete() @@ -681,19 +681,19 @@ public func defaultPresentationData() -> PresentationData { let chatBubbleCorners = PresentationChatBubbleCorners(mainRadius: CGFloat(themeSettings.chatBubbleSettings.mainRadius), auxiliaryRadius: CGFloat(themeSettings.chatBubbleSettings.auxiliaryRadius), mergeBubbleCorners: themeSettings.chatBubbleSettings.mergeBubbleCorners) - return PresentationData(strings: defaultPresentationStrings, theme: defaultPresentationTheme, autoNightModeTriggered: false, chatWallpaper: .builtin(nil, WallpaperSettings()), chatFontSize: chatFontSize, chatBubbleCorners: chatBubbleCorners, listsFontSize: listsFontSize, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, nameSortOrder: nameSortOrder, disableAnimations: themeSettings.disableAnimations, largeEmoji: themeSettings.largeEmoji) + return PresentationData(strings: defaultPresentationStrings, theme: defaultPresentationTheme, autoNightModeTriggered: false, chatWallpaper: .builtin(nil, WallpaperSettings()), chatFontSize: chatFontSize, chatBubbleCorners: chatBubbleCorners, listsFontSize: listsFontSize, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, nameSortOrder: nameSortOrder, reduceMotion: themeSettings.reduceMotion, largeEmoji: themeSettings.largeEmoji) } public extension PresentationData { func withFontSizes(chatFontSize: PresentationFontSize, listsFontSize: PresentationFontSize) -> PresentationData { - return PresentationData(strings: self.strings, theme: self.theme, autoNightModeTriggered: self.autoNightModeTriggered, chatWallpaper: self.chatWallpaper, chatFontSize: chatFontSize, chatBubbleCorners: self.chatBubbleCorners, listsFontSize: listsFontSize, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, nameSortOrder: self.nameSortOrder, disableAnimations: self.disableAnimations, largeEmoji: self.largeEmoji) + return PresentationData(strings: self.strings, theme: self.theme, autoNightModeTriggered: self.autoNightModeTriggered, chatWallpaper: self.chatWallpaper, chatFontSize: chatFontSize, chatBubbleCorners: self.chatBubbleCorners, listsFontSize: listsFontSize, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, nameSortOrder: self.nameSortOrder, reduceMotion: self.reduceMotion, largeEmoji: self.largeEmoji) } func withChatBubbleCorners(_ chatBubbleCorners: PresentationChatBubbleCorners) -> PresentationData { - return PresentationData(strings: self.strings, theme: self.theme, autoNightModeTriggered: self.autoNightModeTriggered, chatWallpaper: self.chatWallpaper, chatFontSize: self.chatFontSize, chatBubbleCorners: chatBubbleCorners, listsFontSize: self.listsFontSize, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, nameSortOrder: self.nameSortOrder, disableAnimations: self.disableAnimations, largeEmoji: self.largeEmoji) + return PresentationData(strings: self.strings, theme: self.theme, autoNightModeTriggered: self.autoNightModeTriggered, chatWallpaper: self.chatWallpaper, chatFontSize: self.chatFontSize, chatBubbleCorners: chatBubbleCorners, listsFontSize: self.listsFontSize, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, nameSortOrder: self.nameSortOrder, reduceMotion: self.reduceMotion, largeEmoji: self.largeEmoji) } func withStrings(_ strings: PresentationStrings) -> PresentationData { - return PresentationData(strings: strings, theme: self.theme, autoNightModeTriggered: self.autoNightModeTriggered, chatWallpaper: self.chatWallpaper, chatFontSize: self.chatFontSize, chatBubbleCorners: chatBubbleCorners, listsFontSize: self.listsFontSize, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, nameSortOrder: self.nameSortOrder, disableAnimations: self.disableAnimations, largeEmoji: self.largeEmoji) + return PresentationData(strings: strings, theme: self.theme, autoNightModeTriggered: self.autoNightModeTriggered, chatWallpaper: self.chatWallpaper, chatFontSize: self.chatFontSize, chatBubbleCorners: chatBubbleCorners, listsFontSize: self.listsFontSize, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, nameSortOrder: self.nameSortOrder, reduceMotion: self.reduceMotion, largeEmoji: self.largeEmoji) } } diff --git a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift index 6463a32f4f..c80310bd04 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift @@ -117,7 +117,8 @@ public final class PresentationThemeRootNavigationBar { public let secondaryTextColor: UIColor public let controlColor: UIColor public let accentTextColor: UIColor - public let backgroundColor: UIColor + public let blurredBackgroundColor: UIColor + public let opaqueBackgroundColor: UIColor public let separatorColor: UIColor public let badgeBackgroundColor: UIColor public let badgeStrokeColor: UIColor @@ -129,14 +130,15 @@ public final class PresentationThemeRootNavigationBar { public let clearButtonBackgroundColor: UIColor public let clearButtonForegroundColor: UIColor - public init(buttonColor: UIColor, disabledButtonColor: UIColor, primaryTextColor: UIColor, secondaryTextColor: UIColor, controlColor: UIColor, accentTextColor: UIColor, backgroundColor: UIColor, separatorColor: UIColor, badgeBackgroundColor: UIColor, badgeStrokeColor: UIColor, badgeTextColor: UIColor, segmentedBackgroundColor: UIColor, segmentedForegroundColor: UIColor, segmentedTextColor: UIColor, segmentedDividerColor: UIColor, clearButtonBackgroundColor: UIColor, clearButtonForegroundColor: UIColor) { + public init(buttonColor: UIColor, disabledButtonColor: UIColor, primaryTextColor: UIColor, secondaryTextColor: UIColor, controlColor: UIColor, accentTextColor: UIColor, blurredBackgroundColor: UIColor, opaqueBackgroundColor: UIColor, separatorColor: UIColor, badgeBackgroundColor: UIColor, badgeStrokeColor: UIColor, badgeTextColor: UIColor, segmentedBackgroundColor: UIColor, segmentedForegroundColor: UIColor, segmentedTextColor: UIColor, segmentedDividerColor: UIColor, clearButtonBackgroundColor: UIColor, clearButtonForegroundColor: UIColor) { self.buttonColor = buttonColor self.disabledButtonColor = disabledButtonColor self.primaryTextColor = primaryTextColor self.secondaryTextColor = secondaryTextColor self.controlColor = controlColor self.accentTextColor = accentTextColor - self.backgroundColor = backgroundColor + self.blurredBackgroundColor = blurredBackgroundColor + self.opaqueBackgroundColor = opaqueBackgroundColor self.separatorColor = separatorColor self.badgeBackgroundColor = badgeBackgroundColor self.badgeStrokeColor = badgeStrokeColor @@ -149,10 +151,10 @@ public final class PresentationThemeRootNavigationBar { self.clearButtonForegroundColor = clearButtonForegroundColor } - public func withUpdated(buttonColor: UIColor? = nil, disabledButtonColor: UIColor? = nil, primaryTextColor: UIColor? = nil, secondaryTextColor: UIColor? = nil, controlColor: UIColor? = nil, accentTextColor: UIColor? = nil, backgroundColor: UIColor? = nil, separatorColor: UIColor? = nil, badgeBackgroundColor: UIColor? = nil, badgeStrokeColor: UIColor? = nil, badgeTextColor: UIColor? = nil, segmentedBackgroundColor: UIColor? = nil, segmentedForegroundColor: UIColor? = nil, segmentedTextColor: UIColor? = nil, segmentedDividerColor: UIColor? = nil, clearButtonBackgroundColor: UIColor? = nil, clearButtonForegroundColor: UIColor? = nil) -> PresentationThemeRootNavigationBar { + public func withUpdated(buttonColor: UIColor? = nil, disabledButtonColor: UIColor? = nil, primaryTextColor: UIColor? = nil, secondaryTextColor: UIColor? = nil, controlColor: UIColor? = nil, accentTextColor: UIColor? = nil, blurredBackgroundColor: UIColor? = nil, opaqueBackgroundColor: UIColor? = nil, separatorColor: UIColor? = nil, badgeBackgroundColor: UIColor? = nil, badgeStrokeColor: UIColor? = nil, badgeTextColor: UIColor? = nil, segmentedBackgroundColor: UIColor? = nil, segmentedForegroundColor: UIColor? = nil, segmentedTextColor: UIColor? = nil, segmentedDividerColor: UIColor? = nil, clearButtonBackgroundColor: UIColor? = nil, clearButtonForegroundColor: UIColor? = nil) -> PresentationThemeRootNavigationBar { let resolvedClearButtonBackgroundColor = clearButtonBackgroundColor ?? self.clearButtonBackgroundColor let resolvedClearButtonForegroundColor = clearButtonForegroundColor ?? self.clearButtonForegroundColor - return PresentationThemeRootNavigationBar(buttonColor: buttonColor ?? self.buttonColor, disabledButtonColor: disabledButtonColor ?? self.disabledButtonColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, secondaryTextColor: secondaryTextColor ?? self.secondaryTextColor, controlColor: controlColor ?? self.controlColor, accentTextColor: accentTextColor ?? self.accentTextColor, backgroundColor: backgroundColor ?? self.backgroundColor, separatorColor: separatorColor ?? self.separatorColor, badgeBackgroundColor: badgeBackgroundColor ?? self.badgeBackgroundColor, badgeStrokeColor: badgeStrokeColor ?? self.badgeStrokeColor, badgeTextColor: badgeTextColor ?? self.badgeTextColor, segmentedBackgroundColor: segmentedBackgroundColor ?? self.segmentedBackgroundColor, segmentedForegroundColor: segmentedForegroundColor ?? self.segmentedForegroundColor, segmentedTextColor: segmentedTextColor ?? self.segmentedTextColor, segmentedDividerColor: segmentedDividerColor ?? self.segmentedDividerColor, clearButtonBackgroundColor: resolvedClearButtonBackgroundColor, clearButtonForegroundColor: resolvedClearButtonForegroundColor) + return PresentationThemeRootNavigationBar(buttonColor: buttonColor ?? self.buttonColor, disabledButtonColor: disabledButtonColor ?? self.disabledButtonColor, primaryTextColor: primaryTextColor ?? self.primaryTextColor, secondaryTextColor: secondaryTextColor ?? self.secondaryTextColor, controlColor: controlColor ?? self.controlColor, accentTextColor: accentTextColor ?? self.accentTextColor, blurredBackgroundColor: blurredBackgroundColor ?? self.blurredBackgroundColor, opaqueBackgroundColor: opaqueBackgroundColor ?? self.opaqueBackgroundColor, separatorColor: separatorColor ?? self.separatorColor, badgeBackgroundColor: badgeBackgroundColor ?? self.badgeBackgroundColor, badgeStrokeColor: badgeStrokeColor ?? self.badgeStrokeColor, badgeTextColor: badgeTextColor ?? self.badgeTextColor, segmentedBackgroundColor: segmentedBackgroundColor ?? self.segmentedBackgroundColor, segmentedForegroundColor: segmentedForegroundColor ?? self.segmentedForegroundColor, segmentedTextColor: segmentedTextColor ?? self.segmentedTextColor, segmentedDividerColor: segmentedDividerColor ?? self.segmentedDividerColor, clearButtonBackgroundColor: resolvedClearButtonBackgroundColor, clearButtonForegroundColor: resolvedClearButtonForegroundColor) } } diff --git a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift index 60cd56e581..4578820207 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationThemeCodable.swift @@ -407,6 +407,7 @@ extension PresentationThemeRootNavigationBar: Codable { case segmentedDivider case clearButtonBackground case clearButtonForeground + case opaqueBackground } public convenience init(from decoder: Decoder) throws { @@ -419,7 +420,8 @@ extension PresentationThemeRootNavigationBar: Codable { secondaryTextColor: try decodeColor(values, .secondaryText), controlColor: try decodeColor(values, .control), accentTextColor: try decodeColor(values, .accentText), - backgroundColor: try decodeColor(values, .background), + blurredBackgroundColor: try decodeColor(values, .background), + opaqueBackgroundColor: try decodeColor(values, .opaqueBackground, fallbackKey: "root.navBar.background"), separatorColor: try decodeColor(values, .separator), badgeBackgroundColor: try decodeColor(values, .badgeFill), badgeStrokeColor: try decodeColor(values, .badgeStroke), @@ -441,7 +443,8 @@ extension PresentationThemeRootNavigationBar: Codable { try encodeColor(&values, self.secondaryTextColor, .secondaryText) try encodeColor(&values, self.controlColor, .control) try encodeColor(&values, self.accentTextColor, .accentText) - try encodeColor(&values, self.backgroundColor, .background) + try encodeColor(&values, self.blurredBackgroundColor, .background) + try encodeColor(&values, self.opaqueBackgroundColor, .opaqueBackground) try encodeColor(&values, self.separatorColor, .separator) try encodeColor(&values, self.badgeBackgroundColor, .badgeFill) try encodeColor(&values, self.badgeStrokeColor, .badgeStroke) diff --git a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift index 30634afe59..94e0b1520d 100644 --- a/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift +++ b/submodules/TelegramPresentationData/Sources/Resources/PresentationResourcesChat.swift @@ -546,8 +546,6 @@ public struct PresentationResourcesChat { return theme.image(PresentationResourceKey.chatHistoryNavigationButtonImage.rawValue, { theme in return generateImage(CGSize(width: 38.0, height: 38.0), contextGenerator: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) - context.setFillColor(theme.chat.historyNavigation.fillColor.cgColor) - context.fillEllipse(in: CGRect(origin: CGPoint(x: 0.5, y: 0.5), size: CGSize(width: size.width - 1.0, height: size.height - 1.0))) context.setLineWidth(0.5) context.setStrokeColor(theme.chat.historyNavigation.strokeColor.cgColor) context.strokeEllipse(in: CGRect(origin: CGPoint(x: 0.25, y: 0.25), size: CGSize(width: size.width - 0.5, height: size.height - 0.5))) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 5f304bdbcc..c865812ab1 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -998,7 +998,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) var attributes: [MessageAttribute] = [] let entities = generateTextEntities(text, enabledTypes: .all) if !entities.isEmpty { @@ -1014,29 +1014,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.interfaceInteraction?.displaySlowmodeTooltip(sourceNode, sourceRect) return false } - - strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({ - if let strongSelf = self { - strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: false, { current in - var current = current - current = current.updatedInterfaceState { interfaceState in - var interfaceState = interfaceState - interfaceState = interfaceState.withUpdatedReplyMessageId(nil) - if clearInput { - interfaceState = interfaceState.withUpdatedComposeInputState(ChatTextInputState(inputText: NSAttributedString())) - } - return interfaceState - }.updatedInputMode { current in - if case let .media(mode, maybeExpanded) = current, maybeExpanded != nil { - return .media(mode: mode, expanded: nil) - } - return current - } - - return current - }) - } - }) var attributes: [MessageAttribute] = [] if let query = query { @@ -1054,6 +1031,30 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if sourceNode is ChatEmptyNodeStickerContentNode { shouldAnimateMessageTransition = true } + + strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({ + if let strongSelf = self { + strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: false, { current in + var current = current + current = current.updatedInterfaceState { interfaceState in + var interfaceState = interfaceState + interfaceState = interfaceState.withUpdatedReplyMessageId(nil) + if clearInput { + interfaceState = interfaceState.withUpdatedComposeInputState(ChatTextInputState(inputText: NSAttributedString())) + } + return interfaceState + }.updatedInputMode { current in + if case let .media(mode, maybeExpanded) = current, maybeExpanded != nil { + return .media(mode: mode, expanded: nil) + } + return current + } + + return current + }) + } + }, shouldAnimateMessageTransition ? correlationId : nil) + if shouldAnimateMessageTransition { if let sourceNode = sourceNode as? ChatMediaInputStickerGridItemNode { strongSelf.chatDisplayNode.messageTransitionNode.add(correlationId: correlationId, source: .stickerMediaInput(input: .inputPanel(itemNode: sourceNode), replyPanel: replyPanel), initiated: { @@ -1101,7 +1102,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } }) } - }) + }, nil) strongSelf.sendMessages([.message(text: "", attributes: [], mediaReference: fileReference.abstract, replyToMessageId: strongSelf.presentationInterfaceState.interfaceState.replyMessageId, localGroupingKey: nil, correlationId: nil)]) } return true @@ -1433,7 +1434,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } }, sendBotCommand: { [weak self] messageId, command in if let strongSelf = self, canSendMessagesToChat(strongSelf.presentationInterfaceState) { - strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({}) + strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({}, nil) var postAsReply = false if !command.contains("@") { switch strongSelf.chatLocation { @@ -1459,7 +1460,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil).withUpdatedComposeInputState(ChatTextInputState(inputText: NSAttributedString(string: ""))).withUpdatedComposeDisableUrlPreview(nil) } }) } - }) + }, nil) var attributes: [MessageAttribute] = [] let entities = generateTextEntities(command, enabledTypes: .all) if !entities.isEmpty { @@ -4512,8 +4513,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G self?.requestLayout(transition: transition) } - self.chatDisplayNode.setupSendActionOnViewUpdate = { [weak self] f in - self?.chatDisplayNode.historyNode.layoutActionOnViewTransition = { [weak self] transition in + self.chatDisplayNode.setupSendActionOnViewUpdate = { [weak self] f, messageCorrelationId in + //print("setup layoutActionOnViewTransition") + + self?.chatDisplayNode.historyNode.layoutActionOnViewTransition = ({ [weak self] transition in f() if let strongSelf = self, let validLayout = strongSelf.validLayout { var mappedTransition: (ChatHistoryListViewTransition, ListViewUpdateSizeAndInsets?)? @@ -4524,7 +4527,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } else { isScheduledMessages = false } - strongSelf.chatDisplayNode.containerLayoutUpdated(validLayout, navigationBarHeight: strongSelf.navigationLayout(layout: validLayout).navigationFrame.maxY, transition: .animated(duration: strongSelf.chatDisplayNode.messageTransitionNode.hasScheduledTransitions ? 0.5 : 0.3, curve: strongSelf.chatDisplayNode.messageTransitionNode.hasScheduledTransitions ? .custom(0.33, 0.0, 0.0, 1.0) : .spring), listViewTransaction: { updateSizeAndInsets, _, _, _ in + strongSelf.chatDisplayNode.containerLayoutUpdated(validLayout, navigationBarHeight: strongSelf.navigationLayout(layout: validLayout).navigationFrame.maxY, transition: .animated(duration: strongSelf.chatDisplayNode.messageTransitionNode.hasScheduledTransitions ? 0.5 : 0.18, curve: strongSelf.chatDisplayNode.messageTransitionNode.hasScheduledTransitions ? .custom(0.33, 0.0, 0.0, 1.0) : .easeInOut), listViewTransaction: { updateSizeAndInsets, _, _, _ in var options = transition.options let _ = options.insert(.Synchronous) let _ = options.insert(.LowLatency) @@ -4570,11 +4573,23 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } } return (transition, nil) - } + }, messageCorrelationId) } self.chatDisplayNode.sendMessages = { [weak self] messages, silentPosting, scheduleTime, isAnyMessageTextPartitioned in if let strongSelf = self { + var correlationIds: [Int64] = [] + for message in messages { + switch message { + case let .message(_, _, _, _, _, correlationId): + if let correlationId = correlationId { + correlationIds.append(correlationId) + } + default: + break + } + } + //print("sendMessages \(correlationIds)") let peerId = strongSelf.chatLocation.peerId strongSelf.commitPurposefulAction() @@ -5411,7 +5426,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil).withUpdatedComposeInputState(ChatTextInputState(inputText: NSAttributedString(string: ""))).withUpdatedComposeDisableUrlPreview(nil) } }) } - }) + }, nil) var attributes: [MessageAttribute] = [] let entities = generateTextEntities(messageText, enabledTypes: .all) if !entities.isEmpty { @@ -8720,7 +8735,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) strongSelf.sendMessages(messages) } } @@ -8947,7 +8962,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) strongSelf.sendMessages([message]) }) strongSelf.effectiveNavigationController?.pushViewController(controller) @@ -8994,7 +9009,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) let message = EnqueueMessage.message(text: "", attributes: [], mediaReference: .standalone(media: media), replyToMessageId: replyMessageId, localGroupingKey: nil, correlationId: nil) enqueueMessages.append(message) } @@ -9053,7 +9068,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) let message = EnqueueMessage.message(text: "", attributes: [], mediaReference: .standalone(media: media), replyToMessageId: replyMessageId, localGroupingKey: nil, correlationId: nil) strongSelf.sendMessages([message]) } else { @@ -9071,7 +9086,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) let message = EnqueueMessage.message(text: "", attributes: [], mediaReference: .standalone(media: media), replyToMessageId: replyMessageId, localGroupingKey: nil, correlationId: nil) strongSelf.sendMessages([message]) } @@ -9391,7 +9406,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) strongSelf.sendMessages([message.withUpdatedReplyToMessageId(replyMessageId)]) })) } @@ -9535,6 +9550,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let strongSelf = self { var completionImpl: (() -> Void)? = completion + var usedCorrelationId: Int64? + var mappedMessages: [EnqueueMessage] = [] for item in items { var message = item.message @@ -9543,6 +9560,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G message = message.withUpdatedCorrelationId(correlationId) if items.count == 1, let getAnimatedTransitionSource = getAnimatedTransitionSource { + usedCorrelationId = correlationId completionImpl = nil strongSelf.chatDisplayNode.messageTransitionNode.add(correlationId: correlationId, source: .mediaInput(ChatMessageTransitionNode.Source.MediaInput(extractSnapshot: { return getAnimatedTransitionSource(uniqueId) @@ -9563,7 +9581,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }) } completionImpl?() - }) + }, usedCorrelationId) strongSelf.sendMessages(messages.map { $0.withUpdatedReplyToMessageId(replyMessageId) }) } @@ -9627,7 +9645,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) strongSelf.sendMessages([message].map { $0.withUpdatedReplyToMessageId(replyMessageId) }) } })) @@ -9643,7 +9661,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) strongSelf.sendMessages([message].map { $0.withUpdatedReplyToMessageId(replyMessageId) }) } })) @@ -9671,7 +9689,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) strongSelf.sendMessages([message].map { $0.withUpdatedReplyToMessageId(replyMessageId) }) } })) @@ -9702,7 +9720,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G return state }) } - }) + }, nil) self.sendMessages([message.withUpdatedReplyToMessageId(replyMessageId)]) } } @@ -9780,19 +9798,15 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } let replyMessageId = strongSelf.presentationInterfaceState.interfaceState.replyMessageId - strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({ - if let strongSelf = self { - strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: false, { - $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } - }) - } - }) let correlationId = Int64.random(in: 0 ..< Int64.max) let updatedMessage = message .withUpdatedReplyToMessageId(replyMessageId) .withUpdatedCorrelationId(correlationId) + var usedCorrelationId = false + if strongSelf.chatDisplayNode.shouldAnimateMessageTransition, let extractedView = videoController.extractVideoSnapshot() { + usedCorrelationId = true strongSelf.chatDisplayNode.messageTransitionNode.add(correlationId: correlationId, source: .videoMessage(ChatMessageTransitionNode.Source.VideoMessage(view: extractedView)), initiated: { [weak videoController] in videoController?.hideVideoSnapshot() guard let strongSelf = self else { @@ -9804,6 +9818,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.videoRecorder.set(.single(nil)) } + strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({ + if let strongSelf = self { + strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: false, { + $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } + }) + } + }, usedCorrelationId ? correlationId : nil) + strongSelf.sendMessages([updatedMessage]) } }, displaySlowmodeTooltip: { [weak self] node, rect in @@ -9892,18 +9914,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let waveform = data.waveform { waveformBuffer = MemoryBuffer(data: waveform) } - - strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({ - if let strongSelf = self { - strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: false, { - $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } - }) - } - }) let correlationId = Int64.random(in: 0 ..< Int64.max) + var usedCorrelationId = false if strongSelf.chatDisplayNode.shouldAnimateMessageTransition, let textInputPanelNode = strongSelf.chatDisplayNode.textInputPanelNode, let micButton = textInputPanelNode.micButton { + usedCorrelationId = true strongSelf.chatDisplayNode.messageTransitionNode.add(correlationId: correlationId, source: .audioMicInput(ChatMessageTransitionNode.Source.AudioMicInput(micButton: micButton)), initiated: { guard let strongSelf = self else { return @@ -9913,6 +9929,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } else { strongSelf.audioRecorder.set(.single(nil)) } + + strongSelf.chatDisplayNode.setupSendActionOnViewUpdate({ + if let strongSelf = self { + strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: false, { + $0.updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } + }) + } + }, usedCorrelationId ? correlationId : nil) strongSelf.sendMessages([.message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: randomId), partialReference: nil, resource: resource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: data.compressedData.count, attributes: [.Audio(isVoice: true, duration: Int(data.duration), title: nil, performer: nil, waveform: waveformBuffer)])), replyToMessageId: strongSelf.presentationInterfaceState.interfaceState.replyMessageId, localGroupingKey: nil, correlationId: correlationId)]) @@ -10006,7 +10030,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.updatedRecordedMediaPreview(nil).updatedInterfaceState { $0.withUpdatedReplyMessageId(nil) } }) } - }) + }, nil) let messages: [EnqueueMessage] = [.message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaFile(fileId: MediaId(namespace: Namespaces.Media.LocalFile, id: Int64.random(in: Int64.min ... Int64.max)), partialReference: nil, resource: recordedMediaPreview.resource, previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "audio/ogg", size: Int(recordedMediaPreview.fileSize), attributes: [.Audio(isVoice: true, duration: Int(recordedMediaPreview.duration), title: nil, performer: nil, waveform: waveformBuffer)])), replyToMessageId: self.presentationInterfaceState.interfaceState.replyMessageId, localGroupingKey: nil, correlationId: nil)] @@ -11523,7 +11547,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if #available(iOSApplicationExtension 9.0, iOS 9.0, *) { let controller = SFSafariViewController(url: parsedUrl) if #available(iOSApplicationExtension 10.0, iOS 10.0, *) { - controller.preferredBarTintColor = self.presentationData.theme.rootController.navigationBar.backgroundColor + controller.preferredBarTintColor = self.presentationData.theme.rootController.navigationBar.opaqueBackgroundColor controller.preferredControlTintColor = self.presentationData.theme.rootController.navigationBar.accentTextColor } return (controller, sourceRect) diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 5846d3dda1..baa1adc6b2 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -167,7 +167,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { var paste: (ChatTextInputPanelPasteData) -> Void = { _ in } var updateTypingActivity: (Bool) -> Void = { _ in } var dismissUrlPreview: () -> Void = { } - var setupSendActionOnViewUpdate: (@escaping () -> Void) -> Void = { _ in } + var setupSendActionOnViewUpdate: (@escaping () -> Void, Int64?) -> Void = { _, _ in } var requestLayout: (ContainedViewLayoutTransition) -> Void = { _ in } var dismissAsOverlay: () -> Void = { } @@ -178,6 +178,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { private var dropDimNode: ASDisplayNode? let messageTransitionNode: ChatMessageTransitionNode + + private let presentationContextMarker = ASDisplayNode() private var containerLayoutAndNavigationBarHeight: (ContainerViewLayout, CGFloat)? @@ -238,7 +240,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { self.navigationBar = navigationBar self.controller = controller - self.backgroundNode = WallpaperBackgroundNode() + self.backgroundNode = WallpaperBackgroundNode(context: context) self.backgroundNode.displaysAsynchronously = false self.titleAccessoryPanelContainer = ChatControllerTitlePanelNodeContainer() @@ -294,6 +296,9 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { guard let strongSelf = self else { return } + if (strongSelf.context.sharedContext.currentPresentationData.with({ $0 })).reduceMotion { + return + } strongSelf.backgroundNode.animateEvent(transition: transition) } @@ -301,7 +306,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { guard let strongSelf = self else { return nil } - return strongSelf.messageTransitionNode.view + return strongSelf.presentationContextMarker.view } self.setViewBlock({ @@ -383,6 +388,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { self.addSubnode(self.inputContextPanelContainer) self.addSubnode(self.messageTransitionNode) + self.addSubnode(self.presentationContextMarker) self.navigationBar?.additionalContentNode.addSubnode(self.titleAccessoryPanelContainer) @@ -1541,6 +1547,9 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { let listBottomInset = self.historyNode.insets.top if let previousListBottomInset = previousListBottomInset, listBottomInset != previousListBottomInset { if abs(listBottomInset - previousListBottomInset) > 80.0 { + if (self.context.sharedContext.currentPresentationData.with({ $0 })).reduceMotion { + return + } self.backgroundNode.animateEvent(transition: transition) } //self.historyNode.didScrollWithOffset?(listBottomInset - previousListBottomInset, transition, nil) @@ -2323,15 +2332,6 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { } if !messages.isEmpty || self.chatPresentationInterfaceState.interfaceState.forwardMessageIds != nil { - self.setupSendActionOnViewUpdate({ [weak self] in - if let strongSelf = self, let textInputPanelNode = strongSelf.inputPanelNode as? ChatTextInputPanelNode { - strongSelf.ignoreUpdateHeight = true - textInputPanelNode.text = "" - strongSelf.requestUpdateChatInterfaceState(.immediate, true, { $0.withUpdatedReplyMessageId(nil).withUpdatedForwardMessageIds(nil).withUpdatedComposeDisableUrlPreview(nil) }) - strongSelf.ignoreUpdateHeight = false - } - }) - completion() if let forwardMessageIds = self.chatPresentationInterfaceState.interfaceState.forwardMessageIds { for id in forwardMessageIds { @@ -2339,6 +2339,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { } } + var usedCorrelationId: Int64? + if !messages.isEmpty, case .message = messages[messages.count - 1] { let correlationId = Int64.random(in: 0 ..< Int64.max) messages[messages.count - 1] = messages[messages.count - 1].withUpdatedCorrelationId(correlationId) @@ -2348,11 +2350,22 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { replyPanel = accessoryPanelNode } if self.shouldAnimateMessageTransition, let inputPanelNode = self.inputPanelNode as? ChatTextInputPanelNode, let textInput = inputPanelNode.makeSnapshotForTransition() { + usedCorrelationId = correlationId let source: ChatMessageTransitionNode.Source = .textInput(textInput: textInput, replyPanel: replyPanel) self.messageTransitionNode.add(correlationId: correlationId, source: source, initiated: { }) } } + + self.setupSendActionOnViewUpdate({ [weak self] in + if let strongSelf = self, let textInputPanelNode = strongSelf.inputPanelNode as? ChatTextInputPanelNode { + strongSelf.ignoreUpdateHeight = true + textInputPanelNode.text = "" + strongSelf.requestUpdateChatInterfaceState(.immediate, true, { $0.withUpdatedReplyMessageId(nil).withUpdatedForwardMessageIds(nil).withUpdatedComposeDisableUrlPreview(nil) }) + strongSelf.ignoreUpdateHeight = false + } + }, usedCorrelationId) + completion() self.sendMessages(messages, silentPosting, scheduleTime, messages.count > 1) } @@ -2442,6 +2455,10 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { } var shouldAnimateMessageTransition: Bool { + if (self.context.sharedContext.currentPresentationData.with({ $0 })).reduceMotion { + return false + } + switch self.historyNode.visibleContentOffset() { case let .known(value) where value < 20.0: return true diff --git a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift index 4d138fabc3..513a553c59 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift @@ -167,45 +167,45 @@ struct ChatHistoryViewTransitionUpdateEntry { } struct ChatHistoryViewTransition { - let historyView: ChatHistoryView - let deleteItems: [ListViewDeleteItem] - let insertEntries: [ChatHistoryViewTransitionInsertEntry] - let updateEntries: [ChatHistoryViewTransitionUpdateEntry] - let options: ListViewDeleteAndInsertOptions - let scrollToItem: ListViewScrollToItem? - let stationaryItemRange: (Int, Int)? - let initialData: InitialMessageHistoryData? - let keyboardButtonsMessage: Message? - let cachedData: CachedPeerData? - let cachedDataMessages: [MessageId: Message]? - let readStateData: [PeerId: ChatHistoryCombinedInitialReadStateData]? - let scrolledToIndex: MessageHistoryAnchorIndex? - let scrolledToSomeIndex: Bool - let animateIn: Bool - let reason: ChatHistoryViewTransitionReason - let flashIndicators: Bool + var historyView: ChatHistoryView + var deleteItems: [ListViewDeleteItem] + var insertEntries: [ChatHistoryViewTransitionInsertEntry] + var updateEntries: [ChatHistoryViewTransitionUpdateEntry] + var options: ListViewDeleteAndInsertOptions + var scrollToItem: ListViewScrollToItem? + var stationaryItemRange: (Int, Int)? + var initialData: InitialMessageHistoryData? + var keyboardButtonsMessage: Message? + var cachedData: CachedPeerData? + var cachedDataMessages: [MessageId: Message]? + var readStateData: [PeerId: ChatHistoryCombinedInitialReadStateData]? + var scrolledToIndex: MessageHistoryAnchorIndex? + var scrolledToSomeIndex: Bool + var animateIn: Bool + var reason: ChatHistoryViewTransitionReason + var flashIndicators: Bool } struct ChatHistoryListViewTransition { - let historyView: ChatHistoryView - let deleteItems: [ListViewDeleteItem] - let insertItems: [ListViewInsertItem] - let updateItems: [ListViewUpdateItem] - let options: ListViewDeleteAndInsertOptions - let scrollToItem: ListViewScrollToItem? - let stationaryItemRange: (Int, Int)? - let initialData: InitialMessageHistoryData? - let keyboardButtonsMessage: Message? - let cachedData: CachedPeerData? - let cachedDataMessages: [MessageId: Message]? - let readStateData: [PeerId: ChatHistoryCombinedInitialReadStateData]? - let scrolledToIndex: MessageHistoryAnchorIndex? - let scrolledToSomeIndex: Bool - let peerType: MediaAutoDownloadPeerType - let networkType: MediaAutoDownloadNetworkType - let animateIn: Bool - let reason: ChatHistoryViewTransitionReason - let flashIndicators: Bool + var historyView: ChatHistoryView + var deleteItems: [ListViewDeleteItem] + var insertItems: [ListViewInsertItem] + var updateItems: [ListViewUpdateItem] + var options: ListViewDeleteAndInsertOptions + var scrollToItem: ListViewScrollToItem? + var stationaryItemRange: (Int, Int)? + var initialData: InitialMessageHistoryData? + var keyboardButtonsMessage: Message? + var cachedData: CachedPeerData? + var cachedDataMessages: [MessageId: Message]? + var readStateData: [PeerId: ChatHistoryCombinedInitialReadStateData]? + var scrolledToIndex: MessageHistoryAnchorIndex? + var scrolledToSomeIndex: Bool + var peerType: MediaAutoDownloadPeerType + var networkType: MediaAutoDownloadNetworkType + var animateIn: Bool + var reason: ChatHistoryViewTransitionReason + var flashIndicators: Bool } private func maxMessageIndexForEntries(_ view: ChatHistoryView, indexRange: (Int, Int)) -> (incoming: MessageIndex?, overall: MessageIndex?) { @@ -485,7 +485,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { private var dequeuedInitialTransitionOnLayout = false private var enqueuedHistoryViewTransitions: [ChatHistoryListViewTransition] = [] private var hasActiveTransition = false - var layoutActionOnViewTransition: ((ChatHistoryListViewTransition) -> (ChatHistoryListViewTransition, ListViewUpdateSizeAndInsets?))? + var layoutActionOnViewTransition: ((ChatHistoryListViewTransition) -> (ChatHistoryListViewTransition, ListViewUpdateSizeAndInsets?), Int64?)? public let historyState = ValuePromise() public var currentHistoryState: ChatHistoryNodeHistoryState? @@ -627,7 +627,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { self.mode = mode let presentationData = context.sharedContext.currentPresentationData.with { $0 } - self.currentPresentationData = ChatPresentationData(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper), fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations, largeEmoji: presentationData.largeEmoji, chatBubbleCorners: presentationData.chatBubbleCorners, animatedEmojiScale: 1.0) + self.currentPresentationData = ChatPresentationData(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper), fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true, largeEmoji: presentationData.largeEmoji, chatBubbleCorners: presentationData.chatBubbleCorners, animatedEmojiScale: 1.0) self.chatPresentationDataPromise = Promise(self.currentPresentationData) @@ -1138,12 +1138,12 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { let animatedEmojiConfig = ChatHistoryAnimatedEmojiConfiguration.with(appConfiguration: appConfiguration) - if previousTheme !== presentationData.theme || previousStrings !== presentationData.strings || previousWallpaper != presentationData.chatWallpaper || previousDisableAnimations != presentationData.disableAnimations || previousAnimatedEmojiScale != animatedEmojiConfig.scale { + if previousTheme !== presentationData.theme || previousStrings !== presentationData.strings || previousWallpaper != presentationData.chatWallpaper || previousAnimatedEmojiScale != animatedEmojiConfig.scale { let themeData = ChatPresentationThemeData(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper) - let chatPresentationData = ChatPresentationData(theme: themeData, fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations, largeEmoji: presentationData.largeEmoji, chatBubbleCorners: presentationData.chatBubbleCorners, animatedEmojiScale: animatedEmojiConfig.scale) + let chatPresentationData = ChatPresentationData(theme: themeData, fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true, largeEmoji: presentationData.largeEmoji, chatBubbleCorners: presentationData.chatBubbleCorners, animatedEmojiScale: animatedEmojiConfig.scale) strongSelf.currentPresentationData = chatPresentationData - strongSelf.dynamicBounceEnabled = !presentationData.disableAnimations + strongSelf.dynamicBounceEnabled = false strongSelf.forEachItemHeaderNode { itemHeaderNode in if let dateNode = itemHeaderNode as? ChatMessageDateHeaderNode { @@ -1771,8 +1771,8 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { let transition = self.enqueuedHistoryViewTransitions.removeFirst() let animated = transition.options.contains(.AnimateInsertion) - - let completion: (ListViewDisplayedItemRange) -> Void = { [weak self] visibleRange in + + let completion: (Bool, ListViewDisplayedItemRange) -> Void = { [weak self] wasTransformed, visibleRange in if let strongSelf = self { strongSelf.historyView = transition.historyView @@ -1920,13 +1920,40 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { } } - if let layoutActionOnViewTransition = self.layoutActionOnViewTransition { - self.layoutActionOnViewTransition = nil + if let (layoutActionOnViewTransition, layoutCorrelationId) = self.layoutActionOnViewTransition { + var foundCorrelationMessage = false + if let layoutCorrelationId = layoutCorrelationId { + itemSearch: for item in transition.insertItems { + if let messageItem = item.item as? ChatMessageItem { + for (message, _) in messageItem.content { + for attribute in message.attributes { + if let attribute = attribute as? OutgoingMessageInfoAttribute { + if attribute.correlationId == layoutCorrelationId { + foundCorrelationMessage = true + break itemSearch + } + } + } + } + } + } + } else { + foundCorrelationMessage = true + } + + if foundCorrelationMessage { + self.layoutActionOnViewTransition = nil + } + let (mappedTransition, updateSizeAndInsets) = layoutActionOnViewTransition(transition) - - self.transaction(deleteIndices: mappedTransition.deleteItems, insertIndicesAndItems: transition.insertItems, updateIndicesAndItems: transition.updateItems, options: mappedTransition.options, scrollToItem: mappedTransition.scrollToItem, updateSizeAndInsets: updateSizeAndInsets, stationaryItemRange: mappedTransition.stationaryItemRange, updateOpaqueState: ChatHistoryTransactionOpaqueState(historyView: transition.historyView), completion: completion) + + self.transaction(deleteIndices: mappedTransition.deleteItems, insertIndicesAndItems: transition.insertItems, updateIndicesAndItems: transition.updateItems, options: mappedTransition.options, scrollToItem: mappedTransition.scrollToItem, updateSizeAndInsets: updateSizeAndInsets, stationaryItemRange: mappedTransition.stationaryItemRange, updateOpaqueState: ChatHistoryTransactionOpaqueState(historyView: transition.historyView), completion: { result in + completion(true, result) + }) } else { - self.transaction(deleteIndices: transition.deleteItems, insertIndicesAndItems: transition.insertItems, updateIndicesAndItems: transition.updateItems, options: transition.options, scrollToItem: transition.scrollToItem, stationaryItemRange: transition.stationaryItemRange, updateOpaqueState: ChatHistoryTransactionOpaqueState(historyView: transition.historyView), completion: completion) + self.transaction(deleteIndices: transition.deleteItems, insertIndicesAndItems: transition.insertItems, updateIndicesAndItems: transition.updateItems, options: transition.options, scrollToItem: transition.scrollToItem, stationaryItemRange: transition.stationaryItemRange, updateOpaqueState: ChatHistoryTransactionOpaqueState(historyView: transition.historyView), completion: { result in + completion(false, result) + }) } if transition.flashIndicators { diff --git a/submodules/TelegramUI/Sources/ChatHistoryNavigationButtonNode.swift b/submodules/TelegramUI/Sources/ChatHistoryNavigationButtonNode.swift index 4105b4aeea..48cf046548 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryNavigationButtonNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryNavigationButtonNode.swift @@ -12,6 +12,7 @@ enum ChatHistoryNavigationButtonType { } class ChatHistoryNavigationButtonNode: ASControlNode { + private let backgroundNode: NavigationBackgroundNode private let imageNode: ASImageNode private let badgeBackgroundNode: ASImageNode private let badgeTextNode: ASTextNode @@ -42,6 +43,8 @@ class ChatHistoryNavigationButtonNode: ASControlNode { init(theme: PresentationTheme, type: ChatHistoryNavigationButtonType) { self.theme = theme self.type = type + + self.backgroundNode = NavigationBackgroundNode(color: theme.chat.inputPanel.panelBackgroundColor) self.imageNode = ASImageNode() self.imageNode.displayWithoutProcessing = true @@ -65,7 +68,11 @@ class ChatHistoryNavigationButtonNode: ASControlNode { self.badgeTextNode.displaysAsynchronously = false super.init() - + + self.addSubnode(self.backgroundNode) + self.backgroundNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: 38.0, height: 38.0)) + self.backgroundNode.update(size: self.backgroundNode.bounds.size, cornerRadius: 38.0 / 2.0, transition: .immediate) + self.addSubnode(self.imageNode) self.imageNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: 38.0, height: 38.0)) @@ -78,7 +85,8 @@ class ChatHistoryNavigationButtonNode: ASControlNode { func updateTheme(theme: PresentationTheme) { if self.theme !== theme { self.theme = theme - + + self.backgroundNode.color = theme.chat.inputPanel.panelBackgroundColor switch self.type { case .down: self.imageNode.image = PresentationResourcesChat.chatHistoryNavigationButtonImage(theme) diff --git a/submodules/TelegramUI/Sources/ChatHistoryNavigationButtons.swift b/submodules/TelegramUI/Sources/ChatHistoryNavigationButtons.swift index 0cbd2d86a5..888f2dcfe1 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryNavigationButtons.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryNavigationButtons.swift @@ -59,10 +59,12 @@ final class ChatHistoryNavigationButtons: ASDisplayNode { self.mentionsButton = ChatHistoryNavigationButtonNode(theme: theme, type: .mentions) self.mentionsButton.alpha = 0.0 + self.mentionsButton.isHidden = true self.mentionsButtonTapNode = ASDisplayNode() self.downButton = ChatHistoryNavigationButtonNode(theme: theme, type: .down) self.downButton.alpha = 0.0 + self.downButton.isHidden = true super.init() @@ -100,19 +102,32 @@ final class ChatHistoryNavigationButtons: ASDisplayNode { if self.displayDownButton { mentionsOffset = buttonSize.height + 12.0 + + self.downButton.isHidden = false transition.updateAlpha(node: self.downButton, alpha: 1.0) transition.updateTransformScale(node: self.downButton, scale: 1.0) } else { - transition.updateAlpha(node: self.downButton, alpha: 0.0) + transition.updateAlpha(node: self.downButton, alpha: 0.0, completion: { [weak self] completed in + guard let strongSelf = self, completed else { + return + } + strongSelf.downButton.isHidden = true + }) transition.updateTransformScale(node: self.downButton, scale: 0.2) } if self.mentionCount != 0 { + self.mentionsButton.isHidden = false transition.updateAlpha(node: self.mentionsButton, alpha: 1.0) transition.updateTransformScale(node: self.mentionsButton, scale: 1.0) self.mentionsButtonTapNode.isHidden = false } else { - transition.updateAlpha(node: self.mentionsButton, alpha: 0.0) + transition.updateAlpha(node: self.mentionsButton, alpha: 0.0, completion: { [weak self] completed in + guard let strongSelf = self, completed else { + return + } + strongSelf.mentionsButton.isHidden = true + }) transition.updateTransformScale(node: self.mentionsButton, scale: 0.2) self.mentionsButtonTapNode.isHidden = true } diff --git a/submodules/TelegramUI/Sources/ChatMediaInputNode.swift b/submodules/TelegramUI/Sources/ChatMediaInputNode.swift index e09ad9ef13..d3abdc20c6 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputNode.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputNode.swift @@ -1092,13 +1092,12 @@ final class ChatMediaInputNode: ChatInputNode { self.strings = strings self.collectionListSeparator.backgroundColor = theme.chat.inputMediaPanel.panelSeparatorColor - self.backgroundColor = theme.chat.inputMediaPanel.stickersBackgroundColor.withAlphaComponent(1.0) + self.panesBackgroundNode.backgroundColor = theme.chat.inputMediaPanel.stickersBackgroundColor.withAlphaComponent(1.0) self.searchContainerNode?.updateThemeAndStrings(theme: theme, strings: strings) self.stickerPane.updateThemeAndStrings(theme: theme, strings: strings) self.gifPane.updateThemeAndStrings(theme: theme, strings: strings) - //self.trendingPane.updateThemeAndStrings(theme: theme, strings: strings) self.themeAndStringsPromise.set(.single((theme, strings))) } @@ -1999,6 +1998,8 @@ final class ChatMediaInputNode: ChatInputNode { transition.updateFrame(node: self.collectionListSeparator, frame: CGRect(origin: CGPoint(x: 0.0, y: 41.0 + collectionListPanelOffset), size: self.collectionListSeparator.bounds.size)) transition.updatePosition(node: self.listView, position: CGPoint(x: self.listView.position.x, y: (41.0 - collectionListPanelOffset) / 2.0)) transition.updatePosition(node: self.gifListView, position: CGPoint(x: self.gifListView.position.x, y: (41.0 - collectionListPanelOffset) / 2.0)) + + self.updatePaneClippingContainer(size: self.paneClippingContainer.bounds.size, offset: collectionListPanelOffset, transition: transition) } override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { diff --git a/submodules/TelegramUI/Sources/ChatMessageTransitionNode.swift b/submodules/TelegramUI/Sources/ChatMessageTransitionNode.swift index 07e41ed094..d613410985 100644 --- a/submodules/TelegramUI/Sources/ChatMessageTransitionNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageTransitionNode.swift @@ -238,21 +238,23 @@ final class ChatMessageTransitionNode: ASDisplayNode { self.containerNode.addSubnode(self.contextSourceNode.contentNode) - let targetAbsoluteRect = self.contextSourceNode.view.convert(self.contextSourceNode.contentRect, to: nil) + let targetAbsoluteRect = self.contextSourceNode.view.convert(self.contextSourceNode.contentRect, to: self.view) if abs(targetAbsoluteRect.minY - 691.6666666666666) > 0.1 { assert(true) } - let sourceBackgroundAbsoluteRect = initialTextInput.backgroundView.frame.offsetBy(dx: initialTextInput.sourceRect.minX, dy: initialTextInput.sourceRect.minY) + + let sourceRect = self.view.convert(initialTextInput.sourceRect, from: nil) + let sourceBackgroundAbsoluteRect = initialTextInput.backgroundView.frame.offsetBy(dx: sourceRect.minX, dy: sourceRect.minY) let sourceAbsoluteRect = CGRect(origin: CGPoint(x: sourceBackgroundAbsoluteRect.minX, y: sourceBackgroundAbsoluteRect.maxY - self.contextSourceNode.contentRect.height), size: self.contextSourceNode.contentRect.size) - let textInput = ChatMessageTransitionNode.Source.TextInput(backgroundView: initialTextInput.backgroundView, contentView: initialTextInput.contentView, sourceRect: initialTextInput.sourceRect) + let textInput = ChatMessageTransitionNode.Source.TextInput(backgroundView: initialTextInput.backgroundView, contentView: initialTextInput.contentView, sourceRect: sourceRect) textInput.backgroundView.frame = CGRect(origin: CGPoint(x: 0.0, y: sourceAbsoluteRect.height - sourceBackgroundAbsoluteRect.height), size: textInput.backgroundView.bounds.size) textInput.contentView.frame = textInput.contentView.frame.offsetBy(dx: 0.0, dy: sourceAbsoluteRect.height - sourceBackgroundAbsoluteRect.height) var sourceReplyPanel: ReplyPanel? if let replyPanel = replyPanel, let replyPanelParentView = replyPanel.view.superview { - var replySourceAbsoluteFrame = replyPanelParentView.convert(replyPanel.originalFrameBeforeDismissed ?? replyPanel.frame, to: nil) + var replySourceAbsoluteFrame = replyPanelParentView.convert(replyPanel.originalFrameBeforeDismissed ?? replyPanel.frame, to: self.view) replySourceAbsoluteFrame.origin.x -= sourceAbsoluteRect.minX - self.contextSourceNode.contentRect.minX replySourceAbsoluteFrame.origin.y -= sourceAbsoluteRect.minY - self.contextSourceNode.contentRect.minY @@ -305,23 +307,23 @@ final class ChatMessageTransitionNode: ASDisplayNode { switch stickerMediaInput { case let .inputPanel(sourceItemNode): stickerSource = Sticker(imageNode: sourceItemNode.imageNode, animationNode: sourceItemNode.animationNode, placeholderNode: sourceItemNode.placeholderNode, relativeSourceRect: sourceItemNode.imageNode.frame) - sourceAbsoluteRect = sourceItemNode.view.convert(stickerSource.imageNode.frame, to: nil) + sourceAbsoluteRect = sourceItemNode.view.convert(stickerSource.imageNode.frame, to: self.view) case let .mediaPanel(sourceItemNode): stickerSource = Sticker(imageNode: sourceItemNode.imageNode, animationNode: sourceItemNode.animationNode, placeholderNode: sourceItemNode.placeholderNode, relativeSourceRect: sourceItemNode.imageNode.frame) - sourceAbsoluteRect = sourceItemNode.view.convert(stickerSource.imageNode.frame, to: nil) + sourceAbsoluteRect = sourceItemNode.view.convert(stickerSource.imageNode.frame, to: self.view) case let .inputPanelSearch(sourceItemNode): stickerSource = Sticker(imageNode: sourceItemNode.imageNode, animationNode: sourceItemNode.animationNode, placeholderNode: nil, relativeSourceRect: sourceItemNode.imageNode.frame) - sourceAbsoluteRect = sourceItemNode.view.convert(stickerSource.imageNode.frame, to: nil) + sourceAbsoluteRect = sourceItemNode.view.convert(stickerSource.imageNode.frame, to: self.view) case let .emptyPanel(sourceItemNode): stickerSource = Sticker(imageNode: sourceItemNode.stickerNode.imageNode, animationNode: sourceItemNode.stickerNode.animationNode, placeholderNode: nil, relativeSourceRect: sourceItemNode.stickerNode.imageNode.frame) - sourceAbsoluteRect = sourceItemNode.stickerNode.view.convert(sourceItemNode.stickerNode.imageNode.frame, to: nil) + sourceAbsoluteRect = sourceItemNode.stickerNode.view.convert(sourceItemNode.stickerNode.imageNode.frame, to: self.view) } - let targetAbsoluteRect = self.contextSourceNode.view.convert(self.contextSourceNode.contentRect, to: nil) + let targetAbsoluteRect = self.contextSourceNode.view.convert(self.contextSourceNode.contentRect, to: self.view) var sourceReplyPanel: ReplyPanel? if let replyPanel = replyPanel, let replyPanelParentView = replyPanel.view.superview { - var replySourceAbsoluteFrame = replyPanelParentView.convert(replyPanel.originalFrameBeforeDismissed ?? replyPanel.frame, to: nil) + var replySourceAbsoluteFrame = replyPanelParentView.convert(replyPanel.originalFrameBeforeDismissed ?? replyPanel.frame, to: self.view) replySourceAbsoluteFrame.origin.x -= sourceAbsoluteRect.midX - self.contextSourceNode.contentRect.midX replySourceAbsoluteFrame.origin.y -= sourceAbsoluteRect.midY - self.contextSourceNode.contentRect.midY @@ -371,7 +373,7 @@ final class ChatMessageTransitionNode: ASDisplayNode { if let (container, localRect) = audioMicInput.micButton.contentContainer { let snapshotView = container.snapshotView(afterScreenUpdates: false) if let snapshotView = snapshotView { - let sourceAbsoluteRect = container.convert(localRect, to: nil) + let sourceAbsoluteRect = container.convert(localRect, to: self.view) snapshotView.frame = sourceAbsoluteRect container.isHidden = true @@ -382,7 +384,7 @@ final class ChatMessageTransitionNode: ASDisplayNode { if let contextContainer = itemNode.animateFromMicInput(micInputNode: snapshotView, transition: transition) { self.containerNode.addSubnode(contextContainer.contentNode) - let targetAbsoluteRect = contextContainer.view.convert(contextContainer.contentRect, to: nil) + let targetAbsoluteRect = contextContainer.view.convert(contextContainer.contentRect, to: self.view) self.containerNode.frame = targetAbsoluteRect.offsetBy(dx: -contextContainer.contentRect.minX, dy: -contextContainer.contentRect.minY) contextContainer.updateAbsoluteRect?(self.containerNode.frame, UIScreen.main.bounds.size) @@ -418,7 +420,7 @@ final class ChatMessageTransitionNode: ASDisplayNode { self.containerNode.addSubnode(self.contextSourceNode.contentNode) let sourceAbsoluteRect = videoMessage.view.frame - let targetAbsoluteRect = self.contextSourceNode.view.convert(self.contextSourceNode.contentRect, to: nil) + let targetAbsoluteRect = self.contextSourceNode.view.convert(self.contextSourceNode.contentRect, to: self.view) videoMessage.view.frame = videoMessage.view.frame.offsetBy(dx: targetAbsoluteRect.midX - sourceAbsoluteRect.midX, dy: targetAbsoluteRect.midY - sourceAbsoluteRect.midY) @@ -445,7 +447,7 @@ final class ChatMessageTransitionNode: ASDisplayNode { self.containerNode.addSubnode(self.contextSourceNode.contentNode) - let targetAbsoluteRect = self.contextSourceNode.view.convert(self.contextSourceNode.contentRect, to: nil) + let targetAbsoluteRect = self.contextSourceNode.view.convert(self.contextSourceNode.contentRect, to: self.view) let sourceBackgroundAbsoluteRect = snapshotView.frame let sourceAbsoluteRect = CGRect(origin: CGPoint(x: sourceBackgroundAbsoluteRect.midX - self.contextSourceNode.contentRect.size.width / 2.0, y: sourceBackgroundAbsoluteRect.midY - self.contextSourceNode.contentRect.size.height / 2.0), size: self.contextSourceNode.contentRect.size) diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift b/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift index d4efd4270f..bc66e72492 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift @@ -23,6 +23,7 @@ import PeerInfoUI import InviteLinksUI import UndoUI import TelegramCallsUI +import WallpaperBackgroundNode private final class ChatRecentActionsListOpaqueState { let entries: [ChatRecentActionsEntry] @@ -57,8 +58,8 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { private var state: ChatRecentActionsControllerState private var containerLayout: (ContainerViewLayout, CGFloat)? - private let backgroundNode: ASDisplayNode - private let panelBackgroundNode: ASDisplayNode + private let backgroundNode: WallpaperBackgroundNode + private let panelBackgroundNode: NavigationBackgroundNode private let panelSeparatorNode: ASDisplayNode private let panelButtonNode: HighlightableButtonNode @@ -98,18 +99,17 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { self.automaticMediaDownloadSettings = context.sharedContext.currentAutomaticMediaDownloadSettings.with { $0 } - self.backgroundNode = ASDisplayNode() - self.backgroundNode.isLayerBacked = true + self.backgroundNode = WallpaperBackgroundNode(context: context) + self.backgroundNode.isUserInteractionEnabled = false - self.panelBackgroundNode = ASDisplayNode() - self.panelBackgroundNode.backgroundColor = self.presentationData.theme.chat.inputPanel.panelBackgroundColor + self.panelBackgroundNode = NavigationBackgroundNode(color: self.presentationData.theme.chat.inputPanel.panelBackgroundColor) self.panelSeparatorNode = ASDisplayNode() self.panelSeparatorNode.backgroundColor = self.presentationData.theme.chat.inputPanel.panelSeparatorColor self.panelButtonNode = HighlightableButtonNode() self.panelButtonNode.setTitle(self.presentationData.strings.Channel_AdminLog_InfoPanelTitle, with: Font.regular(17.0), with: self.presentationData.theme.chat.inputPanel.panelControlAccentColor, for: []) self.listNode = ListView() - self.listNode.dynamicBounceEnabled = !self.presentationData.disableAnimations + self.listNode.dynamicBounceEnabled = false self.listNode.transform = CATransform3DMakeRotation(CGFloat(Double.pi), 0.0, 0.0, 1.0) self.listNode.accessibilityPageScrolledString = { row, count in return presentationData.strings.VoiceOver_ScrollStatus(row, count).0 @@ -121,13 +121,14 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { self.state = ChatRecentActionsControllerState(chatWallpaper: self.presentationData.chatWallpaper, theme: self.presentationData.theme, strings: self.presentationData.strings, fontSize: self.presentationData.chatFontSize) - self.chatPresentationDataPromise = Promise(ChatPresentationData(theme: ChatPresentationThemeData(theme: self.presentationData.theme, wallpaper: self.presentationData.chatWallpaper), fontSize: self.presentationData.chatFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: self.presentationData.disableAnimations, largeEmoji: self.presentationData.largeEmoji, chatBubbleCorners: self.presentationData.chatBubbleCorners)) + self.chatPresentationDataPromise = Promise(ChatPresentationData(theme: ChatPresentationThemeData(theme: self.presentationData.theme, wallpaper: self.presentationData.chatWallpaper), fontSize: self.presentationData.chatFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: true, largeEmoji: self.presentationData.largeEmoji, chatBubbleCorners: self.presentationData.chatBubbleCorners)) self.eventLogContext = ChannelAdminEventLogContext(postbox: self.context.account.postbox, network: self.context.account.network, peerId: self.peer.id) super.init() - self.backgroundNode.contents = chatControllerBackgroundImage(theme: self.state.theme, wallpaper: self.state.chatWallpaper, mediaBox: context.sharedContext.accountManager.mediaBox, knockoutMode: context.sharedContext.immediateExperimentalUISettings.knockoutWallpaper)?.cgImage + self.backgroundNode.image = chatControllerBackgroundImage(theme: self.state.theme, wallpaper: self.state.chatWallpaper, mediaBox: context.sharedContext.accountManager.mediaBox, knockoutMode: context.sharedContext.immediateExperimentalUISettings.knockoutWallpaper) + self.backgroundNode.update(wallpaper: self.state.chatWallpaper) self.addSubnode(self.backgroundNode) self.addSubnode(self.listNode) @@ -610,7 +611,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { |> deliverOnMainQueue).start(next: { [weak self] presentationData in if let strongSelf = self { strongSelf.presentationData = presentationData - strongSelf.chatPresentationDataPromise.set(.single(ChatPresentationData(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper), fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations, largeEmoji: presentationData.largeEmoji, chatBubbleCorners: presentationData.chatBubbleCorners))) + strongSelf.chatPresentationDataPromise.set(.single(ChatPresentationData(theme: ChatPresentationThemeData(theme: presentationData.theme, wallpaper: presentationData.chatWallpaper), fontSize: presentationData.chatFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true, largeEmoji: presentationData.largeEmoji, chatBubbleCorners: presentationData.chatBubbleCorners))) strongSelf.updateThemeAndStrings(theme: presentationData.theme, strings: presentationData.strings) } @@ -629,7 +630,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { } func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) { - self.panelBackgroundNode.backgroundColor = theme.chat.inputPanel.panelBackgroundColor + self.panelBackgroundNode.color = theme.chat.inputPanel.panelBackgroundColor self.panelSeparatorNode.backgroundColor = theme.chat.inputPanel.panelSeparatorColor self.panelButtonNode.setTitle(presentationData.strings.Channel_AdminLog_InfoPanelTitle, with: Font.regular(17.0), with: theme.chat.inputPanel.panelControlAccentColor, for: []) } @@ -645,10 +646,12 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { let cleanInsets = layout.insets(options: []) transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(), size: layout.size)) + self.backgroundNode.updateLayout(size: self.backgroundNode.bounds.size, transition: transition) let intrinsicPanelHeight: CGFloat = 47.0 let panelHeight = intrinsicPanelHeight + cleanInsets.bottom transition.updateFrame(node: self.panelBackgroundNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - panelHeight), size: CGSize(width: layout.size.width, height: panelHeight))) + self.panelBackgroundNode.update(size: self.panelBackgroundNode.bounds.size, transition: transition) transition.updateFrame(node: self.panelSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - panelHeight), size: CGSize(width: layout.size.width, height: UIScreenPixel))) transition.updateFrame(node: self.panelButtonNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - panelHeight), size: CGSize(width: layout.size.width, height: intrinsicPanelHeight))) diff --git a/submodules/TelegramUI/Sources/ChatSearchResultsContollerNode.swift b/submodules/TelegramUI/Sources/ChatSearchResultsContollerNode.swift index 5a42e01f36..a5aafc5f90 100644 --- a/submodules/TelegramUI/Sources/ChatSearchResultsContollerNode.swift +++ b/submodules/TelegramUI/Sources/ChatSearchResultsContollerNode.swift @@ -140,7 +140,7 @@ class ChatSearchResultsControllerNode: ViewControllerTracingNode, UIScrollViewDe let presentationData = context.sharedContext.currentPresentationData.with { $0 } self.presentationData = presentationData - self.presentationDataPromise = Promise(ChatListPresentationData(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: self.presentationData.disableAnimations)) + self.presentationDataPromise = Promise(ChatListPresentationData(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: true)) self.listNode = ListView() self.listNode.verticalScrollIndicatorColor = self.presentationData.theme.list.scrollIndicatorColor @@ -303,9 +303,8 @@ class ChatSearchResultsControllerNode: ViewControllerTracingNode, UIScrollViewDe } func updatePresentationData(_ presentationData: PresentationData) { - let previousTheme = self.presentationData.theme self.presentationData = presentationData - self.presentationDataPromise.set(.single(ChatListPresentationData(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: self.presentationData.disableAnimations))) + self.presentationDataPromise.set(.single(ChatListPresentationData(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: true))) self.listNode.forEachItemHeaderNode({ itemHeaderNode in if let itemHeaderNode = itemHeaderNode as? ChatListSearchItemHeaderNode { diff --git a/submodules/TelegramUI/Sources/ContactMultiselectionController.swift b/submodules/TelegramUI/Sources/ContactMultiselectionController.swift index b24609744e..9f7af80a89 100644 --- a/submodules/TelegramUI/Sources/ContactMultiselectionController.swift +++ b/submodules/TelegramUI/Sources/ContactMultiselectionController.swift @@ -216,7 +216,7 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection } override func loadDisplayNode() { - self.displayNode = ContactMultiselectionControllerNode(context: self.context, mode: self.mode, options: self.options, filters: self.filters) + self.displayNode = ContactMultiselectionControllerNode(navigationBar: self.navigationBar, context: self.context, mode: self.mode, options: self.options, filters: self.filters) switch self.contactsNode.contentNode { case let .contacts(contactsNode): self._listReady.set(contactsNode.ready) @@ -525,11 +525,31 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection break } } + + private var suspendNavigationBarLayout: Bool = false + private var suspendedNavigationBarLayout: ContainerViewLayout? + private var additionalNavigationBarBackgroundHeight: CGFloat = 0.0 + + override public func updateNavigationBarLayout(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { + if self.suspendNavigationBarLayout { + self.suspendedNavigationBarLayout = layout + return + } + self.applyNavigationBarLayout(layout, navigationLayout: self.navigationLayout(layout: layout), additionalBackgroundHeight: self.additionalNavigationBarBackgroundHeight, transition: transition) + } override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { + self.suspendNavigationBarLayout = true + super.containerLayoutUpdated(layout, transition: transition) - self.contactsNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, actualNavigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, transition: transition) + self.additionalNavigationBarBackgroundHeight = self.contactsNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, actualNavigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, transition: transition) + + self.suspendNavigationBarLayout = false + if let suspendedNavigationBarLayout = self.suspendedNavigationBarLayout { + self.suspendedNavigationBarLayout = suspendedNavigationBarLayout + self.applyNavigationBarLayout(suspendedNavigationBarLayout, navigationLayout: self.navigationLayout(layout: layout), additionalBackgroundHeight: self.additionalNavigationBarBackgroundHeight, transition: transition) + } } @objc func cancelPressed() { diff --git a/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift b/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift index 7c42ff4435..c96e0e47d2 100644 --- a/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift +++ b/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift @@ -43,6 +43,7 @@ enum ContactMultiselectionContentNode { } final class ContactMultiselectionControllerNode: ASDisplayNode { + private let navigationBar: NavigationBar? let contentNode: ContactMultiselectionContentNode let tokenListNode: EditableTokenListNode var searchResultsNode: ContactListNode? @@ -67,7 +68,9 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { private var presentationData: PresentationData private var presentationDataDisposable: Disposable? - init(context: AccountContext, mode: ContactMultiselectionControllerMode, options: [ContactListAdditionalOption], filters: [ContactListFilter]) { + init(navigationBar: NavigationBar?, context: AccountContext, mode: ContactMultiselectionControllerMode, options: [ContactListAdditionalOption], filters: [ContactListFilter]) { + self.navigationBar = navigationBar + self.context = context let presentationData = context.sharedContext.currentPresentationData.with { $0 } self.presentationData = presentationData @@ -109,7 +112,7 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { self.contentNode = .contacts(ContactListNode(context: context, presentation: .single(.natural(options: options, includeChatList: includeChatList)), filters: filters, selectionState: ContactListNodeGroupSelectionState())) } - self.tokenListNode = EditableTokenListNode(theme: EditableTokenListNodeTheme(backgroundColor: self.presentationData.theme.rootController.navigationBar.backgroundColor, separatorColor: self.presentationData.theme.rootController.navigationBar.separatorColor, placeholderTextColor: self.presentationData.theme.list.itemPlaceholderTextColor, primaryTextColor: self.presentationData.theme.list.itemPrimaryTextColor, selectedTextColor: self.presentationData.theme.list.itemCheckColors.foregroundColor, selectedBackgroundColor: self.presentationData.theme.list.itemCheckColors.fillColor, accentColor: self.presentationData.theme.list.itemAccentColor, keyboardColor: self.presentationData.theme.rootController.keyboardColor), placeholder: placeholder) + self.tokenListNode = EditableTokenListNode(theme: EditableTokenListNodeTheme(backgroundColor: .clear, separatorColor: self.presentationData.theme.rootController.navigationBar.separatorColor, placeholderTextColor: self.presentationData.theme.list.itemPlaceholderTextColor, primaryTextColor: self.presentationData.theme.list.itemPrimaryTextColor, selectedTextColor: self.presentationData.theme.list.itemCheckColors.foregroundColor, selectedBackgroundColor: self.presentationData.theme.list.itemCheckColors.fillColor, accentColor: self.presentationData.theme.list.itemAccentColor, keyboardColor: self.presentationData.theme.rootController.keyboardColor), placeholder: placeholder) super.init() @@ -120,7 +123,7 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { self.backgroundColor = self.presentationData.theme.chatList.backgroundColor self.addSubnode(self.contentNode.node) - self.addSubnode(self.tokenListNode) + self.navigationBar?.additionalContentNode.addSubnode(self.tokenListNode) switch self.contentNode { case let .contacts(contactsNode): @@ -255,7 +258,7 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { } } - func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, actualNavigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) { + func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, actualNavigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) -> CGFloat { self.containerLayout = (layout, navigationBarHeight, actualNavigationBarHeight) var insets = layout.insets(options: [.input]) @@ -288,6 +291,8 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { searchResultsNode.containerLayoutUpdated(ContainerViewLayout(size: layout.size, metrics: layout.metrics, deviceMetrics: layout.deviceMetrics, intrinsicInsets: insets, safeInsets: layout.safeInsets, additionalInsets: layout.additionalInsets, statusBarHeight: layout.statusBarHeight, inputHeight: layout.inputHeight, inputHeightIsInteractivellyChanging: layout.inputHeightIsInteractivellyChanging, inVoiceOver: layout.inVoiceOver), headerInsets: headerInsets, transition: transition) searchResultsNode.frame = CGRect(origin: CGPoint(), size: layout.size) } + + return tokenListHeight } func animateIn() { diff --git a/submodules/TelegramUI/Sources/ContactSelectionControllerNode.swift b/submodules/TelegramUI/Sources/ContactSelectionControllerNode.swift index f53326a268..acf802b1bf 100644 --- a/submodules/TelegramUI/Sources/ContactSelectionControllerNode.swift +++ b/submodules/TelegramUI/Sources/ContactSelectionControllerNode.swift @@ -297,7 +297,7 @@ final class ContactSelectionCountPanelNode: ASDisplayNode { super.init() - self.backgroundColor = theme.rootController.navigationBar.backgroundColor + self.backgroundColor = theme.rootController.navigationBar.opaqueBackgroundColor self.addSubnode(self.badgeBackground) self.addSubnode(self.badgeLabel) diff --git a/submodules/TelegramUI/Sources/DocumentPreviewController.swift b/submodules/TelegramUI/Sources/DocumentPreviewController.swift index c389573d96..971ca25c4e 100644 --- a/submodules/TelegramUI/Sources/DocumentPreviewController.swift +++ b/submodules/TelegramUI/Sources/DocumentPreviewController.swift @@ -40,7 +40,7 @@ final class DocumentPreviewController: UINavigationController, QLPreviewControll super.init(nibName: nil, bundle: nil) - self.navigationBar.barTintColor = theme.rootController.navigationBar.backgroundColor + self.navigationBar.barTintColor = theme.rootController.navigationBar.opaqueBackgroundColor self.navigationBar.tintColor = theme.rootController.navigationBar.accentTextColor self.navigationBar.shadowImage = generateImage(CGSize(width: 1.0, height: 1.0), rotatedContext: { size, context in context.clear(CGRect(origin: CGPoint(), size: size)) @@ -51,8 +51,7 @@ final class DocumentPreviewController: UINavigationController, QLPreviewControll self.navigationBar.titleTextAttributes = [NSAttributedString.Key.font: Font.semibold(17.0), NSAttributedString.Key.foregroundColor: theme.rootController.navigationBar.primaryTextColor] let controller = QLPreviewController(nibName: nil, bundle: nil) - controller.navigation_setDismiss({ [weak self] in - //self?.cancelPressed() + controller.navigation_setDismiss({ }, rootController: self) controller.delegate = self controller.dataSource = self @@ -201,9 +200,9 @@ final class CompactDocumentPreviewController: QLPreviewController, QLPreviewCont func presentDocumentPreviewController(rootController: UIViewController, theme: PresentationTheme, strings: PresentationStrings, postbox: Postbox, file: TelegramMediaFile) { if #available(iOSApplicationExtension 9.0, iOS 9.0, *) { let navigationBar = UINavigationBar.appearance(whenContainedInInstancesOf: [QLPreviewController.self]) - navigationBar.barTintColor = theme.rootController.navigationBar.backgroundColor + navigationBar.barTintColor = theme.rootController.navigationBar.opaqueBackgroundColor navigationBar.setBackgroundImage(generateImage(CGSize(width: 1.0, height: 1.0), rotatedContext: { size, context in - context.setFillColor(theme.rootController.navigationBar.backgroundColor.cgColor) + context.setFillColor(theme.rootController.navigationBar.opaqueBackgroundColor.cgColor) context.fill(CGRect(origin: CGPoint(), size: size)) }), for: .default) navigationBar.isTranslucent = true diff --git a/submodules/TelegramUI/Sources/EditableTokenListNode.swift b/submodules/TelegramUI/Sources/EditableTokenListNode.swift index 15ae33ed4b..440a6a7e3f 100644 --- a/submodules/TelegramUI/Sources/EditableTokenListNode.swift +++ b/submodules/TelegramUI/Sources/EditableTokenListNode.swift @@ -112,6 +112,7 @@ private final class CaretIndicatorNode: ASImageNode { final class EditableTokenListNode: ASDisplayNode, UITextFieldDelegate { private let theme: EditableTokenListNodeTheme + private let backgroundNode: NavigationBackgroundNode private let scrollNode: ASScrollNode private let placeholderNode: ASTextNode private var tokenNodes: [TokenNode] = [] @@ -127,6 +128,8 @@ final class EditableTokenListNode: ASDisplayNode, UITextFieldDelegate { init(theme: EditableTokenListNodeTheme, placeholder: String) { self.theme = theme + + self.backgroundNode = NavigationBackgroundNode(color: theme.backgroundColor) self.scrollNode = ASScrollNode() self.scrollNode.view.alwaysBounceVertical = true @@ -157,9 +160,9 @@ final class EditableTokenListNode: ASDisplayNode, UITextFieldDelegate { self.separatorNode.backgroundColor = theme.separatorColor super.init() + self.addSubnode(self.backgroundNode) self.addSubnode(self.scrollNode) - - self.backgroundColor = theme.backgroundColor + self.addSubnode(self.separatorNode) self.scrollNode.addSubnode(self.placeholderNode) self.scrollNode.addSubnode(self.textFieldScrollNode) @@ -306,8 +309,7 @@ final class EditableTokenListNode: ASDisplayNode, UITextFieldDelegate { let contentHeight = currentOffset.y + 29.0 + verticalInset let nodeHeight = min(contentHeight, 110.0) - let separatorHeight = UIScreenPixel - transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: nodeHeight - separatorHeight), size: CGSize(width: width, height: separatorHeight))) + transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: width, height: UIScreenPixel))) transition.updateFrame(node: self.scrollNode, frame: CGRect(origin: CGPoint(), size: CGSize(width: width, height: nodeHeight))) if !abs(previousContentHeight - contentHeight).isLess(than: CGFloat.ulpOfOne) { @@ -322,6 +324,9 @@ final class EditableTokenListNode: ASDisplayNode, UITextFieldDelegate { } } self.scrollNode.view.contentSize = CGSize(width: width, height: contentHeight) + + transition.updateFrame(node: self.backgroundNode, frame: CGRect(origin: CGPoint(), size: CGSize(width: width, height: nodeHeight))) + self.backgroundNode.update(size: self.backgroundNode.bounds.size, transition: transition) return nodeHeight } diff --git a/submodules/TelegramUI/Sources/LegacyInstantVideoController.swift b/submodules/TelegramUI/Sources/LegacyInstantVideoController.swift index 6206d9cdb8..bbf2aa8b02 100644 --- a/submodules/TelegramUI/Sources/LegacyInstantVideoController.swift +++ b/submodules/TelegramUI/Sources/LegacyInstantVideoController.swift @@ -124,7 +124,7 @@ final class InstantVideoController: LegacyController, StandalonePresentableContr func legacyInputMicPalette(from theme: PresentationTheme) -> TGModernConversationInputMicPallete { let inputPanelTheme = theme.chat.inputPanel - return TGModernConversationInputMicPallete(dark: theme.overallDarkAppearance, buttonColor: inputPanelTheme.actionControlFillColor, iconColor: inputPanelTheme.actionControlForegroundColor, backgroundColor: inputPanelTheme.panelBackgroundColor, borderColor: inputPanelTheme.panelSeparatorColor, lock: inputPanelTheme.panelControlAccentColor, textColor: inputPanelTheme.primaryTextColor, secondaryTextColor: inputPanelTheme.secondaryTextColor, recording: inputPanelTheme.mediaRecordingDotColor) + return TGModernConversationInputMicPallete(dark: theme.overallDarkAppearance, buttonColor: inputPanelTheme.actionControlFillColor, iconColor: inputPanelTheme.actionControlForegroundColor, backgroundColor: theme.rootController.navigationBar.opaqueBackgroundColor, borderColor: inputPanelTheme.panelSeparatorColor, lock: inputPanelTheme.panelControlAccentColor, textColor: inputPanelTheme.primaryTextColor, secondaryTextColor: inputPanelTheme.secondaryTextColor, recording: inputPanelTheme.mediaRecordingDotColor) } func legacyInstantVideoController(theme: PresentationTheme, panelFrame: CGRect, context: AccountContext, peerId: PeerId, slowmodeState: ChatSlowmodeState?, hasSchedule: Bool, send: @escaping (InstantVideoController, EnqueueMessage?) -> Void, displaySlowmodeTooltip: @escaping (ASDisplayNode, CGRect) -> Void, presentSchedulePicker: @escaping (@escaping (Int32) -> Void) -> Void) -> InstantVideoController { diff --git a/submodules/TelegramUI/Sources/OpenUrl.swift b/submodules/TelegramUI/Sources/OpenUrl.swift index 34bfe2b7f4..106fd25f93 100644 --- a/submodules/TelegramUI/Sources/OpenUrl.swift +++ b/submodules/TelegramUI/Sources/OpenUrl.swift @@ -732,7 +732,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur if let window = navigationController?.view.window { let controller = SFSafariViewController(url: parsedUrl) if #available(iOSApplicationExtension 10.0, iOS 10.0, *) { - controller.preferredBarTintColor = presentationData.theme.rootController.navigationBar.backgroundColor + controller.preferredBarTintColor = presentationData.theme.rootController.navigationBar.opaqueBackgroundColor controller.preferredControlTintColor = presentationData.theme.rootController.navigationBar.accentTextColor } window.rootViewController?.present(controller, animated: true) diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index 36090c50a9..ce27b00ebf 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -1946,7 +1946,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { var transitionSourceTitleFrame = CGRect() var transitionSourceSubtitleFrame = CGRect() - self.backgroundNode.color = presentationData.theme.rootController.navigationBar.backgroundColor + self.backgroundNode.color = presentationData.theme.rootController.navigationBar.blurredBackgroundColor if let navigationTransition = self.navigationTransition, let sourceAvatarNode = (navigationTransition.sourceNavigationBar.rightButtonNode.singleCustomNode as? ChatAvatarNavigationNode)?.avatarNode { transitionSourceHeight = navigationTransition.sourceNavigationBar.backgroundNode.bounds.height @@ -1955,7 +1955,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { transitionSourceTitleFrame = navigationTransition.sourceTitleFrame transitionSourceSubtitleFrame = navigationTransition.sourceSubtitleFrame - self.expandedBackgroundNode.updateColor(color: presentationData.theme.rootController.navigationBar.backgroundColor.mixedWith(presentationData.theme.list.itemBlocksBackgroundColor, alpha: 1.0 - transitionFraction), forceKeepBlur: true, transition: transition) + self.expandedBackgroundNode.updateColor(color: presentationData.theme.rootController.navigationBar.blurredBackgroundColor.mixedWith(presentationData.theme.list.itemBlocksBackgroundColor, alpha: 1.0 - transitionFraction), forceKeepBlur: true, transition: transition) if self.isAvatarExpanded, case .animated = transition, transitionFraction == 1.0 { self.avatarListNode.animateAvatarCollapse(transition: transition) @@ -1963,7 +1963,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { } else { let backgroundTransitionFraction: CGFloat = max(0.0, min(1.0, contentOffset / (112.0 + avatarSize))) - self.expandedBackgroundNode.updateColor(color: presentationData.theme.rootController.navigationBar.backgroundColor.mixedWith(presentationData.theme.list.itemBlocksBackgroundColor, alpha: 1.0 - backgroundTransitionFraction), forceKeepBlur: true, transition: transition) + self.expandedBackgroundNode.updateColor(color: presentationData.theme.rootController.navigationBar.blurredBackgroundColor.mixedWith(presentationData.theme.list.itemBlocksBackgroundColor, alpha: 1.0 - backgroundTransitionFraction), forceKeepBlur: true, transition: transition) } self.avatarListNode.avatarContainerNode.updateTransitionFraction(transitionFraction, transition: transition) @@ -1980,7 +1980,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { self.navigationBackgroundNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: width, height: navigationHeight)) self.navigationBackgroundNode.update(size: self.navigationBackgroundNode.bounds.size, transition: .immediate) self.navigationSeparatorNode.frame = CGRect(origin: CGPoint(x: 0.0, y: navigationHeight), size: CGSize(width: width, height: UIScreenPixel)) - self.navigationBackgroundNode.color = presentationData.theme.rootController.navigationBar.backgroundColor + self.navigationBackgroundNode.color = presentationData.theme.rootController.navigationBar.blurredBackgroundColor self.navigationSeparatorNode.backgroundColor = presentationData.theme.rootController.navigationBar.separatorColor transition.updateAlpha(node: self.navigationBackgroundNode, alpha: state.isEditing && self.isSettings ? min(1.0, contentOffset / (navigationHeight * 0.5)) : 0.0) self.separatorNode.backgroundColor = presentationData.theme.list.itemBlocksSeparatorColor diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoPaneContainerNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoPaneContainerNode.swift index 7eb018e8dd..7bdc48aae2 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoPaneContainerNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoPaneContainerNode.swift @@ -692,7 +692,7 @@ final class PeerInfoPaneContainerNode: ASDisplayNode, UIGestureRecognizerDelegat transition.updateAlpha(node: self.coveringBackgroundNode, alpha: expansionFraction) self.backgroundColor = presentationData.theme.list.itemBlocksBackgroundColor - self.coveringBackgroundNode.color = presentationData.theme.rootController.navigationBar.backgroundColor + self.coveringBackgroundNode.color = presentationData.theme.rootController.navigationBar.opaqueBackgroundColor self.separatorNode.backgroundColor = presentationData.theme.list.itemBlocksSeparatorColor self.tabsSeparatorNode.backgroundColor = presentationData.theme.list.itemBlocksSeparatorColor diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 2d9bdfef93..c28f9f32a7 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -465,7 +465,7 @@ final class PeerInfoSelectionPanelNode: ASDisplayNode { } func update(layout: ContainerViewLayout, presentationData: PresentationData, transition: ContainedViewLayoutTransition) -> CGFloat { - self.backgroundNode.backgroundColor = presentationData.theme.rootController.navigationBar.backgroundColor + self.backgroundNode.backgroundColor = presentationData.theme.rootController.navigationBar.blurredBackgroundColor self.separatorNode.backgroundColor = presentationData.theme.rootController.navigationBar.separatorColor let interfaceState = ChatPresentationInterfaceState(chatWallpaper: .color(0), theme: presentationData.theme, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, limitsConfiguration: .defaultValue, fontSize: .regular, bubbleCorners: PresentationChatBubbleCorners(mainRadius: 16.0, auxiliaryRadius: 8.0, mergeBubbleCorners: true), accountPeerId: self.context.account.peerId, mode: .standard(previewing: false), chatLocation: .peer(self.peerId), subject: nil, peerNearbyData: nil, greetingData: nil, pendingUnpinnedAllMessages: false, activeGroupCallInfo: nil, hasActiveGroupCall: false, importState: nil) diff --git a/submodules/TelegramUI/Sources/PeerMediaCollectionSectionsNode.swift b/submodules/TelegramUI/Sources/PeerMediaCollectionSectionsNode.swift index 536bab0372..983769ee0e 100644 --- a/submodules/TelegramUI/Sources/PeerMediaCollectionSectionsNode.swift +++ b/submodules/TelegramUI/Sources/PeerMediaCollectionSectionsNode.swift @@ -35,7 +35,7 @@ final class PeerMediaCollectionSectionsNode: ASDisplayNode { super.init() - self.backgroundColor = self.theme.rootController.navigationBar.backgroundColor + self.backgroundColor = self.theme.rootController.navigationBar.opaqueBackgroundColor self.segmentedControlNode.selectedIndexChanged = { [weak self] index in self?.indexUpdated?(index) @@ -57,7 +57,7 @@ final class PeerMediaCollectionSectionsNode: ASDisplayNode { if interfaceState.theme !== self.theme { self.theme = interfaceState.theme self.separatorNode.backgroundColor = self.theme.rootController.navigationBar.separatorColor - self.backgroundColor = self.theme.rootController.navigationBar.backgroundColor + self.backgroundColor = self.theme.rootController.navigationBar.opaqueBackgroundColor self.segmentedControlNode.updateTheme(SegmentedControlTheme(theme: self.theme)) } diff --git a/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift b/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift index 63b2298c9f..37f95e9e7a 100644 --- a/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift +++ b/submodules/TelegramUI/Sources/PeerSelectionControllerNode.swift @@ -29,7 +29,7 @@ final class PeerSelectionControllerNode: ASDisplayNode { var navigationBar: NavigationBar? - private let toolbarBackgroundNode: ASDisplayNode? + private let toolbarBackgroundNode: NavigationBackgroundNode? private let toolbarSeparatorNode: ASDisplayNode? private let segmentedControlNode: SegmentedControlNode? @@ -71,8 +71,7 @@ final class PeerSelectionControllerNode: ASDisplayNode { self.presentationData = presentationData if hasChatListSelector && hasContactSelector { - self.toolbarBackgroundNode = ASDisplayNode() - self.toolbarBackgroundNode?.backgroundColor = self.presentationData.theme.rootController.navigationBar.backgroundColor + self.toolbarBackgroundNode = NavigationBackgroundNode(color: self.presentationData.theme.rootController.navigationBar.blurredBackgroundColor) self.toolbarSeparatorNode = ASDisplayNode() self.toolbarSeparatorNode?.backgroundColor = self.presentationData.theme.rootController.navigationBar.separatorColor @@ -94,7 +93,7 @@ final class PeerSelectionControllerNode: ASDisplayNode { chatListcategories.append(ChatListNodeAdditionalCategory(id: 0, icon: PresentationResourcesItemList.createGroupIcon(self.presentationData.theme), title: self.presentationData.strings.PeerSelection_ImportIntoNewGroup, appearance: .action)) } - self.chatListNode = ChatListNode(context: context, groupId: .root, previewing: false, fillPreloadItems: false, mode: .peers(filter: filter, isSelecting: false, additionalCategories: chatListcategories, chatListFilters: nil), theme: self.presentationData.theme, fontSize: presentationData.listsFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations) + self.chatListNode = ChatListNode(context: context, groupId: .root, previewing: false, fillPreloadItems: false, mode: .peers(filter: filter, isSelecting: false, additionalCategories: chatListcategories, chatListFilters: nil), theme: self.presentationData.theme, fontSize: presentationData.listsFontSize, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: true) super.init() @@ -175,9 +174,9 @@ final class PeerSelectionControllerNode: ASDisplayNode { private func updateThemeAndStrings() { self.backgroundColor = self.presentationData.theme.chatList.backgroundColor self.searchDisplayController?.updatePresentationData(self.presentationData) - self.chatListNode.updateThemeAndStrings(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: self.presentationData.disableAnimations) + self.chatListNode.updateThemeAndStrings(theme: self.presentationData.theme, fontSize: self.presentationData.listsFontSize, strings: self.presentationData.strings, dateTimeFormat: self.presentationData.dateTimeFormat, nameSortOrder: self.presentationData.nameSortOrder, nameDisplayOrder: self.presentationData.nameDisplayOrder, disableAnimations: true) - self.toolbarBackgroundNode?.backgroundColor = self.presentationData.theme.rootController.navigationBar.backgroundColor + self.toolbarBackgroundNode?.color = self.presentationData.theme.rootController.navigationBar.blurredBackgroundColor self.toolbarSeparatorNode?.backgroundColor = self.presentationData.theme.rootController.navigationBar.separatorColor self.segmentedControlNode?.updateTheme(SegmentedControlTheme(theme: self.presentationData.theme)) } @@ -192,6 +191,7 @@ final class PeerSelectionControllerNode: ASDisplayNode { if let segmentedControlNode = self.segmentedControlNode, let toolbarBackgroundNode = self.toolbarBackgroundNode, let toolbarSeparatorNode = self.toolbarSeparatorNode { toolbarHeight += 44.0 transition.updateFrame(node: toolbarBackgroundNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - toolbarHeight), size: CGSize(width: layout.size.width, height: toolbarHeight))) + toolbarBackgroundNode.update(size: toolbarBackgroundNode.bounds.size, transition: transition) transition.updateFrame(node: toolbarSeparatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - toolbarHeight), size: CGSize(width: layout.size.width, height: UIScreenPixel))) let controlSize = segmentedControlNode.updateLayout(.sizeToFit(maximumWidth: layout.size.width, minimumWidth: 200.0, height: 32.0), transition: transition) diff --git a/submodules/TelegramUI/Sources/ThemeUpdateManager.swift b/submodules/TelegramUI/Sources/ThemeUpdateManager.swift index db37c1f418..58dc72a6d5 100644 --- a/submodules/TelegramUI/Sources/ThemeUpdateManager.swift +++ b/submodules/TelegramUI/Sources/ThemeUpdateManager.swift @@ -139,7 +139,7 @@ final class ThemeUpdateManagerImpl: ThemeUpdateManager { theme = updatedTheme } - return PresentationThemeSettings(theme: theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations) + return PresentationThemeSettings(theme: theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: current.themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, reduceMotion: current.reduceMotion) }) }).start() } diff --git a/submodules/TelegramUI/Sources/WallpaperUploadManager.swift b/submodules/TelegramUI/Sources/WallpaperUploadManager.swift index 3d5211e7f6..00a84853a5 100644 --- a/submodules/TelegramUI/Sources/WallpaperUploadManager.swift +++ b/submodules/TelegramUI/Sources/WallpaperUploadManager.swift @@ -130,7 +130,7 @@ final class WallpaperUploadManagerImpl: WallpaperUploadManager { var themeSpecificChatWallpapers = current.themeSpecificChatWallpapers themeSpecificChatWallpapers[themeReference.index] = updatedWallpaper themeSpecificChatWallpapers[coloredThemeIndex(reference: themeReference, accentColor: current.themeSpecificAccentColors[themeReference.index])] = updatedWallpaper - return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, disableAnimations: current.disableAnimations) + return PresentationThemeSettings(theme: current.theme, themeSpecificAccentColors: current.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: current.useSystemFont, fontSize: current.fontSize, listsFontSize: current.listsFontSize, chatBubbleSettings: current.chatBubbleSettings, automaticThemeSwitchSetting: current.automaticThemeSwitchSetting, largeEmoji: current.largeEmoji, reduceMotion: current.reduceMotion) })).start() } diff --git a/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift b/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift index 57f98c02d8..8e6e92315a 100644 --- a/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift @@ -568,7 +568,7 @@ public struct PresentationThemeSettings: PreferencesEntry { public var chatBubbleSettings: PresentationChatBubbleSettings public var automaticThemeSwitchSetting: AutomaticThemeSwitchSetting public var largeEmoji: Bool - public var disableAnimations: Bool + public var reduceMotion: Bool private func wallpaperResources(_ wallpaper: TelegramWallpaper) -> [MediaResourceId] { switch wallpaper { @@ -606,10 +606,10 @@ public struct PresentationThemeSettings: PreferencesEntry { } public static var defaultSettings: PresentationThemeSettings { - return PresentationThemeSettings(theme: .builtin(.dayClassic), themeSpecificAccentColors: [:], themeSpecificChatWallpapers: [:], useSystemFont: true, fontSize: .regular, listsFontSize: .regular, chatBubbleSettings: .default, automaticThemeSwitchSetting: AutomaticThemeSwitchSetting(trigger: .system, theme: .builtin(.night)), largeEmoji: true, disableAnimations: true) + return PresentationThemeSettings(theme: .builtin(.dayClassic), themeSpecificAccentColors: [:], themeSpecificChatWallpapers: [:], useSystemFont: true, fontSize: .regular, listsFontSize: .regular, chatBubbleSettings: .default, automaticThemeSwitchSetting: AutomaticThemeSwitchSetting(trigger: .system, theme: .builtin(.night)), largeEmoji: true, reduceMotion: false) } - public init(theme: PresentationThemeReference, themeSpecificAccentColors: [Int64: PresentationThemeAccentColor], themeSpecificChatWallpapers: [Int64: TelegramWallpaper], useSystemFont: Bool, fontSize: PresentationFontSize, listsFontSize: PresentationFontSize, chatBubbleSettings: PresentationChatBubbleSettings, automaticThemeSwitchSetting: AutomaticThemeSwitchSetting, largeEmoji: Bool, disableAnimations: Bool) { + public init(theme: PresentationThemeReference, themeSpecificAccentColors: [Int64: PresentationThemeAccentColor], themeSpecificChatWallpapers: [Int64: TelegramWallpaper], useSystemFont: Bool, fontSize: PresentationFontSize, listsFontSize: PresentationFontSize, chatBubbleSettings: PresentationChatBubbleSettings, automaticThemeSwitchSetting: AutomaticThemeSwitchSetting, largeEmoji: Bool, reduceMotion: Bool) { self.theme = theme self.themeSpecificAccentColors = themeSpecificAccentColors self.themeSpecificChatWallpapers = themeSpecificChatWallpapers @@ -619,7 +619,7 @@ public struct PresentationThemeSettings: PreferencesEntry { self.chatBubbleSettings = chatBubbleSettings self.automaticThemeSwitchSetting = automaticThemeSwitchSetting self.largeEmoji = largeEmoji - self.disableAnimations = disableAnimations + self.reduceMotion = reduceMotion } public init(decoder: PostboxDecoder) { @@ -644,7 +644,7 @@ public struct PresentationThemeSettings: PreferencesEntry { self.chatBubbleSettings = decoder.decodeObjectForKey("chatBubbleSettings", decoder: { PresentationChatBubbleSettings(decoder: $0) }) as? PresentationChatBubbleSettings ?? PresentationChatBubbleSettings.default self.automaticThemeSwitchSetting = (decoder.decodeObjectForKey("automaticThemeSwitchSetting", decoder: { AutomaticThemeSwitchSetting(decoder: $0) }) as? AutomaticThemeSwitchSetting) ?? AutomaticThemeSwitchSetting(trigger: .system, theme: .builtin(.night)) self.largeEmoji = decoder.decodeBoolForKey("largeEmoji", orElse: true) - self.disableAnimations = decoder.decodeBoolForKey("disableAnimations", orElse: true) + self.reduceMotion = decoder.decodeBoolForKey("reduceMotion", orElse: false) } public func encode(_ encoder: PostboxEncoder) { @@ -661,7 +661,7 @@ public struct PresentationThemeSettings: PreferencesEntry { encoder.encodeObject(self.chatBubbleSettings, forKey: "chatBubbleSettings") encoder.encodeObject(self.automaticThemeSwitchSetting, forKey: "automaticThemeSwitchSetting") encoder.encodeBool(self.largeEmoji, forKey: "largeEmoji") - encoder.encodeBool(self.disableAnimations, forKey: "disableAnimations") + encoder.encodeBool(self.reduceMotion, forKey: "reduceMotion") } public func isEqual(to: PreferencesEntry) -> Bool { @@ -673,43 +673,43 @@ public struct PresentationThemeSettings: PreferencesEntry { } public static func ==(lhs: PresentationThemeSettings, rhs: PresentationThemeSettings) -> Bool { - return lhs.theme == rhs.theme && lhs.themeSpecificAccentColors == rhs.themeSpecificAccentColors && lhs.themeSpecificChatWallpapers == rhs.themeSpecificChatWallpapers && lhs.useSystemFont == rhs.useSystemFont && lhs.fontSize == rhs.fontSize && lhs.listsFontSize == rhs.listsFontSize && lhs.chatBubbleSettings == rhs.chatBubbleSettings && lhs.automaticThemeSwitchSetting == rhs.automaticThemeSwitchSetting && lhs.largeEmoji == rhs.largeEmoji && lhs.disableAnimations == rhs.disableAnimations + return lhs.theme == rhs.theme && lhs.themeSpecificAccentColors == rhs.themeSpecificAccentColors && lhs.themeSpecificChatWallpapers == rhs.themeSpecificChatWallpapers && lhs.useSystemFont == rhs.useSystemFont && lhs.fontSize == rhs.fontSize && lhs.listsFontSize == rhs.listsFontSize && lhs.chatBubbleSettings == rhs.chatBubbleSettings && lhs.automaticThemeSwitchSetting == rhs.automaticThemeSwitchSetting && lhs.largeEmoji == rhs.largeEmoji && lhs.reduceMotion == rhs.reduceMotion } public func withUpdatedTheme(_ theme: PresentationThemeReference) -> PresentationThemeSettings { - return PresentationThemeSettings(theme: theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, disableAnimations: self.disableAnimations) + return PresentationThemeSettings(theme: theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, reduceMotion: self.reduceMotion) } public func withUpdatedThemeSpecificAccentColors(_ themeSpecificAccentColors: [Int64: PresentationThemeAccentColor]) -> PresentationThemeSettings { - return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, disableAnimations: self.disableAnimations) + return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, reduceMotion: self.reduceMotion) } public func withUpdatedThemeSpecificChatWallpapers(_ themeSpecificChatWallpapers: [Int64: TelegramWallpaper]) -> PresentationThemeSettings { - return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, disableAnimations: self.disableAnimations) + return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, reduceMotion: self.reduceMotion) } public func withUpdatedUseSystemFont(_ useSystemFont: Bool) -> PresentationThemeSettings { - return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, disableAnimations: self.disableAnimations) + return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, reduceMotion: self.reduceMotion) } public func withUpdatedFontSizes(fontSize: PresentationFontSize, listsFontSize: PresentationFontSize) -> PresentationThemeSettings { - return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: fontSize, listsFontSize: listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, disableAnimations: self.disableAnimations) + return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: fontSize, listsFontSize: listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, reduceMotion: self.reduceMotion) } public func withUpdatedChatBubbleSettings(_ chatBubbleSettings: PresentationChatBubbleSettings) -> PresentationThemeSettings { - return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, disableAnimations: self.disableAnimations) + return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, reduceMotion: self.reduceMotion) } public func withUpdatedAutomaticThemeSwitchSetting(_ automaticThemeSwitchSetting: AutomaticThemeSwitchSetting) -> PresentationThemeSettings { - return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, disableAnimations: self.disableAnimations) + return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, reduceMotion: self.reduceMotion) } public func withUpdatedLargeEmoji(_ largeEmoji: Bool) -> PresentationThemeSettings { - return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: largeEmoji, disableAnimations: self.disableAnimations) + return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: largeEmoji, reduceMotion: self.reduceMotion) } - public func withUpdatedDisableAnimations(_ disableAnimations: Bool) -> PresentationThemeSettings { - return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, disableAnimations: disableAnimations) + public func withUpdatedReduceMotion(_ reduceMotion: Bool) -> PresentationThemeSettings { + return PresentationThemeSettings(theme: self.theme, themeSpecificAccentColors: self.themeSpecificAccentColors, themeSpecificChatWallpapers: self.themeSpecificChatWallpapers, useSystemFont: self.useSystemFont, fontSize: self.fontSize, listsFontSize: self.listsFontSize, chatBubbleSettings: self.chatBubbleSettings, automaticThemeSwitchSetting: self.automaticThemeSwitchSetting, largeEmoji: self.largeEmoji, reduceMotion: reduceMotion) } } diff --git a/submodules/WallpaperBackgroundNode/BUILD b/submodules/WallpaperBackgroundNode/BUILD index 64bd9d17c4..f962c22f02 100644 --- a/submodules/WallpaperBackgroundNode/BUILD +++ b/submodules/WallpaperBackgroundNode/BUILD @@ -15,6 +15,11 @@ swift_library( "//submodules/GradientBackground:GradientBackground", "//submodules/TelegramPresentationData:TelegramPresentationData", "//submodules/SyncCore:SyncCore", + "//submodules/TelegramCore:TelegramCore", + "//submodules/Postbox:Postbox", + "//submodules/AccountContext:AccountContext", + "//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit", + "//submodules/WallpaperResources:WallpaperResources", ], visibility = [ "//visibility:public", diff --git a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift index 0bbe798466..cd637a78a8 100644 --- a/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift +++ b/submodules/WallpaperBackgroundNode/Sources/WallpaperBackgroundNode.swift @@ -5,15 +5,25 @@ import Display import GradientBackground import TelegramPresentationData import SyncCore +import TelegramCore +import AccountContext +import SwiftSignalKit +import WallpaperResources +import Postbox private let motionAmount: CGFloat = 32.0 public final class WallpaperBackgroundNode: ASDisplayNode { + private let context: AccountContext + private let contentNode: ASDisplayNode private var gradientBackgroundNode: GradientBackgroundNode? + private let patternImageNode: TransformImageNode private var validLayout: CGSize? private var wallpaper: TelegramWallpaper? + + private let patternImageDisposable = MetaDisposable() private var motionEnabled: Bool = false { didSet { @@ -74,11 +84,15 @@ public final class WallpaperBackgroundNode: ASDisplayNode { } } - public override init() { + public init(context: AccountContext) { + self.context = context self.imageContentMode = .scaleAspectFill self.contentNode = ASDisplayNode() self.contentNode.contentMode = self.imageContentMode + + self.patternImageNode = TransformImageNode() + self.patternImageNode.layer.compositingFilter = "softLightBlendMode" super.init() @@ -87,7 +101,12 @@ public final class WallpaperBackgroundNode: ASDisplayNode { self.addSubnode(self.contentNode) } + deinit { + self.patternImageDisposable.dispose() + } + public func update(wallpaper: TelegramWallpaper) { + let previousWallpaper = self.wallpaper if self.wallpaper == wallpaper { return } @@ -97,12 +116,28 @@ public final class WallpaperBackgroundNode: ASDisplayNode { if self.gradientBackgroundNode == nil { let gradientBackgroundNode = createGradientBackgroundNode() self.gradientBackgroundNode = gradientBackgroundNode - self.addSubnode(gradientBackgroundNode) + self.insertSubnode(gradientBackgroundNode, aboveSubnode: self.contentNode) + gradientBackgroundNode.addSubnode(self.patternImageNode) } self.gradientBackgroundNode?.updateColors(colors: gradient?.colors.map({ color -> UIColor in return UIColor(rgb: color) }) ?? defaultBuiltinWallpaperGradientColors) self.contentNode.isHidden = true + } else if case let .file(_, _, _, _, isPattern, _, _, _, settings) = wallpaper, isPattern, !settings.additionalColors.isEmpty { + if self.gradientBackgroundNode == nil { + let gradientBackgroundNode = createGradientBackgroundNode() + self.gradientBackgroundNode = gradientBackgroundNode + self.insertSubnode(gradientBackgroundNode, aboveSubnode: self.contentNode) + gradientBackgroundNode.addSubnode(self.patternImageNode) + } + var colors: [UInt32] = [] + colors.append(settings.color ?? 0) + colors.append(settings.bottomColor ?? 0) + colors.append(contentsOf: settings.additionalColors) + self.gradientBackgroundNode?.updateColors(colors: colors.map({ color -> UIColor in + return UIColor(rgb: color) + })) + self.contentNode.isHidden = true } else { if let gradientBackgroundNode = self.gradientBackgroundNode { self.gradientBackgroundNode = nil @@ -119,6 +154,44 @@ public final class WallpaperBackgroundNode: ASDisplayNode { self.contentNode.isHidden = false } + switch wallpaper { + case let .file(id, _, _, _, isPattern, _, _, file, settings): + var updated = true + if let previousWallpaper = previousWallpaper { + switch previousWallpaper { + case let .file(previousId, _, _, _, previousIsPattern, _, _, _, _): + if id == previousId && isPattern == previousIsPattern { + updated = false + } + default: + break + } + } + + if updated { + func reference(for resource: MediaResource, media: Media, message: Message?) -> MediaResourceReference { + if let message = message { + return .media(media: .message(message: MessageReference(message), media: media), resource: resource) + } + return .wallpaper(wallpaper: nil, resource: resource) + } + + var convertedRepresentations: [ImageRepresentationWithReference] = [] + for representation in file.previewRepresentations { + convertedRepresentations.append(ImageRepresentationWithReference(representation: representation, reference: reference(for: representation.resource, media: file, message: nil))) + } + let dimensions = file.dimensions ?? PixelDimensions(width: 2000, height: 4000) + convertedRepresentations.append(ImageRepresentationWithReference(representation: .init(dimensions: dimensions, resource: file.resource, progressiveSizes: [], immediateThumbnailData: nil), reference: reference(for: file.resource, media: file, message: nil))) + + let signal = patternWallpaperImage(account: self.context.account, accountManager: self.context.sharedContext.accountManager, representations: convertedRepresentations, mode: .screen, autoFetchFullSize: true) + self.patternImageNode.setSignal(signal) + } + self.patternImageNode.alpha = CGFloat(settings.intensity ?? 50) / 100.0 + self.patternImageNode.isHidden = false + default: + self.patternImageNode.isHidden = true + } + if let size = self.validLayout { self.updateLayout(size: size, transition: .immediate) } @@ -135,6 +208,11 @@ public final class WallpaperBackgroundNode: ASDisplayNode { transition.updateFrame(node: gradientBackgroundNode, frame: CGRect(origin: CGPoint(), size: size)) gradientBackgroundNode.updateLayout(size: size, transition: transition) } + + let makeImageLayout = self.patternImageNode.asyncLayout() + let applyImage = makeImageLayout(TransformImageArguments(corners: ImageCorners(), imageSize: size, boundingSize: size, intrinsicInsets: UIEdgeInsets(), custom: PatternWallpaperArguments(colors: [.clear], rotation: nil, customPatternColor: .black, preview: false))) + applyImage() + transition.updateFrame(node: self.patternImageNode, frame: CGRect(origin: CGPoint(), size: size)) if isFirstLayout && !self.frame.isEmpty { self.updateScale() @@ -142,17 +220,6 @@ public final class WallpaperBackgroundNode: ASDisplayNode { } public func animateEvent(transition: ContainedViewLayoutTransition) { - guard let wallpaper = self.wallpaper else { - return - } - switch wallpaper { - case let .builtin(_, settings): - if !settings.motion { - //return - } - default: - break - } self.gradientBackgroundNode?.animateEvent(transition: transition) } } diff --git a/submodules/WallpaperResources/Sources/WallpaperResources.swift b/submodules/WallpaperResources/Sources/WallpaperResources.swift index f6ab694f04..0332fe9a7c 100644 --- a/submodules/WallpaperResources/Sources/WallpaperResources.swift +++ b/submodules/WallpaperResources/Sources/WallpaperResources.swift @@ -300,10 +300,12 @@ public struct PatternWallpaperArguments: TransformImageCustomArguments { let colors: [UIColor] let rotation: Int32? let preview: Bool + let customPatternColor: UIColor? - public init(colors: [UIColor], rotation: Int32?, preview: Bool = false) { + public init(colors: [UIColor], rotation: Int32?, customPatternColor: UIColor? = nil, preview: Bool = false) { self.colors = colors self.rotation = rotation + self.customPatternColor = customPatternColor self.preview = preview } @@ -405,7 +407,7 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da prominent = true } - var scale: CGFloat = 0.0 + let scale: CGFloat = 0.0 return .single((thumbnailData, fullSizeData, fullSizeComplete)) |> map { (thumbnailData, fullSizeData, fullSizeComplete) in @@ -446,8 +448,12 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da c.setBlendMode(.copy) if colors.count == 1 { - c.setFillColor(color.cgColor) - c.fill(arguments.drawingRect) + if customArguments.colors[0].alpha.isZero { + c.clear(arguments.drawingRect) + } else { + c.setFillColor(color.cgColor) + c.fill(arguments.drawingRect) + } } else { let gradientColors = colors.map { $0.cgColor } as CFArray let delta: CGFloat = 1.0 / (CGFloat(colors.count) - 1.0) @@ -486,7 +492,7 @@ public func patternWallpaperImageInternal(thumbnailData: Data?, fullSizeData: Da c.clip(to: fittedRect, mask: image) if colors.count == 1 { - c.setFillColor(patternColor(for: color, intensity: intensity, prominent: prominent).cgColor) + c.setFillColor(customArguments.customPatternColor?.cgColor ?? patternColor(for: color, intensity: intensity, prominent: prominent).cgColor) c.fill(arguments.drawingRect) } else { let gradientColors = colors.map { patternColor(for: $0, intensity: intensity, prominent: prominent).cgColor } as CFArray @@ -777,7 +783,7 @@ public func drawThemeImage(context c: CGContext, theme: PresentationTheme, wallp break } - c.setFillColor(theme.rootController.navigationBar.backgroundColor.cgColor) + c.setFillColor(theme.rootController.navigationBar.opaqueBackgroundColor.cgColor) c.fill(CGRect(origin: CGPoint(x: 0.0, y: drawingRect.height - 42.0), size: CGSize(width: drawingRect.width, height: 42.0))) c.setFillColor(theme.rootController.navigationBar.separatorColor.cgColor) diff --git a/submodules/WebSearchUI/Sources/WebSearchController.swift b/submodules/WebSearchUI/Sources/WebSearchController.swift index 9272ed5519..71c802442d 100644 --- a/submodules/WebSearchUI/Sources/WebSearchController.swift +++ b/submodules/WebSearchUI/Sources/WebSearchController.swift @@ -172,7 +172,7 @@ public final class WebSearchController: ViewController { self.interfaceState = self.interfaceState.withUpdatedQuery(query) } - super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: presentationData.theme).withUpdatedSeparatorColor(presentationData.theme.rootController.navigationBar.backgroundColor), strings: NavigationBarStrings(presentationStrings: presentationData.strings))) + super.init(navigationBarPresentationData: NavigationBarPresentationData(theme: NavigationBarTheme(rootControllerTheme: presentationData.theme).withUpdatedSeparatorColor(presentationData.theme.rootController.navigationBar.opaqueBackgroundColor), strings: NavigationBarStrings(presentationStrings: presentationData.strings))) self.statusBar.statusBarStyle = presentationData.theme.rootController.statusBarStyle.style self.scrollToTop = { [weak self] in diff --git a/submodules/WebSearchUI/Sources/WebSearchControllerNode.swift b/submodules/WebSearchUI/Sources/WebSearchControllerNode.swift index 8a13114399..80bc1ec2bf 100644 --- a/submodules/WebSearchUI/Sources/WebSearchControllerNode.swift +++ b/submodules/WebSearchUI/Sources/WebSearchControllerNode.swift @@ -350,10 +350,10 @@ class WebSearchControllerNode: ASDisplayNode { } if themeUpdated { - self.segmentedBackgroundNode.backgroundColor = self.theme.rootController.navigationBar.backgroundColor + self.segmentedBackgroundNode.backgroundColor = self.theme.rootController.navigationBar.opaqueBackgroundColor self.segmentedSeparatorNode.backgroundColor = self.theme.rootController.navigationBar.separatorColor self.segmentedControlNode.updateTheme(SegmentedControlTheme(theme: self.theme)) - self.toolbarBackgroundNode.backgroundColor = self.theme.rootController.navigationBar.backgroundColor + self.toolbarBackgroundNode.backgroundColor = self.theme.rootController.navigationBar.opaqueBackgroundColor self.toolbarSeparatorNode.backgroundColor = self.theme.rootController.navigationBar.separatorColor }