Esempio n. 1
0
 Image _getImage()
 {
     return(this.widget.data == null
         ? CachedNetworkImageProvider.cachedNetworkImage(
                this.widget.isOriginalImage?this.widget.url : CImageUtils.SizeToScreenImageUrl(this.widget.url),
                fit : BoxFit.cover,
                headers : this.widget.headers)
         : Image.memory(bytes: this.widget.data));
 }
Esempio n. 2
0
        public override Widget build(BuildContext context)
        {
            var attachmentUrLs = this.game.attachmentURLs;

            if (attachmentUrLs.isNullOrEmpty())
            {
                return(new Container());
            }

            Widget swiperContent;

            if (attachmentUrLs.Count == 1)
            {
                var imageUrl = attachmentUrLs.FirstOrDefault();
                swiperContent = new GestureDetector(
                    onTap: () => { },
                    child: new PlaceholderImage(
                        imageUrl: imageUrl,
                        fit: BoxFit.fill,
                        useCachedNetworkImage: true,
                        color: CColorUtils.GetSpecificDarkColorFromId(id: imageUrl)
                        )
                    );
            }
            else
            {
                swiperContent = new Swiper.Swiper(
                    (cxt, index) => {
                    var imageUrl = attachmentUrLs[index: index];
                    return(new PlaceholderImage(
                               CImageUtils.SizeToScreenImageUrl(imageUrl: imageUrl),
                               fit: BoxFit.fill,
                               useCachedNetworkImage: true,
                               color: CColorUtils.GetSpecificDarkColorFromId(id: imageUrl)
                               ));
                },
                    itemCount: attachmentUrLs.Count,
                    autoplay: true,
                    onTap: index => { },
                    pagination: new SwiperPagination(margin: EdgeInsets.only(bottom: 5))
                    );
            }

            return(new Container(
                       child: new AspectRatio(
                           aspectRatio: 16 / 9f,
                           child: swiperContent
                           )
                       ));
        }
        Widget _buildSwiper()
        {
            var homeSliderIds = this.widget.viewModel.homeSliderIds;

            if (homeSliderIds.isNullOrEmpty())
            {
                return(new Container());
            }

            Widget swiperContent;

            if (homeSliderIds.Count == 1)
            {
                var homeSliderId = homeSliderIds[0];
                var imageUrl     = this.widget.viewModel.rankDict.ContainsKey(key: homeSliderId)
                    ? this.widget.viewModel.rankDict[key : homeSliderId].image
                                   : "";
                swiperContent = new GestureDetector(
                    onTap: () => {
                    var redirectURL = this.widget.viewModel.rankDict.ContainsKey(key: homeSliderId)
                            ? this.widget.viewModel.rankDict[key: homeSliderId].redirectURL
                            : "";
                    if (redirectURL.isNotEmpty())
                    {
                        this.widget.actionModel.openUrl(obj: redirectURL);
                    }
                },
                    child: new PlaceholderImage(
                        imageUrl: imageUrl,
                        fit: BoxFit.fill,
                        useCachedNetworkImage: true,
                        color: CColorUtils.GetSpecificDarkColorFromId(id: homeSliderId)
                        )
                    );
            }
            else
            {
                swiperContent = new Swiper(
                    (cxt, index) => {
                    var homeSliderId = homeSliderIds[index: index];
                    var imageUrl     = this.widget.viewModel.rankDict.ContainsKey(key: homeSliderId)
                            ? this.widget.viewModel.rankDict[key: homeSliderId].image
                            : "";
                    return(new PlaceholderImage(
                               CImageUtils.SizeToScreenImageUrl(imageUrl: imageUrl),
                               fit: BoxFit.fill,
                               useCachedNetworkImage: true,
                               color: CColorUtils.GetSpecificDarkColorFromId(id: homeSliderId)
                               ));
                },
                    itemCount: homeSliderIds.Count,
                    autoplay: true,
                    onTap: index => {
                    var homeSliderId = homeSliderIds[index: index];
                    var redirectURL  = this.widget.viewModel.rankDict.ContainsKey(key: homeSliderId)
                            ? this.widget.viewModel.rankDict[key: homeSliderId].redirectURL
                            : "";
                    if (redirectURL.isNotEmpty())
                    {
                        this.widget.actionModel.openUrl(obj: redirectURL);
                    }
                },
                    pagination: new SwiperPagination(margin: EdgeInsets.only(bottom: 5))
                    );
            }

            return(new Container(
                       padding: EdgeInsets.only(top: 8, left: 16, right: 16),
                       decoration: new BoxDecoration(
                           borderRadius: BorderRadius.all(8),
                           color: CColors.White
                           ),
                       child: new AspectRatio(
                           aspectRatio: 3,
                           child: new ClipRRect(
                               borderRadius: BorderRadius.all(8),
                               child: swiperContent
                               )
                           )
                       ));
        }