Пример #1
0
        List <Widget> _buildItems(BuildContext context, out int commentIndex)
        {
            var originItems = new List <Widget> {
                this._buildContentHead()
            };

            originItems.AddRange(
                ContentDescription.map(
                    context: context,
                    cont: this._article.body,
                    contentMap: this._article.contentMap,
                    this._article.videoSliceMap,
                    this._article.videoPosterMap,
                    openUrl: this.widget.actionModel.openUrl,
                    playVideo: this.widget.actionModel.playVideo,
                    this.widget.actionModel.pushToLogin,
                    UserInfoManager.isLogin()
                        ? CCommonUtils.GetUserLicense(UserInfoManager.initUserInfo().userId,
                                                      this.widget.viewModel.userLicenseDict)
                        : "",
                    this.widget.actionModel.browserImage
                    )
                );
            // originItems.Add(this._buildActionCards(this._article.like));
            originItems.Add(this._buildRelatedArticles());
            commentIndex = originItems.Count;
            originItems.AddRange(this._buildComments(context: context));

            return(originItems);
        }
        Widget _buildUserCard(BuildContext context, int index)
        {
            var followingUsers = this.widget.viewModel.followingUsers;

            var      followingUser = followingUsers[index : index];
            UserType userType      = UserType.unFollow;

            if (!this.widget.viewModel.isLoggedIn)
            {
                userType = UserType.unFollow;
            }
            else
            {
                bool followUserLoading;
                if (this.widget.viewModel.userDict.ContainsKey(key: followingUser.id))
                {
                    var user = this.widget.viewModel.userDict[key : followingUser.id];
                    followUserLoading = user.followUserLoading ?? false;
                }
                else
                {
                    followUserLoading = false;
                }

                if (this.widget.viewModel.currentUserId == followingUser.id)
                {
                    userType = UserType.me;
                }
                else if (followUserLoading)
                {
                    userType = UserType.loading;
                }
                else if (this.widget.viewModel.followMap.ContainsKey(key: followingUser.id))
                {
                    userType = UserType.follow;
                }
            }

            return(new UserCard(
                       user: followingUser,
                       CCommonUtils.GetUserLicense(userId: followingUser.id,
                                                   userLicenseMap: this.widget.viewModel.userLicenseDict),
                       () => this.widget.actionModel.pushToUserDetail(obj: followingUser.id),
                       userType: userType,
                       () => this._onFollow(userType: userType, userId: followingUser.id),
                       key: new ObjectKey(value: followingUser.id)
                       ));
        }
Пример #3
0
        Widget _buildUserCard(BuildContext context, int index)
        {
            var searchUserIds = this.widget.viewModel.searchUserIds;

            var searchUserId = searchUserIds[index : index];

            if (!this.widget.viewModel.userDict.ContainsKey(key: searchUserId))
            {
                return(new Container());
            }

            var      searchUser = this.widget.viewModel.userDict[key : searchUserId];
            UserType userType   = UserType.unFollow;

            if (!this.widget.viewModel.isLoggedIn)
            {
                userType = UserType.unFollow;
            }
            else
            {
                if (this.widget.viewModel.currentUserId == searchUser.id)
                {
                    userType = UserType.me;
                }
                else if (searchUser.followUserLoading ?? false)
                {
                    userType = UserType.loading;
                }
                else if (this.widget.viewModel.followMap.ContainsKey(key: searchUser.id))
                {
                    userType = UserType.follow;
                }
            }

            return(new UserCard(
                       user: searchUser,
                       CCommonUtils.GetUserLicense(userId: searchUser.id,
                                                   userLicenseMap: this.widget.viewModel.userLicenseDict),
                       () => this.widget.actionModel.pushToUserDetail(obj: searchUser.id),
                       userType: userType,
                       () => this._onFollow(userType: userType, userId: searchUser.id),
                       true,
                       new ObjectKey(value: searchUser.id)
                       ));
        }
