Esempio n. 1
0
        Widget flexColumn()
        {
            var image = Image.network(
                "https://tse3.mm.bing.net/th?id=OIP.XOAIpvR1kh-CzISe_Nj9GgHaHs&pid=Api",
                width: 100,
                height: 100
                );
            List <Widget> columnImages = new List <Widget>();

            columnImages.Add(image);
            columnImages.Add(image);
            columnImages.Add(image);

            var column = new Column(
                textDirection: null,
                textBaseline: null,
                key: null,
                mainAxisAlignment: MainAxisAlignment.start,
                mainAxisSize: MainAxisSize.max,
                crossAxisAlignment: CrossAxisAlignment.center,
                verticalDirection: VerticalDirection.down,
                children: columnImages
                );

            return(column);
        }
Esempio n. 2
0
        public override Widget build(BuildContext context)
        {
            if (this.type == OwnerType.team)
            {
                return(this._buildTeamAvatar());
            }

            var avatarUrl = this.user.avatar ?? "";
            var fullName  = this.user.fullName ?? this.user.name;
            var result    = _extractName(fullName) ?? "";

            return(new ClipRRect(
                       borderRadius: BorderRadius.circular(this.size / 2),
                       child: avatarUrl.isEmpty()
                    ? new Container(
                           child: new _Placeholder(result, this.size)
                           )
                    : new Container(
                           width: this.size,
                           height: this.size,
                           color: new Color(0xFFD8D8D8),
                           child: Image.network(avatarUrl, fit: BoxFit.cover)
                           )
                       ));
        }
        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: Image.network(this.imageUrl,
                                         width: this.width,
                                         height: this.height,
                                         fit: this.fit
                                         )
                    );
            }

            return(new ClipRRect(
                       borderRadius: BorderRadius.all(this.borderRadius == null ? 0 : (float)this.borderRadius),
                       child: child
                       ));
        }
            public override Widget build(BuildContext context)
            {
                var imageSimplePath = "test.gif";
                var absolutePath    = getAbsoluteImagePathForApp(imageSimplePath);

                return(new Container(
                           child: new Column(
                               children: new List <Widget>
                {
                    new Lottie("wine.json", size: new Size(100, 100)),
                    new Container(
                        width: 100,
                        height: 100,
                        decoration: new BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(8))
                            ),
                        child: Image.file(absolutePath, gaplessPlayback: true, isAbsolutePath: true)
                        ),
                    new Container(width: 50f, height: 50f, child: Image.file(imageSimplePath, gaplessPlayback: true)),
                    new Container(
                        width: 200,
                        height: 100,
                        decoration: new BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(8))
                            ),
                        child: Image.network(
                            "https://unity-cn-cms-prd-1254078910.cos.ap-shanghai.myqcloud.com/assetstore-cms-media/img-7dfe215f-0075-4f9c-9b5a-be5ee88b866b",
                            gaplessPlayback: true)
                        )
                }
                               )
                           ));
            }
Esempio n. 5
0
        Widget stack()
        {
            var image = new Container(
                width: 150,
                height: 150,
                child: Image.network(
                    "https://tse3.mm.bing.net/th?id=OIP.XOAIpvR1kh-CzISe_Nj9GgHaHs&pid=Api",
                    width: 100,
                    height: 100
                    )
                );
            var text = new Container(
                width: 150,
                height: 150,
                child: new Text("TTTTTTTTTTTTTTTTEST")
                );
            List <Widget> rowImages = new List <Widget>();

            rowImages.Add(image);
            rowImages.Add(text);
            return(new Stack(
                       children: rowImages,
                       alignment: Alignment.center
                       ));
        }
Esempio n. 6
0
        Widget container()
        {
            var image = Image.network(
                "https://tse3.mm.bing.net/th?id=OIP.XOAIpvR1kh-CzISe_Nj9GgHaHs&pid=Api",
                width: 100,
                height: 100,
                repeat: ImageRepeat.repeatX
                );
            var container = new Container(
                width: 200,
                height: 200,
                margin: EdgeInsets.all(30.0f),
                padding: EdgeInsets.all(15.0f),
                child: image,
                decoration: new BoxDecoration(
                    color: CLColors.white,
                    borderRadius: BorderRadius.all(30),
                    gradient: new LinearGradient(colors: new List <Color> {
                CLColors.blue, CLColors.red, CLColors.green
            })
                    )
                );

            return(container);
        }
