Example #1
0
 Widget _buildLikeCountWidget()
 {
     return(!this.widget.showLikeCount
         ? new Container()
         : new Container(
                margin: EdgeInsets.only(4),
                child: new Text(
                    CStringUtils.CountToString(count: this._likeCount ?? 0, "点赞"),
                    style: CTextStyle.PRegularBody5.merge(new TextStyle(height: 1))
                    )
                ));
 }
Example #2
0
        public override Widget build(BuildContext context) {
            if (this.message == null) {
                return new Container();
            }

            var replyCount = this.message.parentMessageId.isNotEmpty()
                ? (this.message.lowerMessageIds ?? new List<string>()).Count
                : (this.message.replyMessageIds ?? new List<string>()).Count;
            return new Container(
                color: CColors.White,
                padding: EdgeInsets.only(16, 16, 16),
                child: new Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: new List<Widget> {
                        new GestureDetector(
                            onTap: () => this.pushToUserDetail(obj: this.message.author.id),
                            child: new Container(
                                height: 24,
                                margin: EdgeInsets.only(right: 8),
                                child: Avatar.User(user: this.message.author, 24)
                            )
                        ),
                        new Expanded(
                            child: new Container(
                                child: new Column(
                                    crossAxisAlignment: CrossAxisAlignment.start,
                                    children: new List<Widget> {
                                        this._buildCommentAvatarName(),
                                        this._buildCommentContent(),
                                        new Row(
                                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                            children: new List<Widget> {
                                                new Text(
                                                    $"{DateConvert.DateStringFromNonce(nonce: this.message.nonce)}",
                                                    style: CTextStyle.PSmallBody4
                                                ),
                                                new Container(
                                                    child: new Row(
                                                        children: new List<Widget> {
                                                            new GestureDetector(
                                                                onTap: this.praiseCallBack,
                                                                child: new Container(
                                                                    color: CColors.White,
                                                                    child: new Text(
                                                                        $"点赞 {CStringUtils.CountToString(count: this.message.reactions.Count)}",
                                                                        style: this.isPraised
                                                                            ? CTextStyle.PRegularBlue
                                                                            : CTextStyle.PRegularBody4
                                                                    )
                                                                )
                                                            ),
                                                            new GestureDetector(
                                                                onTap: this.replyCallBack,
                                                                child: new Container(
                                                                    margin: EdgeInsets.only(15),
                                                                    child: new Text(
                                                                        $"回复 {CStringUtils.CountToString(count: replyCount)}",
                                                                        style: CTextStyle.PRegularBody4
                                                                    )
                                                                )
                                                            )
                                                        }
                                                    )
                                                )
                                            }
                                        ),
                                        new Container(
                                            margin: EdgeInsets.only(top: 12),
                                            height: 1,
                                            color: CColors.Separator2
                                        )
                                    }
                                )
                            )
                        )
                    }
                )
            );
        }
Example #3
0
        Widget _buildBottom()
        {
            int articleLikeCount = 0;

            if (this.article.likeCount > 0)
            {
                articleLikeCount = this.article.likeCount;
            }

            return(new Container(
                       height: 56,
                       child: new Stack(
                           alignment: Alignment.center,
                           children: new List <Widget> {
                new Positioned(
                    left: 0,
                    child: new GestureDetector(
                        onTap: () => this.likeCallBack(),
                        child: new Container(
                            color: CColors.Transparent,
                            height: 56,
                            padding: EdgeInsets.only(16, right: 20),
                            child: new IgnorePointer(
                                child: new LikeButton.LikeButton(
                                    isLiked => new Icon(
                                        isLiked ? Icons.favorite : Icons.favorite_border,
                                        color: isLiked ? CColors.SecondaryPink : CColors.Icon,
                                        size: 24
                                        ),
                                    circleColor: new CircleColor(
                                        start: CColors.SecondaryPink,
                                        end: CColors.SecondaryPink
                                        ),
                                    likeCount: articleLikeCount,
                                    isLiked: this.isLike,
                                    size: 24,
                                    isShowBubbles: false,
                                    showLikeCount: true,
                                    likeButtonPadding: EdgeInsets.zero
                                    )
                                )
                            )
                        )
                    ),
                new Positioned(
                    left: 96,
                    child: new Container(
                        child: new GestureDetector(
                            onTap: this.commentCallBack,
                            child: new Container(
                                color: CColors.Transparent,
                                height: 56,
                                padding: EdgeInsets.only(right: 20),
                                child: new Row(
                                    children: new List <Widget> {
                    new Icon(icon: Icons.comment, size: 24, color: CColors.Icon),
                    new Container(
                        margin: EdgeInsets.only(6),
                        child: new Text(
                            CStringUtils.CountToString(count: this.article.commentCount, "评论"),
                            style: CTextStyle.PRegularBody5.merge(new TextStyle(height: 1))
                            )
                        )
                }
                                    )
                                )
                            )
                        )
                    ),
                new Align(
                    alignment: Alignment.centerRight,
                    child: new GestureDetector(
                        child: new Container(
                            color: CColors.Transparent,
                            height: 56,
                            padding: EdgeInsets.symmetric(horizontal: 16),
                            child: new Icon(
                                icon: Icons.ellipsis,
                                size: 20,
                                color: CColors.BrownGrey
                                )
                            ),
                        onTap: this.moreCallBack
                        )
                    )
            }
                           )
                       ));
        }
