Пример #1
0
 public BoxConstraints getBoxConstraints(SliverConstraints constraints)
 {
     return(constraints.asBoxConstraints(
                minExtent: this.mainAxisExtent ?? 0.0f,
                maxExtent: this.mainAxisExtent ?? 0.0f,
                crossAxisExtent: this.crossAxisExtent ?? 0.0f
                ));
 }
Пример #2
0
        protected override void performLayout()
        {
            SliverConstraints constraints = this.constraints;

            D.assert(constraints.axisDirection == AxisDirection.down);
            D.assert(constraints.growthDirection == GrowthDirection.forward);
            float layoutExtent =
                (_hasLayoutExtent ? 1.0f : 0.0f) * _refreshIndicatorExtent;

            if (layoutExtent != layoutExtentOffsetCompensation)
            {
                geometry = new SliverGeometry(
                    scrollOffsetCorrection: layoutExtent - layoutExtentOffsetCompensation
                    );
                layoutExtentOffsetCompensation = layoutExtent;
            }
            bool  active             = constraints.overlap <0.0 || layoutExtent> 0.0;
            float overscrolledExtent =
                constraints.overlap < 0.0f ? constraints.overlap.abs() : 0.0f;

            child.layout(
                constraints.asBoxConstraints(
                    maxExtent: layoutExtent + overscrolledExtent
                    ),
                parentUsesSize: true
                );
            if (active)
            {
                geometry = new SliverGeometry(
                    scrollExtent: layoutExtent,
                    paintOrigin: -overscrolledExtent - constraints.scrollOffset,
                    paintExtent: Mathf.Max(
                        Mathf.Max(child.size.height, layoutExtent) - constraints.scrollOffset, 0.0f),
                    maxPaintExtent: Mathf.Max(
                        Mathf.Max(child.size.height, layoutExtent) - constraints.scrollOffset, 0.0f),
                    layoutExtent: Mathf.Max(layoutExtent - constraints.scrollOffset, 0.0f));
            }
            else
            {
                geometry = SliverGeometry.zero;
            }
        }