Esempio n. 1
0
        Widget _buildHeadImage(BuildContext context)
        {
            if (!this.isShowImage)
            {
                return(new Container());
            }

            var imageUrl    = this.eventObj.avatar ?? "";
            var aspectRatio = 16.0f / 9;

            if (Application.platform != RuntimePlatform.Android)
            {
                aspectRatio = 3f / 2;
            }

            return(new Container(
                       child: new AspectRatio(
                           aspectRatio: aspectRatio,
                           child: new PlaceholderImage(
                               imageUrl.EndsWith(".gif")
                            ? imageUrl
                            : CImageUtils.SuitableSizeImageUrl(MediaQuery.of(context).size.width, imageUrl),
                               fit: BoxFit.cover
                               )
                           )
                       ));
        }
        Widget _buildArticleInfo()
        {
            const float imageWidth   = 100;
            const float imageHeight  = 66;
            const float borderRadius = 4;
            var         imageUrl     = this.article.thumbnail.url.EndsWith(".gif")
                ? this.article.thumbnail.url
                : CImageUtils.SuitableSizeImageUrl(imageWidth: imageWidth, imageUrl: this.article.thumbnail.url);

            return(new Container(
                       padding: EdgeInsets.only(16, 10, 16),
                       child: new Column(
                           crossAxisAlignment: CrossAxisAlignment.start,
                           children: new List <Widget> {
                new Text(
                    data: this.article.title,
                    style: CTextStyle.H5,
                    maxLines: 2,
                    overflow: TextOverflow.ellipsis
                    ),
                new Container(
                    margin: EdgeInsets.only(top: 10),
                    child: new Row(
                        children: new List <Widget> {
                    new Expanded(
                        child: new Container(
                            height: imageHeight,
                            child: new Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: new List <Widget> {
                        new Text(
                            data: this.article.subTitle,
                            style: CTextStyle.PRegularBody3,
                            maxLines: 3,
                            overflow: TextOverflow.ellipsis
                            )
                    }
                                )
                            )
                        ),
                    new Container(
                        margin: EdgeInsets.only(8),
                        child: new PlaceholderImage(
                            imageUrl: imageUrl,
                            width: imageWidth,
                            height: imageHeight,
                            borderRadius: borderRadius,
                            fit: BoxFit.cover,
                            color: CColorUtils.GetSpecificDarkColorFromId(id: this.article.id)
                            )
                        )
                }
                        )
                    )
            }
                           )
                       ));
        }
Esempio n. 3
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. 4
0
        public override Widget build(BuildContext context)
        {
            if (this.article == null)
            {
                return(new Container());
            }

            const float imageWidth   = 100;
            const float imageHeight  = 66;
            const float borderRadius = 4;

            var time         = this.article.publishedTime;
            var thumbnailUrl = this.article.thumbnail?.url ?? "";
            var imageUrl     = thumbnailUrl.EndsWith(".gif")
                ? thumbnailUrl
                : CImageUtils.SuitableSizeImageUrl(imageWidth: imageWidth, imageUrl: thumbnailUrl);
            var card = new Container(
                color: CColors.White,
                padding: EdgeInsets.only(top: 16),
                child: new Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: new List <Widget> {
                new Container(
                    padding: EdgeInsets.symmetric(horizontal: 16),
                    child: new Text(
                        data: this.article.title,
                        style: CTextStyle.H5,
                        maxLines: 2,
                        textAlign: TextAlign.left,
                        overflow: TextOverflow.ellipsis
                        )
                    ),
                new Container(
                    margin: EdgeInsets.only(top: 8, bottom: 8),
                    padding: EdgeInsets.symmetric(horizontal: 16),
                    child: new Row(
                        children: new List <Widget> {
                    new Expanded(
                        child: new Container(
                            height: imageHeight,
                            child: new Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: new List <Widget> {
                        new Text(
                            data: this.article.subTitle,
                            style: CTextStyle.PRegularBody2,
                            maxLines: 3,
                            overflow: TextOverflow.ellipsis
                            )
                    }
                                )
                            )
                        ),
                    new Container(
                        margin: EdgeInsets.only(8.0f),
                        child: new PlaceholderImage(
                            imageUrl: imageUrl,
                            width: imageWidth,
                            height: imageHeight,
                            borderRadius: borderRadius,
                            fit: BoxFit.cover,
                            true
                            )
                        )
                }
                        )
                    ),
                new Container(
                    height: 36,
                    child: new Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: new List <Widget> {
                    new Expanded(
                        child: new Container(
                            height: 20,
                            padding: EdgeInsets.only(16),
                            alignment: Alignment.topLeft,
                            child: new ArticleCardInfo(
                                fullName: this.fullName,
                                time: time,
                                viewCount: this.article.viewCount
                                )
                            )
                        ),
                    new CustomButton(
                        padding: EdgeInsets.only(16, right: 16, bottom: 16),
                        child: new Icon(
                            icon: Icons.ellipsis,
                            size: 20,
                            color: CColors.BrownGrey
                            ),
                        onPressed: this.moreCallBack
                        )
                }
                        )
                    )
            }
                    )
                );

            return(new GestureDetector(
                       child: card,
                       onTap: this.onTap
                       ));
        }
