예제 #1
0
        protected override Widget Build(BuildContext context)
        {
            Widget MakeContainer(int w, int h, int n) => new Container(
                size: WidgetSize.Fixed(w, h),
                backgroundColor: Color.Lerp(Color.blue, Color.green, n / 15f)
                );

            return(new Container(
                       backgroundColor: Color.gray,
                       child: new ScrollList(
                           crossAxisAlignment: CrossAxisAlignment.Center,
                           mainAxisAlignment: MainAxisAlignment.Center,
                           children: new List <Widget>
            {
                MakeContainer(100, 100, 1),
                MakeContainer(120, 110, 2),
                MakeContainer(110, 120, 3),
                MakeContainer(100, 140, 4),
                MakeContainer(150, 110, 5),
                MakeContainer(110, 100, 6),
                MakeContainer(100, 100, 7),
                MakeContainer(120, 110, 8),
                MakeContainer(100, 100, 9),
                MakeContainer(100, 100, 10),
            }
                           )
                       ));
        }
예제 #2
0
 protected override Widget Build(BuildContext context)
 {
     return(new Container(
                size: WidgetSize.Stretched,
                backgroundColor: Color.white,
                child: new CompositeTransition(
                    opacity: _opacity,
                    position: _position,
                    rotation: _rotation,
                    child: new Container(
                        size: WidgetSize.Fixed(300, 200),
                        backgroundColor: Color.black
                        )
                    )
                ));
 }
예제 #3
0
        private WidgetSize CalculateInnerSize()
        {
            var width  = 0f;
            var height = 0f;

            var lineWidth    = 0.0f;
            var lineHeight   = 0.0f;
            var lineChildNum = 0;

            var maxLineWidth    = Widget.MaxCrossAxisExtent;
            var maxLineChildNum = Widget.MaxCrossAxisCount;

            foreach (var child in Children)
            {
                var childSize = child.Size;

                if (float.IsInfinity(childSize.MaxWidth) || float.IsInfinity(childSize.MaxHeight))
                {
                    continue;
                }

                if (lineChildNum + 1 <= maxLineChildNum &&
                    lineWidth + childSize.MaxWidth <= maxLineWidth)
                {
                    lineChildNum++;
                    lineWidth += childSize.MaxWidth;
                    lineHeight = Math.Max(lineHeight, childSize.MaxHeight);
                }
                else
                {
                    width   = Math.Max(width, lineWidth);
                    height += lineHeight;

                    lineChildNum = 1;
                    lineWidth    = childSize.MaxWidth;
                    lineHeight   = childSize.MaxHeight;
                }
            }

            width   = Math.Max(width, lineWidth);
            height += lineHeight;

            width = Math.Min(width, MaxCrossAxisExtent);

            return(WidgetSize.Fixed(width, height));
        }
예제 #4
0
 public override WidgetSize CalculateSize() => WidgetSize.Fixed(0, 0);