Ejemplo n.º 1
0
        public override void performLayout(Size size)
        {
            Size iconSize = null;

            if (hasChild(dropdownIcon))
            {
                iconSize = layoutChild(dropdownIcon, BoxConstraints.loose(size));
                positionChild(dropdownIcon, _offsetForIcon(size, iconSize));
            }

            string bottomLine = hasChild(accountEmail)
                ? accountEmail
                : (hasChild(accountName) ? accountName : null);

            if (bottomLine != null)
            {
                Size constraintSize = iconSize == null ? size : size - new Offset(iconSize.width, 0.0f);
                iconSize = iconSize ?? new Size(UserAccountsDrawerHeaderUtils._kAccountDetailsHeight,
                                                UserAccountsDrawerHeaderUtils._kAccountDetailsHeight);

                Size   bottomLineSize   = layoutChild(bottomLine, BoxConstraints.loose(constraintSize));
                Offset bottomLineOffset = _offsetForBottomLine(size, iconSize, bottomLineSize);
                positionChild(bottomLine, bottomLineOffset);

                if (bottomLine == accountEmail && hasChild(accountName))
                {
                    Size nameSize = layoutChild(accountName, BoxConstraints.loose(constraintSize));
                    positionChild(accountName, _offsetForName(size, nameSize, bottomLineOffset));
                }
            }
        }
Ejemplo n.º 2
0
 public override BoxConstraints getConstraintsForChild(BoxConstraints constraints)
 {
     return(BoxConstraints.loose(
                constraints.biggest - new Offset(material_._kMenuScreenPadding * 2.0f,
                                                 material_._kMenuScreenPadding * 2.0f)
                ));
 }
Ejemplo n.º 3
0
        public override void performLayout(Size size)
        {
            const float    margin           = 56.0f;
            bool           landscape        = size.width > size.height;
            float          imageWidth       = (landscape ? size.width / 2.0f : size.width) - margin * 2.0f;
            BoxConstraints imageConstraints = new BoxConstraints(maxHeight: 224.0f, maxWidth: imageWidth);
            Size           imageSize        = this.layoutChild(image, imageConstraints);
            const float    imageY           = 0.0f;

            this.positionChild(image, new Offset(margin, imageY));

            float          productWidth       = landscape ? size.width / 2.0f : size.width - margin;
            BoxConstraints productConstraints = new BoxConstraints(maxWidth: productWidth);
            Size           productSize        = this.layoutChild(product, productConstraints);
            float          productX           = landscape ? size.width / 2.0f : margin;
            float          productY           = landscape ? 0.0f : imageY + imageSize.height + 16.0f;

            this.positionChild(product, new Offset(productX, productY));

            Size iconSize = this.layoutChild(icon, BoxConstraints.loose(size));

            this.positionChild(icon, new Offset(productX - iconSize.width - 16.0f, productY + 8.0f));

            float vendorWidth = landscape ? size.width - margin : productWidth;

            this.layoutChild(vendor, new BoxConstraints(maxWidth: vendorWidth));
            float vendorX = landscape ? margin : productX;
            float vendorY = productY + productSize.height + 16.0f;

            this.positionChild(vendor, new Offset(vendorX, vendorY));
        }
Ejemplo n.º 4
0
 public override BoxConstraints getConstraintsForChild(BoxConstraints constraints)
 {
     return(BoxConstraints.loose(constraints.biggest -
                                 new Offset(
                                     PopupMenuUtils._kMenuScreenPadding * 2.0f,
                                     PopupMenuUtils._kMenuScreenPadding * 2.0f)));
 }
