public static PageView builder(
     IndexedWidgetBuilder itemBuilder,
     Key key = null,
     Axis scrollDirection                = Axis.horizontal,
     bool reverse                        = false,
     PageController controller           = null,
     ScrollPhysics physics               = null,
     bool pageSnapping                   = true,
     ValueChanged <int> onPageChanged    = null,
     int itemCount                       = 0,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start
     )
 {
     return(new PageView(
                itemBuilder: itemBuilder,
                key: key,
                scrollDirection: scrollDirection,
                reverse: reverse,
                controller: controller,
                physics: physics,
                pageSnapping: pageSnapping,
                onPageChanged: onPageChanged,
                itemCount: itemCount,
                dragStartBehavior: dragStartBehavior
                ));
 }
Exemplo n.º 2
0
        protected ScrollPosition(
            ScrollPhysics physics      = null,
            ScrollContext context      = null,
            bool keepScrollOffset      = true,
            ScrollPosition oldPosition = null,
            string debugLabel          = null
            )
        {
            D.assert(physics != null);
            D.assert(context != null);
            D.assert(context.vsync != null);

            this.physics          = physics;
            this.context          = context;
            this.keepScrollOffset = keepScrollOffset;
            this.debugLabel       = debugLabel;

            if (oldPosition != null)
            {
                this.absorb(oldPosition);
            }

            if (keepScrollOffset)
            {
                this.restoreScrollOffset();
            }
        }
        public ScrollPositionWithSingleContext(
            ScrollPhysics physics      = null,
            ScrollContext context      = null,
            float?initialPixels        = 0.0f,
            bool keepScrollOffset      = true,
            ScrollPosition oldPosition = null,
            string debugLabel          = null
            ) : base(
                physics: physics,
                context: context,
                keepScrollOffset: keepScrollOffset,
                oldPosition: oldPosition,
                debugLabel: debugLabel
                )
        {
            if (this._pixels == null && initialPixels != null)
            {
                this.correctPixels(initialPixels.Value);
            }

            if (this.activity == null)
            {
                this.goIdle();
            }

            D.assert(this.activity != null);
        }
Exemplo n.º 4
0
 public SingleChildScrollView(
     Key key = null,
     Axis scrollDirection                = Axis.vertical,
     bool reverse                        = false,
     EdgeInsets padding                  = null,
     bool?primary                        = null,
     ScrollPhysics physics               = null,
     ScrollController controller         = null,
     Widget child                        = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start
     ) : base(key: key)
 {
     D.assert(!(controller != null && primary == true),
              () =>
              "Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
              "You cannot both set primary to true and pass an explicit controller.");
     this.scrollDirection   = scrollDirection;
     this.reverse           = reverse;
     this.padding           = padding;
     this.primary           = primary ?? controller == null && scrollDirection == Axis.vertical;
     this.physics           = physics;
     this.controller        = controller;
     this.child             = child;
     this.dragStartBehavior = dragStartBehavior;
 }
Exemplo n.º 5
0
        void _updatePosition()
        {
            this._configuration = ScrollConfiguration.of(this.context);
            this._physics       = this._configuration.getScrollPhysics(this.context);
            if (this.widget.physics != null)
            {
                this._physics = this.widget.physics.applyTo(this._physics);
            }

            ScrollController controller  = this.widget.controller;
            ScrollPosition   oldPosition = this.position;

            if (oldPosition != null)
            {
                if (controller != null)
                {
                    controller.detach(oldPosition);
                }

                Window.instance.scheduleMicrotask(oldPosition.dispose);
            }

            this._position = controller == null
                ? null
                : controller.createScrollPosition(this._physics, this, oldPosition);
            this._position = this._position
                             ?? new ScrollPositionWithSingleContext(physics: this._physics, context: this,
                                                                    oldPosition: oldPosition);
            D.assert(this.position != null);
            if (controller != null)
            {
                controller.attach(this.position);
            }
        }
Exemplo n.º 6
0
 public PageView(
     Key key = null,
     Axis scrollDirection                = Axis.horizontal,
     bool reverse                        = false,
     PageController controller           = null,
     ScrollPhysics physics               = null,
     bool pageSnapping                   = true,
     ValueChanged <int> onPageChanged    = null,
     List <Widget> children              = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start,
     IndexedWidgetBuilder itemBuilder    = null,
     SliverChildDelegate childDelegate   = null,
     int itemCount                       = 0
     ) : base(key: key)
 {
     this.scrollDirection   = scrollDirection;
     this.reverse           = reverse;
     this.physics           = physics;
     this.pageSnapping      = pageSnapping;
     this.onPageChanged     = onPageChanged;
     this.dragStartBehavior = dragStartBehavior;
     this.controller        = controller ?? PageViewUtils._defaultPageController;
     if (itemBuilder != null)
     {
         this.childrenDelegate = new SliverChildBuilderDelegate(itemBuilder, childCount: itemCount);
     }
     else if (childDelegate != null)
     {
         this.childrenDelegate = childDelegate;
     }
     else
     {
         this.childrenDelegate = new SliverChildListDelegate(children ?? new List <Widget>());
     }
 }
