Widget _buildOuterPagination( SwiperPlugin pagination, Widget swiper, SwiperPluginConfig config) { List <Widget> list = new List <Widget>(); //Only support bottom yet! if (widget.containerHeight != 0 || widget.containerWidth != 0) { list.Add(swiper); } else { list.Add(new Expanded(child: swiper)); } list.Add(new Align( alignment: Alignment.center, child: pagination.build(context, config) )); return(new Column( children: list, crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min )); }
Widget buildButton(SwiperPluginConfig config, Color color, IconData iconDaga, int quarterTurns, bool previous) { return(new GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => { if (previous) { config.controller.previous(animation: true); } else { config.controller.next(animation: true); } }, child: new Padding( padding: padding, child: new RotatedBox( quarterTurns: quarterTurns, child: new Icon( iconDaga, //semanticLabel: previous? "Previous" : "Next", size: size, color: color ))) )); }
public override Widget build(BuildContext context, SwiperPluginConfig config) { ThemeData themeData = Theme.of(context); Color activeColor = this.activeColor ?? themeData.primaryColor; Color color = this.color ?? themeData.scaffoldBackgroundColor; if (Axis.vertical == config.scrollDirection) { return(new Column( key: key, mainAxisSize: MainAxisSize.min, children: new List <Widget> { new Text( data: (config.activeIndex + 1).ToString(), style: new TextStyle(color: activeColor, fontSize: activeFontSize) ), new Text( "/", style: new TextStyle(color: color, fontSize: fontSize) ), new Text( data: config.itemCount.ToString(), style: new TextStyle(color: color, fontSize: fontSize) ) } )); } else { return(new Row( key: key, mainAxisSize: MainAxisSize.min, children: new List <Widget> { new Text( data: (config.activeIndex + 1).ToString(), style: new TextStyle(color: activeColor, fontSize: activeFontSize) ), new Text( " /" + config.itemCount.ToString(), style: new TextStyle(color: color, fontSize: fontSize) ) } )); } }
public override Widget build(BuildContext context, SwiperPluginConfig config) { ThemeData themeData = Theme.of(context); Color activeColor = this.activeColor ?? themeData.primaryColor; Color color = this.color ?? themeData.scaffoldBackgroundColor; List <Widget> list = new List <Widget>(); if (config.itemCount > 20) { UnityEngine.Debug.LogWarning( "The itemCount is too big, we suggest use FractionPaginationBuilder instead of DotSwiperPaginationBuilder in this sitituation"); } int itemCount = config.itemCount; int activeIndex = config.activeIndex; for (int i = 0; i < itemCount; ++i) { bool active = i == activeIndex; Size size = active ? this.activeSize : this.size; list.Add(new SizedBox( width: size.width, height: size.height, child: new Container( color: active ? activeColor : color, key: Key.key("pagination_$i"), margin: EdgeInsets.all(space) ) )); } if (config.scrollDirection == Axis.vertical) { return(new Column( key: key, mainAxisSize: MainAxisSize.min, children: list )); } else { return(new Row( key: key, mainAxisSize: MainAxisSize.min, children: list )); } }
//@override public override Widget build(BuildContext context, SwiperPluginConfig config) { ThemeData themeData = Theme.of(context); Color color = this.color ?? themeData.primaryColor; Color disableColor = this.disableColor ?? themeData.disabledColor; Color prevColor; Color nextColor; if (config.loop) { prevColor = nextColor = color; } else { bool next = config.activeIndex < config.itemCount - 1; bool prev = config.activeIndex > 0; prevColor = prev ? color : disableColor; nextColor = next ? color : disableColor; } Widget child; if (config.scrollDirection == Axis.horizontal) { child = new Row( key: key, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { buildButton(config, prevColor, iconPrevious, 0, true), buildButton(config, nextColor, iconNext, 0, false) } ); } else { child = new Column( key: key, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: new List <Widget> { buildButton(config, prevColor, iconPrevious, -3, true), buildButton(config, nextColor, iconNext, -3, false) } ); } return(new Container( height: float.PositiveInfinity, child: child, width: float.PositiveInfinity )); }
public override Widget build(BuildContext context) { Widget swiper = _buildSwiper(); List <Widget> listForStack = null; SwiperPluginConfig config = null; if (widget.control != null) { //Stack config = _ensureConfig(config); listForStack = _ensureListForStack( swiper, listForStack, widget.control.build(context, config)); } if (widget.plugins != null) { config = _ensureConfig(config); foreach (SwiperPlugin plugin in widget.plugins) { listForStack = _ensureListForStack( swiper, listForStack, plugin.build(context, config)); } } if (widget.pagination != null) { config = _ensureConfig(config); if (widget.outer) { return(_buildOuterPagination( widget.pagination,//TODO:Check 修改了 _buildOuterPagination的第一个参数 listForStack == null ? swiper : new Stack(children: listForStack), config)); } else { listForStack = _ensureListForStack( swiper, listForStack, widget.pagination.build(context, config)); } } if (listForStack != null) { return(new Stack( children: listForStack )); } return(swiper); }
SwiperPluginConfig _ensureConfig(SwiperPluginConfig config) { if (config == null) { config = new SwiperPluginConfig( outer: widget.outer, itemCount: widget.itemCount, layout: widget.layout, indicatorLayout: widget.indicatorLayout, pageController: _pageController, activeIndex: _activeIndex, scrollDirection: widget.scrollDirection, controller: _controller, loop: widget.loop); } return(config); }
public override Widget build(BuildContext context, SwiperPluginConfig config) { Alignment alignment = this.alignment ?? (config.scrollDirection == Axis.horizontal ? Alignment.bottomCenter : Alignment.centerRight); Widget child = new Container( margin: margin, child: this.builder.build(context, config) ); if (!config.outer) { child = new Align( key: key, alignment: alignment, child: child ); } return(child); }
public override Widget build(BuildContext context, SwiperPluginConfig config) { return(builder(context, config)); }
public override Widget build(BuildContext context, SwiperPluginConfig config) { if (config.itemCount > 20) { UnityEngine.Debug.LogWarning( "The itemCount is too big, we suggest use FractionPaginationBuilder instead of DotSwiperPaginationBuilder in this sitituation"); } Color activeColor = this.activeColor; Color color = this.color; if (activeColor == null || color == null) { ThemeData themeData = Theme.of(context); activeColor = this.activeColor ?? themeData.primaryColor; color = this.color ?? themeData.scaffoldBackgroundColor; } if (config.indicatorLayout != PageIndicatorLayout.NONE && config.layout == SwiperLayout.DEFAULT) { return(new PageIndicator( count: config.itemCount, controller: config.pageController, layout: config.indicatorLayout, size: size, activeColor: activeColor, color: color, space: space )); } List <Widget> list = new List <Widget>(); int itemCount = config.itemCount; int activeIndex = config.activeIndex; for (int i = 0; i < itemCount; ++i) { bool active = i == activeIndex; list.Add(new Container( key: Key.key("pagination_" + i), margin: EdgeInsets.all(space), child: new ClipRRect(//TODO:check 换成圆形组件 borderRadius: BorderRadius.circular(10f), child: new Container( color: active ? activeColor : color, width: active ? activeSize : size, height: active ? activeSize : size ) ) )); } if (config.scrollDirection == Axis.vertical) { return(new Column( key: key, mainAxisSize: MainAxisSize.min, children: list )); } else { return(new Row( key: key, mainAxisSize: MainAxisSize.min, children: list )); } }
SwiperPluginView(SwiperPlugin plugin, SwiperPluginConfig config) { this.plugin = plugin; this.config = config; }
//SwiperPlugin(); public abstract Widget build(BuildContext context, SwiperPluginConfig config);