Exemplo n.º 1
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));
    }
Exemplo n.º 2
0
    public static Swiper List(

        PageTransformer transformer,
        IList list,
        float containerHeight,
        float containerWidth,
        float itemHeight,
        float itemWidth,
        CustomLayoutOption customLayoutOption,
        SwiperDataBuilder builder,
        ValueChanged <int> onIndexChanged,
        Key key,
        int index,
        SwiperOnTap onTap,
        ScrollPhysics physics,
        Curve curve,
        float fade,
        SwiperPlugin pagination,
        SwiperPlugin control,
        List <SwiperPlugin> plugins,
        SwiperController controller,
        float viewportFraction = 1.0f,
        bool loop            = true,
        int duration         = kDefaultAutoplayTransactionDuration,
        Axis scrollDirection = Axis.horizontal,
        bool autoplay        = false,
        int autoplayDelay    = kDefaultAutoplayDelayMs,
        bool reverse         = false,
        bool autoplayDisableOnInteraction = true,
        bool outer  = false,
        float scale = 1.0f
        )
    {
        return(new Swiper(
                   transformer: transformer,
                   customLayoutOption: customLayoutOption,
                   containerHeight: containerHeight,
                   containerWidth: containerWidth,
                   viewportFraction: viewportFraction,
                   itemHeight: itemHeight,
                   itemWidth: itemWidth,
                   outer: outer,
                   scale: scale,
                   autoplay: autoplay,
                   autoplayDelay: autoplayDelay,
                   autoplayDisableOnInteraction: autoplayDisableOnInteraction,
                   duration: duration,
                   onIndexChanged: onIndexChanged,
                   index: index,
                   onTap: onTap,
                   curve: curve ?? Curves.ease,
                   key: key,
                   scrollDirection: scrollDirection,
                   pagination: pagination,
                   control: control,
                   controller: controller,
                   loop: loop,
                   plugins: plugins,
                   physics: physics,
                   fade: fade,
                   itemBuilder: (BuildContext context, int ind) =>
        {
            return builder(context, list[ind], ind);
        },
                   itemCount: list.Count));
    }
Exemplo n.º 3
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;
    }