From 492a91377a90e449dbc3bad9493d72124b3e89a4 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Tue, 5 Dec 2023 01:46:49 +0400 Subject: [PATCH] Profile improvements --- .../Sources/PeerInfoAvatarListNode.swift | 7 +++++- .../Sources/PeerInfoHeaderButtonNode.swift | 24 ++++++++++++------ .../Sources/PeerInfoHeaderNode.swift | 25 ++++++++++++++++--- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift index 3f388af6db9..5b03157cac3 100644 --- a/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift +++ b/submodules/PeerInfoAvatarListNode/Sources/PeerInfoAvatarListNode.swift @@ -599,6 +599,9 @@ private final class VariableBlurView: UIVisualEffectView { fatalError("init(coder:) has not been implemented") } + override func updateTraitsIfNeeded() { + } + private func resetEffect() { let filterClassStringEncoded = "Q0FGaWx0ZXI=" let filterClassString: String = { @@ -669,6 +672,7 @@ public final class PeerAvatarBottomShadowNode: ASDisplayNode { self.imageView = UIImageView() self.imageView.contentMode = .scaleToFill + self.imageView.alpha = 0.8 super.init() @@ -702,6 +706,7 @@ public final class PeerAvatarBottomShadowNode: ASDisplayNode { self.backgroundNode.updateColor(color: UIColor(white: 0.0, alpha: 0.1), enableSaturation: false, forceKeepBlur: true, transition: .immediate) + self.view.addSubview(self.imageView) //self.addSubnode(self.backgroundNode) } @@ -1688,7 +1693,7 @@ public final class PeerInfoAvatarListContainerNode: ASDisplayNode { transition.updateAlpha(node: self.setByYouNode, alpha: 0.7) self.setByYouNode.attributedText = NSAttributedString(string: photoTitle, font: Font.regular(12.0), textColor: UIColor.white) let setByYouSize = self.setByYouNode.updateLayout(size) - self.setByYouNode.frame = CGRect(origin: CGPoint(x: size.width - setByYouSize.width - 14.0, y: size.height - setByYouSize.height - 18.0), size: setByYouSize) + self.setByYouNode.frame = CGRect(origin: CGPoint(x: size.width - setByYouSize.width - 14.0, y: size.height - setByYouSize.height - 40.0), size: setByYouSize) self.setByYouNode.isUserInteractionEnabled = hasLink } else { transition.updateAlpha(node: self.setByYouNode, alpha: 0.0) diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderButtonNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderButtonNode.swift index 38474a74ee6..9c8a96680c6 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderButtonNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderButtonNode.swift @@ -42,7 +42,7 @@ final class PeerInfoHeaderButtonNode: HighlightableButtonNode { private let action: (PeerInfoHeaderButtonNode, ContextGesture?) -> Void let referenceNode: ContextReferenceContentNode let containerNode: ContextControllerSourceNode - private let backgroundNode: NavigationBackgroundNode + //private let backgroundNode: NavigationBackgroundNode private let contentNode: ASDisplayNode private let iconNode: ASImageNode private let textNode: ImmediateTextNode @@ -52,6 +52,9 @@ final class PeerInfoHeaderButtonNode: HighlightableButtonNode { private var icon: PeerInfoHeaderButtonIcon? private var isActive: Bool? + let backgroundContainerView: UIView + let backgroundView: UIView + init(key: PeerInfoHeaderButtonKey, action: @escaping (PeerInfoHeaderButtonNode, ContextGesture?) -> Void) { self.key = key self.action = action @@ -60,8 +63,13 @@ final class PeerInfoHeaderButtonNode: HighlightableButtonNode { self.containerNode = ContextControllerSourceNode() self.containerNode.animateScale = false - self.backgroundNode = NavigationBackgroundNode(color: UIColor(white: 1.0, alpha: 0.2), enableBlur: true, enableSaturation: false) - self.backgroundNode.isUserInteractionEnabled = false + self.backgroundContainerView = UIView() + self.backgroundView = UIView() + self.backgroundView.backgroundColor = .white + self.backgroundContainerView.addSubview(self.backgroundView) + + /*self.backgroundNode = NavigationBackgroundNode(color: UIColor(white: 1.0, alpha: 0.2), enableBlur: true, enableSaturation: false) + self.backgroundNode.isUserInteractionEnabled = false*/ self.contentNode = ASDisplayNode() self.contentNode.isUserInteractionEnabled = false @@ -80,7 +88,7 @@ final class PeerInfoHeaderButtonNode: HighlightableButtonNode { self.accessibilityTraits = .button self.containerNode.addSubnode(self.referenceNode) - self.referenceNode.addSubnode(self.backgroundNode) + //self.referenceNode.addSubnode(self.backgroundNode) self.referenceNode.addSubnode(self.contentNode) self.contentNode.addSubnode(self.iconNode) self.addSubnode(self.containerNode) @@ -259,12 +267,14 @@ final class PeerInfoHeaderButtonNode: HighlightableButtonNode { let backgroundY: CGFloat = size.height * (1.0 - fraction) let backgroundFrame = CGRect(origin: CGPoint(x: 0.0, y: backgroundY), size: CGSize(width: size.width, height: max(0.0, size.height - backgroundY))) - transition.updateFrame(node: self.backgroundNode, frame: backgroundFrame) + //transition.updateFrame(node: self.backgroundNode, frame: backgroundFrame) + transition.updateFrame(view: self.backgroundView, frame: backgroundFrame) transition.updateSublayerTransformScale(node: self.contentNode, scale: 1.0 * fraction + 0.001 * (1.0 - fraction)) - self.backgroundNode.update(size: backgroundFrame.size, cornerRadius: min(11.0, backgroundFrame.height * 0.5), transition: transition) - self.backgroundNode.updateColor(color: backgroundColor, transition: transition) + transition.updateCornerRadius(layer: self.backgroundView.layer, cornerRadius: min(11.0, backgroundFrame.height * 0.5)) + //self.backgroundNode.update(size: backgroundFrame.size, cornerRadius: min(11.0, backgroundFrame.height * 0.5), transition: transition) + //self.backgroundNode.updateColor(color: backgroundColor, transition: transition) transition.updateFrame(node: self.iconNode, frame: CGRect(origin: CGPoint(x: floor((size.width - iconSize.width) / 2.0), y: 1.0), size: iconSize)) if let animatedIconView = self.animatedIcon?.view { transition.updateFrame(view: animatedIconView, frame: CGRect(origin: CGPoint(x: floor((size.width - iconSize.width) / 2.0), y: 1.0), size: iconSize)) diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift index 61c3b54eb31..c6bb1f3716e 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift @@ -99,6 +99,8 @@ final class PeerInfoHeaderNode: ASDisplayNode { let backgroundBannerView: UIView let backgroundCover = ComponentView() let buttonsContainerNode: SparseNode + let buttonsBackgroundNode: NavigationBackgroundNode + let buttonsMaskView: UIView let regularContentNode: PeerInfoHeaderRegularContentNode let editingContentNode: PeerInfoHeaderEditingContentNode let avatarOverlayNode: PeerInfoEditingAvatarOverlayNode @@ -206,6 +208,11 @@ final class PeerInfoHeaderNode: ASDisplayNode { self.buttonsContainerNode = SparseNode() self.buttonsContainerNode.clipsToBounds = true + self.buttonsBackgroundNode = NavigationBackgroundNode(color: .clear, enableBlur: true, enableSaturation: false) + self.buttonsContainerNode.addSubnode(self.buttonsBackgroundNode) + self.buttonsMaskView = UIView() + self.buttonsBackgroundNode.view.mask = self.buttonsMaskView + self.regularContentNode = PeerInfoHeaderRegularContentNode() var requestUpdateLayoutImpl: (() -> Void)? self.editingContentNode = PeerInfoHeaderEditingContentNode(context: context, requestUpdateLayout: { @@ -820,8 +827,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { if self.isSettings { expandedAvatarListHeight = expandedAvatarListHeight + 60.0 } else { - let avatarEnlargementFactor: CGFloat = 1.35 - expandedAvatarListHeight = floor(expandedAvatarListHeight * avatarEnlargementFactor) + expandedAvatarListHeight = expandedAvatarListHeight + 98.0 } let expandedAvatarListSize = CGSize(width: width, height: expandedAvatarListHeight) @@ -847,7 +853,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { isFake = peer.isFake || peer.isScam } - let titleShadowColor = UIColor(white: 0.0, alpha: 0.1) + let titleShadowColor: UIColor? = nil if let peer = peer { var title: String @@ -1108,7 +1114,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { var bottomShadowHeight: CGFloat = 88.0 if !self.isSettings { - bottomShadowHeight += 110.0 + bottomShadowHeight += 100.0 } let bottomShadowFrame = CGRect(origin: CGPoint(x: 0.0, y: expandedAvatarHeight - bottomShadowHeight), size: CGSize(width: width, height: bottomShadowHeight)) transition.updateFrame(node: self.avatarListNode.listContainerNode.bottomShadowNode, frame: bottomShadowFrame, beginWithCurrentState: true) @@ -1636,6 +1642,10 @@ final class PeerInfoHeaderNode: ASDisplayNode { buttonRightOrigin.y += actionButtonSize.height + 24.0 } + transition.updateFrameAdditive(node: self.buttonsBackgroundNode, frame: CGRect(origin: CGPoint(x: 0.0, y: buttonRightOrigin.y), size: CGSize(width: width, height: buttonSize.height))) + self.buttonsBackgroundNode.update(size: self.buttonsBackgroundNode.bounds.size, transition: transition) + self.buttonsBackgroundNode.updateColor(color: contentButtonBackgroundColor, enableBlur: true, transition: transition) + for buttonKey in buttonKeys.reversed() { let buttonNode: PeerInfoHeaderButtonNode var wasAdded = false @@ -1648,6 +1658,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { }) self.buttonNodes[buttonKey] = buttonNode self.buttonsContainerNode.addSubnode(buttonNode) + self.buttonsMaskView.addSubview(buttonNode.backgroundContainerView) } let buttonFrame = CGRect(origin: CGPoint(x: buttonRightOrigin.x - buttonSize.width, y: buttonRightOrigin.y), size: buttonSize) @@ -1658,6 +1669,8 @@ final class PeerInfoHeaderNode: ASDisplayNode { } else { buttonTransition.updateFrame(node: buttonNode, frame: buttonFrame) } + buttonTransition.updateFrame(view: buttonNode.backgroundContainerView, frame: buttonFrame.offsetBy(dx: 0.0, dy: -buttonFrame.minY)) + let buttonText: String let buttonIcon: PeerInfoHeaderButtonIcon switch buttonKey { @@ -1717,8 +1730,10 @@ final class PeerInfoHeaderNode: ASDisplayNode { if wasAdded { buttonNode.alpha = 0.0 + buttonNode.backgroundContainerView.alpha = 0.0 } transition.updateAlpha(node: buttonNode, alpha: buttonsTransitionFraction) + transition.updateAlpha(layer: buttonNode.backgroundContainerView.layer, alpha: buttonsTransitionFraction) if case .mute = buttonKey, buttonNode.containerNode.alpha.isZero, additive { if case let .animated(duration, curve) = transition { @@ -1736,7 +1751,9 @@ final class PeerInfoHeaderNode: ASDisplayNode { if !buttonKeys.contains(key) { if let buttonNode = self.buttonNodes[key] { self.buttonNodes.removeValue(forKey: key) + transition.updateAlpha(layer: buttonNode.backgroundContainerView.layer, alpha: 0.0) transition.updateAlpha(node: buttonNode, alpha: 0.0) { [weak buttonNode] _ in + buttonNode?.backgroundContainerView.removeFromSuperview() buttonNode?.removeFromSupernode() } }