Example #1
0
 public _StackSwiper(
     Key key      = null,
     Curve curve  = null,
     int?duration = null,
     SwiperController controller       = null,
     ValueChanged <int> onIndexChanged = null,
     float?itemHeight = null,
     float?itemWidth  = null,
     IndexedWidgetBuilder itemBuilder = null,
     int?index            = null,
     bool?loop            = null,
     int?itemCount        = null,
     Axis scrollDirection = Axis.horizontal
     ) : base(
         loop: loop,
         key: key,
         itemWidth: itemWidth,
         itemHeight: itemHeight,
         itemBuilder: itemBuilder,
         curve: curve,
         duration: duration,
         controller: controller,
         index: index,
         onIndexChanged: onIndexChanged,
         itemCount: itemCount,
         scrollDirection: scrollDirection)
 {
 }
Example #2
0
        public static CupertinoPicker builder(
            float itemExtent,
            ValueChanged <int> onSelectedItemChanged,
            IndexedWidgetBuilder itemBuilder,
            Key key               = null,
            float diameterRatio   = CupertinoPickerUtils._kDefaultDiameterRatio,
            Color backgroundColor = null,
            float offAxisFraction = 0.0f,
            bool useMagnifier     = false,
            float magnification   = 1.0f,
            FixedExtentScrollController scrollController = null,
            int?childCount = null
            )
        {
            D.assert(itemBuilder != null);
            D.assert(diameterRatio > 0.0f, () => RenderListWheelViewport.diameterRatioZeroMessage);
            D.assert(magnification > 0);
            D.assert(itemExtent > 0);

            return(new CupertinoPicker(
                       itemExtent: itemExtent,
                       onSelectedItemChanged: onSelectedItemChanged,
                       key: key,
                       diameterRatio: diameterRatio,
                       backgroundColor: backgroundColor,
                       offAxisFraction: offAxisFraction,
                       useMagnifier: useMagnifier,
                       magnification: magnification,
                       scrollController: scrollController,
                       childDelegate: new ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount)
                       ));
        }
Example #3
0
 public _SubSwiper(
     Key key          = null,
     bool?loop        = null,
     float?itemHeight = null,
     float?itemWidth  = null,
     int?duration     = null,
     Curve curve      = null,
     IndexedWidgetBuilder itemBuilder = null,
     SwiperController controller      = null,
     int?index            = null,
     int?itemCount        = null,
     Axis scrollDirection = Axis.horizontal,
     ValueChanged <int> onIndexChanged = null
     ) : base(key: key)
 {
     this.loop            = loop;
     this.itemHeight      = itemHeight;
     this.itemWidth       = itemWidth;
     this.duration        = duration;
     this.curve           = curve;
     this.itemBuilder     = itemBuilder;
     this.controller      = controller;
     this.index           = index;
     this.itemCount       = itemCount;
     this.scrollDirection = scrollDirection;
     this.onIndexChanged  = onIndexChanged;
 }
 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
         );
 }
Example #5
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);
        }
Example #6
0
        public CupertinoPicker(
            float itemExtent,
            Key key               = null,
            float?diameterRatio   = null,
            Color backgroundColor = null,
            float offAxisFraction = 0.0f,
            bool useMagnifier     = false,
            float magnification   = 1.0f,
            FixedExtentScrollController scrollController = null,
            float?squeeze = null,

            ValueChanged <int> onSelectedItemChanged = null,
            IndexedWidgetBuilder itemBuilder         = null,
            int?childCount = null
            )
        {
            diameterRatio = diameterRatio == null ? CupertinoPickerUtils._kDefaultDiameterRatio : diameterRatio;
            squeeze       = squeeze == null ?  CupertinoPickerUtils._kSqueeze : squeeze;
            D.assert(itemBuilder != null);
            D.assert(diameterRatio > 0.0f, () => RenderListWheelViewport.diameterRatioZeroMessage);
            D.assert(magnification > 0);
            D.assert(itemExtent > 0);
            D.assert(squeeze > 0);
            this.diameterRatio         = diameterRatio;
            this.backgroundColor       = backgroundColor;
            this.offAxisFraction       = offAxisFraction;
            this.useMagnifier          = useMagnifier;
            this.magnification         = magnification;
            this.scrollController      = scrollController;
            this.squeeze               = squeeze;
            this.itemExtent            = itemExtent;
            this.onSelectedItemChanged = onSelectedItemChanged;
            childDelegate              = new ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount);
        }