Ejemplo n.º 5
0
        public override void performLayout(Size size)
        {
            float  columnCardX      = size.width / 5.0f;
            float  columnCardWidth  = size.width - columnCardX;
            float  columnCardHeight = size.height / this.cardCount;
            float  rowCardWidth     = size.width;
            Offset offset           = this.translation.alongSize(size);
            float  columnCardY      = 0.0f;
            float  rowCardX         = -(this.selectedIndex * rowCardWidth);

            float columnTitleX  = size.width / 10.0f;
            float rowTitleWidth = size.width * ((1 + this.tCollapsed) / 2.25f);
            float rowTitleX     = (size.width - rowTitleWidth) / 2.0f - this.selectedIndex * rowTitleWidth;

            const float paddedSectionIndicatorWidth = AnimationWidgetsUtils.kSectionIndicatorWidth + 8.0f;
            float       rowIndicatorWidth           = paddedSectionIndicatorWidth +
                                                      (1.0f - this.tCollapsed) * (rowTitleWidth - paddedSectionIndicatorWidth);
            float rowIndicatorX = (size.width - rowIndicatorWidth) / 2.0f - this.selectedIndex * rowIndicatorWidth;

            for (int index = 0; index < this.cardCount; index++)
            {
                Rect   columnCardRect = Rect.fromLTWH(columnCardX, columnCardY, columnCardWidth, columnCardHeight);
                Rect   rowCardRect    = Rect.fromLTWH(rowCardX, 0.0f, rowCardWidth, size.height);
                Rect   cardRect       = this._interpolateRect(columnCardRect, rowCardRect).shift(offset);
                string cardId         = $"card{index}";
                if (this.hasChild(cardId))
                {
                    this.layoutChild(cardId, BoxConstraints.tight(cardRect.size));
                    this.positionChild(cardId, cardRect.topLeft);
                }

                Size   titleSize         = this.layoutChild($"title{index}", BoxConstraints.loose(cardRect.size));
                float  columnTitleY      = columnCardRect.centerLeft.dy - titleSize.height / 2.0f;
                float  rowTitleY         = rowCardRect.centerLeft.dy - titleSize.height / 2.0f;
                float  centeredRowTitleX = rowTitleX + (rowTitleWidth - titleSize.width) / 2.0f;
                Offset columnTitleOrigin = new Offset(columnTitleX, columnTitleY);
                Offset rowTitleOrigin    = new Offset(centeredRowTitleX, rowTitleY);
                Offset titleOrigin       = this._interpolatePoint(columnTitleOrigin, rowTitleOrigin);
                this.positionChild($"title{index}", titleOrigin + offset);

                Size   indicatorSize         = this.layoutChild($"indicator{index}", BoxConstraints.loose(cardRect.size));
                float  columnIndicatorX      = cardRect.centerRight.dx - indicatorSize.width - 16.0f;
                float  columnIndicatorY      = cardRect.bottomRight.dy - indicatorSize.height - 16.0f;
                Offset columnIndicatorOrigin = new Offset(columnIndicatorX, columnIndicatorY);
                Rect   titleRect             = Rect.fromPoints(titleOrigin, titleSize.bottomRight(titleOrigin));
                float  centeredRowIndicatorX = rowIndicatorX + (rowIndicatorWidth - indicatorSize.width) / 2.0f;
                float  rowIndicatorY         = titleRect.bottomCenter.dy + 16.0f;
                Offset rowIndicatorOrigin    = new Offset(centeredRowIndicatorX, rowIndicatorY);
                Offset indicatorOrigin       = this._interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin);
                this.positionChild($"indicator{index}", indicatorOrigin + offset);

                columnCardY   += columnCardHeight;
                rowCardX      += rowCardWidth;
                rowTitleX     += rowTitleWidth;
                rowIndicatorX += rowIndicatorWidth;
            }
        }
Ejemplo n.º 6
0
        void _layoutChildren()
        {
            BoxConstraints sizedConstraints = _overflowOpen
                ? constraints
                : BoxConstraints.loose(new Size(
                                           constraints.maxWidth,
                                           MaterialUtils._kToolbarHeight
                                           ));

            int   i     = -1;
            float width = 0.0f;

            visitChildren((RenderObject renderObjectChild) => {
                i++;

                if (_lastIndexThatFits != -1 && !overflowOpen)
                {
                    return;
                }

                RenderBox child = renderObjectChild as RenderBox;
                child.layout(sizedConstraints.loosen(), parentUsesSize: true);
                width += child.size.width;

                if (width > sizedConstraints.maxWidth && _lastIndexThatFits == -1)
                {
                    _lastIndexThatFits = i - 1;
                }
            });

            RenderBox navButton = firstChild;

            if (_lastIndexThatFits != -1 &&
                _lastIndexThatFits == childCount - 2 &&
                width - navButton.size.width <= sizedConstraints.maxWidth)
            {
                _lastIndexThatFits = -1;
            }
        }