Esempio n. 7
0
        // _buildImage, buildcheckbox, build bullet, buildTablecell
        Widget _buildImage(string src)
        {
            var parts = src.Split('#');

            if (parts.isEmpty())
            {
                return(new SizedBox());
            }

            var   path = parts.first();
            float width = 0, height = 0;

            if (parts.Length == 2)
            {
                var dimensions = parts.last().Split('x');
                if (dimensions.Length == 2)
                {
                    width  = float.Parse(dimensions[0]);
                    height = float.Parse(dimensions[1]);
                }
            }

            var    uri = new Uri(path);
            Widget child;

            if (uri.Scheme == "http" || uri.Scheme == "https")
            {
                child = Image.network(uri.ToString(), null, 1);
            }
            else if (uri.Scheme == "data")
            {
                // todo
                child = this._handleDataSchemeUri(uri, width, height);
            }
            else if (uri.Scheme == "resource")
            {
                //TODO:
                child = Image.asset(path.Substring(9), null, null, width, height);
            }
            else
            {
                string filePath = this.imageDirectory == null
                    ? uri.ToString()
                    : Path.Combine(this.imageDirectory, uri.ToString());

                child = Image.file(filePath, null, 1, width, height);
            }

            if (this._linkHandlers.isNotEmpty())
            {
                TapGestureRecognizer recognizer = this._linkHandlers.last() as TapGestureRecognizer;
                return(new GestureDetector(null, child, null, null, recognizer.onTap));
            }
            else
            {
                return(child);
            }
        }
Esempio n. 8
0
 private Widget _buildAvatar()
 {
     return(new Center(
                child: new Container(
                    width: 256,
                    height: 256,
                    child: Image.network(Datas.AppManager.Instance.GetUserData.AvatarUrl)
                    )
                ));
 }
Esempio n. 9
0
 Widget _buildBanner(BuildContext context)
 {
     return(new Container(
                height: 450,
                color: CLColors.white,
                child: Image.network(
                    "https://d2ujflorbtfzji.cloudfront.net/banner/5c57178c-4be6-4903-953b-85125bfb7154.jpg",
                    fit: BoxFit.cover
                    )
                ));
 }
Esempio n. 10
0
 Widget _buildBanner(BuildContext context)
 {
     return(new Container(
                height: 450,
                color: CLColors.white,
                child: Image.network(
                    "https://assetstorev1-prd-cdn.unity3d.com/banner/9716cc07-748c-43cc-8809-10113119c97a.jpg",
                    fit: BoxFit.cover,
                    filterMode: FilterMode.Bilinear
                    )
                ));
 }
Esempio n. 11
0
        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.LoadingGrey,
                               child: this.useCachedNetworkImage
                                ? (Widget) new CachedNetworkImage(src: httpsUrl)
                                : Image.network(src: httpsUrl)
                               )
                           )
                       ));
        }
Esempio n. 12
0
        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))
                        )
                    )
            }))));
        }
Esempio n. 13
0
        Widget _buildTeamAvatar()
        {
            var avatarUrl = this.team.avatar ?? "";
            var name      = this.team.name;
            var result    = _extractName(name) ?? "";

            if (avatarUrl.Length <= 0)
            {
                return(new _Placeholder(result, this.size));
            }

            return(new Container(
                       width: this.size,
                       height: this.size,
                       color: new Color(0xFFD8D8D8),
                       child: Image.network(avatarUrl)
                       ));
        }
Esempio n. 14
0
        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;

            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: Image.network(src: this.avatarUrl)
                               )
                           )
                       ));
        }
Esempio n. 15
0
        Widget _buildHeadImage(Widget child)
        {
            var eventObj = this.widget.eventObj;
            var imageUrl = eventObj.background != null ? eventObj.background : "";

            return(new Container(
                       color: new Color(0xFFD8D8D8),
                       child: new AspectRatio(
                           aspectRatio: 16.0f / 9.0f,
                           child: new Stack(
                               fit: StackFit.expand,
                               children: new List <Widget> {
                Image.network(
                    imageUrl,
                    fit: BoxFit.cover
                    ),
                child
            }
                               )
                           )
                       ));
        }
Esempio n. 16
0
 public override Widget build(BuildContext context)
 {
     return(new Container(
                child: new Column(
                    children: new List <Widget>
     {
         AnimatedLottie.file("wine.json", frame: frame, curve: Curves.linear),
         new Container(
             width: 100,
             height: 100,
             decoration: new BoxDecoration(
                 borderRadius: BorderRadius.all(Radius.circular(8))
                 ),
             child: Image.file("test.gif", gaplessPlayback: true)
             ),
         new Container(
             width: 200,
             height: 100,
             decoration: new BoxDecoration(
                 borderRadius: BorderRadius.all(Radius.circular(8))
                 ),
             child: Image.network(
                 "https://unity-cn-cms-prd-1254078910.cos.ap-shanghai.myqcloud.com/assetstore-cms-media/img-7dfe215f-0075-4f9c-9b5a-be5ee88b866b",
                 gaplessPlayback: true)
             ),
         new GestureDetector(
             onTap: () => { setState(() => { frame += 1; }); },
             child: new Container(
                 color: Color.black,
                 padding: EdgeInsets.symmetric(20, 20),
                 child: new Text("Click Me",
                                 style: new TextStyle(fontWeight: FontWeight.w700))
                 )
             )
     }
                    )
                ));
 }