Пример #4
0
        Widget _buildLecture(User host)
        {
            if (host == null)
            {
                return(new Container());
            }

            return(new Container(
                       padding: EdgeInsets.symmetric(horizontal: 16),
                       margin: EdgeInsets.only(bottom: 24),
                       color: CColors.White,
                       child: new Column(
                           crossAxisAlignment: CrossAxisAlignment.start,
                           children: new List <Widget> {
                new GestureDetector(
                    onTap: () => this.pushToUserDetail(obj: host.id),
                    child: new Row(
                        children: new List <Widget> {
                    new Container(
                        margin: EdgeInsets.only(right: 8),
                        child: Avatar.User(user: host, 48)
                        ),
                    new Flexible(
                        child: new Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget> {
                        new Row(
                            children: new List <Widget> {
                            new Flexible(
                                child: new Text(
                                    host.fullName ?? host.name ?? "",
                                    maxLines: 1,
                                    style: new TextStyle(
                                        color: CColors.TextBody,
                                        height: 1,
                                        fontFamily: "Roboto-Medium",
                                        fontSize: 16
                                        ),
                                    overflow: TextOverflow.ellipsis
                                    )
                                ),
                            CImageUtils.GenBadgeImage(
                                badges: host.badges,
                                CCommonUtils.GetUserLicense(
                                    userId: host.id,
                                    userLicenseMap: this.userLicenseDict
                                    ),
                                EdgeInsets.only(4)
                                )
                        }
                            ),
                        host.title.isNotEmpty()
                                                    ? new Container(
                            child: new Text(
                                data: host.title,
                                maxLines: 1,
                                overflow: TextOverflow.ellipsis,
                                style: CTextStyle.PRegularBody3
                                )
                            )
                                                    : new Container()
                    }
                            )
                        )
                }
                        )
                    ),
                new Container(
                    margin: EdgeInsets.only(top: 8),
                    child: new Text(
                        data: host.description,
                        style: new TextStyle(
                            color: CColors.TextBody3,
                            fontFamily: "Roboto-Regular",
                            fontSize: 16
                            )
                        )
                    )
            }
                           )
                       ));
        }
Пример #5
0
        Widget _buildContentHead()
        {
            var user = this.eventObj.user ?? new User();

            return(new Container(
                       padding: EdgeInsets.symmetric(horizontal: 16),
                       margin: EdgeInsets.only(top: 16, bottom: 20),
                       child: new Column(
                           crossAxisAlignment: CrossAxisAlignment.start,
                           children: new List <Widget> {
                new Text(
                    this.eventObj.title ?? "",
                    this.titleKey,
                    style: CTextStyle.H4
                    ),
                new Container(
                    margin: EdgeInsets.only(top: 20),
                    child: new Row(
                        children: new List <Widget> {
                    new Container(
                        margin: EdgeInsets.only(right: 8),
                        child: new GestureDetector(
                            onTap: () => this.pushToUserDetail(user.id),
                            child: Avatar.User(user, 32)
                            )
                        ),
                    new Expanded(
                        child: new Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: new List <Widget> {
                        new GestureDetector(
                            onTap: () => this.pushToUserDetail(user.id),
                            child: new Row(
                                children: new List <Widget> {
                            new Flexible(
                                child: new Text(
                                    user.fullName ?? user.name ?? "",
                                    style: CTextStyle.PMediumBody.merge(
                                        new TextStyle(height: 1)),
                                    maxLines: 1,
                                    overflow: TextOverflow.ellipsis
                                    )
                                ),
                            CImageUtils.GenBadgeImage(
                                badges: user.badges,
                                CCommonUtils.GetUserLicense(
                                    userId: user.id,
                                    userLicenseMap: this.userLicenseDict
                                    ),
                                EdgeInsets.only(4)
                                )
                        }
                                )
                            ),
                        new Text(
                            $"{DateConvert.DateStringFromNow(this.eventObj.createdTime ?? DateTime.Now)}发布",
                            style: CTextStyle.PSmallBody3
                            )
                    }
                            )
                        )
                }
                        )
                    )
            }
                           )
                       ));
        }