Example #7
0
    public _CustomLayoutSwiper(

        CustomLayoutOption option,
        float itemWidth,
        bool loop,
        float itemHeight,
        ValueChanged <int> onIndexChanged,

        IndexedWidgetBuilder itemBuilder,
        Curve curve,
        int duration,
        int index,
        int itemCount,
        Axis scrollDirection,

        SwiperController controller,
        Key key = null)
        : base(
            loop: loop,
            onIndexChanged: onIndexChanged,
            itemWidth: itemWidth,
            itemHeight: itemHeight,
            key: key,
            itemBuilder: itemBuilder,
            curve: curve,
            duration: duration,
            index: index,
            itemCount: itemCount,
            controller: controller,
            scrollDirection: scrollDirection)
    {
        D.assert(option != null);
        this.option = option;
    }
Example #8
0
 public _SubSwiper(
     Key key,
     bool loop,
     float itemHeight,
     float itemWidth,
     int duration,
     Curve curve,
     IndexedWidgetBuilder itemBuilder,
     SwiperController controller,
     int index,
     int itemCount,
     ValueChanged <int> onIndexChanged,
     Axis scrollDirection = Axis.horizontal)
     : base(key: key)
 {
     this.loop            = loop;
     this.itemHeight      = itemHeight;
     this.itemWidth       = itemWidth;
     this.duration        = duration;
     this.curve           = curve ?? Curves.ease;
     this.itemBuilder     = itemBuilder;
     this.controller      = controller;
     this.index           = index;
     this.itemCount       = itemCount;
     this.onIndexChanged  = onIndexChanged;
     this.scrollDirection = scrollDirection;
 }
Example #9
0
 public _StackSwiper(
     Curve curve,
     int duration,
     SwiperController controller,
     ValueChanged <int> onIndexChanged,
     float itemHeight,
     float itemWidth,
     IndexedWidgetBuilder itemBuilder,
     int index,
     bool loop,
     int itemCount,
     Axis scrollDirection,
     Key key = null
     ) : base(
         loop: loop,
         key: key,
         itemWidth: itemWidth,
         itemHeight: itemHeight,
         itemBuilder: itemBuilder,
         curve: curve,
         duration: duration,
         controller: controller,
         index: index,
         onIndexChanged: onIndexChanged,
         itemCount: itemCount,
         scrollDirection: scrollDirection)
 {
 }
Example #10
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>());
     }
 }
 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
                ));
 }
 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
                ));
 }
Example #13
0
 public CustomListView(
     RefreshController controller = null,
     bool enablePullUp            = DefaultConstants.default_enablePullUp,
     bool enablePullDown          = DefaultConstants.default_enablePullDown,
     OnRefresh onRefresh          = null,
     bool hasBottomMargin         = false,
     int?itemCount = null,
     IndexedWidgetBuilder itemBuilder = null,
     Widget headerWidget = null,
     Widget footerWidget = null,
     bool hasScrollBar   = true,
     bool hasRefresh     = true,
     Key key             = null
     ) : base(key: key)
 {
     D.assert(() => {
         if (this.hasRefresh)
         {
             return(this.onRefresh != null);
         }
         return(true);
     });
     this.controller      = controller;
     this.enablePullUp    = enablePullUp;
     this.enablePullDown  = enablePullDown;
     this.onRefresh       = onRefresh;
     this.hasBottomMargin = hasBottomMargin;
     this.itemCount       = itemCount;
     this.itemBuilder     = itemBuilder;
     this.headerWidget    = headerWidget;
     this.footerWidget    = footerWidget;
     this.hasScrollBar    = hasScrollBar;
     this.hasRefresh      = hasRefresh;
 }
 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
                ));
 }
Example #15
0
 public ListWheelChildBuilderDelegate(
     IndexedWidgetBuilder builder,
     int?childCount = null
     )
 {
     D.assert(builder != null);
     this.builder    = builder;
     this.childCount = childCount;
 }