Exemplo n.º 7
0
 public static ListView custom(
     Key key = null,
     Axis scrollDirection                 = Axis.vertical,
     bool reverse                         = false,
     ScrollController controller          = null,
     bool?primary                         = null,
     ScrollPhysics physics                = null,
     bool shrinkWrap                      = false,
     EdgeInsets padding                   = null,
     float?itemExtent                     = null,
     SliverChildDelegate childrenDelegate = null,
     float?cacheExtent                    = null
     )
 {
     return(new ListView(
                key,
                scrollDirection,
                reverse,
                controller,
                primary,
                physics,
                shrinkWrap,
                padding,
                itemExtent,
                childrenDelegate,
                cacheExtent));
 }
Exemplo n.º 8
0
        bool _shouldUpdatePosition(Scrollable oldWidget)
        {
            ScrollPhysics newPhysics = widget.physics;
            ScrollPhysics oldPhysics = oldWidget.physics;

            do
            {
                Type newPhysicsType = newPhysics != null?newPhysics.GetType() : null;

                Type oldPhysicsType = oldPhysics != null?oldPhysics.GetType() : null;

                if (newPhysicsType != oldPhysicsType)
                {
                    return(true);
                }

                if (newPhysics != null)
                {
                    newPhysics = newPhysics.parent;
                }

                if (oldPhysics != null)
                {
                    oldPhysics = oldPhysics.parent;
                }
            } while (newPhysics != null || oldPhysics != null);

            Type controllerType    = widget.controller == null ? null : widget.controller.GetType();
            Type oldControllerType = oldWidget.controller == null ? null : oldWidget.controller.GetType();

            return(controllerType != oldControllerType);
        }
Exemplo n.º 9
0
 public static ListView seperated(
     Key key = null,
     Axis scrollDirection                  = Axis.vertical,
     bool reverse                          = false,
     ScrollController controller           = null,
     bool?primary                          = null,
     ScrollPhysics physics                 = null,
     bool shrinkWrap                       = false,
     EdgeInsets padding                    = null,
     IndexedWidgetBuilder itemBuilder      = null,
     IndexedWidgetBuilder separatorBuilder = null,
     int itemCount                         = 0,
     bool addAutomaticKeepAlives           = true,
     bool addRepaintBoundaries             = true,
     float?cacheExtent                     = null
     )
 {
     return(new ListView(
                key,
                scrollDirection,
                reverse,
                controller,
                primary,
                physics,
                shrinkWrap,
                padding,
                itemBuilder,
                separatorBuilder,
                itemCount,
                addAutomaticKeepAlives,
                addRepaintBoundaries,
                cacheExtent
                ));
 }