Esempio n. 17
0
        public override Widget build(BuildContext context)
        {
            Widget child;

            if (this.imageUrl.isEmpty())
            {
                child = new Container(
                    width: this.width,
                    height: this.height,
                    color: this.color
                    );
            }
            else
            {
                child = new Container(
                    width: this.width,
                    height: this.height,
                    color: this.color,
                    child: !this.useCachedNetworkImage
                        ? Image.network(
                        src: this.imageUrl,
                        width: this.width,
                        height: this.height,
                        fit: this.fit
                        ) : (Widget) new CachedNetworkImage(
                        src: this.imageUrl,
                        fit: this.fit
                        )
                    );
            }

            return(new ClipRRect(
                       borderRadius: BorderRadius.all(this.borderRadius ?? 0),
                       child: child
                       ));
        }
Esempio n. 18
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
                       ));
        }
Esempio n. 19
0
        static Widget _Atomic(BuildContext context, string type, string contentType, string title, string dataUrl,
                              _OriginalImage originalImage, string videoStatus, string videoPoster,
                              string url, string downloadUrl, string attachmentId, Action <string> openUrl,
                              Action <string, bool, int> playVideo, Action loginAction, bool needUpdate, int limitSeconds,
                              Action <string> browserImage = null)
        {
            if (type == "ATTACHMENT" && contentType != "video/mp4")
            {
                return(new Container());
            }

            var playButton = Positioned.fill(
                new Container()
                );

            if (type == "VIDEO" || type == "ATTACHMENT")
            {
                playButton = Positioned.fill(
                    new Center(
                        child: videoStatus == "completed"
                            ? UserInfoManager.isLogin()
                                ? new CustomButton(
                            onPressed: () => {
                    if (type == "ATTACHMENT")
                    {
                        if (url.isEmpty())
                        {
                            playVideo(downloadUrl, false, 0);
                        }
                        else
                        {
                            playVideo($"{Config.apiAddress}/playlist/{attachmentId}", needUpdate,
                                      limitSeconds);
                        }
                    }
                    else
                    {
                        if (url == null || url.Length <= 0)
                        {
                            return;
                        }

                        openUrl(url);
                    }
                },
                            child: new Container(
                                width: 60,
                                height: 60,
                                decoration: new BoxDecoration(
                                    CColors.H5White,
                                    borderRadius: BorderRadius.all(30)
                                    ),
                                child: new Icon(
                                    Icons.play_arrow,
                                    size: 45,
                                    color: CColors.Icon
                                    )
                                )
                            )
                                : (Widget) new GestureDetector(
                            onTap: () => { loginAction(); },
                            child: new Container(
                                color: CColors.Black.withOpacity(0.5f),
                                alignment: Alignment.center,
                                child: new Text("Login to view this video",
                                                style: CTextStyle.PXLargeWhite.merge(
                                                    new TextStyle(decoration: TextDecoration.underline)))
                                ))
                            : new Container(
                            color: CColors.Black.withOpacity(0.5f),
                            alignment: Alignment.center,
                            child: new Text("Video is processing, try it later", style: CTextStyle.PXLargeWhite)
                            )
                        )
                    );
            }

            var attachWidth  = MediaQuery.of(context).size.width - 32;
            var attachHeight = attachWidth * 9 / 16;

            if (type == "ATTACHMENT")
            {
                return(new Container(
                           color: CColors.White,
                           padding: EdgeInsets.only(bottom: 32),
                           alignment: Alignment.center,
                           child: new Container(
                               padding: EdgeInsets.only(16, right: 16),
                               child: new Column(
                                   children: new List <Widget> {
                    new Stack(
                        children: new List <Widget> {
                        new Container(
                            width: attachWidth,
                            height: attachHeight,
                            color: CColors.Black,
                            child: Image.network(
                                videoPoster,
                                fit: BoxFit.cover
                                )
                            ),
                        playButton
                    }
                        )
                }
                                   )
                               )
                           ));
            }

            var width = originalImage.width < MediaQuery.of(context).size.width - 32
                ? originalImage.width
                : MediaQuery.of(context).size.width - 32;
            var height   = width * originalImage.height / originalImage.width;
            var imageUrl = originalImage.url;

            if (imageUrl.isNotEmpty())
            {
                imageUrl = imageUrl.EndsWith(".gif") || imageUrl.EndsWith(".png")
                    ? imageUrl
                    : CImageUtils.SuitableSizeImageUrl(MediaQuery.of(context).size.width, imageUrl);
                imageUrls.Add(imageUrl);
            }

            var nodes = new List <Widget> {
                new Stack(
                    children: new List <Widget> {
                    new GestureDetector(
                        child: new Hero(
                            tag: imageUrl,
                            child: new PlaceholderImage(
                                imageUrl: imageUrl,
                                width: width,
                                height: height,
                                fit: BoxFit.cover,
                                useCachedNetworkImage: true
                                )
                            ), onTap: () => {
                        if (dataUrl.isNotEmpty())
                        {
                            openUrl(obj: dataUrl);
                        }
                        else
                        {
                            browserImage?.Invoke(imageUrl);
                        }
                    }
                        ),
                    playButton
                }
                    )
            };

            if (title != null)
            {
                var imageTitle = new Container(
                    decoration: new BoxDecoration(
                        border: new Border(
                            bottom: new BorderSide(
                                CColors.Separator,
                                2
                                )
                            )
                        ),
                    child: new Container(
                        margin: EdgeInsets.only(4, 8, 4, 4),
                        child: new Text(
                            title,
                            style: CTextStyle.PRegularBody4
                            )
                        )
                    );
                nodes.Add(imageTitle);
            }

            return(new Container(
                       color: CColors.White,
                       padding: EdgeInsets.only(bottom: 32),
                       alignment: Alignment.center,
                       child: new Container(
                           padding: EdgeInsets.only(16, right: 16),
                           child: new Column(
                               children: nodes
                               )
                           )
                       ));
        }
