Skip to content

Commit

Permalink
Profile improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac committed Dec 4, 2023
1 parent 9a57af8 commit 492a913
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -669,6 +672,7 @@ public final class PeerAvatarBottomShadowNode: ASDisplayNode {

self.imageView = UIImageView()
self.imageView.contentMode = .scaleToFill
self.imageView.alpha = 0.8

super.init()

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ final class PeerInfoHeaderNode: ASDisplayNode {
let backgroundBannerView: UIView
let backgroundCover = ComponentView<Empty>()
let buttonsContainerNode: SparseNode
let buttonsBackgroundNode: NavigationBackgroundNode
let buttonsMaskView: UIView
let regularContentNode: PeerInfoHeaderRegularContentNode
let editingContentNode: PeerInfoHeaderEditingContentNode
let avatarOverlayNode: PeerInfoEditingAvatarOverlayNode
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
}
}
Expand Down

0 comments on commit 492a913

Please sign in to comment.