Пример #6
0
        Widget _buildTeamInfo(BuildContext context)
        {
            var team = this.widget.viewModel.team;

            return(new CoverImage(
                       coverImage: team.coverImage,
                       height: imageBaseHeight + CCommonUtils.getSafeAreaTopPadding(context: context),
                       new Container(
                           padding: EdgeInsets.only(16, 0, 16, 24),
                           child: new Column(
                               mainAxisAlignment: MainAxisAlignment.end,
                               children: new List <Widget> {
                new Row(
                    children: new List <Widget> {
                    new Container(
                        margin: EdgeInsets.only(right: 16),
                        child: Avatar.Team(
                            team: team,
                            80,
                            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(
                                    data: team.name,
                                    style: CTextStyle.H4White.merge(
                                        new TextStyle(height: 1)),
                                    maxLines: 1,
                                    overflow: TextOverflow.ellipsis
                                    )
                                ),
                            CImageUtils.GenBadgeImage(
                                badges: team.badges,
                                CCommonUtils.GetUserLicense(
                                    userId: team.id
                                    ),
                                EdgeInsets.only(4, 6)
                                )
                        }
                            )
                    }
                            )
                        )
                }
                    ),
                new Container(
                    margin: EdgeInsets.only(top: 16),
                    child: new Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: new List <Widget> {
                    new Row(
                        children: new List <Widget> {
                        _buildFollowCount(
                            "粉丝",
                            $"{team.stats?.followCount ?? 0}",
                            () => {
                            if (this.widget.viewModel.isLoggedIn)
                            {
                                this.widget.actionModel.pushToTeamFollower(
                                    obj: this.widget.viewModel.team.id);
                            }
                            else
                            {
                                this.widget.actionModel.pushToLogin();
                            }
                        }
                            ),
                        new SizedBox(width: 16),
                        _buildFollowCount(
                            "成员",
                            $"{team.stats?.membersCount ?? 0}",
                            () => this.widget.actionModel.pushToTeamMember(
                                obj: this.widget.viewModel.team.id)
                            )
                    }
                        ),
                    this._buildFollowButton()
                }
                        )
                    )
            }
                               )
                           )
                       ));
        }