Example #4
0
        public override Widget build(BuildContext context)
        {
            Widget likeCountWidget;

            if (this.widget.totalLikeCount + this._likeCount > 0)
            {
                var totalLikeCount = CStringUtils.CountToString(this.widget.totalLikeCount + this._likeCount);
                likeCountWidget = new Text(
                    data: totalLikeCount,
                    style: new TextStyle(
                        fontSize: 12,
                        fontFamily: "Roboto-Regular",
                        color: CColors.Thumb
                        )
                    );
            }
            else
            {
                likeCountWidget = new Container();
            }

            return(new Stack(
                       fit: StackFit.expand,
                       children: new List <Widget> {
                this.widget.child,
                new AnimatedPositioned(
                    right: this.widget.isPullUp ? -24 : 16,
                    bottom: 24,
                    duration: TimeSpan.FromMilliseconds(200),
                    child: new GestureDetector(
                        onTap: () => {
                    if (this.widget.isPullUp)
                    {
                        return;
                    }

                    var isLoginIn = this.widget.boolCallback();
                    if (!isLoginIn)
                    {
                        return;
                    }
                    this._controller.reset();
                    this._controller.forward();
                    if (!this._like)
                    {
                        this.setState(() => this._like = true);
                    }
                    if (this._likeCount + this.widget.likeCount < 50)
                    {
                        this.setState(() => this._likeCount += 1);
                    }
                    if (this._lastDateTime == null)
                    {
                        this._lastDateTime = DateTime.Now;
                        this.setState(() => this._isLike = true);
                        this._startTimer();
                    }
                    else
                    {
                        var currentDateTime = DateTime.Now;
                        var ts = currentDateTime.Subtract((DateTime)this._lastDateTime);
                        if (ts.TotalMilliseconds <= likeTime)
                        {
                            this._startTimer();
                        }
                        this._lastDateTime = currentDateTime;
                    }
                },
                        child: new Opacity(
                            this.widget.isPullUp ? 0.5f : 1,
                            child: new ScaleTransition(
                                scale: this._scaleAnimation,
                                child: new Container(
                                    width: 48,
                                    height: 48,
                                    decoration: new BoxDecoration(
                                        color: CColors.White,
                                        borderRadius: BorderRadius.all(24),
                                        boxShadow: new List <BoxShadow> {
                    new BoxShadow(
                        CColors.Black.withOpacity(0.1f),
                        blurRadius: 8,
                        spreadRadius: 0,
                        offset: new Offset(0, 0))
                }
                                        ),
                                    child: new Column(
                                        mainAxisAlignment: MainAxisAlignment.center,
                                        children: new List <Widget> {
                    new Icon(
                        this.widget.like || this._like ? Icons.thumb_bold : Icons.thumb_line,
                        size: 24,
                        color: CColors.Thumb
                        ),
                    likeCountWidget
                }
                                        )
                                    )
                                )
                            )
                        )
                    ),
                new AnimatedPositioned(
                    child: new Opacity(
                        this._isLike ? 1 : 0,
                        child: new ScaleTransition(
                            scale: this._scaleAnimation,
                            alignment: Alignment.center,
                            child: new Container(
                                width: 32,
                                height: 32,
                                decoration: new BoxDecoration(
                                    color: CColors.Gerakdine,
                                    borderRadius: BorderRadius.all(16)
                                    ),
                                alignment: Alignment.center,
                                child: new Text(
                                    $"+{this._likeCount + this.widget.likeCount}",
                                    style: new TextStyle(
                                        fontSize: 12,
                                        fontFamily: "Roboto-Regular",
                                        color: CColors.White
                                        )
                                    )
                                )
                            )
                        ),
                    duration: TimeSpan.FromMilliseconds(134),
                    bottom: this._isLike ? 96 : 70,
                    right: 24,
                    curve: Curves.bounceOut
                    )
            }
                       ));
        }
        Widget _buildBottom()
        {
            int articleLikeCount = this.article.appLikeCount > 0 ? this.article.appLikeCount : 0;

            return(new Container(
                       height: 56,
                       child: new Stack(
                           alignment: Alignment.center,
                           children: new List <Widget> {
                new Positioned(
                    left: 0,
                    child: new GestureDetector(
                        onTap: () => this.likeCallBack(),
                        child: new Container(
                            color: CColors.Transparent,
                            height: 56,
                            padding: EdgeInsets.only(16, right: 20),
                            child: new IgnorePointer(
                                child: new Row(
                                    children: new List <Widget> {
                    new Container(
                        padding: EdgeInsets.only(bottom: 4),
                        child: new Icon(
                            this.isLike ? Icons.thumb_bold : Icons.thumb_line,
                            size: 24,
                            color: this.isLike ? CColors.Thumb : CColors.Icon
                            )
                        ),
                    new Container(
                        margin: EdgeInsets.only(6),
                        child: new Text(
                            CStringUtils.CountToString(count: articleLikeCount,
                                                       "点赞"),
                            style: CTextStyle.PRegularBody5.merge(new TextStyle(height: 1))
                            )
                        )
                }
                                    )
                                )
                            )
                        )
                    ),
                new Positioned(
                    left: 96,
                    child: new Container(
                        child: new GestureDetector(
                            onTap: this.commentCallBack,
                            child: new Container(
                                color: CColors.Transparent,
                                height: 56,
                                padding: EdgeInsets.only(right: 20),
                                child: new Row(
                                    children: new List <Widget> {
                    new Icon(icon: Icons.comment, size: 24, color: CColors.Icon),
                    new Container(
                        margin: EdgeInsets.only(6),
                        child: new Text(
                            CStringUtils.CountToString(count: this.article.commentCount,
                                                       "评论"),
                            style: CTextStyle.PRegularBody5.merge(new TextStyle(height: 1))
                            )
                        )
                }
                                    )
                                )
                            )
                        )
                    ),
                new Align(
                    alignment: Alignment.centerRight,
                    child: new GestureDetector(
                        child: new Container(
                            color: CColors.Transparent,
                            height: 56,
                            padding: EdgeInsets.symmetric(horizontal: 16),
                            child: new Icon(
                                icon: Icons.ellipsis,
                                size: 20,
                                color: CColors.BrownGrey
                                )
                            ),
                        onTap: this.moreCallBack
                        )
                    )
            }
                           )
                       ));
        }
        Widget _buildLoginInNavigationBar()
        {
            var    user = this.widget.viewModel.userDict[key : this.widget.viewModel.user.userId];
            Widget titleWidget;

            if (user.title != null && user.title.isNotEmpty())
            {
                titleWidget = new Container(
                    padding: EdgeInsets.only(top: 4),
                    child: new Text(
                        data: user.title,
                        style: new TextStyle(
                            fontSize: 14,
                            fontFamily: "Roboto-Regular",
                            color: CColors.Grey80
                            ),
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis
                        )
                    );
            }
            else
            {
                titleWidget = new Container();
            }

            return(new Stack(
                       children: new List <Widget> {
                new Container(
                    color: CColors.BgGrey,
                    padding: EdgeInsets.only(bottom: 56),
                    child: new GestureDetector(
                        onTap: () => this.widget.actionModel.pushToUserDetail(obj: user.id),
                        child: new Container(
                            padding: EdgeInsets.only(
                                top: CCommonUtils.getSafeAreaTopPadding(context: this.context)),
                            decoration: new BoxDecoration(
                                color: CColors.Black,
                                new DecorationImage(
                                    new AssetImage("image/default-background-cover"),
                                    fit: BoxFit.cover
                                    )
                                ),
                            child: new Column(
                                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                children: new List <Widget> {
                    this._buildQrScanWidget(true),
                    new Container(
                        padding: EdgeInsets.only(16, 16, 16, 64),
                        child: new Row(
                            children: new List <Widget> {
                        new Container(
                            margin: EdgeInsets.only(right: 12),
                            child: Avatar.User(
                                user: user,
                                64,
                                true
                                )
                            ),
                        new Expanded(
                            child: new Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: new List <Widget> {
                            new Row(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: new List <Widget> {
                                new Flexible(
                                    child: new Text(
                                        user.fullName ?? user.name,
                                        style: CTextStyle.H4White
                                        .defaultHeight(),
                                        maxLines: 1,
                                        overflow: TextOverflow.ellipsis
                                        )
                                    ),
                                CImageUtils.GenBadgeImage(
                                    badges: user.badges,
                                    CCommonUtils.GetUserLicense(
                                        userId: user.id,
                                        userLicenseMap: this.widget.viewModel
                                        .userLicenseDict
                                        ),
                                    EdgeInsets.only(4, 6)
                                    )
                            }
                                ),
                            titleWidget
                        }
                                )
                            ),
                        new Padding(
                            padding: EdgeInsets.symmetric(horizontal: 4),
                            child: new Text(
                                "个人主页",
                                style: new TextStyle(
                                    fontSize: 14,
                                    fontFamily: "Roboto-Regular",
                                    color: CColors.Grey80
                                    )
                                )
                            ),
                        new Icon(
                            icon: Icons.baseline_forward_arrow,
                            size: 16,
                            color: CColors.LightBlueGrey
                            )
                    }
                            )
                        )
                }
                                )
                            )
                        )
                    ),
                new Align(
                    alignment: Alignment.bottomCenter,
                    child: new Container(
                        margin: EdgeInsets.only(16, 0, 16, 16),
                        height: 80,
                        decoration: new BoxDecoration(
                            color: CColors.White,
                            borderRadius: BorderRadius.all(8),
                            boxShadow: new List <BoxShadow> {
                    new BoxShadow(
                        CColors.Black.withOpacity(0.2f),
                        blurRadius: 8
                        )
                }
                            ),
                        child: new Row(
                            children: new List <Widget> {
                    new Expanded(
                        child: new CustomButton(
                            onPressed: () => {
                        if (this.widget.viewModel.isLoggedIn && user.id.isNotEmpty())
                        {
                            this.widget.actionModel.pushToUserFollowing(arg1: user.id, 0);
                        }
                    },
                            child: new Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: new List <Widget> {
                        new Text(
                            CStringUtils.CountToString((user.followingUsersCount ?? 0) + (user.followingTeamsCount ?? 0), "0"),
                            style: CTextStyle.Bold20
                            ),
                        new Container(height: 4),
                        new Text(
                            "关注",
                            style: CTextStyle.PSmallBody3.defaultHeight()
                            )
                    }
                                )
                            )
                        ),
                    new Container(height: 32, width: 1, color: CColors.Separator.withOpacity(0.5f)),
                    new Expanded(
                        child: new CustomButton(
                            onPressed: () => {
                        if (this.widget.viewModel.isLoggedIn && user.id.isNotEmpty())
                        {
                            this.widget.actionModel.pushToUserFollower(obj: user.id);
                        }
                    },
                            child: new Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: new List <Widget> {
                        new Text(
                            CStringUtils.CountToString(user.followCount ?? 0, "0"),
                            style: CTextStyle.Bold20
                            ),
                        new Container(height: 4),
                        new Text(
                            "粉丝",
                            style: CTextStyle.PSmallBody3.defaultHeight()
                            )
                    }
                                )
                            )
                        ),
                    new Container(height: 32, width: 1, color: CColors.Separator.withOpacity(0.5f)),
                    new Expanded(
                        child: new CustomButton(
                            onPressed: () => {
                        // if (this.widget.viewModel.isLoggedIn && user.id.isNotEmpty()) {
                        //     this.widget.actionModel.pushToUserLike(obj: user.id);
                        // }
                    },
                            child: new Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: new List <Widget> {
                        new Text(
                            CStringUtils.CountToString(user.appArticleLikedCount ?? 0, "0"),
                            style: CTextStyle.Bold20
                            ),
                        new Container(height: 4),
                        new Text(
                            "赞",
                            style: CTextStyle.PSmallBody3.defaultHeight()
                            )
                    }
                                )
                            )
                        )
                }
                            )
                        )
                    )
            }
                       ));
        }