@@ -58,18 +58,18 @@ private let groupIcon: UIImage = {
5858
5959public class ChatMessageReplyInfoNode : ASDisplayNode {
6060 public final class TransitionReplyPanel {
61- public let titleNode : ASDisplayNode
62- public let textNode : ASDisplayNode
63- public let lineNode : ASDisplayNode
64- public let imageNode : ASDisplayNode
61+ public let titleView : UIView
62+ public let textView : UIView
63+ public let lineView : UIView
64+ public let imageView : UIView ?
6565 public let relativeSourceRect : CGRect
6666 public let relativeTargetRect : CGRect
6767
68- public init ( titleNode : ASDisplayNode , textNode : ASDisplayNode , lineNode : ASDisplayNode , imageNode : ASDisplayNode , relativeSourceRect: CGRect , relativeTargetRect: CGRect ) {
69- self . titleNode = titleNode
70- self . textNode = textNode
71- self . lineNode = lineNode
72- self . imageNode = imageNode
68+ public init ( titleView : UIView , textView : UIView , lineView : UIView , imageView : UIView ? , relativeSourceRect: CGRect , relativeTargetRect: CGRect ) {
69+ self . titleView = titleView
70+ self . textView = textView
71+ self . lineView = lineView
72+ self . imageView = imageView
7373 self . relativeSourceRect = relativeSourceRect
7474 self . relativeTargetRect = relativeTargetRect
7575 }
@@ -971,84 +971,88 @@ public class ChatMessageReplyInfoNode: ASDisplayNode {
971971
972972 if let titleNode = self . titleNode {
973973 let offset = CGPoint (
974- x: localRect. minX + sourceReplyPanel. titleNode . frame. minX - titleNode. frame. minX,
975- y: localRect. minY + sourceReplyPanel. titleNode . frame. midY - titleNode. frame. midY
974+ x: localRect. minX + sourceReplyPanel. titleView . frame. minX - titleNode. frame. minX,
975+ y: localRect. minY + sourceReplyPanel. titleView . frame. midY - titleNode. frame. midY
976976 )
977977
978978 transition. horizontal. animatePositionAdditive ( node: titleNode, offset: CGPoint ( x: offset. x, y: 0.0 ) )
979979 transition. vertical. animatePositionAdditive ( node: titleNode, offset: CGPoint ( x: 0.0 , y: offset. y) )
980980
981- sourceParentNode. addSubnode ( sourceReplyPanel. titleNode )
981+ sourceParentNode. view . addSubview ( sourceReplyPanel. titleView )
982982
983983 titleNode. layer. animateAlpha ( from: 0.0 , to: 1.0 , duration: 0.1 )
984984
985- sourceReplyPanel. titleNode . frame = sourceReplyPanel. titleNode . frame
985+ sourceReplyPanel. titleView . frame = sourceReplyPanel. titleView . frame
986986 . offsetBy ( dx: sourceParentOffset. x, dy: sourceParentOffset. y)
987987 . offsetBy ( dx: localRect. minX - offset. x, dy: localRect. minY - offset. y)
988- transition. horizontal. animatePositionAdditive ( node : sourceReplyPanel. titleNode , offset: CGPoint ( x: offset. x, y: 0.0 ) , removeOnCompletion: false )
989- transition. vertical. animatePositionAdditive ( node : sourceReplyPanel. titleNode , offset: CGPoint ( x: 0.0 , y: offset. y) , removeOnCompletion: false )
988+ transition. horizontal. animatePositionAdditive ( layer : sourceReplyPanel. titleView . layer , offset: CGPoint ( x: offset. x, y: 0.0 ) , removeOnCompletion: false )
989+ transition. vertical. animatePositionAdditive ( layer : sourceReplyPanel. titleView . layer , offset: CGPoint ( x: 0.0 , y: offset. y) , removeOnCompletion: false )
990990 }
991991
992992 if let textNode = self . textNode {
993993 let offset = CGPoint (
994- x: localRect. minX + sourceReplyPanel. textNode . frame. minX - textNode. textNode. frame. minX,
995- y: localRect. minY + sourceReplyPanel. textNode . frame. midY - textNode. textNode. frame. midY
994+ x: localRect. minX + sourceReplyPanel. textView . frame. minX - textNode. textNode. frame. minX,
995+ y: localRect. minY + sourceReplyPanel. textView . frame. midY - textNode. textNode. frame. midY
996996 )
997997
998998 transition. horizontal. animatePositionAdditive ( node: textNode. textNode, offset: CGPoint ( x: offset. x, y: 0.0 ) )
999999 transition. vertical. animatePositionAdditive ( node: textNode. textNode, offset: CGPoint ( x: 0.0 , y: offset. y) )
10001000
1001- sourceParentNode. addSubnode ( sourceReplyPanel. textNode )
1001+ sourceParentNode. view . addSubview ( sourceReplyPanel. textView )
10021002
10031003 textNode. textNode. layer. animateAlpha ( from: 0.0 , to: 1.0 , duration: 0.1 )
10041004
1005- sourceReplyPanel. textNode . frame = sourceReplyPanel. textNode . frame
1005+ sourceReplyPanel. textView . frame = sourceReplyPanel. textView . frame
10061006 . offsetBy ( dx: sourceParentOffset. x, dy: sourceParentOffset. y)
10071007 . offsetBy ( dx: localRect. minX - offset. x, dy: localRect. minY - offset. y)
1008- transition. horizontal. animatePositionAdditive ( node : sourceReplyPanel. textNode , offset: CGPoint ( x: offset. x, y: 0.0 ) , removeOnCompletion: false )
1009- transition. vertical. animatePositionAdditive ( node : sourceReplyPanel. textNode , offset: CGPoint ( x: 0.0 , y: offset. y) , removeOnCompletion: false )
1008+ transition. horizontal. animatePositionAdditive ( layer : sourceReplyPanel. textView . layer , offset: CGPoint ( x: offset. x, y: 0.0 ) , removeOnCompletion: false )
1009+ transition. vertical. animatePositionAdditive ( layer : sourceReplyPanel. textView . layer , offset: CGPoint ( x: 0.0 , y: offset. y) , removeOnCompletion: false )
10101010 }
10111011
10121012 if let imageNode = self . imageNode {
1013- let offset = CGPoint (
1014- x: localRect. minX + sourceReplyPanel. imageNode. frame. midX - imageNode. frame. midX,
1015- y: localRect. minY + sourceReplyPanel. imageNode. frame. midY - imageNode. frame. midY
1016- )
1017-
1018- transition. horizontal. animatePositionAdditive ( node: imageNode, offset: CGPoint ( x: offset. x, y: 0.0 ) )
1019- transition. vertical. animatePositionAdditive ( node: imageNode, offset: CGPoint ( x: 0.0 , y: offset. y) )
1020-
1021- sourceParentNode. addSubnode ( sourceReplyPanel. imageNode)
1022-
1023- imageNode. layer. animateAlpha ( from: 0.0 , to: 1.0 , duration: 0.1 )
1024-
1025- sourceReplyPanel. imageNode. frame = sourceReplyPanel. imageNode. frame
1026- . offsetBy ( dx: sourceParentOffset. x, dy: sourceParentOffset. y)
1027- . offsetBy ( dx: localRect. minX - offset. x, dy: localRect. minY - offset. y)
1028- transition. horizontal. animatePositionAdditive ( node: sourceReplyPanel. imageNode, offset: CGPoint ( x: offset. x, y: 0.0 ) , removeOnCompletion: false )
1029- transition. vertical. animatePositionAdditive ( node: sourceReplyPanel. imageNode, offset: CGPoint ( x: 0.0 , y: offset. y) , removeOnCompletion: false )
1013+ if let sourceImageView = sourceReplyPanel. imageView {
1014+ let offset = CGPoint (
1015+ x: localRect. minX + sourceImageView. frame. midX - imageNode. frame. midX,
1016+ y: localRect. minY + sourceImageView. frame. midY - imageNode. frame. midY
1017+ )
1018+
1019+ transition. horizontal. animatePositionAdditive ( node: imageNode, offset: CGPoint ( x: offset. x, y: 0.0 ) )
1020+ transition. vertical. animatePositionAdditive ( node: imageNode, offset: CGPoint ( x: 0.0 , y: offset. y) )
1021+
1022+ sourceParentNode. view. addSubview ( sourceImageView)
1023+
1024+ imageNode. layer. animateAlpha ( from: 0.0 , to: 1.0 , duration: 0.1 )
1025+
1026+ sourceImageView. frame = sourceImageView. frame
1027+ . offsetBy ( dx: sourceParentOffset. x, dy: sourceParentOffset. y)
1028+ . offsetBy ( dx: localRect. minX - offset. x, dy: localRect. minY - offset. y)
1029+ transition. horizontal. animatePositionAdditive ( layer: sourceImageView. layer, offset: CGPoint ( x: offset. x, y: 0.0 ) , removeOnCompletion: false )
1030+ transition. vertical. animatePositionAdditive ( layer: sourceImageView. layer, offset: CGPoint ( x: 0.0 , y: offset. y) , removeOnCompletion: false )
1031+ } else {
1032+ imageNode. layer. animateAlpha ( from: 0.0 , to: 1.0 , duration: 0.1 )
1033+ }
10301034 }
10311035
10321036 do {
10331037 let backgroundView = self . backgroundView
10341038
10351039 let offset = CGPoint (
1036- x: localRect. minX + sourceReplyPanel. lineNode . frame. minX - backgroundView. frame. minX,
1037- y: localRect. minY + sourceReplyPanel. lineNode . frame. minY - backgroundView. frame. minY
1040+ x: localRect. minX + sourceReplyPanel. lineView . frame. minX - backgroundView. frame. minX,
1041+ y: localRect. minY + sourceReplyPanel. lineView . frame. minY - backgroundView. frame. minY
10381042 )
10391043
10401044 transition. horizontal. animatePositionAdditive ( layer: backgroundView. layer, offset: CGPoint ( x: offset. x, y: 0.0 ) )
10411045 transition. vertical. animatePositionAdditive ( layer: backgroundView. layer, offset: CGPoint ( x: 0.0 , y: offset. y) )
10421046
1043- sourceParentNode. addSubnode ( sourceReplyPanel. lineNode )
1047+ sourceParentNode. view . addSubview ( sourceReplyPanel. lineView )
10441048
10451049 backgroundView. layer. animateAlpha ( from: 0.0 , to: 1.0 , duration: 0.1 )
10461050
1047- sourceReplyPanel. lineNode . frame = sourceReplyPanel. lineNode . frame
1051+ sourceReplyPanel. lineView . frame = sourceReplyPanel. lineView . frame
10481052 . offsetBy ( dx: sourceParentOffset. x, dy: sourceParentOffset. y)
10491053 . offsetBy ( dx: localRect. minX - offset. x, dy: localRect. minY - offset. y)
1050- transition. horizontal. animatePositionAdditive ( node : sourceReplyPanel. lineNode , offset: CGPoint ( x: offset. x, y: 0.0 ) , removeOnCompletion: false )
1051- transition. vertical. animatePositionAdditive ( node : sourceReplyPanel. lineNode , offset: CGPoint ( x: 0.0 , y: offset. y) , removeOnCompletion: false )
1054+ transition. horizontal. animatePositionAdditive ( layer : sourceReplyPanel. lineView . layer , offset: CGPoint ( x: offset. x, y: 0.0 ) , removeOnCompletion: false )
1055+ transition. vertical. animatePositionAdditive ( layer : sourceReplyPanel. lineView . layer , offset: CGPoint ( x: 0.0 , y: offset. y) , removeOnCompletion: false )
10521056
10531057 return offset
10541058 }
0 commit comments