1

I'm wonder what is the correct way to center textNode inside vertical ASSStackNode which is inside horizontal ASStackNode without setting any sizes?

I've tried different options with ASCenterLayout / ASRelativeLayout around vertical layout, flewGrow, flexShrink. Only possible way that I see is static layout with minimum height around vertical layout. But wanna find if there are another way.

Images to better picture:

My layout structure:

Layout

What I get when one of text fields is empty:

enter image description here

What I want to see:

enter image description here

1 Answers1

1

If your ASTextNode is empty or nil. Isn't mean node not exist. If you want hide node if it empty, you must write a simple logic for it. For exlude it Spec from calculation. What i use on ADK1.9:

- (ASLayoutSpec *)layoutSpecThatFits: (ASSizeRange)constrainedSize
{
  NSMutableArray *arrayOfChildren = [NSMutableArray new];
  [arrayOfChildren insertObject:self.titleNode];
  if (self.textNode.text.length > 0) {
    [arrayOfChildren insertObject:self.textNode];
  }
  ASStackLayoutSpec *verticalElementCoreStack = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:8
                                                                                 justifyContent:ASStackLayoutJustifyContentCenter alignItems:ASStackLayoutAlignItemsStretch
                                                                                       children:arrayOfChildren];
  return verticalElementCoreStack;
}
Bimawa
  • 3,535
  • 2
  • 25
  • 45