0

I am using AsyncDisplayKit for creating my layouts.

From the image below, I can't figure out why the RepliedChatView at the top doesn't stretch to the end for short text but works fine on a long/multiline text. How can I fix this?

enter image description here

 override public func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
    let stack = ASStackLayoutSpec()
    stack.direction = .vertical
    stack.style.flexShrink = 1.0
    stack.style.flexGrow = 1.0

    stack.setChild(chatReplyNode, at: 0)
    stack.setChild(bubbleNode, at: 1)

    let verticalSpec = ASBackgroundLayoutSpec()
    verticalSpec.style.flexGrow = 1.0
    verticalSpec.style.flexShrink = 1.0
    verticalSpec.background = bubbleImageNode

    let messageContent = MessageModel(mockMessage: message)

        if(messageContent.message.count <= 20){

            let horizon = ASStackLayoutSpec(direction: .horizontal, spacing: 10, justifyContent: .start, alignItems: ASStackLayoutAlignItems.start, children: [stack , timeNode])
                verticalSpec.child = ASInsetLayoutSpec(
                    insets: UIEdgeInsets(
                        top: textNodeVerticalOffset,
                        left: textNodeVerticalOffset,
                        bottom: textNodeVerticalOffset,
                        right: textNodeVerticalOffset
                    ),
                    child: horizon)
        }else{
            stack.setChild(timeNode, at: 2)
            verticalSpec.child = ASInsetLayoutSpec(
                insets: UIEdgeInsets(
                    top: 8,
                    left: textNodeVerticalOffset,
                    bottom: 5,
                    right: textNodeVerticalOffset
            ), child: stack)
        }

   //space it
    let insetSpec = ASInsetLayoutSpec(insets: isOutgoing ? UIEdgeInsets(top: 1, left: 62, bottom: 5, right: 20) : UIEdgeInsets(top: 1, left: 20, bottom: 5, right: 62), child: verticalSpec)

    let stackSpec = ASStackLayoutSpec()
    stackSpec.direction = .vertical
    stackSpec.style.flexGrow = 1.0
    stackSpec.style.flexShrink = 1.0
    stackSpec.justifyContent = .center
    stackSpec.alignItems = isOutgoing ? .end : .start
    stackSpec.spacing = 0
    stackSpec.children = [insetSpec]
    return stackSpec
}
SimpuMind
  • 365
  • 8
  • 22

1 Answers1

0

I read your layouts and see next image:

enter image description here

Bimawa
  • 3,535
  • 2
  • 25
  • 45