Esempio n. 20
0
        Widget _parseNode(HtmlNode node)
        {
            if (this.customRender != null)
            {
                Widget customWidget = this.customRender(node, this._parseNodeList(node.ChildNodes));
                if (customWidget != null)
                {
                    return(customWidget);
                }
            }

            if (node.NodeType is HtmlNodeType.Element)
            {
                if (!_supportedElements.Contains(node.Name))
                {
                    return(new Container());
                }

                switch (node.Name)
                {
                case "a":
                    return(new GestureDetector(
                               child: DefaultTextStyle.merge(
                                   child: new Wrap(
                                       children: this._parseNodeList(node.ChildNodes)
                                       ),
                                   style: this.linkStyle
                                   ),
                               onTap: () => {
                        if (node.Attributes.Contains("href") && this.onLinkTap != null)
                        {
                            string url = node.Attributes["href"].Value;
                            this.onLinkTap(url);
                        }
                    }));

                case "abbr":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   decoration: TextDecoration.underline,
                                   decorationStyle: TextDecorationStyle.solid
                                   )
                               ));

                case "acronym":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   decoration: TextDecoration.underline,
                                   decorationStyle: TextDecorationStyle.solid
                                   )
                               ));

                case "address":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontStyle: FontStyle.italic
                                   )
                               ));

                case "article":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "aside":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "b":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontWeight: FontWeight.bold
                                   )
                               ));

                case "bdi":
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "bdo":
                    if (node.Attributes["dir"] != null)
                    {
                        return(new Directionality(
                                   child: new Wrap(
                                       children: this._parseNodeList(node.ChildNodes)
                                       ),
                                   textDirection: node.Attributes["dir"].Value == "rtl"
                                    ? TextDirection.rtl
                                    : TextDirection.ltr
                                   ));
                    }

                    //Direction attribute is required, just render the text normally now.
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "big":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontSize: 20.0f
                                   )
                               ));

                case "blockquote":
                    return(new Padding(
                               padding:
                               EdgeInsets.fromLTRB(40.0f, this.blockSpacing, 40.0f, this.blockSpacing),
                               child: new Container(
                                   width: this.width,
                                   child: new Wrap(
                                       crossAxisAlignment: WrapCrossAlignment.center,
                                       children: this._parseNodeList(node.ChildNodes)
                                       )
                                   )
                               ));

                case "body":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "br":
                    if (this._isNotFirstBreakTag(node))
                    {
                        return(new Container(width: this.width, height: this.blockSpacing));
                    }

                    return(new Container(width: this.width));

                case "caption":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   alignment: WrapAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "center":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes),
                                   alignment: WrapAlignment.center
                                   )));

                case "cite":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontStyle: FontStyle.italic
                                   )
                               ));

                case "code":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontFamily: "monospace"
                                   )
                               ));

                case "data":
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "dd":
                    return(new Padding(
                               padding: EdgeInsets.only(left: 40.0f),
                               child: new Container(
                                   width: this.width,
                                   child: new Wrap(
                                       crossAxisAlignment: WrapCrossAlignment.center,
                                       children: this._parseNodeList(node.ChildNodes)
                                       )
                                   )));

                case "del":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   decoration: TextDecoration.lineThrough
                                   )
                               ));

                case "dfn":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontStyle: FontStyle.italic
                                   )
                               ));

                case "div":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "dl":
                    return(new Padding(
                               padding: EdgeInsets.only(top: this.blockSpacing, bottom: this.blockSpacing),
                               child: new Column(
                                   children: this._parseNodeList(node.ChildNodes),
                                   crossAxisAlignment: CrossAxisAlignment.start
                                   )));

                case "dt":
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "em":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontStyle: FontStyle.italic
                                   )
                               ));

                case "figcaption":
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "figure":
                    return(new Padding(
                               padding:
                               EdgeInsets.fromLTRB(40.0f, this.blockSpacing, 40.0f, this.blockSpacing),
                               child: new Column(
                                   children: this._parseNodeList(node.ChildNodes),
                                   crossAxisAlignment: CrossAxisAlignment.center
                                   )));

                case "font":
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "footer":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "h1":
                    return(DefaultTextStyle.merge(
                               child: new Container(
                                   width: this.width,
                                   child: new Wrap(
                                       crossAxisAlignment: WrapCrossAlignment.center,
                                       children: this._parseNodeList(node.ChildNodes)
                                       )
                                   ),
                               style: new TextStyle(
                                   fontSize: 28.0f,
                                   fontWeight: FontWeight.bold
                                   )
                               ));

                case "h2":
                    return(DefaultTextStyle.merge(
                               child: new Container(
                                   width: this.width,
                                   child: new Wrap(
                                       crossAxisAlignment: WrapCrossAlignment.center,
                                       children: this._parseNodeList(node.ChildNodes)
                                       )
                                   ),
                               style: new TextStyle(
                                   fontSize: 21.0f,
                                   fontWeight: FontWeight.bold
                                   )
                               ));

                case "h3":
                    return(DefaultTextStyle.merge(
                               child: new Container(
                                   width: this.width,
                                   child: new Wrap(
                                       crossAxisAlignment: WrapCrossAlignment.center,
                                       children: this._parseNodeList(node.ChildNodes)
                                       )
                                   ),
                               style: new TextStyle(
                                   fontSize: 16.0f,
                                   fontWeight: FontWeight.bold
                                   )
                               ));

                case "h4":
                    return(DefaultTextStyle.merge(
                               child: new Container(
                                   width: this.width,
                                   child: new Wrap(
                                       crossAxisAlignment: WrapCrossAlignment.center,
                                       children: this._parseNodeList(node.ChildNodes)
                                       )
                                   ),
                               style: new TextStyle(
                                   fontSize: 14.0f,
                                   fontWeight: FontWeight.bold
                                   )
                               ));

                case "h5":
                    return(DefaultTextStyle.merge(
                               child: new Container(
                                   width: this.width,
                                   child: new Wrap(
                                       crossAxisAlignment: WrapCrossAlignment.center,
                                       children: this._parseNodeList(node.ChildNodes)
                                       )
                                   ),
                               style: new TextStyle(
                                   fontSize: 12.0f,
                                   fontWeight: FontWeight.bold
                                   )
                               ));

                case "h6":
                    return(DefaultTextStyle.merge(
                               child: new Container(
                                   width: this.width,
                                   child: new Wrap(
                                       crossAxisAlignment: WrapCrossAlignment.center,
                                       children: this._parseNodeList(node.ChildNodes)
                                       )
                                   ),
                               style: new TextStyle(
                                   fontSize: 10.0f,
                                   fontWeight: FontWeight.bold
                                   )
                               ));

                case "header":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "hr":
                    return(new Padding(
                               padding: EdgeInsets.only(top: 7.0f, bottom: 7.0f),
                               child: new Divider(height: 1.0f, color: Colors.black38)
                               ));

                case "i":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontStyle: FontStyle.italic
                                   )
                               ));

                case "img":
                    return(new Builder(
                               builder: (BuildContext context) => {
                        if (this.showImages)
                        {
                            if (node.Attributes["src"] != null)
                            {
                                if (node.Attributes["src"].Value.StartsWith("data:image") &&
                                    node.Attributes["src"].Value.Contains("base64,"))
                                {
                                    return Image.memory(Convert.FromBase64String(
                                                            node.Attributes["src"].Value.Split(new string[] { "base64," },
                                                                                               StringSplitOptions.None)[1].Trim()));
                                }

                                return Image.network(node.Attributes["src"].Value);
                            }
                            else if (node.Attributes["alt"] != null)
                            {
                                //Temp fix for https://github.com/flutter/flutter/issues/736
                                if (node.Attributes["alt"].Value.EndsWith(" "))
                                {
                                    return new Container(
                                        padding: EdgeInsets.only(right: 2.0f),
                                        child: new Text(node.Attributes["alt"].Value));
                                }
                                else
                                {
                                    return new Text(node.Attributes["alt"].Value);
                                }
                            }
                        }

                        return new Container();
                    }
                               ));

                case "ins":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   decoration: TextDecoration.underline
                                   )
                               ));

                case "kbd":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontFamily: "monospace"
                                   )
                               ));

                case "li":
                    string     type        = node.ParentNode.Name; // Parent type; usually ol or ul
                    EdgeInsets markPadding = EdgeInsets.symmetric(horizontal: 4.0f);
                    Widget     mark;
                    switch (type)
                    {
                    case "ul":
                        mark = new Container(child: new Text("•"), padding: markPadding);
                        break;

                    case "ol":
                        int index = node.ParentNode.ChildNodes.IndexOf(node) + 1;
                        mark = new Container(child: new Text($"{index}."), padding: markPadding);
                        break;

                    default:         //Fallback to middle dot
                        mark = new Container(width: 0.0f, height: 0.0f);
                        break;
                    }

                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: new List <Widget> {
                        mark,
                        new Wrap(
                            crossAxisAlignment: WrapCrossAlignment.center,
                            children: this._parseNodeList(node.ChildNodes))
                    }
                                   )
                               ));

                case "main":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "mark":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   color: Colors.black,
                                   background: this._getPaint(Colors.yellow)
                                   )
                               ));

                case "nav":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "noscript":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   alignment: WrapAlignment.start,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "ol":
                    return(new Column(
                               children: this._parseNodeList(node.ChildNodes),
                               crossAxisAlignment: CrossAxisAlignment.start
                               ));

                case "p":
                    return(new Padding(
                               padding: EdgeInsets.only(top: this.blockSpacing, bottom: this.blockSpacing),
                               child: new Container(
                                   width: this.width,
                                   child: new Wrap(
                                       crossAxisAlignment: WrapCrossAlignment.center,
                                       alignment: WrapAlignment.start,
                                       children: this._parseNodeList(node.ChildNodes)
                                       )
                                   )
                               ));

                case "pre":
                    return(new Padding(
                               padding: EdgeInsets.all(this.blockSpacing),
                               child: DefaultTextStyle.merge(
                                   child: new Text(node.InnerHtml),
                                   style: new TextStyle(
                                       fontFamily: "monospace"
                                       )
                                   )
                               ));

                case "q":
                    List <Widget> children = new List <Widget>();
                    children.Add(new Text("\""));
                    children.AddRange(this._parseNodeList(node.ChildNodes));
                    children.Add(new Text("\""));
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: children
                                   ),
                               style: new TextStyle(
                                   fontStyle: FontStyle.italic
                                   )
                               ));

                case "rp":
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "rt":
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "ruby":
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "s":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   decoration: TextDecoration.lineThrough
                                   )
                               ));

                case "samp":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontFamily: "monospace"
                                   )
                               ));

                case "section":
                    return(new Container(
                               width: this.width,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "small":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontSize: 10.0f
                                   )
                               ));

                case "span":
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "strike":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   decoration: TextDecoration.lineThrough
                                   )
                               ));

                case "strong":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontWeight: FontWeight.bold
                                   )
                               ));

                case "sub":
                case "sup":
                    //Use builder to capture the parent font to inherit the font styles
                    return(new Builder(builder: (BuildContext context) => {
                        DefaultTextStyle parent = DefaultTextStyle.of(context);
                        TextStyle parentStyle = parent.style;

                        var painter = new TextPainter(
                            text: new TextSpan(
                                text: node.InnerText,
                                style: parentStyle
                                ),
                            textDirection: TextDirection.ltr);
                        painter.layout();
                        //print(painter.size);

                        //Get the height from the default text
                        var height = painter.size.height *
                                     1.35f;     //compute a higher height for the text to increase the offset of the Positioned text

                        painter = new TextPainter(
                            text: new TextSpan(
                                text: node.InnerText,
                                style: parentStyle.merge(new TextStyle(
                                                             fontSize:
                                                             parentStyle.fontSize * RichTextParserUtils.OFFSET_TAGS_FONT_SIZE_FACTOR))
                                ),
                            textDirection: TextDirection.ltr);
                        painter.layout();
                        //print(painter.size);

                        //Get the width from the reduced/positioned text
                        var width = painter.size.width;

                        //print("Width: $width, Height: $height");

                        return DefaultTextStyle.merge(
                            child: new Wrap(
                                crossAxisAlignment: WrapCrossAlignment.center,
                                children: new List <Widget> {
                            new Stack(
                                fit: StackFit.loose,
                                children: new List <Widget> {
                                //The Stack needs a non-positioned object for the next widget to respect the space so we create
                                //a sized box to fill the required space
                                new SizedBox(
                                    width: width,
                                    height: height
                                    ),
                                DefaultTextStyle.merge(
                                    child: new Positioned(
                                        child: new Wrap(children: this._parseNodeList(node.ChildNodes)),
                                        bottom: node.Name == "sub" ? 0 : (int?)null,
                                        top: node.Name == "sub" ? (int?)null : 0
                                        ),
                                    style: new TextStyle(
                                        fontSize: parentStyle.fontSize *
                                        RichTextParserUtils.OFFSET_TAGS_FONT_SIZE_FACTOR)
                                    )
                            }
                                )
                        }
                                )
                            );
                    }));

                case "table":
                    return(new Column(
                               children: this._parseNodeList(node.ChildNodes),
                               crossAxisAlignment: CrossAxisAlignment.start
                               ));

                case "tbody":
                    return(new Column(
                               children: this._parseNodeList(node.ChildNodes),
                               crossAxisAlignment: CrossAxisAlignment.start
                               ));

                case "td":
                    int colspan = 1;
                    if (node.Attributes["colspan"] != null)
                    {
                        int.TryParse(node.Attributes["colspan"].Value, out colspan);
                    }

                    return(new Expanded(
                               flex: colspan,
                               child: new Wrap(
                                   crossAxisAlignment: WrapCrossAlignment.center,
                                   children: this._parseNodeList(node.ChildNodes)
                                   )
                               ));

                case "template":
                    //Not usually displayed in HTML
                    return(new Container());

                case "tfoot":
                    return(new Column(
                               children: this._parseNodeList(node.ChildNodes),
                               crossAxisAlignment: CrossAxisAlignment.start
                               ));

                case "th":
                    int _colspan = 1;
                    if (node.Attributes["colspan"] != null)
                    {
                        int.TryParse(node.Attributes["colspan"].Value, out _colspan);
                    }

                    return(DefaultTextStyle.merge(
                               child: new Expanded(
                                   flex: _colspan,
                                   child: new Wrap(
                                       crossAxisAlignment: WrapCrossAlignment.center,
                                       alignment: WrapAlignment.center,
                                       children: this._parseNodeList(node.ChildNodes)
                                       )
                                   ),
                               style: new TextStyle(
                                   fontWeight: FontWeight.bold
                                   )
                               ));

                case "thead":
                    return(new Column(
                               children: this._parseNodeList(node.ChildNodes),
                               crossAxisAlignment: CrossAxisAlignment.start
                               ));

                case "time":
                    return(new Wrap(
                               children: this._parseNodeList(node.ChildNodes)
                               ));

                case "tr":
                    return(new Row(
                               children: this._parseNodeList(node.ChildNodes),
                               crossAxisAlignment: CrossAxisAlignment.center
                               ));

                case "tt":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontFamily: "monospace"
                                   )
                               ));

                case "u":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   decoration: TextDecoration.underline
                                   )
                               ));

                case "ul":
                    return(new Column(
                               children: this._parseNodeList(node.ChildNodes),
                               crossAxisAlignment: CrossAxisAlignment.start
                               ));

                case "var":
                    return(DefaultTextStyle.merge(
                               child: new Wrap(
                                   children: this._parseNodeList(node.ChildNodes)
                                   ),
                               style: new TextStyle(
                                   fontStyle: FontStyle.italic
                                   )
                               ));
                }
            }
            else if (node.NodeType is HtmlNodeType.Text)
            {
                //We don't need to worry about rendering extra whitespace
                if (node.InnerText.Trim() == "" && node.InnerText.IndexOf(" ") == -1)
                {
                    return(new Wrap());
                }

                if (node.InnerText.Trim() == "" && node.InnerText.IndexOf(" ") != -1)
                {
                    (node as HtmlTextNode).Text = " ";
                }

                string finalText = this.trimStringHtml(node.InnerText);
                //Temp fix for https://github.com/flutter/flutter/issues/736
                if (finalText.EndsWith(" "))
                {
                    return(new Container(
                               padding: EdgeInsets.only(right: 2.0f), child: new Text(finalText)));
                }
                else
                {
                    return(new Text(finalText));
                }
            }

            return(new Wrap());
        }