Example #16
0
 public _TabSwitchingView(
     int currentTabIndex,
     int tabNumber,
     IndexedWidgetBuilder tabBuilder
     )
 {
     D.assert(tabNumber > 0);
     D.assert(tabBuilder != null);
     this.currentTabIndex = currentTabIndex;
     this.tabNumber       = tabNumber;
     this.tabBuilder      = tabBuilder;
 }
Example #17
0
 public SliverChildBuilderDelegate(
     IndexedWidgetBuilder builder,
     int?childCount = null,
     bool addAutomaticKeepAlives = true,
     bool addRepaintBoundaries   = true
     )
 {
     D.assert(builder != null);
     this.builder                = builder;
     this.childCount             = childCount;
     this.addAutomaticKeepAlives = addAutomaticKeepAlives;
     this.addRepaintBoundaries   = addRepaintBoundaries;
 }
Example #18
0
 public CupertinoTabScaffold(
     Key key = null,
     CupertinoTabBar tabBar          = null,
     IndexedWidgetBuilder tabBuilder = null,
     Color backgroundColor           = null,
     bool resizeToAvoidBottomInset   = true
     ) : base(key: key)
 {
     D.assert(tabBar != null);
     D.assert(tabBuilder != null);
     this.tabBar                   = tabBar;
     this.tabBuilder               = tabBuilder;
     this.backgroundColor          = backgroundColor;
     this.resizeToAvoidBottomInset = resizeToAvoidBottomInset;
 }
 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,
     IndexedWidgetBuilder itemBuilder      = null,
     IndexedWidgetBuilder separatorBuilder = null,
     int itemCount                         = 0,
     bool addAutomaticKeepAlives           = true,
     bool addRepaintBoundaries             = true,
     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(itemBuilder != null);
     D.assert(separatorBuilder != null);
     D.assert(itemCount >= 0);
     this.itemExtent       = null;
     this.childrenDelegate = new SliverChildBuilderDelegate(
         (context, index) => {
         int itemIndex = index / 2;
         return(index % 2 == 0
                 ? itemBuilder(context, itemIndex)
                 : separatorBuilder(context, itemIndex));
     },
         childCount: Mathf.Max(0, itemCount * 2 - 1),
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
        public override Widget build(BuildContext context)
        {
            IndexedWidgetBuilder builder = this._transformer == null
                ? (IndexedWidgetBuilder)this._buildItemNormal
                : this._buildItem;
            Widget child = new PageView(
                itemBuilder: builder,
                itemCount: this._pageController.getRealItemCount(),
                onPageChanged: this._onIndexChanged,
                controller: this._pageController,
                scrollDirection: this.widget.scrollDirection,
                physics: this.widget.physics,
                pageSnapping: this.widget.pageSnapping,
                reverse: this._pageController.reverse
                );

            if (this._transformer == null)
            {
                return(child);
            }

            return(new NotificationListener <ScrollNotification>(
                       onNotification: notification => {
                if (notification is ScrollStartNotification)
                {
                    this._calcCurrentPixels();
                    this._done = false;
                    this._fromIndex = this._activeIndex;
                }
                else if (notification is ScrollEndNotification)
                {
                    this._calcCurrentPixels();
                    this._fromIndex = this._activeIndex;
                    this._done = true;
                }

                return false;
            },
                       child: child
                       ));
        }
 ListView(
     Key key = null,
     Axis scrollDirection                = Axis.vertical,
     bool reverse                        = false,
     ScrollController controller         = null,
     bool?primary                        = null,
     ScrollPhysics physics               = null,
     bool shrinkWrap                     = false,
     EdgeInsetsGeometry padding          = null,
     float?itemExtent                    = null,
     IndexedWidgetBuilder itemBuilder    = null,
     int?itemCount                       = null,
     bool addAutomaticKeepAlives         = true,
     bool addRepaintBoundaries           = true,
     float?cacheExtent                   = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start,
     ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
     ) : base(key: key,
              scrollDirection: scrollDirection,
              reverse: reverse,
              controller: controller,
              primary: primary,
              physics: physics,
              shrinkWrap: shrinkWrap,
              padding: padding,
              cacheExtent: cacheExtent,
              dragStartBehavior: dragStartBehavior,
              keyboardDismissBehavior: keyboardDismissBehavior
              )
 {
     D.assert(itemCount == null || itemCount >= 0);
     this.itemExtent  = itemExtent;
     childrenDelegate = new SliverChildBuilderDelegate(
         itemBuilder,
         childCount: itemCount,
         addAutomaticKeepAlives: addAutomaticKeepAlives,
         addRepaintBoundaries: addRepaintBoundaries
         );
 }
Example #22
0
 public CupertinoTabScaffold(
     Key key = null,
     CupertinoTabBar tabBar            = null,
     IndexedWidgetBuilder tabBuilder   = null,
     CupertinoTabController controller = null,
     Color backgroundColor             = null,
     bool resizeToAvoidBottomInset     = true
     ) : base(key: key)
 {
     D.assert(tabBar != null);
     D.assert(tabBuilder != null);
     D.assert(
         controller == null || controller.index < tabBar.items.Count, () =>
         $"The CupertinoTabController's current index {controller.index} is " +
         $"out of bounds for the tab bar with {tabBar.items.Count} tabs"
         );
     this.tabBar                   = tabBar;
     this.controller               = controller;
     this.tabBuilder               = tabBuilder;
     this.backgroundColor          = backgroundColor;
     this.resizeToAvoidBottomInset = resizeToAvoidBottomInset;
 }
 public static ListView builder(
     Key key = null,
     Axis scrollDirection                = Axis.vertical,
     bool reverse                        = false,
     ScrollController controller         = null,
     bool?primary                        = null,
     ScrollPhysics physics               = null,
     bool shrinkWrap                     = false,
     EdgeInsetsGeometry padding          = null,
     float?itemExtent                    = null,
     IndexedWidgetBuilder itemBuilder    = null,
     int?itemCount                       = null,
     bool addAutomaticKeepAlives         = true,
     bool addRepaintBoundaries           = true,
     float?cacheExtent                   = null,
     DragStartBehavior dragStartBehavior = DragStartBehavior.start,
     ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
     )
 {
     return(new ListView(
                key: key,
                scrollDirection: scrollDirection,
                reverse: reverse,
                controller: controller,
                primary: primary,
                physics: physics,
                shrinkWrap: shrinkWrap,
                padding: padding,
                cacheExtent: cacheExtent,
                itemExtent: itemExtent,
                itemBuilder: itemBuilder,
                itemCount: itemCount,
                addAutomaticKeepAlives: addAutomaticKeepAlives,
                addRepaintBoundaries: addRepaintBoundaries,
                dragStartBehavior: dragStartBehavior,
                keyboardDismissBehavior: keyboardDismissBehavior
                ));
 }
 public TransformerPageView(
     Key key                                  = null,
     int?index                                = null,
     TimeSpan?duration                        = null,
     Curve curve                              = null,
     float viewportFraction                   = 1.0f,
     bool loop                                = false,
     Axis scrollDirection                     = Axis.horizontal,
     ScrollPhysics physics                    = null,
     bool pageSnapping                        = true,
     ValueChanged <int> onPageChanged         = null,
     IndexController controller               = null,
     PageTransformer transformer              = null,
     IndexedWidgetBuilder itemBuilder         = null,
     TransformerPageController pageController = null,
     int?itemCount                            = null
     ) : base(key: key)
 {
     D.assert(itemCount != null);
     D.assert(itemCount == 0 || itemBuilder != null || transformer != null);
     this.duration =
         duration ?? TimeSpan.FromMilliseconds(TransformerPageViewUtils.kDefaultTransactionDuration);
     this.index            = index;
     this.duration         = duration;
     this.curve            = curve ?? Curves.ease;
     this.viewportFraction = viewportFraction;
     this.loop             = loop;
     this.scrollDirection  = scrollDirection;
     this.physics          = physics;
     this.pageSnapping     = pageSnapping;
     this.onPageChanged    = onPageChanged;
     this.controller       = controller;
     this.transformer      = transformer;
     this.itemBuilder      = itemBuilder;
     this.pageController   = pageController;
     this.itemCount        = itemCount.Value;
 }
Example #25
0
    /// Creates a scrollable list that works page by page using widgets that are
    /// created on demand.
    ///
    /// This constructor is appropriate for page views with a large (or infinite)
    /// number of children because the builder is called only for those children
    /// that are actually visible.
    ///
    /// Providing a non-null [itemCount] lets the [PageView] compute the maximum
    /// scroll extent.
    ///
    /// [itemBuilder] will be called only with indices greater than or equal to
    /// zero and less than [itemCount].
    public TransformerPageView(

        int index,
        Curve curve,
        ScrollPhysics physics,
        ValueChanged <int> onPageChanged,
        IndexController controller,
        PageTransformer transformer,
        IndexedWidgetBuilder itemBuilder,
        TransformerPageController pageController,
        int itemCount,
        TimeSpan?duration      = null,
        Key key                = null,
        float viewportFraction = 1,
        Axis scrollDirection   = Axis.horizontal,
        bool loop              = false,
        bool pageSnapping      = true
        ) : base(key: key)
    {
        this.index            = index;
        this.curve            = curve == null ? Curves.ease : curve;
        this.loop             = loop;
        this.scrollDirection  = scrollDirection;
        this.physics          = physics;
        this.onPageChanged    = onPageChanged;
        this.controller       = controller;
        this.transformer      = transformer;
        this.itemBuilder      = itemBuilder;
        this.pageController   = pageController;
        this.itemCount        = itemCount;
        this.viewportFraction = viewportFraction;
        this.scrollDirection  = scrollDirection;
        this.loop             = loop;
        this.pageSnapping     = pageSnapping;
        this.duration         = duration ?? TimeSpan.FromMilliseconds(kDefaultTransactionDuration);
    }
Example #26
0
    public Swiper(

        IndexedWidgetBuilder itemBuilder,
        int itemCount,
        SwiperPlugin pagination,
        SwiperPlugin control,
        /// since v1.0.0
        float containerHeight,
        float containerWidth,
        float itemHeight,
        float itemWidth,
        float scale = 1,
        float fade  = 1,
        CustomLayoutOption customLayoutOption = null,

        SwiperController controller = null,
        PageTransformer transformer = null,
        int index = 0,
        List <SwiperPlugin> plugins       = null,
        ValueChanged <int> onIndexChanged = null,
        ScrollPhysics physics             = null,
        ///
        SwiperOnTap onTap = null,

        Curve curve                       = null,
        Key key                           = null,
        float viewportFraction            = 1.0f,
        bool autoplay                     = false,
        bool loop                         = true,
        Axis scrollDirection              = Axis.horizontal,
        SwiperLayout layout               = SwiperLayout.DEFAULT,
        int autoplayDelay                 = kDefaultAutoplayDelayMs,
        bool autoplayDisableOnInteraction = true,
        int duration                      = kDefaultAutoplayTransactionDuration,
        bool outer                        = false,

        PageIndicatorLayout indicatorLayout = PageIndicatorLayout.NONE
        ) :
        base(key: key)
    {
        D.assert(itemBuilder != null || transformer != null, () => { return("itemBuilder and transformItemBuilder must not be both null"); });
        D.assert(
            !loop ||
            ((loop &&
              layout == SwiperLayout.DEFAULT &&
              (indicatorLayout == PageIndicatorLayout.SCALE ||
               indicatorLayout == PageIndicatorLayout.COLOR ||
               indicatorLayout == PageIndicatorLayout.NONE)) ||
             (loop && layout != SwiperLayout.DEFAULT)),
            () => "Only support `PageIndicatorLayout.SCALE` and `PageIndicatorLayout.COLOR`when layout==SwiperLayout.DEFAULT in loop mode");

        this.itemBuilder        = itemBuilder;
        this.indicatorLayout    = indicatorLayout;
        this.transformer        = transformer;
        this.onIndexChanged     = onIndexChanged;
        this.itemCount          = itemCount;
        this.index              = index;
        this.onTap              = onTap;
        this.plugins            = plugins;
        this.control            = control;
        this.physics            = physics;
        this.controller         = controller;
        this.pagination         = pagination;
        this.customLayoutOption = customLayoutOption;
        this.containerHeight    = containerHeight;
        this.containerWidth     = containerWidth;
        this.viewportFraction   = viewportFraction;
        this.itemHeight         = itemHeight;
        this.itemWidth          = itemWidth;
        this.scale              = scale;
        this.fade            = fade;
        this.curve           = curve ?? Curves.ease;
        this.autoplay        = autoplay;
        this.loop            = loop;
        this.scrollDirection = scrollDirection;
        this.layout          = layout;
        this.autoplayDelay   = autoplayDelay;
        this.autoplayDisableOnInteraction = autoplayDisableOnInteraction;
        this.duration = duration;
        this.outer    = outer;
    }
Example #27
0
    public static Swiper Children(
        Key key,
        IndexedWidgetBuilder itemBuilder,
        PageTransformer transformer,
        int itemCount,
        ValueChanged <int> onIndexChanged,
        int index,
        SwiperOnTap onTap,
        List <SwiperPlugin> plugins,
        SwiperPlugin control,
        ScrollPhysics physics,
        SwiperController controller,
        SwiperPlugin pagination,
        CustomLayoutOption customLayoutOption,
        List <Widget> children,
        /// since v1.0.0
        float containerHeight,
        float containerWidth,
        float itemHeight,
        float itemWidth,
        float scale,
        float fade,

        ///

        Curve curve,
        float viewportFraction = 1.0f,
        bool autoplay          = false,
        bool loop            = true,
        Axis scrollDirection = Axis.horizontal,
        SwiperLayout layout  = SwiperLayout.DEFAULT,
        int autoplayDelay    = kDefaultAutoplayDelayMs,
        bool autoplayDisableOnInteraction = true,
        int duration = kDefaultAutoplayTransactionDuration,
        bool outer   = false,
        PageIndicatorLayout indicatorLayout = PageIndicatorLayout.NONE,
        bool reverse = false

        )
    {
        D.assert(children != null, () => "children must not be null");

        return(new Swiper(
                   transformer: transformer,
                   customLayoutOption: customLayoutOption,
                   containerHeight: containerHeight,
                   containerWidth: containerWidth,
                   viewportFraction: viewportFraction,
                   itemHeight: itemHeight,
                   itemWidth: itemWidth,
                   outer: outer,
                   scale: scale,
                   fade: fade,
                   autoplay: autoplay,
                   autoplayDelay: autoplayDelay,
                   autoplayDisableOnInteraction: autoplayDisableOnInteraction,
                   duration: duration,
                   onIndexChanged: onIndexChanged,
                   index: index,
                   onTap: onTap,
                   curve: curve ?? Curves.ease,
                   scrollDirection: scrollDirection,
                   pagination: pagination,
                   control: control,
                   controller: controller,
                   loop: loop,
                   plugins: plugins,
                   physics: physics,
                   key: key,
                   itemBuilder: (BuildContext context, int ind) =>
        {
            return children[ind];
        },
                   itemCount: children.Count));
    }
Example #28
0
        Widget _buildSwiper()
        {
            IndexedWidgetBuilder itemBuilder = this.widget.onTap != null ? this._wrapTap : this.widget.itemBuilder;

            if (this.widget.layout == SwiperLayout.stack)
            {
                return(new _StackSwiper(
                           loop: this.widget.loop,
                           itemWidth: this.widget.itemWidth,
                           itemHeight: this.widget.itemHeight,
                           itemCount: this.widget.itemCount,
                           itemBuilder: itemBuilder,
                           index: this._activeIndex,
                           curve: this.widget.curve,
                           duration: this.widget.duration,
                           onIndexChanged: this._onIndexChanged,
                           controller: this._controller,
                           scrollDirection: this.widget.scrollDirection
                           ));
            }
            else if (this._isPageViewLayout())
            {
                PageTransformer transformer = this.widget.transformer;
                if (this.widget.scale != null || this.widget.fade != null)
                {
                    transformer = new ScaleAndFadeTransformer(scale: this.widget.scale, fade: this.widget.fade);
                }

                Widget child = new TransformerPageView(
                    pageController: this._pageController,
                    loop: this.widget.loop,
                    itemCount: this.widget.itemCount,
                    itemBuilder: itemBuilder,
                    transformer: transformer,
                    viewportFraction: this.widget.viewportFraction,
                    index: this._activeIndex,
                    duration: TimeSpan.FromMilliseconds(this.widget.duration),
                    scrollDirection: this.widget.scrollDirection,
                    onPageChanged: this._onIndexChanged,
                    curve: this.widget.curve,
                    physics: this.widget.physics,
                    controller: this._controller
                    );
                if (this.widget.autoplayDisableOnInteraction && this.widget.autoplay)
                {
                    return(new NotificationListener <ScrollNotification>(
                               child: child,
                               onNotification: notification => {
                        if (notification is ScrollStartNotification scrollStartNotification)
                        {
                            if (scrollStartNotification.dragDetails != null)
                            {
                                if (this._timer != null)
                                {
                                    this._stopAutoplay();
                                }
                            }
                        }
                        else if (notification is ScrollEndNotification)
                        {
                            if (this._timer == null)
                            {
                                this._startAutoplay();
                            }
                        }

                        return false;
                    }
                               ));
                }

                return(child);
            }
            else if (this.widget.layout == SwiperLayout.tinder)
            {
                return(new _TinderSwiper(
                           loop: this.widget.loop,
                           itemWidth: this.widget.itemWidth,
                           itemHeight: this.widget.itemHeight,
                           itemCount: this.widget.itemCount,
                           itemBuilder: itemBuilder,
                           index: this._activeIndex,
                           curve: this.widget.curve,
                           duration: this.widget.duration,
                           onIndexChanged: this._onIndexChanged,
                           controller: this._controller,
                           scrollDirection: this.widget.scrollDirection
                           ));
            }
            else if (this.widget.layout == SwiperLayout.custom)
            {
                return(new _CustomLayoutSwiper(
                           loop: this.widget.loop,
                           option: this.widget.customLayoutOption,
                           itemWidth: this.widget.itemWidth,
                           itemHeight: this.widget.itemHeight,
                           itemCount: this.widget.itemCount,
                           itemBuilder: itemBuilder,
                           index: this._activeIndex,
                           curve: this.widget.curve,
                           duration: this.widget.duration,
                           onIndexChanged: this._onIndexChanged,
                           controller: this._controller,
                           scrollDirection: this.widget.scrollDirection
                           ));
            }
            else
            {
                return(new Container());
            }
        }
        ListView(
            Key key = null,
            Axis scrollDirection                  = Axis.vertical,
            bool reverse                          = false,
            ScrollController controller           = null,
            bool?primary                          = null,
            ScrollPhysics physics                 = null,
            bool shrinkWrap                       = false,
            EdgeInsetsGeometry padding            = null,
            IndexedWidgetBuilder itemBuilder      = null,
            IndexedWidgetBuilder separatorBuilder = null,
            int itemCount                         = 0,
            bool addAutomaticKeepAlives           = true,
            bool addRepaintBoundaries             = true,
            float?cacheExtent                     = null,
            DragStartBehavior dragStartBehavior   = DragStartBehavior.start,
            ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual
            ) : base(
                key: key,
                scrollDirection: scrollDirection,
                reverse: reverse,
                controller: controller,
                primary: primary,
                physics: physics,
                shrinkWrap: shrinkWrap,
                padding: padding,
                cacheExtent: cacheExtent,
                dragStartBehavior: dragStartBehavior,
                keyboardDismissBehavior: keyboardDismissBehavior
                )
        {
            D.assert(itemBuilder != null);
            D.assert(separatorBuilder != null);
            D.assert(itemCount >= 0);
            itemExtent       = null;
            childrenDelegate = new SliverChildBuilderDelegate(
                (context, index) => {
                int itemIndex = index / 2;
                Widget widget = null;
                if (index % 2 == 0)
                {
                    widget = itemBuilder(context, itemIndex);
                }
                else
                {
                    widget = separatorBuilder(context, itemIndex);
                    D.assert(() => {
                        if (widget == null)
                        {
                            throw new UIWidgetsError("separatorBuilder cannot return null.");
                        }

                        return(true);
                    });
                }
                return(widget);
            },
                childCount: _computeActualChildCount(itemCount),
                addAutomaticKeepAlives: addAutomaticKeepAlives,
                addRepaintBoundaries: addRepaintBoundaries
                );
        }