Esempio n. 5
0
        public override Widget build(BuildContext context)
        {
            if (this.model == null)
            {
                return(new Container());
            }

            const float imageWidth   = 114;
            const float imageHeight  = 76;
            const float borderRadius = 4;

            var gap        = this.topPadding ? 16 : 0;
            var time       = Convert.ToDateTime(this.model.begin.startTime);
            var hour       = $"{time.Hour.ToString().PadLeft(2, '0')}";
            var minute     = $"{time.Minute.ToString().PadLeft(2, '0')}";
            var hourMinute = $"{hour}:{minute}";
            var address    = this.place ?? "";
            var imageUrl   = this.model.avatar ?? this.model.background;
            var card       = new Container(
                height: 108 + gap,
                padding: EdgeInsets.only(16, 16 + gap, 16, 16),
                color: CColors.White,
                child: new Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: new List <Widget> {
                new Container(
                    width: 32,
                    margin: EdgeInsets.only(right: 10),
                    child: new Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: new List <Widget> {
                    new Text(
                        time.Day.ToString(),
                        style: new TextStyle(
                            height: 1.33f,
                            fontSize: 24,
                            fontFamily: "Roboto-Bold",
                            color: CColors.SecondaryPink
                            )
                        ),
                    new Text(
                        $"{time.Month.ToString()}月",
                        style: CTextStyle.CaptionBody
                        )
                }
                        )
                    ),
                new Expanded(
                    child: new Container(
                        margin: EdgeInsets.only(right: 8),
                        child: new Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget> {
                    new Container(
                        margin: EdgeInsets.only(bottom: 8),
                        child: new Text(this.model.title,
                                        style: CTextStyle.PLargeMedium,
                                        maxLines: 2,
                                        overflow: TextOverflow.ellipsis
                                        )
                        ),
                    new Text(this.model.mode == "online"
                                                ? $"{hourMinute} · {this.model.participantsCount}人已预订"
                                                : $"{hourMinute}  · {address}",
                             style: CTextStyle.PSmallBody3
                             )
                }
                            )
                        )
                    ),
                new Container(
                    child: new Stack(
                        children: new List <Widget> {
                    new PlaceholderImage(
                        imageUrl.EndsWith(".gif")
                                            ? imageUrl
                                            : CImageUtils.SuitableSizeImageUrl(imageWidth, imageUrl),
                        imageWidth,
                        imageHeight,
                        borderRadius,
                        BoxFit.cover
                        ),
                    new Positioned(
                        bottom: 0,
                        right: 0,
                        child: new ClipRRect(
                            borderRadius: BorderRadius.only(bottomRight: 4),
                            child: new Container(
                                width: 41,
                                height: 24,
                                color: this.model.mode == "online"
                                                    ? CColors.SecondaryPink
                                                    : CColors.PrimaryBlue,
                                alignment: Alignment.center,
                                child: new Text(this.model.mode == "online" ? "线上" : "线下",
                                                style: CTextStyle.CaptionWhite,
                                                textAlign: TextAlign.center
                                                )
                                )
                            )
                        )
                }
                        )
                    )
            }
                    )
                );

            return(new GestureDetector(
                       child: card,
                       onTap: this.onTap
                       ));
        }
