Example #1
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
                ));
 }
Example #2
0
        public CupertinoPicker(
            float itemExtent,
            ValueChanged <int> onSelectedItemChanged,
            List <Widget> children = null,
            Key key               = null,
            float diameterRatio   = CupertinoPickerUtils._kDefaultDiameterRatio,
            Color backgroundColor = null,
            float offAxisFraction = 0.0f,
            bool useMagnifier     = false,
            float magnification   = 1.0f,
            FixedExtentScrollController scrollController = null,
            bool looping = false,
            ListWheelChildDelegate childDelegate = null
            ) : base(key: key)
        {
            D.assert(children != null || childDelegate != null);
            D.assert(diameterRatio > 0.0, () => RenderListWheelViewport.diameterRatioZeroMessage);
            D.assert(magnification > 0);
            D.assert(itemExtent > 0);

            this.childDelegate = childDelegate ?? (looping
                                     ? (ListWheelChildDelegate) new ListWheelChildLoopingListDelegate(
                                                       children: children)
                                     : (ListWheelChildDelegate) new ListWheelChildListDelegate(children: children));

            this.itemExtent            = itemExtent;
            this.onSelectedItemChanged = onSelectedItemChanged;
            this.diameterRatio         = diameterRatio;
            this.backgroundColor       = backgroundColor ?? CupertinoPickerUtils._kDefaultBackground;
            this.offAxisFraction       = offAxisFraction;
            this.useMagnifier          = useMagnifier;
            this.magnification         = magnification;
            this.scrollController      = scrollController;
        }
Example #3
0
        public override void update(Widget newWidget)
        {
            ListWheelViewport oldWidget = this.widget;

            base.update(newWidget);
            ListWheelChildDelegate newDelegate = ((ListWheelViewport)newWidget).childDelegate;
            ListWheelChildDelegate oldDelegate = oldWidget.childDelegate;

            if (newDelegate != oldDelegate &&
                (newDelegate.GetType() != oldDelegate.GetType() || newDelegate.shouldRebuild(oldDelegate)))
            {
                this.performRebuild();
            }
        }
Example #4
0
 public ListWheelScrollView(
     float itemExtent,
     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,
     float squeeze = 1.0f,
     ValueChanged <int> onSelectedItemChanged = null,
     float overAndUnderCenterOpacity          = 1.0f,
     bool clipToSize = true,
     bool renderChildrenOutsideViewport   = false,
     ListWheelChildDelegate childDelegate = null
     ) : base(key: key)
 {
     D.assert(childDelegate != null);
     D.assert(diameterRatio > 0.0, () => RenderListWheelViewport.diameterRatioZeroMessage);
     D.assert(perspective > 0);
     D.assert(perspective <= 0.01, () => RenderListWheelViewport.perspectiveTooHighMessage);
     D.assert(magnification > 0);
     D.assert(overAndUnderCenterOpacity >= 0 && overAndUnderCenterOpacity <= 1);
     D.assert(itemExtent != null);
     D.assert(itemExtent > 0);
     D.assert(squeeze > 0);
     D.assert(
         !renderChildrenOutsideViewport || !clipToSize, () =>
         RenderListWheelViewport.clipToSizeAndRenderChildrenOutsideViewportConflict
         );
     this.controller                    = controller;
     this.physics                       = physics;
     this.diameterRatio                 = diameterRatio;
     this.perspective                   = perspective;
     this.offAxisFraction               = offAxisFraction;
     this.useMagnifier                  = useMagnifier;
     this.magnification                 = magnification;
     this.overAndUnderCenterOpacity     = overAndUnderCenterOpacity;
     this.itemExtent                    = itemExtent;
     this.squeeze                       = squeeze;
     this.onSelectedItemChanged         = onSelectedItemChanged;
     this.clipToSize                    = clipToSize;
     this.renderChildrenOutsideViewport = renderChildrenOutsideViewport;
     this.childDelegate                 = childDelegate;
 }
Example #5
0
 public ListWheelViewport(
     Key key                              = null,
     float diameterRatio                  = RenderListWheelViewport.defaultDiameterRatio,
     float perspective                    = RenderListWheelViewport.defaultPerspective,
     float offAxisFraction                = 0.0f,
     bool useMagnifier                    = false,
     float magnification                  = 1.0f,
     float overAndUnderCenterOpacity      = 1.0f,
     float?itemExtent                     = null,
     float squeeze                        = 1.0f,
     bool clipToSize                      = true,
     bool renderChildrenOutsideViewport   = false,
     ViewportOffset offset                = null,
     ListWheelChildDelegate childDelegate = null
     ) : base(key: key)
 {
     D.assert(childDelegate != null);
     D.assert(offset != null);
     D.assert(diameterRatio > 0, () => RenderListWheelViewport.diameterRatioZeroMessage);
     D.assert(perspective > 0);
     D.assert(perspective <= 0.01, () => RenderListWheelViewport.perspectiveTooHighMessage);
     D.assert(overAndUnderCenterOpacity >= 0 && overAndUnderCenterOpacity <= 1);
     D.assert(itemExtent != null);
     D.assert(itemExtent > 0);
     D.assert(
         !renderChildrenOutsideViewport || !clipToSize,
         () => RenderListWheelViewport.clipToSizeAndRenderChildrenOutsideViewportConflict
         );
     this.diameterRatio             = diameterRatio;
     this.perspective               = perspective;
     this.offAxisFraction           = offAxisFraction;
     this.useMagnifier              = useMagnifier;
     this.magnification             = magnification;
     this.overAndUnderCenterOpacity = overAndUnderCenterOpacity;
     this.itemExtent = itemExtent;
     this.squeeze    = squeeze;
     this.clipToSize = clipToSize;
     this.renderChildrenOutsideViewport = renderChildrenOutsideViewport;
     this.offset        = offset;
     this.childDelegate = childDelegate;
 }
Example #6
0
 public bool shouldRebuild(ListWheelChildDelegate oldDelegate)
 {
     return(this.children != ((ListWheelChildListDelegate)oldDelegate).children);
 }
Example #7
0
 public bool shouldRebuild(ListWheelChildDelegate oldDelegate)
 {
     return(this.builder != ((ListWheelChildBuilderDelegate)oldDelegate).builder ||
            this.childCount != ((ListWheelChildBuilderDelegate)oldDelegate).childCount);
 }