Пример #7
0
        Widget _buildUserInfo(BuildContext context)
        {
            var    user = this.widget.viewModel.user ?? new User();
            Widget titleWidget;

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

            return(new CoverImage(
                       coverImage: user.coverImage,
                       imageBaseHeight + CCommonUtils.getSafeAreaTopPadding(context: context),
                       new Container(
                           padding: EdgeInsets.only(16, 0, 16, 24),
                           child: new Column(
                               mainAxisAlignment: MainAxisAlignment.end,
                               children: new List <Widget> {
                new Row(
                    children: new List <Widget> {
                    new Container(
                        margin: EdgeInsets.only(right: 16),
                        child: Avatar.User(
                            user: user,
                            80,
                            true
                            )
                        ),
                    new Expanded(
                        child: new Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            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.merge(
                                        new TextStyle(height: 1)),
                                    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 Container(
                    margin: EdgeInsets.only(top: 16),
                    child: new Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: new List <Widget> {
                    new Row(
                        children: new List <Widget> {
                        _buildFollowCount(
                            "关注",
                            $"{(user.followingUsersCount ?? 0) + (user.followingTeamsCount ?? 0)}",
                            () =>
                            this.widget.actionModel.pushToUserFollowing(
                                arg1: this.widget.viewModel.user.id, 0)
                            ),
                        new SizedBox(width: 16),
                        _buildFollowCount(
                            "粉丝",
                            $"{user.followCount ?? 0}",
                            () =>
                            this.widget.actionModel.pushToUserFollower(
                                obj: this.widget.viewModel.user.id)
                            )
                    }
                        ),
                    this._buildFollowButton()
                }
                        )
                    )
            }
                               )
                           )
                       ));
        }
Пример #8
0
        Widget _buildFollowArticleCard(BuildContext context, int index, bool isFollow = true)
        {
            var articleIds = isFollow
                ? this.widget.viewModel.followArticleIds
                : this.widget.viewModel.hotArticleIds;

            var articleId = articleIds[index : index];

            if (!this.widget.viewModel.articleDict.ContainsKey(key: articleId))
            {
                return(new Container());
            }

            var article = this.widget.viewModel.articleDict[key : articleId];

            if (this.widget.viewModel.blockArticleList.Contains(item: article.id))
            {
                return(new Container());
            }

            if (article.ownerType == OwnerType.user.ToString())
            {
                if (this.widget.viewModel.currentUserId == article.userId)
                {
                    return(new Container());
                }

                var      user     = this.widget.viewModel.userDict[key : article.userId];
                UserType userType = UserType.unFollow;
                if (isFollow)
                {
                    userType = UserType.me;
                }
                else if (!this.widget.viewModel.isLoggedIn)
                {
                    userType = UserType.unFollow;
                }
                else
                {
                    if (this.widget.viewModel.currentUserId == article.userId)
                    {
                        userType = UserType.me;
                    }
                    else if (user.followUserLoading ?? false)
                    {
                        userType = UserType.loading;
                    }
                    else if (this.widget.viewModel.followMap.ContainsKey(key: article.userId))
                    {
                        userType = UserType.follow;
                    }
                }

                return(FollowArticleCard.User(
                           article: article,
                           user: user,
                           CCommonUtils.GetUserLicense(userId: user.id, userLicenseMap: this.widget.viewModel.userLicenseDict),
                           this.widget.viewModel.likeMap.ContainsKey(key: article.id),
                           userType: userType,
                           () => this.widget.actionModel.pushToArticleDetail(obj: article.id),
                           () => this.widget.actionModel.pushToUserDetail(obj: user.id),
                           () => this._onFollow(article: article, userType: userType),
                           () => this._onLike(article: article),
                           () => this._onComment(article: article),
                           () => this._onShare(article: article),
                           new ObjectKey(value: article.id)
                           ));
            }

            if (article.ownerType == OwnerType.team.ToString())
            {
                var      team     = this.widget.viewModel.teamDict[key : article.teamId];
                UserType userType = UserType.unFollow;
                if (isFollow)
                {
                    userType = UserType.me;
                }
                else if (!this.widget.viewModel.isLoggedIn)
                {
                    userType = UserType.unFollow;
                }
                else
                {
                    if (this.widget.viewModel.currentUserId == article.teamId)
                    {
                        userType = UserType.me;
                    }
                    else if (team.followTeamLoading ?? false)
                    {
                        userType = UserType.loading;
                    }
                    else if (this.widget.viewModel.followMap.ContainsKey(key: article.teamId))
                    {
                        userType = UserType.follow;
                    }
                }

                return(FollowArticleCard.Team(
                           article: article,
                           team: team,
                           this.widget.viewModel.likeMap.ContainsKey(key: article.id),
                           userType: userType,
                           () => this.widget.actionModel.pushToArticleDetail(obj: article.id),
                           () => this.widget.actionModel.pushToTeamDetail(obj: team.id),
                           () => this._onFollow(article: article, userType: userType),
                           () => this._onLike(article: article),
                           () => this._onComment(article: article),
                           () => this._onShare(article: article),
                           new ObjectKey(value: article.id)
                           ));
            }

            return(new Container());
        }
Пример #9
0
        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 Text(
                    data: user.title,
                    style: new TextStyle(
                        fontSize: 14,
                        fontFamily: "Roboto-Regular",
                        color: CColors.BgGrey
                        ),
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis
                    );
            }
            else
            {
                titleWidget = new Container();
            }

            var content = new Container(
                height: 184 + CCommonUtils.getSafeAreaTopPadding(context: this.context),
                padding: EdgeInsets.only(16, CCommonUtils.getSafeAreaTopPadding(context: this.context), bottom: 16),
                child: new Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: new List <Widget> {
                _buildQrScanWidget(),
                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(
                            mainAxisAlignment: MainAxisAlignment.center,
                            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.merge(new TextStyle(height: 1)),
                                    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 Container(
                        padding: EdgeInsets.only(12, right: 16),
                        child: new Icon(
                            icon: Icons.chevron_right,
                            size: 24,
                            color: CColors.LightBlueGrey
                            )
                        )
                }
                    )
            }
                    )
                );

            return(new GestureDetector(
                       onTap: () => this.widget.actionModel.pushToUserDetail(obj: user.id),
                       child: new Stack(
                           children: new List <Widget> {
                Positioned.fill(new Stack(
                                    children: new List <Widget> {
                    new Stack(
                        children: new List <Widget> {
                        new Container(color: new Color(0xFF212121)),
                        new Positioned(
                            top: 30,
                            right: 30,
                            child: new Icon(Icons.UnityLogo, size: 210, color: new Color(0xFF2b2b2b)))
                    })
                })),
                content
            })
                       ));
        }
        public override Widget build(BuildContext context)
        {
            Widget content;

            if (this.widget.viewModel.searchFollowingUserLoading)
            {
                content = new GlobalLoading();
            }
            else if (this.widget.viewModel.searchFollowingKeyword.Length > 0)
            {
                if (this.widget.viewModel.searchFollowingUsers.Count > 0)
                {
                    var enablePullUp = this.widget.viewModel.searchFollowingUserHasMore;
                    content = new Container(
                        color: CColors.Background,
                        child: new CustomListView(
                            controller: this._refreshController,
                            enablePullDown: false,
                            enablePullUp: enablePullUp,
                            onRefresh: this._onRefreshSearchFollowing,
                            itemCount: this.widget.viewModel.searchFollowingUsers.Count,
                            itemBuilder: (cxt, index) => {
                        var searchUser = this.widget.viewModel.searchFollowingUsers[index: index];
                        return(new UserCard(
                                   user: searchUser,
                                   CCommonUtils.GetUserLicense(userId: searchUser.id,
                                                               userLicenseMap: this.widget.viewModel.userLicenseDict),
                                   () => this.widget.actionModel.pushToUserDetail(obj: searchUser.id),
                                   key: new ObjectKey(value: searchUser.id)
                                   ));
                    },
                            headerWidget: CustomListViewConstant.defaultHeaderWidget,
                            footerWidget: enablePullUp ? null : CustomListViewConstant.defaultFooterWidget
                            )
                        );
                }
                else
                {
                    content = new BlankView(
                        "哎呀,换个关键词试试吧",
                        "image/default-search"
                        );
                }
            }
            else if (this.widget.viewModel.followingUserLoading && this.widget.viewModel.followingUsers.isEmpty())
            {
                content = new GlobalLoading();
            }
            else if (this.widget.viewModel.followingUsers.Count <= 0)
            {
                content = new BlankView(
                    "没有关注的人,去首页看看吧",
                    "image/default-following"
                    );
            }
            else
            {
                var followingUsers = this.widget.viewModel.followingUsers;
                var enablePullUp   = this.widget.viewModel.followingUsersHasMore;
                content = new CustomListView(
                    controller: this._refreshController,
                    enablePullDown: true,
                    enablePullUp: enablePullUp,
                    onRefresh: this._onRefreshFollowing,
                    itemCount: followingUsers.Count,
                    itemBuilder: this._buildUserCard,
                    headerWidget: CustomListViewConstant.defaultHeaderWidget,
                    footerWidget: enablePullUp ? null : CustomListViewConstant.defaultFooterWidget
                    );
            }

            return(new Container(
                       color: CColors.Background,
                       child: content
                       ));
        }
