Asyncdisplaykit: Do you have a slack or IRC group?

Created on 22 Dec 2015  路  22Comments  路  Source: facebookarchive/AsyncDisplayKit

Hi :)

I really like the framework, but I think it lags some guides to get started with 2.0.
Do you have a slack channel or IRC where you can ask questions?

Most helpful comment

Nice! Mind if I snag an invite @fatuhoku?

All 22 comments

Thank you for trying out ASDK and welcome to the community! We use neither Slack nor IRC currently. The same matter has been was discussed in #729 couple of months ago. I agree that such channel will be useful and not sure why we haven't created it yet. cc @appleguy :P

@nguyenhuy that's a shame :/

The question I have is how you can make dynamically sized table nodes.
The following image is how I would like the cells to be rendered

Code

  override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec! {
    postNode.flexGrow = true

    let vStack = ASStackLayoutSpec.verticalStackLayoutSpec()
    vStack.spacing = 8
    vStack.flexGrow = true
    vStack.setChildren([titleNode, postNode])

    return ASInsetLayoutSpec(insets: UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16), child: vStack)
  }

And the result which from the above code seems not to work.
Do you have any idea where I go wrong?

As you can see in the result the cells are fixed sizes, and thus the first cell is not even displaying "This is a short text"
Result:

You can wrap text nodes inside new ASInsetLayoutSpecs, then use those inset specs as children of the stack spec. You can do this because both ASDisplayNode and ASLayoutSpec are subclasses of ASLayoutable, and ASLayoutSpecs accepts ASLayoutable child/children.

BTW, I think you don't need to enable the flexGrow property of these objects at all. Or maybe you have reasons to do so but I don't know :)

@nguyenhuy hmm I don't see how that resolves the problem? Just tried with this code and it gives the exact same output. It seems like the cells doesn't know that it should resize it self or something:

    let insetTitle = ASInsetLayoutSpec(insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0), child: titleNode)
    let insetPost = ASInsetLayoutSpec(insets: UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0), child: postNode)
    let vStack = ASStackLayoutSpec.verticalStackLayoutSpec()
    vStack.setChildren([insetTitle, insetPost])
    vStack.spacing = 8
//    vStack.flexGrow = true // with or without this is the same
    return ASInsetLayoutSpec(insets: UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8), child: vStack)

Do I explicitly need to tell the nodes that they are dynamic in their height or something?

Oh, I misread your question. You don't even need new inset specs. Sorry!

After setting a new text, you need to call cellNode.setNeedsLayout() and things should just work. Example code (with and without animation) can be found here.

I tried, but there's no difference :(

  convenience init(joke: Joke) {
    self.init()
    self.joke = joke
    titleNode = ASTextNode()
    titleNode.attributedString = NSAttributedString(string: joke.title, attributes: TextStyles.titleStyle)
    addSubnode(titleNode)

    postNode = ASTextNode()
    postNode.attributedString = NSAttributedString(string: joke.joke, attributes: TextStyles.jokeStyle)
    addSubnode(postNode)

    // Update layout after setting text
    titleNode.setNeedsLayout()
    postNode.setNeedsLayout()
  }

  override func layoutSpecThatFits(constrainedSize: ASSizeRange) -> ASLayoutSpec! {
    let vStack = ASStackLayoutSpec.verticalStackLayoutSpec()
    vStack.flexGrow = true
    vStack.spacing = 8
    vStack.setChildren([titleNode, postNode])

    return ASInsetLayoutSpec(insets: UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8), child: vStack)
  }

Are you using ASCollectionView?

No, I'm using the ASTableView
let tableView = ASTableView(frame: .zero, style: .Plain, asyncDataFetching: true)

Then your code looks right to me. The KittenNode in Kittens sample is also a self-sizing table cell node and it works fine. Can you try to post a sample project, I will debug it as soon as available.

Let me spare you the time. It seems to be working after I ditched Carthage and used pods instead on the master branch. Maybe Carthage didn't overwrite the old version of ASDK I used before I switched to the master branch and thus didn't get the changes or maybe is ASDK just not compatible with carthage. Nevertheless. It works as expected now :) Thanks for your help :)

haha, happy to help (though I didn't help much). I should have asked you what version of ASDK you were using. IIRC, we do support Carthage. If it is Carthage to blame, we actually need to fix it somehow :)

BTW, please remove the unnecessary setNeedsLayout calls in init, they can turn out to be expensive. Cheers!

I took the initiative to create a Slack group over here:

https://asyncdisplaykit.slack.com

@nguyenhuy @appleguy @chrene please feel free to join and chat about ASDK and add any relevant people! I feel like ASDK is really missing its support network.

Nice! Mind if I snag an invite @fatuhoku?

@fatuhoku Invitation please :)

@fatuhoku can you invite me and add me as an administrator? That's funny, it was only two days ago that I tried to create the Slack Channel under that name and was very surprised to find it taken! At the moment I am now using asyncdisplaykitorg ... But would like to use the name that you have set up :)

Invite me at [email protected], and please also send me an email directly in case the invitation gets filtered as spam

@fatuhoku Can you send me an invite too please?

Gladly :) just a few moments... Your e-mail please @nguyenhuy.

It's a little bit of work to set up an automatic invite system like
https://github.com/rauchg/slackin. Might need to pay for hosting separately as well. That way it'd be open to all.

@fatuhoku mine is allforone1511 at gmail. Thank you!

Yes, we should figure out a way to automate the invite system.

Guys pls create IRC channel and made a link to Slack.. I'm just Hate last :(

@bimawa IRC isn't great with sharing images, videos, code snippets, etc that the ASDK community loves to use :)

If you email me at [email protected], we'll get you on Slack within a few hours!

@appleguy Hi Scott! Yea i'm in slack, ty for that. Just my Slack have 10 team groups, and its hard load my mac. I try move to IRC for all messagers with bots and BitlBee support. And images its not trouble for irc. I'm just open it in my browse in one click. Maybe its possible to connect IRC channel to our Slack? Just for ugly guys like me :)

Was this page helpful?
0 / 5 - 0 ratings