Пример #1
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)
 {
 }
Пример #2
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;
    }
Пример #3
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;
 }
Пример #4
0
 public override void initState()
 {
     _controller = widget.controller;
     if (_controller == null)
     {
         _controller = new SwiperController();
     }
     _controller.addListener(_onController);
     _handleAutoplay();
     base.initState();
 }
Пример #5
0
    public override void didUpdateWidget(StatefulWidget oldWidget)
    {
        Swiper sp = oldWidget as Swiper;

        if (sp != null && _controller != sp.controller)
        {
            if (sp.controller != null)
            {
                sp.controller.removeListener(_onController);
                _controller = sp.controller;
                _controller.addListener(_onController);
            }
        }
        _handleAutoplay();
        base.didUpdateWidget(oldWidget);
    }
Пример #6
0
 public SwiperPluginConfig(
     int activeIndex,
     int itemCount,
     PageIndicatorLayout indicatorLayout,
     bool outer,
     Axis scrollDirection,
     SwiperController controller,
     PageController pageController,
     SwiperLayout layout,
     bool loop)
 {
     D.assert(scrollDirection != null);
     D.assert(controller != null);
     this.activeIndex     = activeIndex;
     this.itemCount       = itemCount;
     this.indicatorLayout = indicatorLayout;
     this.outer           = outer;
     this.scrollDirection = scrollDirection;
     this.controller      = controller;
     this.pageController  = pageController;
     this.layout          = layout;
     this.loop            = loop;
 }
Пример #7
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));
    }
Пример #8
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));
    }
Пример #9
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;
    }