Пример #11
0
        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()
                            )
                    }
                                )
                            )
                        )
                }
                            )
                        )
                    )
            }
                       ));
        }
Пример #12
0
        IEnumerable <Widget> _buildComments(BuildContext context)
        {
            List <string> channelComments = new List <string>();

            if (this.widget.viewModel.channelMessageList.ContainsKey(key: this._article.channelId))
            {
                channelComments = this.widget.viewModel.channelMessageList[key : this._article.channelId];
            }

            var mediaQuery = MediaQuery.of(context);
            var comments   = new List <Widget> {
                new Container(
                    color: CColors.White,
                    width: mediaQuery.size.width,
                    padding: EdgeInsets.only(16, 16, 16),
                    child: new Text(
                        "评论",
                        style: CTextStyle.H5,
                        textAlign: TextAlign.left
                        )
                    )
            };

            var titleHeight = CTextUtils.CalculateTextHeight(
                "评论",
                CTextStyle.H5,
                mediaQuery.size.width - 16 * 2 // 16 is horizontal padding
                ) + 16;                        // 16 is top padding

            float safeAreaPadding = 0;

            if (Application.platform != RuntimePlatform.Android)
            {
                safeAreaPadding = mediaQuery.padding.vertical;
            }

            var height = mediaQuery.size.height - navBarHeight - 44 - safeAreaPadding;

            if (channelComments.Count == 0)
            {
                var blankView = new Container(
                    height: height - titleHeight,
                    child: new BlankView(
                        "快来写下第一条评论吧",
                        "image/default-comment"
                        )
                    );
                comments.Add(item: blankView);
                return(comments);
            }

            var   messageDict    = this.widget.viewModel.channelMessageDict[key : this._article.channelId];
            float contentHeights = 0;

            foreach (var commentId in channelComments)
            {
                if (!messageDict.ContainsKey(key: commentId))
                {
                    break;
                }

                var message     = messageDict[key : commentId];
                var userLicense = CCommonUtils.GetUserLicense(userId: message.author.id,
                                                              userLicenseMap: this.widget.viewModel.userLicenseDict);
                bool isPraised      = _isPraised(message: message, loginUserId: this.widget.viewModel.loginUserId);
                var  parentName     = "";
                var  parentAuthorId = "";
                if (message.upperMessageId.isNotEmpty())
                {
                    if (messageDict.ContainsKey(key: message.upperMessageId))
                    {
                        var parentMessage = messageDict[key : message.upperMessageId];
                        parentName     = parentMessage.author.fullName;
                        parentAuthorId = parentMessage.author.id;
                    }
                }
                else if (message.parentMessageId.isNotEmpty())
                {
                    if (messageDict.ContainsKey(key: message.parentMessageId))
                    {
                        var parentMessage = messageDict[key : message.parentMessageId];
                        parentName     = parentMessage.author.fullName;
                        parentAuthorId = parentMessage.author.id;
                    }
                }

                var content = MessageUtils.AnalyzeMessage(message.content, message.mentions,
                                                          message.mentionEveryone) + (parentName.isEmpty() ? "" : $"回复@{parentName}");
                var contentHeight = CTextUtils.CalculateTextHeight(
                    content,
                    CTextStyle.PLargeBody,
                    // 16 is horizontal padding, 24 is avatar size, 8 is content left margin to avatar
                    mediaQuery.size.width - 16 * 2 - 24 - 8
                    ) + 16 + 24 + 3 + 5 + 22 + 12;
                // 16 is top padding, 24 is avatar size, 3 is content top margin to avatar, 5 is content bottom margin to commentTime
                // 22 is commentTime height, 12 is commentTime bottom margin
                contentHeights += contentHeight;
                var card = new CommentCard(
                    message: message,
                    userLicense: userLicense,
                    isPraised: isPraised,
                    parentName: parentName,
                    parentAuthorId: parentAuthorId,
                    () => ReportManager.showReportView(
                        isLoggedIn: this.widget.viewModel.isLoggedIn,
                        reportType: ReportType.comment,
                        () => this.widget.actionModel.pushToLogin(),
                        () => this.widget.actionModel.pushToReport(arg1: commentId, arg2: ReportType.comment)
                        ),
                    replyCallBack: () => this._sendComment(
                        "Article_Comment",
                        message.parentMessageId.isNotEmpty() ? message.parentMessageId : commentId,
                        message.parentMessageId.isNotEmpty() ? commentId : "",
                        message.author.fullName.isEmpty() ? "" : message.author.fullName
                        ),
                    praiseCallBack: () => {
                    if (!this.widget.viewModel.isLoggedIn)
                    {
                        this.widget.actionModel.pushToLogin();
                    }
                    else
                    {
                        if (isPraised)
                        {
                            this.widget.actionModel.removeLikeComment(arg: message);
                        }
                        else
                        {
                            this.widget.actionModel.likeComment(arg: message);
                        }
                    }
                },
                    pushToUserDetail: this.widget.actionModel.pushToUserDetail
                    );
                comments.Add(item: card);
            }

            float endHeight = 0;

            if (!this._article.hasMore)
            {
                comments.Add(new EndView());
                endHeight = 52;
            }

            if (titleHeight + contentHeights + endHeight < height)
            {
                return(new List <Widget> {
                    new Container(
                        height: height,
                        child: new Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: comments
                            )
                        )
                });
            }

            return(comments);
        }