Esempio n. 6
0
        public override Widget build(BuildContext context)
        {
            if (this.images.isNullOrEmpty())
            {
                return(new Container());
            }

            Widget firstImage;

            if (this.images.Count > 0)
            {
                firstImage = new PlaceholderImage(
                    CImageUtils.SuitableSizeImageUrl(
                        imageWidth: MediaQuery.of(context: context).size.width,
                        this.images[0]
                        ),
                    this.size + this.ratioGap * 2,
                    this.size + this.ratioGap * 2,
                    6,
                    fit: BoxFit.cover,
                    true,
                    CColorUtils.GetSpecificDarkColorFromId(this.images[0])
                    );
            }
            else
            {
                firstImage = new Container();
            }

            Widget secondImage;

            if (this.images.Count > 1)
            {
                secondImage = this.onlyShowFirst
                    ? (Widget) new Container(
                    width: this.size + this.ratioGap * 2,
                    height: this.size + this.ratioGap * 2,
                    decoration: new BoxDecoration(borderRadius: BorderRadius.all(6),
                                                  color: Color.fromRGBO(207, 213, 219, 1))
                    )
                    : new PlaceholderImage(
                    CImageUtils.SuitableSizeImageUrl(
                        imageWidth: MediaQuery.of(context: context).size.width,
                        this.images[1]
                        ),
                    this.size + this.ratioGap,
                    this.size + this.ratioGap,
                    6,
                    fit: BoxFit.cover,
                    true,
                    CColorUtils.GetSpecificDarkColorFromId(this.images[1])
                    );
            }
            else
            {
                secondImage = new Container();
            }

            Widget thirdImage;

            if (this.images.Count > 2)
            {
                thirdImage = this.onlyShowFirst
                    ? (Widget) new Container(
                    width: this.size + this.ratioGap * 2,
                    height: this.size + this.ratioGap * 2,
                    decoration: new BoxDecoration(borderRadius: BorderRadius.all(6),
                                                  color: Color.fromRGBO(137, 150, 165, 1))
                    )
                    : new PlaceholderImage(
                    CImageUtils.SuitableSizeImageUrl(
                        imageWidth: MediaQuery.of(context: context).size.width,
                        this.images[2]
                        ),
                    width: this.size,
                    height: this.size,
                    6,
                    fit: BoxFit.cover,
                    true,
                    CColorUtils.GetSpecificDarkColorFromId(this.images[2])
                    );
            }
            else
            {
                thirdImage = new Container();
            }

            return(new Container(
                       width: this.size + this.ratioGap * 2 + this.horizontalGap * (this.images.Count - 1),
                       height: this.size + this.ratioGap * 2 + this.verticalGap * (this.images.Count - 1),
                       child: new Stack(
                           children: new List <Widget> {
                new Positioned(
                    right: 0,
                    bottom: 0,
                    child: thirdImage
                    ),
                new Positioned(
                    right: this.horizontalGap,
                    bottom: this.verticalGap,
                    child: secondImage
                    ),
                new Positioned(
                    left: 0,
                    top: 0,
                    child: firstImage
                    )
            }
                           )
                       ));
        }