Exemplo n.º 10
0
 public ListView(
     Key key = null,
     Axis scrollDirection                = Axis.vertical,
     bool reverse                        = false,
     ScrollController controller         = null,
     bool?primary                        = null,
     ScrollPhysics physics               = null,
     bool shrinkWrap                     = false,
     EdgeInsets padding                  = null,
     float?itemExtent                    = null,
     bool addAutomaticKeepAlives         = true,
     bool addRepaintBoundaries           = true,
     float?cacheExtent                   = null,
     List <Widget> children              = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent,
         dragStartBehavior: dragStartBehavior
         )
 {
     this.itemExtent       = itemExtent;
     this.childrenDelegate = new SliverChildListDelegate(
         children,
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
Exemplo n.º 11
0
 public BoxScrollView(
     Key key = null,
     Axis scrollDirection                = Axis.vertical,
     bool reverse                        = false,
     ScrollController controller         = null,
     bool?primary                        = null,
     ScrollPhysics physics               = null,
     bool shrinkWrap                     = false,
     EdgeInsets padding                  = null,
     float?cacheExtent                   = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         cacheExtent: cacheExtent,
         dragStartBehavior: dragStartBehavior
         )
 {
     this.padding = padding;
 }
Exemplo n.º 12
0
 public CustomScrollView(
     Key key = null,
     Axis scrollDirection        = Axis.vertical,
     bool reverse                = false,
     ScrollController controller = null,
     bool?primary                = null,
     ScrollPhysics physics       = null,
     bool shrinkWrap             = false,
     Key center            = null,
     float anchor          = 0.0f,
     float?cacheExtent     = null,
     List <Widget> slivers = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         center: center,
         anchor: anchor,
         cacheExtent: cacheExtent,
         dragStartBehavior: dragStartBehavior
         )
 {
     this.slivers = slivers ?? new List <Widget>();
 }
Exemplo n.º 13
0
 ListView(
     Key key = null,
     Axis scrollDirection                 = Axis.vertical,
     bool reverse                         = false,
     ScrollController controller          = null,
     bool?primary                         = null,
     ScrollPhysics physics                = null,
     bool shrinkWrap                      = false,
     EdgeInsets padding                   = null,
     float?itemExtent                     = null,
     SliverChildDelegate childrenDelegate = null,
     float?cacheExtent                    = null
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent
         )
 {
     D.assert(childrenDelegate != null);
     this.itemExtent       = itemExtent;
     this.childrenDelegate = childrenDelegate;
 }
Exemplo n.º 14
0
 public GridView(
     Key key = null,
     Axis scrollDirection                 = Axis.vertical,
     bool reverse                         = false,
     ScrollController controller          = null,
     bool?primary                         = null,
     ScrollPhysics physics                = null,
     bool shrinkWrap                      = false,
     EdgeInsets padding                   = null,
     SliverGridDelegate gridDelegate      = null,
     SliverChildDelegate childrenDelegate = null,
     float?cacheExtent                    = null,
     DragStartBehavior dragStartBehavior  = DragStartBehavior.start
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent,
         dragStartBehavior: dragStartBehavior
         )
 {
     D.assert(gridDelegate != null);
     D.assert(childrenDelegate != null);
     this.gridDelegate     = gridDelegate;
     this.childrenDelegate = childrenDelegate;
 }
Exemplo n.º 15
0
        protected ScrollView(
            Key key = null,
            Axis scrollDirection        = Axis.vertical,
            bool reverse                = false,
            ScrollController controller = null,
            bool?primary                = null,
            ScrollPhysics physics       = null,
            bool shrinkWrap             = false,
            float?cacheExtent           = null
            ) : base(key: key)
        {
            D.assert(!(controller != null && primary == true),
                     "Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
                     "You cannot both set primary to true and pass an explicit controller.");

            primary = primary ?? controller == null && scrollDirection == Axis.vertical;
            physics = physics ?? (primary.Value ? new AlwaysScrollableScrollPhysics() : null);

            this.scrollDirection = scrollDirection;
            this.reverse         = reverse;
            this.controller      = controller;
            this.primary         = primary.Value;
            this.physics         = physics;
            this.shrinkWrap      = shrinkWrap;
            this.cacheExtent     = cacheExtent;
        }
Exemplo n.º 16
0
        public static PageView custom(
            Key key = null,
            Axis scrollDirection                 = Axis.horizontal,
            bool reverse                         = false,
            PageController controller            = null,
            ScrollPhysics physics                = null,
            bool pageSnapping                    = true,
            ValueChanged <int> onPageChanged     = null,
            SliverChildDelegate childrenDelegate = null,
            DragStartBehavior dragStartBehavior  = DragStartBehavior.start,
            bool allowImplicitScrolling          = false
            )
        {
            D.assert(childrenDelegate != null);
            var page = new PageView(
                key: key,
                scrollDirection: scrollDirection,
                reverse: reverse,
                controller: controller ?? PageViewUtils._defaultPageController,
                physics: physics,
                pageSnapping: pageSnapping,
                onPageChanged: onPageChanged,
                allowImplicitScrolling: allowImplicitScrolling,
                dragStartBehavior: dragStartBehavior
                );

            page.childrenDelegate = childrenDelegate;
            return(page);
        }
Exemplo n.º 17
0
 public override ScrollPhysics applyTo(ScrollPhysics ancestor)
 {
     return(new _ForceImplicitScrollPhysics(
                allowImplicitScrolling: allowImplicitScrolling,
                parent:  buildParent(ancestor)
                ));
 }
Exemplo n.º 18
0
        public static PageView builder(
            Key key = null,
            Axis scrollDirection                = Axis.horizontal,
            bool reverse                        = false,
            PageController controller           = null,
            ScrollPhysics physics               = null,
            bool pageSnapping                   = true,
            ValueChanged <int> onPageChanged    = null,
            IndexedWidgetBuilder itemBuilder    = null,
            int itemCount                       = 0,
            DragStartBehavior dragStartBehavior = DragStartBehavior.start,
            bool allowImplicitScrolling         = false
            )
        {
            var page = new PageView(
                key: key,
                scrollDirection: scrollDirection,
                reverse: reverse,
                controller: controller ?? PageViewUtils._defaultPageController,
                physics: physics,
                pageSnapping: pageSnapping,
                onPageChanged: onPageChanged,
                allowImplicitScrolling: allowImplicitScrolling,
                dragStartBehavior: dragStartBehavior
                );

            page.childrenDelegate = new SliverChildBuilderDelegate(itemBuilder, childCount: itemCount);
            return(page);
        }
Exemplo n.º 19
0
 public static ListWheelScrollView useDelegate(
     float itemExtent,
     List <Widget> children = null,
     ListWheelChildDelegate childDelegate = null,
     Key key = null,
     ScrollController controller = null,
     ScrollPhysics physics       = null,
     float diameterRatio         = RenderListWheelViewport.defaultDiameterRatio,
     float perspective           = RenderListWheelViewport.defaultPerspective,
     float offAxisFraction       = 0.0f,
     bool useMagnifier           = false,
     float magnification         = 1.0f,
     ValueChanged <int> onSelectedItemChanged = null,
     bool clipToSize = true,
     bool renderChildrenOutsideViewport = false
     )
 {
     return(new ListWheelScrollView(
                itemExtent: itemExtent,
                children: children,
                childDelegate: childDelegate,
                key: key,
                controller: controller,
                physics: physics,
                diameterRatio: diameterRatio,
                perspective: perspective,
                offAxisFraction: offAxisFraction,
                useMagnifier: useMagnifier,
                magnification: magnification,
                onSelectedItemChanged: onSelectedItemChanged,
                clipToSize: clipToSize,
                renderChildrenOutsideViewport: renderChildrenOutsideViewport
                ));
 }
Exemplo n.º 20
0
 public _ForceImplicitScrollPhysics(
     bool allowImplicitScrolling = false,
     ScrollPhysics parent        = null
     ) : base(parent: parent)
 {
     this.allowImplicitScrolling = allowImplicitScrolling;
 }
Exemplo n.º 21
0
 public static GridView custom(
     Key key = null,
     Axis scrollDirection                 = Axis.vertical,
     bool reverse                         = false,
     ScrollController controller          = null,
     bool?primary                         = null,
     ScrollPhysics physics                = null,
     bool shrinkWrap                      = false,
     EdgeInsets padding                   = null,
     SliverGridDelegate gridDelegate      = null,
     SliverChildDelegate childrenDelegate = null,
     float?cacheExtent                    = null,
     DragStartBehavior dragStartBehavior  = DragStartBehavior.start
     )
 {
     return(new GridView(
                key: key,
                scrollDirection: scrollDirection,
                reverse: reverse,
                controller: controller,
                primary: primary,
                physics: physics,
                shrinkWrap: shrinkWrap,
                padding: padding,
                gridDelegate: gridDelegate,
                childrenDelegate: childrenDelegate,
                cacheExtent: cacheExtent,
                dragStartBehavior: dragStartBehavior
                ));
 }
Exemplo n.º 22
0
        protected ScrollView(
            Key key = null,
            Axis scrollDirection        = Axis.vertical,
            bool reverse                = false,
            ScrollController controller = null,
            bool?primary                = null,
            ScrollPhysics physics       = null,
            bool shrinkWrap             = false,
            Key center        = null,
            float anchor      = 0.0f,
            float?cacheExtent = null,
            DragStartBehavior dragStartBehavior = DragStartBehavior.start
            ) : base(key: key)
        {
            D.assert(!(controller != null && primary == true),
                     () => "Primary ScrollViews obtain their ScrollController via inheritance from a PrimaryScrollController widget. " +
                     "You cannot both set primary to true and pass an explicit controller.");
            D.assert(!shrinkWrap || center == null);
            D.assert(anchor >= 0.0f && anchor <= 1.0f);

            primary = primary ?? controller == null && scrollDirection == Axis.vertical;
            physics = physics ?? (primary.Value ? new AlwaysScrollableScrollPhysics() : null);

            this.scrollDirection   = scrollDirection;
            this.reverse           = reverse;
            this.controller        = controller;
            this.primary           = primary.Value;
            this.physics           = physics;
            this.shrinkWrap        = shrinkWrap;
            this.center            = center;
            this.anchor            = anchor;
            this.cacheExtent       = cacheExtent;
            this.dragStartBehavior = dragStartBehavior;
        }
Exemplo n.º 23
0
 public static GridView builder(
     Key key = null,
     Axis scrollDirection             = Axis.vertical,
     bool reverse                     = false,
     ScrollController controller      = null,
     bool?primary                     = null,
     ScrollPhysics physics            = null,
     bool shrinkWrap                  = false,
     EdgeInsets padding               = null,
     SliverGridDelegate gridDelegate  = null,
     IndexedWidgetBuilder itemBuilder = null,
     int?itemCount                    = null,
     bool addAutomaticKeepAlives      = true,
     bool addRepaintBoundaries        = true,
     float?cacheExtent                = null
     )
 {
     return(new GridView(
                key: key,
                scrollDirection: scrollDirection,
                reverse: reverse,
                controller: controller,
                primary: primary,
                physics: physics,
                shrinkWrap: shrinkWrap,
                padding: padding,
                gridDelegate: gridDelegate,
                itemBuilder: itemBuilder,
                itemCount: itemCount,
                addAutomaticKeepAlives: addAutomaticKeepAlives,
                addRepaintBoundaries: addRepaintBoundaries,
                cacheExtent: cacheExtent
                ));
 }
Exemplo n.º 24
0
 public GridView(
     Key key = null,
     Axis scrollDirection             = Axis.vertical,
     bool reverse                     = false,
     ScrollController controller      = null,
     bool?primary                     = null,
     ScrollPhysics physics            = null,
     bool shrinkWrap                  = false,
     EdgeInsets padding               = null,
     SliverGridDelegate gridDelegate  = null,
     IndexedWidgetBuilder itemBuilder = null,
     int?itemCount                    = null,
     bool addAutomaticKeepAlives      = true,
     bool addRepaintBoundaries        = true,
     float?cacheExtent                = null
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent
         )
 {
     this.gridDelegate     = gridDelegate;
     this.childrenDelegate = new SliverChildBuilderDelegate(
         itemBuilder,
         childCount: itemCount,
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
Exemplo n.º 25
0
 public GridView(
     Key key = null,
     Axis scrollDirection            = Axis.vertical,
     bool reverse                    = false,
     ScrollController controller     = null,
     bool?primary                    = null,
     ScrollPhysics physics           = null,
     bool shrinkWrap                 = false,
     EdgeInsets padding              = null,
     SliverGridDelegate gridDelegate = null,
     bool addAutomaticKeepAlives     = true,
     bool addRepaintBoundaries       = true,
     float?cacheExtent               = null,
     List <Widget> children          = null
     ) : base(
         key: key,
         scrollDirection: scrollDirection,
         reverse: reverse,
         controller: controller,
         primary: primary,
         physics: physics,
         shrinkWrap: shrinkWrap,
         padding: padding,
         cacheExtent: cacheExtent
         )
 {
     D.assert(gridDelegate != null);
     this.childrenDelegate = new SliverChildListDelegate(
         children ?? new List <Widget>(),
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
Exemplo n.º 26
0
        protected ScrollPhysics buildParent(ScrollPhysics ancestor)
        {
            if (this.parent == null)
            {
                return(ancestor);
            }

            return(this.parent.applyTo(ancestor) ?? ancestor);
        }
Exemplo n.º 27
0
 public override ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context,
                                                     ScrollPosition oldPosition)
 {
     return(new _FixedExtentScrollPosition(
                physics: physics,
                context: context,
                initialItem: this.initialItem,
                oldPosition: oldPosition
                ));
 }
Exemplo n.º 28
0
 public override ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context,
                                                     ScrollPosition oldPosition)
 {
     return(new _PagePosition(
                physics: physics,
                context: context,
                initialPage: this.initialPage,
                keepPage: this.keepPage,
                viewportFraction: this.viewportFraction,
                oldPosition: oldPosition
                ));
 }
Exemplo n.º 29
0
 public TestScrollPositionWithSingleContext(
     ScrollPhysics physics      = null,
     ScrollContext context      = null,
     float?initialPixels        = 0.0f,
     bool keepScrollOffset      = true,
     ScrollPosition oldPosition = null,
     string debugLabel          = null
     ) : base(physics: physics,
              context: context,
              keepScrollOffset: keepScrollOffset,
              oldPosition: oldPosition,
              debugLabel: debugLabel)
 {
 }
Exemplo n.º 30
0
 public virtual ScrollPosition createScrollPosition(
     ScrollPhysics physics,
     ScrollContext context,
     ScrollPosition oldPosition
     )
 {
     return(new ScrollPositionWithSingleContext(
                physics: physics,
                context: context,
                initialPixels: this.initialScrollOffset,
                keepScrollOffset: this.keepScrollOffset,
                oldPosition: oldPosition,
                debugLabel: this.debugLabel
                ));
 }