public Widget BulidTopSwiper(List <string> urls) { List <Widget> children = new List <Widget>(); foreach (var item in urls) { Widget it = Image.network(item, fit: BoxFit.fill); children.Add(it); } TransformerPageController controller = new TransformerPageController(initialPage: 0, itemCount: urls.Count); return(new Container( height: 270, width: 375, child: new Stack( children: new List <Widget> { TransformerPageView.children(index: 0, children: children, pageController: controller ), new Align( alignment: Alignment.bottomCenter, child: new Padding( padding: EdgeInsets.only(bottom: 20), child: new PageIndicator(layout: PageIndicatorLayout.WARM, size: 7, activeSize: 7, controller: controller, space: 5.0f, count: urls.Count , color: new Unity.UIWidgets.ui.Color(0xFFEAEAEA), activeColor: new Unity.UIWidgets.ui.Color(0xFF404759)) ) ) } ) )); }
Widget _buildSwiper() { IndexedWidgetBuilder itemBuilder; if (widget.onTap != null) { itemBuilder = _wrapTap; } else { itemBuilder = widget.itemBuilder; } if (widget.layout == SwiperLayout.STACK) { return(new _StackSwiper( loop: widget.loop, itemWidth: widget.itemWidth, itemHeight: widget.itemHeight, itemCount: widget.itemCount, itemBuilder: itemBuilder, index: _activeIndex, curve: widget.curve, duration: widget.duration, onIndexChanged: _onIndexChanged, controller: _controller, scrollDirection: widget.scrollDirection )); } else if (_isPageViewLayout()) { PageTransformer transformer = widget.transformer; if (widget.scale != 0 || widget.fade != 0) { transformer = new ScaleAndFadeTransformer(scale: widget.scale, fade: widget.fade); } Widget child = new TransformerPageView( pageController: _pageController, loop: widget.loop, itemCount: widget.itemCount, itemBuilder: itemBuilder, transformer: transformer, viewportFraction: widget.viewportFraction, index: _activeIndex, duration: TimeSpan.FromMilliseconds(widget.duration), scrollDirection: widget.scrollDirection, onPageChanged: _onIndexChanged, curve: widget.curve, physics: widget.physics, controller: _controller ); if (widget.autoplayDisableOnInteraction && widget.autoplay) { return(new NotificationListener <ScrollNotification>( child: child, onNotification: (ScrollNotification notification) => { ScrollStartNotification ssno = notification as ScrollStartNotification; if (ssno != null) { if (ssno.dragDetails != null) { //by human if (_timer != null) { _stopAutoplay(); } } } else if (notification is ScrollEndNotification) { if (_timer == null) { _startAutoplay(); } } return false; } )); } return(child); } else if (widget.layout == SwiperLayout.TINDER) { return(new _TinderSwiper( loop: widget.loop, itemWidth: widget.itemWidth, itemHeight: widget.itemHeight, itemCount: widget.itemCount, itemBuilder: itemBuilder, index: _activeIndex, curve: widget.curve, duration: widget.duration, onIndexChanged: _onIndexChanged, controller: _controller, scrollDirection: widget.scrollDirection )); } else if (widget.layout == SwiperLayout.CUSTOM) { return(new _CustomLayoutSwiper( loop: widget.loop, option: widget.customLayoutOption, itemWidth: widget.itemWidth, itemHeight: widget.itemHeight, itemCount: widget.itemCount, itemBuilder: itemBuilder, index: _activeIndex, curve: widget.curve, duration: widget.duration, onIndexChanged: _onIndexChanged, controller: _controller, scrollDirection: widget.scrollDirection )); } else { return(new Container()); } }
public override Widget build(BuildContext context) { var children = new List <Widget> { new Container( width: 1080, height: 800, color: Colors.red ), new Container( width: 1080, height: 800, color: Colors.green ), new Container( width: 1080, height: 800, color: Colors.blueAccent ), new Container( width: 1080, height: 800, color: Colors.grey ) }; return(new Scaffold( appBar: new AppBar( title: new Text(widget.title) ), body: new Column( children: new List <Widget> { new Row( children: new List <Widget> { new Checkbox( value: loop, onChanged: (va) => { setState(() => { if (va == true) { //controller = new TransformerPageController(itemCount:4,loop:true); } else { //controller = new PageController(initialPage:0); } loop = (bool)va; }); } ), new Text("loop") } ), new RadioGroup( titles: new List <string> { "COLOR", "DROP", "NONE", "SCALE", "SLIDE", "WARM" }, onIndexChanged: (index) => { setState(() => { _index = index; layout = layouts[index]; }); } ), new Container( width: 1080, height: 800, child: new Stack( children: new List <Widget> { TransformerPageView.children(index: 0, children: children, pageController: controller ), new Align( alignment: Alignment.bottomCenter, child: new Padding( padding: EdgeInsets.only(bottom: 20), child: getItem() ) ) } ) ) } ) )); }