Esempio n. 21
0
            public override Widget build(BuildContext context)
            {
                var card = new Container(
                    margin: EdgeInsets.only(right: 45),
                    child: new Container(
                        child: new Column(
                            children: new List <Widget> {
                    new Container(
                        decoration: new BoxDecoration(
                            color: CLColors.white,
                            borderRadius: BorderRadius.only(topLeft: 3, topRight: 3)
                            ),
                        width: 200,
                        height: 124,
                        child: Image.network(
                            this.imageSrc,
                            fit: BoxFit.fill
                            )
                        ),
                    new Container(
                        color: CLColors.white,
                        width: 200,
                        height: 86,
                        padding: EdgeInsets.fromLTRB(14, 12, 14, 8),
                        child: new Column(
                            crossAxisAlignment: CrossAxisAlignment.baseline,
                            children: new List <Widget> {
                        new Container(
                            height: 18,
                            padding: EdgeInsets.only(top: 3),
                            child:
                            new Text(this.category,
                                     style: new TextStyle(
                                         fontSize: 11,
                                         color: CLColors.text5
                                         )
                                     )
                            ),
                        new Container(
                            height: 20,
                            padding: EdgeInsets.only(top: 2),
                            child:
                            new Text(this.name,
                                     style: new TextStyle(
                                         fontSize: 14,
                                         color: CLColors.text6
                                         )
                                     )
                            ),
                        new Container(
                            height: 22,
                            padding: EdgeInsets.only(top: 4),
                            child: new Row(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: new List <Widget> {
                            new Container(
                                child: new Row(
                                    children: new List <Widget> {
                                new Container(
                                    margin: EdgeInsets.only(right: 10),
                                    child: new Text(
                                        "$" + this.price,
                                        style: new TextStyle(
                                            fontSize: 14,
                                            color: CLColors.text7,
                                            decoration: TextDecoration.lineThrough
                                            )
                                        )
                                    ),
                                new Container(
                                    child: new Text(
                                        "$" + this.priceDiscount,
                                        style: new TextStyle(
                                            fontSize: 14,
                                            color: CLColors.text8
                                            )
                                        )
                                    )
                            })
                                ),
                            this.showBadge
                                                            ? new Container(
                                width: 80,
                                height: 18,
                                color: CLColors.black,
                                child: new Row(
                                    mainAxisAlignment: MainAxisAlignment.center,
                                    crossAxisAlignment: CrossAxisAlignment.center,
                                    children: new List <Widget> {
                                new Text(
                                    "Plus/Pro",
                                    style: new TextStyle(
                                        fontSize: 11,
                                        color: CLColors.white
                                        )
                                    )
                            }
                                    )
                                )
                                                            : new Container()
                        }
                                )
                            )
                    }
                            )
                        )
                }
                            )
                        )
                    );

                return(card);
            }
