コード例 #1
0
        static Widget _buildEmbeddedName(string image, string name)
        {
            if (image.isEmpty() && name.isEmpty())
            {
                return(new Container());
            }

            return(new Row(
                       crossAxisAlignment: CrossAxisAlignment.center,
                       children: new List <Widget> {
                image == null
                        ? (Widget) new Container(width: 14, height: 14)
                        : CachedNetworkImageProvider.cachedNetworkImage(
                    src: image,
                    width: 14, height: 14, fit: BoxFit.cover
                    ),
                new Container(width: 4),
                new Expanded(
                    child: new Text(
                        name ?? "",
                        style: CTextStyle.PMediumBody.copyWith(height: 1),
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis
                        )
                    )
            }
                       ));
        }
コード例 #2
0
        public static Image cachedNetworkImage(
            string src,
            Key key                              = null,
            float scale                          = 1.0f,
            float?width                          = null,
            float?height                         = null,
            Color color                          = null,
            BlendMode colorBlendMode             = BlendMode.srcIn,
            BoxFit?fit                           = null,
            Alignment alignment                  = null,
            ImageRepeat repeat                   = ImageRepeat.noRepeat,
            Rect centerSlice                     = null,
            bool gaplessPlayback                 = false,
            FilterMode filterMode                = FilterMode.Bilinear,
            IDictionary <string, string> headers = null
            )
        {
            var imageProvider = new CachedNetworkImageProvider(url: src, scale: scale, headers: headers);

            return(new Image(
                       key: key,
                       image: imageProvider,
                       width: width,
                       height: height,
                       color: color,
                       colorBlendMode: colorBlendMode,
                       fit: fit,
                       alignment: alignment,
                       repeat: repeat,
                       centerSlice: centerSlice,
                       gaplessPlayback: gaplessPlayback,
                       filterMode: filterMode
                       ));
        }
コード例 #3
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));
 }
コード例 #4
0
        public override void didUpdateWidget(StatefulWidget oldWidget)
        {
            base.didUpdateWidget(oldWidget: oldWidget);
            CachedNetworkImage cachedImage = oldWidget as CachedNetworkImage;

            if (this.widget.src != cachedImage.src || this.widget.placeholder != cachedImage.placeholder)
            {
                this._imageProvider = new CachedNetworkImageProvider(url: this.widget.src,
                                                                     scale: this.widget.scale, headers: this.widget.headers);

                this._resolveImage();
            }
        }
コード例 #5
0
 public override void initState()
 {
     this._imageProvider = new CachedNetworkImageProvider(
         url: this.widget.src,
         scale: this.widget.scale,
         headers: this.widget.headers
         );
     this._imageResolver = new _CachedImageProviderResolver(this, listener: this._updatePhase);
     this._controller    = new AnimationController(
         1.0f,
         vsync: this
         );
     this._controller.addListener(() => this.setState(() => { }));
     this._controller.addStatusListener(status => this._updatePhase());
     base.initState();
 }
コード例 #6
0
ファイル: PhotoView.cs プロジェクト: 510074793/ConnectAppCN
        public override Widget build(BuildContext context)
        {
            var headers = this.widget.headers ?? new Dictionary <string, string> {
                { HttpManager.COOKIE, HttpManager.getCookie() },
                { "ConnectAppVersion", Config.versionNumber },
                { "X-Requested-With", "XmlHttpRequest" }
            };
            var pageView = new PageView(
                controller: this.widget.controller,
                onPageChanged: index => { this.setState(() => { this.currentIndex = index; }); },
                children: this.widget.urls.Select <string, Widget>(url => {
                return(this.widget.useCachedNetworkImage
                        ? CachedNetworkImageProvider.cachedNetworkImage(
                           url,
                           fit: BoxFit.contain,
                           headers: headers)
                        : Image.network(url,
                                        fit: BoxFit.contain,
                                        headers: headers));
            }).ToList());

            return(new GestureDetector(
                       onTap: () => { StoreProvider.store.dispatcher.dispatch(new MainNavigatorPopAction()); },
                       onLongPress: this._pickImage,
                       child: new Container(
                           color: CColors.Black,
                           child: new Stack(
                               alignment: Alignment.center,
                               children: new List <Widget> {
                pageView,
                new Positioned(
                    bottom: 30,
                    child: new Container(
                        height: 40,
                        padding: EdgeInsets.symmetric(0, 24),
                        alignment: Alignment.center,
                        decoration: new BoxDecoration(
                            color: Color.fromRGBO(0, 0, 0, 0.5f),
                            borderRadius: BorderRadius.all(20)
                            ),
                        child: new Text($"{this.currentIndex + 1}/{this.widget.urls.Count}",
                                        style: CTextStyle.PLargeWhite.copyWith(height: 1))
                        )
                    )
            }))));
        }