Ejemplo n.º 7
0
        public override void performLayout(Size size)
        {
            Size priceSize = this.layoutChild(price, BoxConstraints.loose(size));

            this.positionChild(price, new Offset(size.width - priceSize.width, 0.0f));

            float       halfWidth  = size.width / 2.0f;
            float       halfHeight = size.height / 2.0f;
            const float halfUnit   = ShrineHomeUtils.unitSize / 2.0f;
            const float margin     = 16.0f;

            Size  imageSize = this.layoutChild(image, BoxConstraints.loose(size));
            float imageX    = imageSize.width < halfWidth - halfUnit
                ? halfWidth / 2.0f - imageSize.width / 2.0f - halfUnit
                : halfWidth - imageSize.width;

            this.positionChild(image, new Offset(imageX, halfHeight - imageSize.height / 2.0f));

            float          maxTitleWidth       = halfWidth + ShrineHomeUtils.unitSize - margin;
            BoxConstraints titleBoxConstraints = new BoxConstraints(maxWidth: maxTitleWidth);
            Size           titleSize           = this.layoutChild(title, titleBoxConstraints);
            float          titleX = halfWidth - ShrineHomeUtils.unitSize;
            float          titleY = halfHeight - titleSize.height;

            this.positionChild(title, new Offset(titleX, titleY));

            Size  descriptionSize = this.layoutChild(description, titleBoxConstraints);
            float descriptionY    = titleY + titleSize.height + margin;

            this.positionChild(description, new Offset(titleX, descriptionY));

            this.layoutChild(vendor, titleBoxConstraints);
            float vendorY = descriptionY + descriptionSize.height + margin;

            this.positionChild(vendor, new Offset(titleX, vendorY));
        }
Ejemplo n.º 8
0
        public override void performLayout(Size size)
        {
            float leadingWidth  = 0.0f;
            float trailingWidth = 0.0f;

            if (this.hasChild(_ToolbarSlot.leading))
            {
                BoxConstraints constraints = new BoxConstraints(
                    minWidth: 0.0f,
                    maxWidth: size.width / 3.0f,
                    minHeight: size.height,
                    maxHeight: size.height
                    );
                leadingWidth = this.layoutChild(_ToolbarSlot.leading, constraints).width;
                float leadingX = 0.0f;
                switch (this.textDirection)
                {
                case TextDirection.rtl:
                    leadingX = size.width - leadingWidth;
                    break;

                case TextDirection.ltr:
                    leadingX = 0.0f;
                    break;
                }

                this.positionChild(_ToolbarSlot.leading, new Offset(leadingX, 0.0f));
            }

            if (this.hasChild(_ToolbarSlot.trailing))
            {
                BoxConstraints constraints  = BoxConstraints.loose(size);
                Size           trailingSize = this.layoutChild(_ToolbarSlot.trailing, constraints);
                float          trailingX    = 0.0f;
                switch (this.textDirection)
                {
                case TextDirection.rtl:
                    trailingX = 0.0f;
                    break;

                case TextDirection.ltr:
                    trailingX = size.width - trailingSize.width;
                    break;
                }

                float trailingY = (size.height - trailingSize.height) / 2.0f;
                trailingWidth = trailingSize.width;
                this.positionChild(_ToolbarSlot.trailing, new Offset(trailingX, trailingY));
            }

            if (this.hasChild(_ToolbarSlot.middle))
            {
                float          maxWidth    = Mathf.Max(size.width - leadingWidth - trailingWidth - this.middleSpacing * 2.0f, 0.0f);
                BoxConstraints constraints = BoxConstraints.loose(size).copyWith(maxWidth: maxWidth);
                Size           middleSize  = this.layoutChild(_ToolbarSlot.middle, constraints);

                float middleStartMargin = leadingWidth + this.middleSpacing;
                float middleStart       = middleStartMargin;
                float middleY           = (size.height - middleSize.height) / 2.0f;
                // If the centered middle will not fit between the leading and trailing
                // widgets, then align its left or right edge with the adjacent boundary.
                if (this.centerMiddle)
                {
                    middleStart = (size.width - middleSize.width) / 2.0f;
                    if (middleStart + middleSize.width > size.width - trailingWidth)
                    {
                        middleStart = size.width - trailingWidth - middleSize.width;
                    }
                    else if (middleStart < middleStartMargin)
                    {
                        middleStart = middleStartMargin;
                    }
                }

                float middleX = 0.0f;
                switch (this.textDirection)
                {
                case TextDirection.rtl:
                    middleX = size.width - middleSize.width - middleStart;
                    break;

                case TextDirection.ltr:
                    middleX = middleStart;
                    break;
                }

                this.positionChild(_ToolbarSlot.middle, new Offset(middleX, middleY));
            }
        }