Esempio n. 22
0
        Widget _buildBlogger(User user, string resetTitle)
        {
            UserType userType = UserType.unFollow;

            if (!this.isLoggedIn)
            {
                userType = UserType.unFollow;
            }
            else
            {
                if (UserInfoManager.getUserInfo().userId == user.id)
                {
                    userType = UserType.me;
                }
                else if (user.followUserLoading ?? false)
                {
                    userType = UserType.loading;
                }
                else if (this.followMap.ContainsKey(key: user.id))
                {
                    userType = UserType.follow;
                }
            }

            return(new GestureDetector(
                       onTap: () => this.onPressItem?.Invoke(text: user.id),
                       child: new Container(
                           width: 160,
                           margin: EdgeInsets.all(6),
                           decoration: new BoxDecoration(
                               color: CColors.White,
                               borderRadius: BorderRadius.all(6),
                               boxShadow: new List <BoxShadow> {
                new BoxShadow(
                    CColors.Black.withOpacity(0.08f),
                    blurRadius: 10,
                    spreadRadius: 1.0f
                    )
            }
                               ),
                           child: new ClipRRect(
                               borderRadius: BorderRadius.all(6),
                               child: new Column(
                                   children: new List <Widget> {
                new Container(
                    height: 88,
                    color: CColorUtils.GetSpecificDarkColorFromId(id: user.id),
                    child: new Stack(
                        fit: StackFit.expand,
                        children: new List <Widget> {
                    user.coverImage.isNotEmpty()
                                                ? Image.network(user.coverImage, fit: BoxFit.fill)
                                                : Image.asset(
                        "image/blogger-avatar-pattern",
                        fit: BoxFit.fill
                        ),
                    Positioned.fill(
                        new Center(
                            child: Avatar.User(user: user, 64, true)
                            )
                        )
                }
                        )
                    ),
                new Padding(
                    padding: EdgeInsets.only(16, 16, 16, 4),
                    child: new Text(data: user.fullName, style: CTextStyle.PXLargeMedium, maxLines: 1)
                    ),
                new Text(
                    $"粉丝{user.followCount ?? 0} • 文章{user.articleCount ?? 0}",
                    style: CTextStyle.PSmallBody4
                    ),
                new Text(resetTitle ?? "", style: CTextStyle.PSmallBody4),
                new Padding(
                    padding: EdgeInsets.only(top: 12),
                    child: new FollowButton(
                        userType: userType,
                        () => this._onFollow(userType: userType, userId: user.id)
                        )
                    )
            }
                                   )
                               )
                           )
                       ));
        }
            Widget _buildImage(string src)
            {
                string[] parts = src.Split('#');
                if (parts.isEmpty()) return SizedBox.expand();

                string path = parts.first();
                float? width = null, height = null;
                if (parts.Length == 2)
                {
                    var dimensions = parts.last().Split('x');
                    if (dimensions.Length == 2)
                    {
                        width = float.Parse(dimensions[0]);
                        height = float.Parse(dimensions[1]);
                    }
                }

                Uri uri;
                Widget child = null;
                if (Uri.TryCreate(src, UriKind.RelativeOrAbsolute, out uri) && uri.IsAbsoluteUri)
                {
                    if (uri.Scheme == "http" || uri.Scheme == "https")
                    {
                        child = Image.network(src: uri.ToString(), scale: 1, width: width, height: height);
                    }
                    else if (uri.Scheme == "data")
                    {
                        child = _handleDataSchemeUri(uri, width, height);
                    }
                    else if (uri.Scheme == "resource")
                    {
                        child = Image.asset(path.Substring(9), scale: 1, width: width, height: height);
                    }
                    else if (uri.Scheme == "file")
                    {
                        child = Image.file(file: uri.ToString(), scale: 1, width: width, height: height);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(imageDirectory))
                    {
                        if (imageDirectory.StartsWith("http"))
                        {
                            uri = new Uri(new Uri(imageDirectory), uri);
                            child = Image.network(src: uri.ToString(), scale: 1, width: width, height: height);
                        }
                        else
                        {
                            child = Image.file(file: System.IO.Path.Combine(imageDirectory, uri.ToString()), scale: 1, width: width, height: height);
                        }
                    }
                    else
                    {
                        child = Image.file(file: uri.ToString(), scale: 1, width: width, height: height);
                    }
                }

                if (_linkHandlers.isNotEmpty())
                {
                    TapGestureRecognizer recognizer = _linkHandlers.last() as TapGestureRecognizer;
                    return new GestureDetector(null, child, null, null, recognizer.onTap);
                }
                else
                {
                    return child;
                }
            }