コード例 #7
0
ファイル: Avatar.cs プロジェクト: 510074793/ConnectAppCN
        public override Widget build(BuildContext context)
        {
            var avatarSize = this.hasWhiteBorder ? this.size : this.size - this.whiteBorderWidth * 2;
            var border     = this.hasWhiteBorder
                ? Border.all(
                color: CColors.White,
                width: this.whiteBorderWidth
                )
                : null;

            // fix Android 9 http request error
            var httpsUrl = this.avatarUrl.httpToHttps();

            return(new Container(
                       width: this.size,
                       height: this.size,
                       decoration: new BoxDecoration(
                           borderRadius: BorderRadius.circular(this.avatarShape == AvatarShape.circle
                        ? this.size / 2
                        : DefaultRectCorner),
                           border: border
                           ),
                       child: new ClipRRect(
                           borderRadius: BorderRadius.circular(this.avatarShape == AvatarShape.circle
                        ? avatarSize
                        : this.hasWhiteBorder ? DefaultRectCorner / 2 : DefaultRectCorner),
                           child: this.avatarUrl.isEmpty()
                        ? new Container(
                               child: new _Placeholder(
                                   this.id ?? "",
                                   this.fullName ?? "",
                                   size: avatarSize
                                   )
                               )
                        : new Container(
                               width: avatarSize,
                               height: avatarSize,
                               color: CColors.AvatarLoading,
                               child: this.useCachedNetworkImage
                                ? CachedNetworkImageProvider.cachedNetworkImage(src: httpsUrl)
                                : Image.network(src: httpsUrl)
                               )
                           )
                       ));
        }
コード例 #8
0
        public override Widget build(BuildContext context)
        {
            Widget child;

            if (this.imageUrl == null || this.imageUrl.Length <= 0)
            {
                child = new Container(
                    width: this.width,
                    height: this.height,
                    color: new Color(0xFFD8D8D8)
                    );
            }
            else
            {
                child = new Container(
                    width: this.width,
                    height: this.height,
                    color: new Color(0xFFD8D8D8),
                    child: !this.useCachedNetworkImage
                        ? Image.network(
                        src: this.imageUrl,
                        width: this.width,
                        height: this.height,
                        fit: this.fit
                        ) : CachedNetworkImageProvider.cachedNetworkImage(
                        src: this.imageUrl,
                        fit: this.fit
                        )
                    );
            }

            return(new ClipRRect(
                       borderRadius: BorderRadius.all(this.borderRadius ?? 0),
                       child: child
                       ));
        }
コード例 #9
0
        public override Widget build(BuildContext context)
        {
            if (this.channel == null)
            {
                return(new Container());
            }

            Widget image = Positioned.fill(
                CachedNetworkImageProvider.cachedNetworkImage(
                    this.channel?.thumbnail ?? "",
                    fit: BoxFit.cover
                    )
                );
            Widget gradient = Positioned.fill(
                new Container(
                    decoration: new BoxDecoration(
                        gradient: new LinearGradient(
                            begin: Alignment.topCenter,
                            end: Alignment.bottomCenter,
                            new List <Color> {
                Color.fromARGB(20, 0, 0, 0),
                Color.fromARGB(80, 0, 0, 0)
            }
                            )
                        )
                    )
                );

            Widget title = new Container(
                height: 72,
                padding: EdgeInsets.symmetric(0, 8),
                child: new Align(
                    alignment: Alignment.bottomLeft,
                    child: new Text(
                        data: this.channel.name,
                        style: CTextStyle.PLargeMediumWhite
                        )
                    )
                );

            Widget count = new Container(
                padding: EdgeInsets.only(top: 4, left: 8),
                child: new Row(
                    children: new List <Widget> {
                new Container(
                    width: 8,
                    height: 8,
                    decoration: new BoxDecoration(
                        color: CColors.AquaMarine,
                        borderRadius: BorderRadius.all(4)
                        )
                    ),
                new Container(width: 4),
                new Text($"{this.channel.memberCount}人",
                         style: CTextStyle.PSmallWhite)
            }
                    )
                );

            Widget content = Positioned.fill(
                new Column(
                    children: new List <Widget> {
                title, count
            }
                    )
                );

            return(new GestureDetector(
                       onTap: this.onTap,
                       child: new Container(
                           width: 120,
                           height: 120,
                           margin: EdgeInsets.only(right: 16),
                           child: new ClipRRect(
                               borderRadius: BorderRadius.all(8),
                               child: new Container(
                                   child: new Stack(
                                       children: new List <Widget> {
                image, gradient, content
            }
                                       )
                                   )
                               )
                           )
                       ));
        }