Ejemplo n.º 9
0
        public override void performLayout(Size size)
        {
            float leadingWidth  = 0.0f;
            float trailingWidth = 0.0f;

            if (hasChild(_ToolbarSlot.leading))
            {
                BoxConstraints constraints = new BoxConstraints(
                    minWidth: 0.0f,
                    maxWidth: size.width / 3.0f,
                    minHeight: size.height,
                    maxHeight: size.height
                    );
                leadingWidth = layoutChild(_ToolbarSlot.leading, constraints).width;
                float leadingX = 0.0f;
                switch (textDirection)
                {
                case TextDirection.rtl:
                    leadingX = size.width - leadingWidth;
                    break;

                case TextDirection.ltr:
                    leadingX = 0.0f;
                    break;
                }

                positionChild(_ToolbarSlot.leading, new Offset(leadingX, 0.0f));
            }

            if (hasChild(_ToolbarSlot.trailing))
            {
                BoxConstraints constraints  = BoxConstraints.loose(size);
                Size           trailingSize = layoutChild(_ToolbarSlot.trailing, constraints);
                float          trailingX    = 0.0f;
                switch (textDirection)
                {
                case TextDirection.rtl:
                    trailingX = 0.0f;
                    break;

                case TextDirection.ltr:
                    trailingX = size.width - trailingSize.width;
                    break;
                }

                float trailingY = (size.height - trailingSize.height) / 2.0f;
                trailingWidth = trailingSize.width;
                positionChild(_ToolbarSlot.trailing, new Offset(trailingX, trailingY));
            }

            if (hasChild(_ToolbarSlot.middle))
            {
                float          maxWidth    = Mathf.Max(size.width - leadingWidth - trailingWidth - middleSpacing * 2.0f, 0.0f);
                BoxConstraints constraints = BoxConstraints.loose(size).copyWith(maxWidth: maxWidth);
                Size           middleSize  = layoutChild(_ToolbarSlot.middle, constraints);

                float middleStartMargin = leadingWidth + middleSpacing;
                float middleStart       = middleStartMargin;
                float middleY           = (size.height - middleSize.height) / 2.0f;

                if (centerMiddle)
                {
                    middleStart = (size.width - middleSize.width) / 2.0f;
                    if (middleStart + middleSize.width > size.width - trailingWidth)
                    {
                        middleStart = size.width - trailingWidth - middleSize.width;
                    }
                    else if (middleStart < middleStartMargin)
                    {
                        middleStart = middleStartMargin;
                    }
                }

                float middleX = 0.0f;
                switch (textDirection)
                {
                case TextDirection.rtl:
                    middleX = size.width - middleSize.width - middleStart;
                    break;

                case TextDirection.ltr:
                    middleX = middleStart;
                    break;
                }

                positionChild(_ToolbarSlot.middle, new Offset(middleX, middleY));
            }
        }