Пример #13
0
        Widget _buildContentHead()
        {
            Widget _avatar = this._article.ownerType == OwnerType.user.ToString()
                ? Avatar.User(user: this._user, 32)
                : Avatar.Team(team: this._team, 32);

            string name;
            Widget badge;
            string description;

            if (this._article.ownerType == "user")
            {
                // user
                name  = this._user.fullName ?? this._user.name;
                badge = CImageUtils.GenBadgeImage(
                    badges: this._user.badges,
                    CCommonUtils.GetUserLicense(
                        userId: this._user.id,
                        userLicenseMap: this.widget.viewModel.userLicenseDict
                        ),
                    EdgeInsets.only(4)
                    );
                description = this._user.title;
            }
            else
            {
                // team
                name  = this._team.name;
                badge = CImageUtils.GenBadgeImage(
                    badges: this._team.badges,
                    CCommonUtils.GetUserLicense(
                        userId: this._team.id
                        ),
                    EdgeInsets.only(4)
                    );
                description = "";
            }

            var    time = this._article.publishedTime;
            Widget descriptionWidget;

            if (description.isNotEmpty())
            {
                descriptionWidget = new Text(
                    data: description,
                    style: CTextStyle.PSmallBody3
                    );
            }
            else
            {
                descriptionWidget = new Container();
            }

            return(new Container(
                       color: CColors.White,
                       padding: EdgeInsets.only(16, 16, 16),
                       child: new Column(
                           crossAxisAlignment: CrossAxisAlignment.start,
                           children: new List <Widget> {
                new TipMenu(
                    new List <TipMenuItem> {
                    new TipMenuItem(
                        "复制",
                        () => Clipboard.setData(new ClipboardData(text: this._article.title))
                        )
                },
                    new Container(
                        color: CColors.Transparent,
                        child: new Text(
                            data: this._article.title,
                            style: CTextStyle.H3
                            )
                        )
                    ),
                new Container(
                    margin: EdgeInsets.only(top: 8),
                    child: new Text(
                        $"阅读 {this._article.viewCount} · {DateConvert.DateStringFromNow(dt: time)}",
                        style: CTextStyle.PSmallBody4
                        )
                    ),
                new Row(
                    children: new List <Widget> {
                    new Expanded(
                        child: new GestureDetector(
                            onTap: () => {
                        if (this._article.ownerType == OwnerType.user.ToString())
                        {
                            this.widget.actionModel.pushToUserDetail(obj: this._user.id);
                        }

                        if (this._article.ownerType == OwnerType.team.ToString())
                        {
                            this.widget.actionModel.pushToTeamDetail(obj: this._team.id);
                        }
                    },
                            child: new Container(
                                margin: EdgeInsets.only(top: 24, right: 16, bottom: 24),
                                color: CColors.Transparent,
                                child: new Row(
                                    mainAxisSize: MainAxisSize.min,
                                    children: new List <Widget> {
                        new Container(
                            margin: EdgeInsets.only(right: 8),
                            child: _avatar
                            ),
                        new Expanded(
                            child: new Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: new List <Widget> {
                            new Row(
                                children: new List <Widget> {
                                new Flexible(
                                    child: new Text(
                                        data: name,
                                        style: CTextStyle.PRegularBody.merge(
                                            new TextStyle(height: 1)),
                                        maxLines: 1,
                                        overflow: TextOverflow.ellipsis
                                        )
                                    ),
                                badge
                            }
                                ),
                            descriptionWidget
                        }
                                )
                            )
                    }
                                    )
                                )
                            )
                        ),
                    this._buildFollowButton()
                }
                    ),
                this._article.subTitle.isEmpty()
                            ? new Container()
                            : (Widget) new TipMenu(
                    new List <TipMenuItem> {
                    new TipMenuItem(
                        "复制",
                        () => Clipboard.setData(new ClipboardData(text: this._article.subTitle))
                        )
                },
                    new Container(
                        margin: EdgeInsets.only(bottom: 24),
                        decoration: new BoxDecoration(
                            color: CColors.Separator2,
                            borderRadius: BorderRadius.all(4)
                            ),
                        padding: EdgeInsets.only(16, 12, 16, 12),
                        width: Screen.width - 32,
                        child: new Text($"{this._article.subTitle}", style: CTextStyle.PLargeBody4)
                        )
                    )
            }
                           )
                       ));
        }