From d53d08d5ddf5b85136ffa1ecdbcebf661a328fe4 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 25 Sep 2022 23:46:12 +0300 Subject: [PATCH] Various fixes --- submodules/Emoji/Sources/EmojiUtils.swift | 2 +- .../Themes/ThemeSettingsThemeItem.swift | 7 ++- .../DefaultDarkPresentationTheme.swift | 16 ++++-- .../Sources/PresentationData.swift | 4 +- .../TelegramUI/Sources/ChatBotInfoItem.swift | 47 ++++++++++++++++- .../Sources/ChatControllerNode.swift | 5 +- .../TelegramUI/Sources/ChatEmptyNode.swift | 5 +- .../ChatMessageActionButtonsNode.swift | 36 ++++++------- .../Sources/ChatMessageActionItemNode.swift | 6 +++ .../ChatMessageAnimatedStickerItemNode.swift | 8 ++- .../Sources/ChatMessageBubbleItemNode.swift | 12 +++-- .../ChatMessageInstantVideoItemNode.swift | 24 ++++++++- .../TelegramUI/Sources/ChatMessageItem.swift | 2 +- .../Sources/ChatMessageStickerItemNode.swift | 24 ++++++++- .../Sources/ChatMessageSwipeToReplyNode.swift | 45 +++++++++++++++- .../ChatRecentActionsControllerNode.swift | 2 +- .../Sources/ChatRecentActionsEmptyNode.swift | 51 +++++++++++++++++-- .../Sources/PeerInfo/PeerInfoScreen.swift | 6 ++- .../Sources/PresentationThemeSettings.swift | 12 +++++ .../TranslateUI/Sources/Translate.swift | 4 +- 20 files changed, 267 insertions(+), 51 deletions(-) diff --git a/submodules/Emoji/Sources/EmojiUtils.swift b/submodules/Emoji/Sources/EmojiUtils.swift index 424fc492bb..4d393fdb6b 100644 --- a/submodules/Emoji/Sources/EmojiUtils.swift +++ b/submodules/Emoji/Sources/EmojiUtils.swift @@ -28,7 +28,7 @@ extension Character { public extension UnicodeScalar { var isEmoji: Bool { switch self.value { - case 0x1F600...0x1F64F, 0x1F300...0x1F5FF, 0x1F680...0x1F6FF, 0x1F1E6...0x1F1FF, 0xE0020...0xE007F, 0xFE00...0xFE0F, 0x1F900...0x1F9FF, 0x1F018...0x1F0F5, 0x1F200...0x1F270, 65024...65039, 9100...9300, 8400...8447, 0x1F004, 0x1F18E, 0x1F191...0x1F19A, 0x1F5E8, 0x1FA70...0x1FA73, 0x1FA78...0x1FA7A, 0x1FA80...0x1FA82, 0x1FA90...0x1FA95, 0x1FAE0, 0x1FAF1, 0x1FAF2, 0x1F382: + case 0x1F600...0x1F64F, 0x1F300...0x1F5FF, 0x1F680...0x1F6FF, 0x1F1E6...0x1F1FF, 0xE0020...0xE007F, 0xFE00...0xFE0F, 0x1F900...0x1F9FF, 0x1F018...0x1F0F5, 0x1F200...0x1F270, 65024...65039, 9100...9300, 8400...8447, 0x1F004, 0x1F18E, 0x1F191...0x1F19A, 0x1F5E8, 0x1FA70...0x1FA73, 0x1FA78...0x1FA7A, 0x1FA80...0x1FA82, 0x1FA90...0x1FA95, 0x1FAE0, 0x1FAF0...0x1FAF6, 0x1F382: return true case 0x2603, 0x265F, 0x267E, 0x2692, 0x26C4, 0x26C8, 0x26CE, 0x26CF, 0x26D1...0x26D3, 0x26E9, 0x26F0...0x26F9, 0x2705, 0x270A, 0x270B, 0x2728, 0x274E, 0x2753...0x2755, 0x274C, 0x2795...0x2797, 0x27B0, 0x27BF: return true diff --git a/submodules/SettingsUI/Sources/Themes/ThemeSettingsThemeItem.swift b/submodules/SettingsUI/Sources/Themes/ThemeSettingsThemeItem.swift index 85fbd1e7f3..a868b85e56 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeSettingsThemeItem.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeSettingsThemeItem.swift @@ -178,6 +178,11 @@ private func createThemeImage(theme: PresentationTheme) -> Signal<(TransformImag context.withContext { c in c.clear(CGRect(origin: CGPoint(), size: drawingRect.size)) + c.setFillColor(theme.list.plainBackgroundColor.cgColor) + let path = UIBezierPath(roundedRect: drawingRect, cornerRadius: arguments.corners.topLeft.radius) + c.addPath(path.cgPath) + c.fillPath() + c.translateBy(x: drawingRect.width / 2.0, y: drawingRect.height / 2.0) c.scaleBy(x: 1.0, y: -1.0) c.translateBy(x: -drawingRect.width / 2.0, y: -drawingRect.height / 2.0) @@ -287,7 +292,7 @@ private final class ThemeSettingsThemeItemIconNode : ListViewItemNode { strongSelf.containerNode.isGestureEnabled = true } if updatedTheme || updatedSelected { - strongSelf.overlayNode.image = generateBorderImage(theme: item.theme, bordered: true, selected: item.selected) + strongSelf.overlayNode.image = generateBorderImage(theme: item.theme, bordered: false, selected: item.selected) } strongSelf.containerNode.frame = CGRect(origin: CGPoint(), size: itemLayout.contentSize) diff --git a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift index 854e2ea5e2..154fa5571c 100644 --- a/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/DefaultDarkPresentationTheme.swift @@ -56,6 +56,12 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit if accentColor.rgb == 0xffffff { monochrome = true bubbleColors = [UIColor(rgb: 0x313131).rgb, UIColor(rgb: 0x313131).rgb] + } else if accentColor.rgb == 0x3e88f7 { + bubbleColors = [ + 0x0771ff, + 0x9047ff, + 0xa256bf, + ] } else { bubbleColors = [accentColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98).rgb, accentColor.rgb] } @@ -312,10 +318,10 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit } public let defaultDarkWallpaperGradientColors: [UIColor] = [ - UIColor(rgb: 0x00b3dd), - UIColor(rgb: 0x3b59f2), - UIColor(rgb: 0x358be2), - UIColor(rgb: 0xa434cf) + UIColor(rgb: 0x598bf6), + UIColor(rgb: 0x7a5eef), + UIColor(rgb: 0xd67cff), + UIColor(rgb: 0xf38b58) ] public func makeDefaultDarkPresentationTheme(extendingThemeReference: PresentationThemeReference? = nil, preview: Bool) -> PresentationTheme { @@ -675,7 +681,7 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati badgeTextColor: UIColor(rgb: 0x000000) ) - let defaultPatternWallpaper: TelegramWallpaper = defaultBuiltinWallpaper(data: .default, colors: defaultDarkWallpaperGradientColors.map(\.rgb), intensity: -35) + let defaultPatternWallpaper: TelegramWallpaper = defaultBuiltinWallpaper(data: .default, colors: defaultDarkWallpaperGradientColors.map(\.rgb), intensity: -34) let chat = PresentationThemeChat( defaultWallpaper: defaultPatternWallpaper, diff --git a/submodules/TelegramPresentationData/Sources/PresentationData.swift b/submodules/TelegramPresentationData/Sources/PresentationData.swift index 8ee1dda8b7..15b333c5c7 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationData.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationData.swift @@ -309,7 +309,7 @@ public func currentPresentationDataAndSettings(accountManager: AccountManager (_ item: ChatBotInfoItem, _ width: ListViewItemLayoutParams) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation) -> Void) { let makeImageLayout = self.imageNode.asyncLayout() let makeTitleLayout = TextNode.asyncLayout(self.titleNode) @@ -292,6 +311,32 @@ final class ChatBotInfoItemNode: ListViewItemNode { strongSelf.titleNode.frame = titleFrame strongSelf.textNode.frame = textFrame + if item.controllerInteraction.presentationContext.backgroundNode?.hasExtraBubbleBackground() == true { + if strongSelf.backgroundContent == nil, let backgroundContent = item.controllerInteraction.presentationContext.backgroundNode?.makeBubbleBackground(for: .free) { + backgroundContent.clipsToBounds = true + + strongSelf.backgroundContent = backgroundContent + strongSelf.insertSubnode(backgroundContent, at: 0) + } + } else { + strongSelf.backgroundContent?.removeFromSupernode() + strongSelf.backgroundContent = nil + } + + if let backgroundContent = strongSelf.backgroundContent { + strongSelf.backgroundNode.isHidden = true + backgroundContent.cornerRadius = item.presentationData.chatBubbleCorners.mainRadius + backgroundContent.frame = backgroundFrame + if let (rect, containerSize) = strongSelf.absolutePosition { + var backgroundFrame = backgroundContent.frame + backgroundFrame.origin.x += rect.minX + backgroundFrame.origin.y += containerSize.height - rect.minY + backgroundContent.update(rect: backgroundFrame, within: containerSize, transition: .immediate) + } + } else { + strongSelf.backgroundNode.isHidden = false + } + strongSelf.setup(context: item.context, videoFile: item.video) if let videoNode = strongSelf.videoNode { videoNode.updateLayout(size: imageFrame.size, transition: .immediate) diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index c67774c73c..cd06e81307 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -1385,7 +1385,8 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { if let restrictedNode = self.restrictedNode { transition.updateFrame(node: restrictedNode, frame: contentBounds) - restrictedNode.updateLayout(size: contentBounds.size, transition: transition) + restrictedNode.update(rect: contentBounds, within: contentBounds.size, transition: transition) + restrictedNode.updateLayout(backgroundNode: self.backgroundNode, size: contentBounds.size, transition: transition) } let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition) @@ -1515,7 +1516,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { if let emptyNode = self.emptyNode, let emptyType = self.emptyType { emptyNode.updateLayout(interfaceState: self.chatPresentationInterfaceState, emptyType: emptyType, loadingNode: nil, backgroundNode: self.backgroundNode, size: contentBounds.size, insets: emptyNodeInsets, transition: transition) transition.updateFrame(node: emptyNode, frame: contentBounds) - emptyNode.update(rect: contentBounds, within: contentBounds.size) + emptyNode.update(rect: contentBounds, within: contentBounds.size, transition: transition) } var contentBottomInset: CGFloat = inputPanelsHeight + 4.0 diff --git a/submodules/TelegramUI/Sources/ChatEmptyNode.swift b/submodules/TelegramUI/Sources/ChatEmptyNode.swift index dbae9369c6..c6b577c852 100644 --- a/submodules/TelegramUI/Sources/ChatEmptyNode.swift +++ b/submodules/TelegramUI/Sources/ChatEmptyNode.swift @@ -954,8 +954,9 @@ final class ChatEmptyNode: ASDisplayNode { if let backgroundContent = self.backgroundContent { self.backgroundNode.isHidden = true - backgroundContent.cornerRadius = min(20.0, self.backgroundNode.bounds.height / 2.0) - backgroundContent.frame = contentFrame + backgroundContent.cornerRadius = min(20.0, self.backgroundNode.bounds.height / 2.0) + transition.updateFrame(node: backgroundContent, frame: contentFrame) + if let (rect, containerSize) = self.absolutePosition { var backgroundFrame = backgroundContent.frame backgroundFrame.origin.x += rect.minX diff --git a/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift b/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift index 2b348b0274..6d0606d162 100644 --- a/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageActionButtonsNode.swift @@ -12,7 +12,7 @@ private let titleFont = Font.medium(16.0) private final class ChatMessageActionButtonNode: ASDisplayNode { private let backgroundBlurNode: NavigationBackgroundNode - private let backgroundMaskNode: ASImageNode + private var titleNode: TextNode? private var iconNode: ASImageNode? private var buttonView: HighlightTrackingButton? @@ -35,9 +35,6 @@ private final class ChatMessageActionButtonNode: ASDisplayNode { self.backgroundBlurNode = NavigationBackgroundNode(color: .clear) self.backgroundBlurNode.isUserInteractionEnabled = false - self.backgroundMaskNode = ASImageNode() - self.backgroundMaskNode.isUserInteractionEnabled = false - self.accessibilityArea = AccessibilityAreaNode() self.accessibilityArea.accessibilityTraits = .button @@ -159,18 +156,6 @@ private final class ChatMessageActionButtonNode: ASDisplayNode { let messageTheme = incoming ? theme.theme.chat.message.incoming : theme.theme.chat.message.outgoing let (titleSize, titleApply) = titleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: title, font: titleFont, textColor: bubbleVariableColor(variableColor: messageTheme.actionButtonsTextColor, wallpaper: theme.wallpaper)), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: max(44.0, constrainedWidth - minimumSideInset - minimumSideInset), height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets(top: 1.0, left: 0.0, bottom: 1.0, right: 0.0))) - let backgroundMaskImage: UIImage? - switch position { - case .middle: - backgroundMaskImage = graphics.chatBubbleActionButtonMiddleMaskImage - case .bottomLeft: - backgroundMaskImage = graphics.chatBubbleActionButtonBottomLeftMaskImage - case .bottomRight: - backgroundMaskImage = graphics.chatBubbleActionButtonBottomRightMaskImage - case .bottomSingle: - backgroundMaskImage = graphics.chatBubbleActionButtonBottomSingleMaskImage - } - return (titleSize.size.width + sideInset + sideInset, { width in return (CGSize(width: width, height: 42.0), { animation in var animation = animation @@ -194,11 +179,8 @@ private final class ChatMessageActionButtonNode: ASDisplayNode { node.longTapRecognizer?.isEnabled = false } - node.backgroundMaskNode.image = backgroundMaskImage - animation.animator.updateFrame(layer: node.backgroundMaskNode.layer, frame: CGRect(origin: CGPoint(), size: CGSize(width: max(0.0, width), height: 42.0)), completion: nil) - animation.animator.updateFrame(layer: node.backgroundBlurNode.layer, frame: CGRect(origin: CGPoint(), size: CGSize(width: max(0.0, width), height: 42.0)), completion: nil) - node.backgroundBlurNode.update(size: node.backgroundBlurNode.bounds.size, cornerRadius: bubbleCorners.auxiliaryRadius, animator: animation.animator) + node.backgroundBlurNode.update(size: node.backgroundBlurNode.bounds.size, cornerRadius: 0.0, animator: animation.animator) node.backgroundBlurNode.updateColor(color: selectDateFillStaticColor(theme: theme.theme, wallpaper: theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: theme.theme, wallpaper: theme.wallpaper), transition: .immediate) if backgroundNode?.hasExtraBubbleBackground() == true { @@ -222,10 +204,12 @@ private final class ChatMessageActionButtonNode: ASDisplayNode { node.backgroundColorNode = nil } + node.cornerRadius = bubbleCorners.auxiliaryRadius + node.clipsToBounds = true + if let backgroundContent = node.backgroundContent { node.backgroundBlurNode.isHidden = true backgroundContent.frame = node.backgroundBlurNode.frame - backgroundContent.cornerRadius = bubbleCorners.auxiliaryRadius node.backgroundColorNode?.frame = backgroundContent.bounds @@ -239,6 +223,16 @@ private final class ChatMessageActionButtonNode: ASDisplayNode { node.backgroundBlurNode.isHidden = false } + if position == .bottomSingle { + let rect = node.backgroundBlurNode.bounds + let maskPath = UIBezierPath(roundRect: rect, topLeftRadius: bubbleCorners.auxiliaryRadius, topRightRadius: bubbleCorners.auxiliaryRadius, bottomLeftRadius: bubbleCorners.mainRadius, bottomRightRadius: bubbleCorners.mainRadius) + let shape = CAShapeLayer() + shape.path = maskPath.cgPath + node.layer.mask = shape + } else { + node.layer.mask = nil + } + if iconImage != nil { if node.iconNode == nil { let iconNode = ASImageNode() diff --git a/submodules/TelegramUI/Sources/ChatMessageActionItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageActionItemNode.swift index c4773edf75..9a5e8bb317 100644 --- a/submodules/TelegramUI/Sources/ChatMessageActionItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageActionItemNode.swift @@ -333,6 +333,12 @@ class ChatMessageActionBubbleContentNode: ChatMessageBubbleContentNode { strongSelf.insertSubnode(backgroundNode, at: 0) } } + + if item.controllerInteraction.presentationContext.backgroundNode?.hasExtraBubbleBackground() == true { + strongSelf.backgroundColorNode.isHidden = true + } else { + strongSelf.backgroundColorNode.isHidden = false + } if backgroundMaskUpdated, let backgroundNode = strongSelf.backgroundNode { if labelRects.count == 1 { diff --git a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift index ee6292924d..ab0d28c5a8 100644 --- a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift @@ -2287,7 +2287,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { if translation.x < -45.0, self.swipeToReplyNode == nil, let item = self.item { self.swipeToReplyFeedback?.impact() - let swipeToReplyNode = ChatMessageSwipeToReplyNode(fillColor: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), foregroundColor: bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.shareButtonForegroundColor, wallpaper: item.presentationData.theme.wallpaper), action: ChatMessageSwipeToReplyNode.Action(self.currentSwipeAction)) + let swipeToReplyNode = ChatMessageSwipeToReplyNode(fillColor: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), foregroundColor: bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.shareButtonForegroundColor, wallpaper: item.presentationData.theme.wallpaper), backgroundNode: item.controllerInteraction.presentationContext.backgroundNode, action: ChatMessageSwipeToReplyNode.Action(self.currentSwipeAction)) self.swipeToReplyNode = swipeToReplyNode self.addSubnode(swipeToReplyNode) animateReplyNodeIn = true @@ -2302,6 +2302,12 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { if let swipeToReplyNode = self.swipeToReplyNode { swipeToReplyNode.frame = CGRect(origin: CGPoint(x: bounds.size.width, y: floor((self.contentSize.height - 33.0) / 2.0)), size: CGSize(width: 33.0, height: 33.0)) + + if let (rect, containerSize) = self.absoluteRect { + let mappedRect = CGRect(origin: CGPoint(x: rect.minX + swipeToReplyNode.frame.minX, y: rect.minY + swipeToReplyNode.frame.minY), size: swipeToReplyNode.frame.size) + swipeToReplyNode.updateAbsoluteRect(mappedRect, within: containerSize) + } + if animateReplyNodeIn { swipeToReplyNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.12) swipeToReplyNode.layer.animateSpring(from: 0.1 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.4) diff --git a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift index 997c2773db..025bbccd7c 100644 --- a/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageBubbleItemNode.swift @@ -2257,10 +2257,10 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode var layoutSize = CGSize(width: params.width, height: layoutBubbleSize.height) if let reactionButtonsSizeAndApply = reactionButtonsSizeAndApply { - layoutSize.height += 2.0 + reactionButtonsSizeAndApply.0.height + layoutSize.height += 4.0 + reactionButtonsSizeAndApply.0.height } if let actionButtonsSizeAndApply = actionButtonsSizeAndApply { - layoutSize.height += actionButtonsSizeAndApply.0.height + layoutSize.height += 1.0 + actionButtonsSizeAndApply.0.height } var layoutInsets = UIEdgeInsets(top: mergedTop.merged ? layoutConstants.bubble.mergedSpacing : layoutConstants.bubble.defaultSpacing, left: 0.0, bottom: mergedBottom.merged ? layoutConstants.bubble.mergedSpacing : layoutConstants.bubble.defaultSpacing, right: 0.0) @@ -3899,7 +3899,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode if translation.x < -45.0, self.swipeToReplyNode == nil, let item = self.item { self.swipeToReplyFeedback?.impact() - let swipeToReplyNode = ChatMessageSwipeToReplyNode(fillColor: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), foregroundColor: bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.shareButtonForegroundColor, wallpaper: item.presentationData.theme.wallpaper), action: ChatMessageSwipeToReplyNode.Action(self.currentSwipeAction)) + let swipeToReplyNode = ChatMessageSwipeToReplyNode(fillColor: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), foregroundColor: bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.shareButtonForegroundColor, wallpaper: item.presentationData.theme.wallpaper), backgroundNode: item.controllerInteraction.presentationContext.backgroundNode, action: ChatMessageSwipeToReplyNode.Action(self.currentSwipeAction)) self.swipeToReplyNode = swipeToReplyNode self.insertSubnode(swipeToReplyNode, belowSubnode: self.messageAccessibilityArea) animateReplyNodeIn = true @@ -3917,6 +3917,12 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode if let swipeToReplyNode = self.swipeToReplyNode { swipeToReplyNode.frame = CGRect(origin: CGPoint(x: bounds.size.width, y: floor((self.contentSize.height - 33.0) / 2.0)), size: CGSize(width: 33.0, height: 33.0)) + + if let (rect, containerSize) = self.absoluteRect { + let mappedRect = CGRect(origin: CGPoint(x: rect.minX + swipeToReplyNode.frame.minX, y: rect.minY + swipeToReplyNode.frame.minY), size: swipeToReplyNode.frame.size) + swipeToReplyNode.updateAbsoluteRect(mappedRect, within: containerSize) + } + if animateReplyNodeIn { swipeToReplyNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.12) swipeToReplyNode.layer.animateSpring(from: 0.1 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.4) diff --git a/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift index 2bb526a3d7..35cb176778 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInstantVideoItemNode.swift @@ -1000,7 +1000,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD if translation.x < -45.0, self.swipeToReplyNode == nil, let item = self.item { self.swipeToReplyFeedback?.impact() - let swipeToReplyNode = ChatMessageSwipeToReplyNode(fillColor: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), foregroundColor: bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.shareButtonForegroundColor, wallpaper: item.presentationData.theme.wallpaper), action: ChatMessageSwipeToReplyNode.Action(self.currentSwipeAction)) + let swipeToReplyNode = ChatMessageSwipeToReplyNode(fillColor: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), foregroundColor: bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.shareButtonForegroundColor, wallpaper: item.presentationData.theme.wallpaper), backgroundNode: item.controllerInteraction.presentationContext.backgroundNode, action: ChatMessageSwipeToReplyNode.Action(self.currentSwipeAction)) self.swipeToReplyNode = swipeToReplyNode self.addSubnode(swipeToReplyNode) animateReplyNodeIn = true @@ -1015,6 +1015,12 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD if let swipeToReplyNode = self.swipeToReplyNode { swipeToReplyNode.frame = CGRect(origin: CGPoint(x: bounds.size.width, y: floor((self.contentSize.height - 33.0) / 2.0)), size: CGSize(width: 33.0, height: 33.0)) + + if let (rect, containerSize) = self.absoluteRect { + let mappedRect = CGRect(origin: CGPoint(x: rect.minX + swipeToReplyNode.frame.minX, y: rect.minY + swipeToReplyNode.frame.minY), size: swipeToReplyNode.frame.size) + swipeToReplyNode.updateAbsoluteRect(mappedRect, within: containerSize) + } + if animateReplyNodeIn { swipeToReplyNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.12) swipeToReplyNode.layer.animateSpring(from: 0.1 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.4) @@ -1328,6 +1334,22 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD var rect = rect rect.origin.y = containerSize.height - rect.maxY + self.insets.top + if let shareButtonNode = self.shareButtonNode { + var shareButtonNodeFrame = shareButtonNode.frame + shareButtonNodeFrame.origin.x += rect.minX + shareButtonNodeFrame.origin.y += rect.minY + + shareButtonNode.updateAbsoluteRect(shareButtonNodeFrame, within: containerSize) + } + + if let actionButtonsNode = self.actionButtonsNode { + var actionButtonsNodeFrame = actionButtonsNode.frame + actionButtonsNodeFrame.origin.x += rect.minX + actionButtonsNodeFrame.origin.y += rect.minY + + actionButtonsNode.updateAbsoluteRect(actionButtonsNodeFrame, within: containerSize) + } + if let reactionButtonsNode = self.reactionButtonsNode { var reactionButtonsNodeFrame = reactionButtonsNode.frame reactionButtonsNodeFrame.origin.x += rect.minX diff --git a/submodules/TelegramUI/Sources/ChatMessageItem.swift b/submodules/TelegramUI/Sources/ChatMessageItem.swift index 547874fe48..df65a72313 100644 --- a/submodules/TelegramUI/Sources/ChatMessageItem.swift +++ b/submodules/TelegramUI/Sources/ChatMessageItem.swift @@ -177,7 +177,7 @@ private func messagesShouldBeMerged(accountPeerId: PeerId, _ lhs: Message, _ rhs for attribute in lhs.attributes { if let attribute = attribute as? ReplyMarkupMessageAttribute { if attribute.flags.contains(.inline) && !attribute.rows.isEmpty { - upperStyle = ChatMessageMerge.semanticallyMerged.rawValue + upperStyle = ChatMessageMerge.none.rawValue } break } diff --git a/submodules/TelegramUI/Sources/ChatMessageStickerItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageStickerItemNode.swift index a8f3362b55..6c3afc923d 100644 --- a/submodules/TelegramUI/Sources/ChatMessageStickerItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageStickerItemNode.swift @@ -277,6 +277,22 @@ class ChatMessageStickerItemNode: ChatMessageItemView { backgroundNode.update(rect: CGRect(origin: CGPoint(x: rect.minX + self.placeholderNode.frame.minX, y: rect.minY + self.placeholderNode.frame.minY), size: self.placeholderNode.frame.size), within: containerSize, transition: .immediate) } + if let shareButtonNode = self.shareButtonNode { + var shareButtonNodeFrame = shareButtonNode.frame + shareButtonNodeFrame.origin.x += rect.minX + shareButtonNodeFrame.origin.y += rect.minY + + shareButtonNode.updateAbsoluteRect(shareButtonNodeFrame, within: containerSize) + } + + if let actionButtonsNode = self.actionButtonsNode { + var actionButtonsNodeFrame = actionButtonsNode.frame + actionButtonsNodeFrame.origin.x += rect.minX + actionButtonsNodeFrame.origin.y += rect.minY + + actionButtonsNode.updateAbsoluteRect(actionButtonsNodeFrame, within: containerSize) + } + if let reactionButtonsNode = self.reactionButtonsNode { var reactionButtonsNodeFrame = reactionButtonsNode.frame reactionButtonsNodeFrame.origin.x += rect.minX @@ -1236,7 +1252,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView { if translation.x < -45.0, self.swipeToReplyNode == nil, let item = self.item { self.swipeToReplyFeedback?.impact() - let swipeToReplyNode = ChatMessageSwipeToReplyNode(fillColor: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), foregroundColor: bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.shareButtonForegroundColor, wallpaper: item.presentationData.theme.wallpaper), action: ChatMessageSwipeToReplyNode.Action(self.currentSwipeAction)) + let swipeToReplyNode = ChatMessageSwipeToReplyNode(fillColor: selectDateFillStaticColor(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), enableBlur: dateFillNeedsBlur(theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper), foregroundColor: bubbleVariableColor(variableColor: item.presentationData.theme.theme.chat.message.shareButtonForegroundColor, wallpaper: item.presentationData.theme.wallpaper), backgroundNode: item.controllerInteraction.presentationContext.backgroundNode, action: ChatMessageSwipeToReplyNode.Action(self.currentSwipeAction)) self.swipeToReplyNode = swipeToReplyNode self.addSubnode(swipeToReplyNode) animateReplyNodeIn = true @@ -1251,6 +1267,12 @@ class ChatMessageStickerItemNode: ChatMessageItemView { if let swipeToReplyNode = self.swipeToReplyNode { swipeToReplyNode.frame = CGRect(origin: CGPoint(x: bounds.size.width, y: floor((self.contentSize.height - 33.0) / 2.0)), size: CGSize(width: 33.0, height: 33.0)) + + if let (rect, containerSize) = self.absoluteRect { + let mappedRect = CGRect(origin: CGPoint(x: rect.minX + swipeToReplyNode.frame.minX, y: rect.minY + swipeToReplyNode.frame.minY), size: swipeToReplyNode.frame.size) + swipeToReplyNode.updateAbsoluteRect(mappedRect, within: containerSize) + } + if animateReplyNodeIn { swipeToReplyNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.12) swipeToReplyNode.layer.animateSpring(from: 0.1 as NSNumber, to: 1.0 as NSNumber, keyPath: "transform.scale", duration: 0.4) diff --git a/submodules/TelegramUI/Sources/ChatMessageSwipeToReplyNode.swift b/submodules/TelegramUI/Sources/ChatMessageSwipeToReplyNode.swift index bbdee19c02..518ee18b0d 100644 --- a/submodules/TelegramUI/Sources/ChatMessageSwipeToReplyNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageSwipeToReplyNode.swift @@ -3,6 +3,7 @@ import UIKit import Display import AsyncDisplayKit import AppBundle +import WallpaperBackgroundNode final class ChatMessageSwipeToReplyNode: ASDisplayNode { enum Action { @@ -11,10 +12,14 @@ final class ChatMessageSwipeToReplyNode: ASDisplayNode { case unlike } + private var backgroundContent: WallpaperBubbleBackgroundNode? + private let backgroundNode: NavigationBackgroundNode private let foregroundNode: ASImageNode - init(fillColor: UIColor, enableBlur: Bool, foregroundColor: UIColor, action: ChatMessageSwipeToReplyNode.Action) { + private var absolutePosition: (CGRect, CGSize)? + + init(fillColor: UIColor, enableBlur: Bool, foregroundColor: UIColor, backgroundNode: WallpaperBackgroundNode?, action: ChatMessageSwipeToReplyNode.Action) { self.backgroundNode = NavigationBackgroundNode(color: fillColor, enableBlur: enableBlur) self.backgroundNode.isUserInteractionEnabled = false @@ -57,11 +62,49 @@ final class ChatMessageSwipeToReplyNode: ASDisplayNode { super.init() + self.allowsGroupOpacity = true + self.addSubnode(self.backgroundNode) self.addSubnode(self.foregroundNode) self.backgroundNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: 33.0, height: 33.0)) self.backgroundNode.update(size: self.backgroundNode.bounds.size, cornerRadius: self.backgroundNode.bounds.height / 2.0, transition: .immediate) self.foregroundNode.frame = CGRect(origin: CGPoint(), size: CGSize(width: 33.0, height: 33.0)) + + if backgroundNode?.hasExtraBubbleBackground() == true { + if let backgroundContent = backgroundNode?.makeBubbleBackground(for: .free) { + backgroundContent.clipsToBounds = true + backgroundContent.allowsGroupOpacity = true + self.backgroundContent = backgroundContent + self.insertSubnode(backgroundContent, at: 0) + } + } else { + self.backgroundContent?.removeFromSupernode() + self.backgroundContent = nil + } + + if let backgroundContent = self.backgroundContent { + self.backgroundNode.isHidden = true + backgroundContent.cornerRadius = min(self.backgroundNode.bounds.width, self.backgroundNode.bounds.height) / 2.0 + backgroundContent.frame = self.backgroundNode.frame + if let (rect, containerSize) = self.absolutePosition { + var backgroundFrame = backgroundContent.frame + backgroundFrame.origin.x += rect.minX + backgroundFrame.origin.y += containerSize.height - rect.minY + backgroundContent.update(rect: backgroundFrame, within: containerSize, transition: .immediate) + } + } else { + self.backgroundNode.isHidden = false + } + } + + func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) { + self.absolutePosition = (rect, containerSize) + if let backgroundContent = self.backgroundContent { + var backgroundFrame = backgroundContent.frame + backgroundFrame.origin.x += rect.minX + backgroundFrame.origin.y += containerSize.height - rect.minY + backgroundContent.update(rect: backgroundFrame, within: containerSize, transition: .immediate) + } } } diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift b/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift index 7202f67970..05c523dcbe 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift @@ -659,7 +659,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { let emptyFrame = CGRect(origin: CGPoint(x: 0.0, y: navigationBarHeight), size: CGSize(width: layout.size.width, height: layout.size.height - navigationBarHeight - panelHeight)) transition.updateFrame(node: self.emptyNode, frame: emptyFrame) - self.emptyNode.updateLayout(size: emptyFrame.size, transition: transition) + self.emptyNode.updateLayout(backgroundNode: self.backgroundNode, size: emptyFrame.size, transition: transition) let contentBottomInset: CGFloat = panelHeight + 4.0 let listInsets = UIEdgeInsets(top: contentBottomInset, left: layout.safeInsets.right, bottom: insets.top, right: layout.safeInsets.left) diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsEmptyNode.swift b/submodules/TelegramUI/Sources/ChatRecentActionsEmptyNode.swift index 1588ddca37..9ad65f4aca 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsEmptyNode.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsEmptyNode.swift @@ -4,6 +4,7 @@ import Display import AsyncDisplayKit import TelegramCore import TelegramPresentationData +import WallpaperBackgroundNode private let titleFont = Font.medium(16.0) private let textFont = Font.regular(15.0) @@ -16,6 +17,11 @@ final class ChatRecentActionsEmptyNode: ASDisplayNode { private let titleNode: TextNode private let textNode: TextNode + private var wallpaperBackgroundNode: WallpaperBackgroundNode? + private var backgroundContent: WallpaperBubbleBackgroundNode? + + private var absolutePosition: (CGRect, CGSize)? + private var layoutParams: CGSize? private var title: String = "" @@ -36,6 +42,8 @@ final class ChatRecentActionsEmptyNode: ASDisplayNode { super.init() + self.allowsGroupOpacity = true + let graphics = PresentationResourcesChat.additionalGraphics(theme, wallpaper: chatWallpaper, bubbleCorners: chatBubbleCorners) self.backgroundNode.image = graphics.chatEmptyItemBackgroundImage @@ -44,7 +52,18 @@ final class ChatRecentActionsEmptyNode: ASDisplayNode { self.addSubnode(self.textNode) } - func updateLayout(size: CGSize, transition: ContainedViewLayoutTransition) { + public func update(rect: CGRect, within containerSize: CGSize, transition: ContainedViewLayoutTransition = .immediate) { + self.absolutePosition = (rect, containerSize) + if let backgroundContent = self.backgroundContent { + var backgroundFrame = backgroundContent.frame + backgroundFrame.origin.x += rect.minX + backgroundFrame.origin.y += rect.minY + backgroundContent.update(rect: backgroundFrame, within: containerSize, transition: transition) + } + } + + func updateLayout(backgroundNode: WallpaperBackgroundNode, size: CGSize, transition: ContainedViewLayoutTransition) { + self.wallpaperBackgroundNode = backgroundNode self.layoutParams = size let insets = UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0) @@ -68,14 +87,40 @@ final class ChatRecentActionsEmptyNode: ASDisplayNode { let _ = titleApply() let _ = textApply() + + if backgroundNode.hasExtraBubbleBackground() == true { + if self.backgroundContent == nil, let backgroundContent = backgroundNode.makeBubbleBackground(for: .free) { + backgroundContent.clipsToBounds = true + + self.backgroundContent = backgroundContent + self.insertSubnode(backgroundContent, at: 0) + } + } else { + self.backgroundContent?.removeFromSupernode() + self.backgroundContent = nil + } + + if let backgroundContent = self.backgroundContent { + self.backgroundNode.isHidden = true + backgroundContent.cornerRadius = 14.0 + backgroundContent.frame = backgroundFrame + if let (rect, containerSize) = self.absolutePosition { + var backgroundFrame = backgroundContent.frame + backgroundFrame.origin.x += rect.minX + backgroundFrame.origin.y += rect.minY + backgroundContent.update(rect: backgroundFrame, within: containerSize, transition: .immediate) + } + } else { + self.backgroundNode.isHidden = false + } } func setup(title: String, text: String) { if self.title != title || self.text != text { self.title = title self.text = text - if let size = self.layoutParams { - self.updateLayout(size: size, transition: .immediate) + if let size = self.layoutParams, let wallpaperBackgroundNode = self.wallpaperBackgroundNode { + self.updateLayout(backgroundNode: wallpaperBackgroundNode, size: size, transition: .immediate) } } } diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index ac5f5c6177..af0c8746b6 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -3509,9 +3509,11 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate } var mediaReference: AnyMediaReference? - for m in message.media { - if let image = m as? TelegramMediaImage { + for media in message.media { + if let image = media as? TelegramMediaImage { mediaReference = AnyMediaReference.standalone(media: image) + } else if let file = media as? TelegramMediaFile { + mediaReference = AnyMediaReference.standalone(media: file) } } diff --git a/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift b/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift index 7d7a5d6aef..34690fd75f 100644 --- a/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift @@ -524,6 +524,18 @@ public struct PresentationThemeAccentColor: PostboxCoding, Equatable { } } + public func colorFor(baseTheme: TelegramBaseTheme) -> UIColor { + if let value = self.accentColor { + return UIColor(rgb: UInt32(bitPattern: value)) + } else { + if baseTheme == .night && self.baseColor == .blue { + return UIColor(rgb: 0x3e88f7) + } else { + return self.baseColor.color + } + } + } + public var customBubbleColors: [UInt32] { return self.bubbleColors } diff --git a/submodules/TranslateUI/Sources/Translate.swift b/submodules/TranslateUI/Sources/Translate.swift index 36c0dc2c08..6ccec4617f 100644 --- a/submodules/TranslateUI/Sources/Translate.swift +++ b/submodules/TranslateUI/Sources/Translate.swift @@ -24,7 +24,7 @@ public var supportedTranslationLanguages = [ "bg", "ca", "ceb", - "zh-Hans", + "zh", // "zh-Hant", // "zh-CN", "zh" // "zh-TW" @@ -126,7 +126,7 @@ public var supportedTranslationLanguages = [ public var popularTranslationLanguages = [ "en", "ar", - "zh-Hans", + "zh", // "zh-Hant", "fr", "de",