From 5b27ca9d4cdbbe030a85cf4e690864d561c041a3 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Fri, 30 Jan 2026 23:53:55 +0800 Subject: [PATCH] Various improvements --- .../GalleryUI/Sources/GalleryFooterNode.swift | 10 +- .../Sources/ChatButtonKeyboardInputNode.swift | 7 ++ .../ChatChannelSubscriberInputPanelNode.swift | 113 +----------------- .../Sources/ChatTextInputPanelNode.swift | 5 +- .../Sources/GlassControlGroup.swift | 12 +- .../Sources/GlassControlPanel.swift | 9 ++ 6 files changed, 38 insertions(+), 118 deletions(-) diff --git a/submodules/GalleryUI/Sources/GalleryFooterNode.swift b/submodules/GalleryUI/Sources/GalleryFooterNode.swift index bbca39feb0..eb618ce121 100644 --- a/submodules/GalleryUI/Sources/GalleryFooterNode.swift +++ b/submodules/GalleryUI/Sources/GalleryFooterNode.swift @@ -29,10 +29,14 @@ public final class GalleryFooterNode: ASDisplayNode { } private var visibilityAlpha: CGFloat = 1.0 + private var isEdgeEffectVisible: Bool = false + public func setVisibilityAlpha(_ alpha: CGFloat, animated: Bool) { self.visibilityAlpha = alpha let transition: ComponentTransition = animated ? .easeInOut(duration: 0.2) : .immediate - transition.setAlpha(view: self.edgeEffectView, alpha: alpha) + if self.isEdgeEffectVisible { + transition.setAlpha(view: self.edgeEffectView, alpha: alpha) + } self.currentFooterContentNode?.setVisibilityAlpha(alpha, animated: true) self.currentOverlayContentNode?.setVisibilityAlpha(alpha) } @@ -151,8 +155,10 @@ public final class GalleryFooterNode: ASDisplayNode { edgeEffectTransition.setFrame(view: self.edgeEffectView, frame: edgeEffectFrame) self.edgeEffectView.update(content: .black, alpha: 0.65, rect: edgeEffectFrame, edge: .bottom, edgeSize: min(edgeEffectHeight, edgeEffectFrame.height), transition: edgeEffectTransition) if let backgroundLayoutInfo, backgroundLayoutInfo.needsShadow { - ComponentTransition(transition).setAlpha(view: self.edgeEffectView, alpha: 1.0) + self.isEdgeEffectVisible = true + ComponentTransition(transition).setAlpha(view: self.edgeEffectView, alpha: self.visibilityAlpha) } else { + self.isEdgeEffectVisible = false ComponentTransition(transition).setAlpha(view: self.edgeEffectView, alpha: 0.0) } diff --git a/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift b/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift index 09e7afb7f3..b5a68e6976 100644 --- a/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatButtonKeyboardInputNode/Sources/ChatButtonKeyboardInputNode.swift @@ -49,7 +49,10 @@ private final class ChatButtonKeyboardInputButtonNode: HighlightTrackingButtonNo self.addSubnode(self.backgroundContainerNode) + self.backgroundView.isUserInteractionEnabled = false self.backgroundContainerNode.view.addSubview(self.backgroundView) + + self.textNode.isUserInteractionEnabled = false self.addSubnode(self.textNode) self.highligthedChanged = { [weak self] highlighted in @@ -66,6 +69,8 @@ private final class ChatButtonKeyboardInputButtonNode: HighlightTrackingButtonNo } func update(context: AccountContext, size: CGSize, theme: PresentationTheme, wallpaperBackgroundNode: WallpaperBackgroundNode?, button: ReplyMarkupButton, message: EngineMessage) { + self.button = button + if theme !== self.theme { self.theme = theme } @@ -114,6 +119,7 @@ private final class ChatButtonKeyboardInputButtonNode: HighlightTrackingButtonNo let iconNode = ASImageNode() iconNode.contentMode = .center self.iconNode = iconNode + iconNode.isUserInteractionEnabled = false self.addSubnode(iconNode) } self.iconNode?.image = iconImage @@ -180,6 +186,7 @@ private final class ChatButtonKeyboardInputButtonNode: HighlightTrackingButtonNo let iconFrame = CGRect(origin: CGPoint(x: contentX, y: floor((size.height - iconSize.height) * 0.5)), size: iconSize) if iconView.superview == nil { + iconView.isUserInteractionEnabled = false self.view.addSubview(iconView) } iconView.frame = iconFrame diff --git a/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift b/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift index ea3fa4def1..c6d30624e2 100644 --- a/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift @@ -477,6 +477,7 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode { transition: ComponentTransition(transition), component: AnyComponent(GlassControlPanelComponent( theme: interfaceState.theme, + preferClearGlass: interfaceState.preferredGlassType == .clear, leftItem: leftPanelItems.isEmpty ? nil : GlassControlPanelComponent.Item( items: leftPanelItems, background: .panel @@ -498,118 +499,6 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode { transition.updateFrame(view: panelView, frame: CGRect(origin: CGPoint(), size: panelFrame.size)) } - /*if self.presentationInterfaceState != interfaceState || force { - let previousState = self.presentationInterfaceState - self.presentationInterfaceState = interfaceState - - if previousState?.theme !== interfaceState.theme { - self.helpButtonIconView.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Accessory Panels/Help"), color: .white)?.withRenderingMode(.alwaysTemplate) - self.helpButtonIconView.tintColor = interfaceState.theme.chat.inputPanel.panelControlColor - - self.suggestedPostButtonIconView.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Accessory Panels/SuggestPost"), color: .white)?.withRenderingMode(.alwaysTemplate) - self.suggestedPostButtonIconView.tintColor = interfaceState.theme.chat.inputPanel.panelControlColor - - self.giftButtonIconView.image = generateTintedImage(image: UIImage(bundleImageName: "Chat/Input/Accessory Panels/Gift"), color: .white)?.withRenderingMode(.alwaysTemplate) - self.giftButtonIconView.tintColor = interfaceState.theme.chat.inputPanel.panelControlColor - } - - if let context = self.context, let peer = interfaceState.renderedPeer?.peer, previousState?.renderedPeer?.peer == nil || !peer.isEqual(previousState!.renderedPeer!.peer!) || previousState?.theme !== interfaceState.theme || previousState?.strings !== interfaceState.strings || previousState?.peerIsMuted != interfaceState.peerIsMuted || previousState?.pinnedMessage != interfaceState.pinnedMessage || force { - - if let action = actionForPeer(context: context, peer: peer, interfaceState: interfaceState, isJoining: self.isJoining, isMuted: interfaceState.peerIsMuted) { - let previousAction = self.action - self.action = action - let (title, _) = titleAndColorForAction(action, theme: interfaceState.theme, strings: interfaceState.strings) - - let _ = previousAction - - let titleColor: UIColor - if case .join = self.action { - titleColor = interfaceState.theme.chat.inputPanel.actionControlForegroundColor - } else { - titleColor = interfaceState.theme.chat.inputPanel.panelControlColor - } - self.buttonTitle.attributedText = NSAttributedString(string: title, font: Font.semibold(15.0), textColor: titleColor) - self.buttonTintTitle.attributedText = NSAttributedString(string: title, font: Font.semibold(15.0), textColor: .black) - self.button.accessibilityLabel = title - } else { - self.action = nil - } - } - } - - let panelHeight = defaultHeight(metrics: metrics) - - if let peer = interfaceState.renderedPeer?.peer as? TelegramChannel { - if case let .broadcast(broadcastInfo) = peer.info, interfaceState.starGiftsAvailable { - if self.giftButton.isHidden && !isFirstTime { - self.giftButton.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - self.giftButton.layer.animateScale(from: 0.01, to: 1.0, duration: 0.2) - } - - self.giftButtonBackgroundView.isHidden = false - self.helpButtonBackgroundView.isHidden = true - self.suggestedPostButtonBackgroundView.isHidden = !broadcastInfo.flags.contains(.hasMonoforum) - self.presentGiftOrSuggestTooltip() - } else if case let .broadcast(broadcastInfo) = peer.info, broadcastInfo.flags.contains(.hasMonoforum) { - self.giftButtonBackgroundView.isHidden = true - self.helpButtonBackgroundView.isHidden = true - self.suggestedPostButtonBackgroundView.isHidden = false - self.presentGiftOrSuggestTooltip() - } else if peer.flags.contains(.isGigagroup), self.action == .muteNotifications || self.action == .unmuteNotifications { - self.giftButtonBackgroundView.isHidden = true - self.helpButtonBackgroundView.isHidden = false - self.suggestedPostButtonBackgroundView.isHidden = true - } else { - self.giftButtonBackgroundView.isHidden = true - self.helpButtonBackgroundView.isHidden = true - self.suggestedPostButtonBackgroundView.isHidden = true - } - } else { - self.giftButtonBackgroundView.isHidden = true - self.helpButtonBackgroundView.isHidden = true - self.suggestedPostButtonBackgroundView.isHidden = true - } - - let buttonTitleSize = self.buttonTitle.updateLayout(CGSize(width: width, height: panelHeight)) - let _ = self.buttonTintTitle.updateLayout(CGSize(width: width, height: panelHeight)) - let buttonSize = CGSize(width: buttonTitleSize.width + 16.0 * 2.0, height: 40.0) - let buttonFrame = CGRect(origin: CGPoint(x: floor((width - buttonSize.width) / 2.0), y: floor((panelHeight - buttonSize.height) * 0.5)), size: buttonSize) - transition.updateFrame(view: self.buttonBackgroundView, frame: buttonFrame) - transition.updateFrame(view: self.button, frame: CGRect(origin: CGPoint(), size: buttonFrame.size)) - let buttonTintColor: GlassBackgroundView.TintColor - if case .join = self.action { - buttonTintColor = .init(kind: .custom, color: interfaceState.theme.chat.inputPanel.inputBackgroundColor.withMultipliedAlpha(0.7), innerColor: interfaceState.theme.chat.inputPanel.actionControlFillColor) - } else { - buttonTintColor = .init(kind: .panel, color: interfaceState.theme.chat.inputPanel.inputBackgroundColor.withMultipliedAlpha(0.7)) - } - self.buttonBackgroundView.update(size: buttonFrame.size, cornerRadius: buttonFrame.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: buttonTintColor, isInteractive: true, transition: ComponentTransition(transition)) - self.buttonTitle.frame = CGRect(origin: CGPoint(x: floor((buttonFrame.width - buttonTitleSize.width) * 0.5), y: floor((buttonFrame.height - buttonTitleSize.height) * 0.5)), size: buttonTitleSize) - self.buttonTintTitle.frame = self.buttonTitle.frame - - let giftButtonFrame = CGRect(x: width - rightInset - 40.0 - 8.0, y: floor((panelHeight - 40.0) * 0.5), width: 40.0, height: 40.0) - transition.updateFrame(view: self.giftButtonBackgroundView, frame: giftButtonFrame) - if let image = self.giftButtonIconView.image { - transition.updateFrame(view: self.giftButtonIconView, frame: image.size.centered(in: CGRect(origin: CGPoint(), size: giftButtonFrame.size))) - } - transition.updateFrame(view: self.giftButton, frame: CGRect(origin: CGPoint(), size: giftButtonFrame.size)) - self.giftButtonBackgroundView.update(size: giftButtonFrame.size, cornerRadius: giftButtonFrame.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: .init(kind: .panel), isInteractive: true, transition: ComponentTransition(transition)) - - let helpButtonFrame = CGRect(x: width - rightInset - 8.0 - 40.0, y: floor((panelHeight - 40.0) * 0.5), width: 40.0, height: 40.0) - transition.updateFrame(view: self.helpButtonBackgroundView, frame: helpButtonFrame) - if let image = self.helpButtonIconView.image { - transition.updateFrame(view: self.helpButtonIconView, frame: image.size.centered(in: CGRect(origin: CGPoint(), size: helpButtonFrame.size))) - } - transition.updateFrame(view: self.helpButton, frame: CGRect(origin: CGPoint(), size: helpButtonFrame.size)) - self.helpButtonBackgroundView.update(size: helpButtonFrame.size, cornerRadius: helpButtonFrame.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: .init(kind: .panel), isInteractive: true, transition: ComponentTransition(transition)) - - let suggestedPostButtonFrame = CGRect(x: leftInset + 8.0, y: floor((panelHeight - 40.0) * 0.5), width: 40.0, height: 40.0) - transition.updateFrame(view: self.suggestedPostButtonBackgroundView, frame: suggestedPostButtonFrame) - if let image = self.suggestedPostButtonIconView.image { - transition.updateFrame(view: self.suggestedPostButtonIconView, frame: image.size.centered(in: CGRect(origin: CGPoint(), size: suggestedPostButtonFrame.size))) - } - transition.updateFrame(view: self.suggestedPostButton, frame: CGRect(origin: CGPoint(), size: suggestedPostButtonFrame.size)) - self.suggestedPostButtonBackgroundView.update(size: suggestedPostButtonFrame.size, cornerRadius: suggestedPostButtonFrame.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: .init(kind: .panel), isInteractive: true, transition: ComponentTransition(transition))*/ - return panelHeight } diff --git a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift index 38970d80f3..d61d72ce43 100644 --- a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift @@ -1422,10 +1422,13 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg self.validLayout = (width, leftInset, rightInset, bottomInset, additionalSideInsets, maxHeight, maxOverlayHeight, metrics, isSecondary, isMediaInputExpanded) let defaultGlassTintColor: GlassBackgroundView.TintColor + let defaultGlassTintWithInnerColor: GlassBackgroundView.TintColor if case .clear = interfaceState.preferredGlassType { defaultGlassTintColor = .init(kind: .clear) + defaultGlassTintWithInnerColor = .init(kind: .clear, innerColor: interfaceState.theme.list.itemCheckColors.fillColor) } else { defaultGlassTintColor = .init(kind: .panel) + defaultGlassTintWithInnerColor = .init(kind: .panel, innerColor: interfaceState.theme.list.itemCheckColors.fillColor) } var leftInset = leftInset @@ -2372,7 +2375,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg let menuButtonFrame = CGRect(x: leftInset + 8.0, y: menuButtonOriginY, width: menuButtonExpanded ? menuButtonWidth : menuCollapsedButtonWidth, height: menuButtonHeight) transition.updateFrameAsPositionAndBounds(node: self.menuButton, frame: menuButtonFrame) transition.updateFrame(view: self.menuButtonBackgroundView, frame: CGRect(origin: CGPoint(), size: menuButtonFrame.size)) - self.menuButtonBackgroundView.update(size: menuButtonFrame.size, cornerRadius: menuButtonFrame.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: defaultGlassTintColor, transition: ComponentTransition(transition)) + self.menuButtonBackgroundView.update(size: menuButtonFrame.size, cornerRadius: menuButtonFrame.height * 0.5, isDark: interfaceState.theme.overallDarkAppearance, tintColor: defaultGlassTintWithInnerColor, transition: ComponentTransition(transition)) transition.updateFrame(node: self.menuButtonClippingNode, frame: CGRect(origin: CGPoint(x: 19.0, y: 0.0), size: CGSize(width: menuButtonWidth - 19.0, height: menuButtonFrame.height))) var menuButtonTitleTransition = transition if buttonTitleUpdated { diff --git a/submodules/TelegramUI/Components/GlassControls/Sources/GlassControlGroup.swift b/submodules/TelegramUI/Components/GlassControls/Sources/GlassControlGroup.swift index b39a135a44..ce0204d62b 100644 --- a/submodules/TelegramUI/Components/GlassControls/Sources/GlassControlGroup.swift +++ b/submodules/TelegramUI/Components/GlassControls/Sources/GlassControlGroup.swift @@ -69,17 +69,20 @@ public final class GlassControlGroupComponent: Component { } public let theme: PresentationTheme + public let preferClearGlass: Bool public let background: Background public let items: [Item] public let minWidth: CGFloat public init( theme: PresentationTheme, + preferClearGlass: Bool, background: Background, items: [Item], minWidth: CGFloat ) { self.theme = theme + self.preferClearGlass = preferClearGlass self.background = background self.items = items self.minWidth = minWidth @@ -89,6 +92,9 @@ public final class GlassControlGroupComponent: Component { if lhs.theme !== rhs.theme { return false } + if lhs.preferClearGlass != rhs.preferClearGlass { + return false + } if lhs.background != rhs.background { return false } @@ -151,13 +157,13 @@ public final class GlassControlGroupComponent: Component { switch component.background { case .panel: foregroundColor = component.theme.chat.inputPanel.panelControlColor - tintColor = .init(kind: .panel) + tintColor = .init(kind: component.preferClearGlass ? .clear : .panel) case .activeTint: foregroundColor = component.theme.list.itemCheckColors.foregroundColor - tintColor = .init(kind: .panel, innerColor: component.theme.list.itemCheckColors.fillColor) + tintColor = .init(kind: component.preferClearGlass ? .clear : .panel, innerColor: component.theme.list.itemCheckColors.fillColor) case let .color(color): foregroundColor = .white - tintColor = .init(kind: .custom(style: .default, color: color)) + tintColor = .init(kind: .custom(style: component.preferClearGlass ? .clear : .default, color: color)) } var contentsWidth: CGFloat = 0.0 diff --git a/submodules/TelegramUI/Components/GlassControls/Sources/GlassControlPanel.swift b/submodules/TelegramUI/Components/GlassControls/Sources/GlassControlPanel.swift index 351a2144d4..998743a195 100644 --- a/submodules/TelegramUI/Components/GlassControls/Sources/GlassControlPanel.swift +++ b/submodules/TelegramUI/Components/GlassControls/Sources/GlassControlPanel.swift @@ -32,6 +32,7 @@ public final class GlassControlPanelComponent: Component { } public let theme: PresentationTheme + public let preferClearGlass: Bool public let leftItem: Item? public let rightItem: Item? public let centralItem: Item? @@ -41,6 +42,7 @@ public final class GlassControlPanelComponent: Component { public init( theme: PresentationTheme, + preferClearGlass: Bool = false, leftItem: Item?, centralItem: Item?, rightItem: Item?, @@ -49,6 +51,7 @@ public final class GlassControlPanelComponent: Component { tag: AnyObject? = nil ) { self.theme = theme + self.preferClearGlass = preferClearGlass self.leftItem = leftItem self.centralItem = centralItem self.rightItem = rightItem @@ -61,6 +64,9 @@ public final class GlassControlPanelComponent: Component { if lhs.theme !== rhs.theme { return false } + if lhs.preferClearGlass != rhs.preferClearGlass { + return false + } if lhs.leftItem != rhs.leftItem { return false } @@ -149,6 +155,7 @@ public final class GlassControlPanelComponent: Component { transition: leftItemTransition, component: AnyComponent(GlassControlGroupComponent( theme: component.theme, + preferClearGlass: component.preferClearGlass, background: leftItem.background, items: leftItem.items, minWidth: availableSize.height @@ -198,6 +205,7 @@ public final class GlassControlPanelComponent: Component { transition: rightItemTransition, component: AnyComponent(GlassControlGroupComponent( theme: component.theme, + preferClearGlass: component.preferClearGlass, background: rightItem.background, items: rightItem.items, minWidth: availableSize.height @@ -264,6 +272,7 @@ public final class GlassControlPanelComponent: Component { transition: centralItemTransition, component: AnyComponent(GlassControlGroupComponent( theme: component.theme, + preferClearGlass: component.preferClearGlass, background: centralItem.background, items: centralItem.items, minWidth: centralItem.keepWide ? 165.0 : availableSize.height