Esempio n. 7
0
        static Widget _Atomic(BuildContext context, string type, string contentType, string title,
                              _OriginalImage originalImage,
                              string url, string downloadUrl, Action <string> openUrl, Action <string> playVideo,
                              Action 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: new CustomButton(
                            onPressed: () => {
                    if (type == "ATTACHMENT")
                    {
                        playVideo($"{downloadUrl}?noLoginRequired=true");
                    }
                    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
                                    )
                                )
                            )
                        )
                    );
            }

            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
                            ),
                        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);
            }

            var nodes = new List <Widget> {
                new Stack(
                    children: new List <Widget> {
                    new GestureDetector(
                        child: new PlaceholderImage(
                            imageUrl,
                            width,
                            height,
                            fit: BoxFit.cover
                            ), onTap: () => {
                        if (browserImage != null)
                        {
                            browserImage();
                        }
                    }),

                    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
                               )
                           )
                       ));
        }
        public override Widget build(BuildContext context)
        {
            if (this.article == null)
            {
                return(new Container());
            }

            const float imageWidth   = 114;
            const float imageHeight  = 76;
            const float borderRadius = 4;

            var time         = this.article.publishedTime;
            var thumbnailUrl = this.article.thumbnail?.url ?? "";
            var imageUrl     = thumbnailUrl.EndsWith(".gif")
                ? thumbnailUrl
                : CImageUtils.SuitableSizeImageUrl(imageWidth: imageWidth, imageUrl: thumbnailUrl);
            var child = new Container(
                color: CColors.White,
                padding: EdgeInsets.all(16),
                height: 108,
                child: new Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: new List <Widget> {
                new Expanded(
                    child: new Container(
                        child: new Column(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget> {
                    new Text(
                        data: this.article.title,
                        style: CTextStyle.PLargeTitle,
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis,
                        textAlign: TextAlign.left
                        ),
                    new ArticleCardInfo(
                        fullName: this.fullName,
                        time: time,
                        viewCount: this.article.viewCount
                        )
                }
                            )
                        )
                    ),
                new Container(
                    margin: EdgeInsets.only(8),
                    child: new PlaceholderImage(
                        imageUrl: imageUrl,
                        width: imageWidth,
                        height: imageHeight,
                        borderRadius: borderRadius,
                        fit: BoxFit.cover
                        )
                    )
            }
                    )
                );

            return(new GestureDetector(
                       onTap: this.onTap,
                       child: child
                       ));
        }
Esempio n. 9
0
        public override Widget build(BuildContext context)
        {
            if (this.article == null)
            {
                return(new Container());
            }

            const float imageWidth   = 100;
            const float imageHeight  = 66;
            const float borderRadius = 4;

            var gap = 0f;

            if (this.topPadding)
            {
                gap = 16;
            }

            var time = this.article.lastPublishedTime == null
                ? this.article.publishedTime
                : this.article.lastPublishedTime;
            var imageUrl = this.article.thumbnail.url.EndsWith(".gif")
                ? this.article.thumbnail.url
                : CImageUtils.SuitableSizeImageUrl(imageWidth, this.article.thumbnail.url);
            var card = new Container(
                color: CColors.White,
                child: new Padding(
                    padding: EdgeInsets.only(16, 16 + gap, 16, 16),
                    child: new Container(
                        child: new Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget> {
                new Container(
                    child: new Text(this.article.title,
                                    style: CTextStyle.H5,
                                    maxLines: 2,
                                    textAlign: TextAlign.left,
                                    overflow: TextOverflow.ellipsis
                                    )
                    ),
                new Container(
                    margin: EdgeInsets.only(top: 8, bottom: 8),
                    child: new Row(
                        children: new List <Widget> {
                    new Expanded(
                        child: new Text(this.article.subTitle,
                                        style: CTextStyle.PRegularBody,
                                        maxLines: 3,
                                        overflow: TextOverflow.ellipsis
                                        )
                        ),
                    new Container(
                        margin: EdgeInsets.only(8.0f),
                        child: new PlaceholderImage(
                            imageUrl,
                            imageWidth,
                            imageHeight,
                            borderRadius,
                            BoxFit.cover
                            )
                        )
                }
                        )
                    ),
                new Container(
                    height: 20,
                    child: new Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: new List <Widget> {
                    new Expanded(
                        child: new ArticleCardInfo(
                            fullName: this.fullName,
                            time: time,
                            viewCount: this.article.viewCount
                            )
                        ),
                    new SizedBox(width: 16),
                    new GestureDetector(
                        child: new Container(
                            height: 20,
                            width: 20,
                            color: CColors.White,
                            child: new Icon(
                                Icons.ellipsis,
                                size: 20,
                                color: CColors.BrownGrey
                                )
                            ),
                        onTap: this.moreCallBack
                        )
                }
                        )
                    )
            }
                            )
                        )
                    )
                );

            return(new GestureDetector(
                       child: card,
                       onTap: this.onTap
                       ));
        }