Widget _buildRelatedArticles()
        {
            if (this._relArticles.Count == 0)
            {
                return(new Container());
            }

            var widgets = new List <Widget>();

            this._relArticles.ForEach(article => {
                //对文章进行过滤
                if (article.id != this._article.id)
                {
                    Widget card;
                    if (article.ownerType == OwnerType.user.ToString())
                    {
                        card = RelatedArticleCard.User(article, this._user,
                                                       () => this.widget.actionModel.pushToArticleDetail(article.id),
                                                       new ObjectKey(article.id));
                    }
                    else
                    {
                        card = RelatedArticleCard.Team(article, this._team,
                                                       () => this.widget.actionModel.pushToArticleDetail(article.id),
                                                       new ObjectKey(article.id));
                    }

                    widgets.Add(card);
                }
            });
            return(new Container(
                       color: CColors.White,
                       margin: EdgeInsets.only(bottom: 16),
                       child: new Column(
                           children: new List <Widget> {
                new Container(
                    height: 1,
                    color: CColors.Separator2,
                    margin: EdgeInsets.only(16, right: 16, bottom: 24)
                    ),
                new Container(
                    child: new Column(
                        children: widgets
                        )
                    )
            }
                           )
                       ));
        }
Beispiel #2
0
        Widget _buildRelatedArticles()
        {
            var relatedArticles = this._article.projects.FindAll(item => item.type == "article");

            if (relatedArticles.Count == 0)
            {
                return(new Container());
            }

            var widgets = new List <Widget>();

            relatedArticles.ForEach(article => {
                //对文章进行过滤
                if (article.id != this._article.id)
                {
                    Widget card;
                    if (article.ownerType == OwnerType.user.ToString())
                    {
                        card = RelatedArticleCard.User(article, this._user,
                                                       () => {
                            AnalyticsManager.ClickEnterArticleDetail("ArticleDetail_Related", article.id,
                                                                     article.title);
                            this.widget.actionModel.pushToArticleDetail(article.id);
                        },
                                                       new ObjectKey(article.id));
                    }
                    else
                    {
                        card = RelatedArticleCard.Team(article, this._team,
                                                       () => {
                            AnalyticsManager.ClickEnterArticleDetail("ArticleDetail_Related", article.id,
                                                                     article.title);
                            this.widget.actionModel.pushToArticleDetail(article.id);
                        },
                                                       new ObjectKey(article.id));
                    }

                    widgets.Add(card);
                }
            });
            if (widgets.isNotEmpty())
            {
                widgets.InsertRange(0, new List <Widget> {
                    new Container(
                        height: 1,
                        color: CColors.Separator2,
                        margin: EdgeInsets.only(16, 16, 16, 40)
                        ),
                    new Container(
                        margin: EdgeInsets.only(16, bottom: 16),
                        child: new Text(
                            "推荐阅读",
                            style: CTextStyle.PLargeMedium
                            )
                        )
                });
            }

            return(new Container(
                       color: CColors.White,
                       margin: EdgeInsets.only(bottom: 16),
                       child: new Column(
                           crossAxisAlignment: CrossAxisAlignment.start,
                           children: widgets
                           )
                       ));
        }
Beispiel #3
0
        public override Widget build(BuildContext context)
        {
            Widget child = new Container();

            if (this.widget.viewModel.searchLoading)
            {
                child = new GlobalLoading();
            }
            else if (this.widget.viewModel.searchKeyword.Length > 0)
            {
                if (this.widget.viewModel.searchArticles.Count > 0)
                {
                    var currentPage = this.widget.viewModel.currentPage;
                    var pages       = this.widget.viewModel.pages;
                    child = new Container(
                        color: CColors.Background,
                        child: new SmartRefresher(
                            controller: this._refreshController,
                            enablePullDown: false,
                            enablePullUp: currentPage != pages.Count - 1,
                            onRefresh: this._onRefresh,
                            child: ListView.builder(
                                physics: new AlwaysScrollableScrollPhysics(),
                                itemCount: this.widget.viewModel.searchArticles.Count,
                                itemBuilder: (cxt, index) => {
                        var searchArticle = this.widget.viewModel.searchArticles[index];
                        if (this.widget.viewModel.blockArticleList.Contains(searchArticle.id))
                        {
                            return(new Container());
                        }

                        if (searchArticle.ownerType == OwnerType.user.ToString())
                        {
                            var user = this.widget.viewModel.userDict[searchArticle.userId];
                            return(RelatedArticleCard.User(searchArticle, user,
                                                           () => { this.widget.actionModel.pushToArticleDetail(searchArticle.id); }));
                        }

                        var team = this.widget.viewModel.teamDict[searchArticle.teamId];
                        return(RelatedArticleCard.Team(searchArticle, team,
                                                       () => { this.widget.actionModel.pushToArticleDetail(searchArticle.id); }));
                    }
                                )
                            )
                        );
                }
                else
                {
                    child = new BlankView("暂无搜索结果");
                }
            }
            else
            {
                child = new ListView(
                    children: new List <Widget> {
                    this._buildSearchHistory(this.widget.viewModel.searchHistoryList), this._buildHotSearch()
                }
                    );
            }

            return(new Container(
                       color: CColors.White,
                       child: new CustomSafeArea(
                           child: new Container(
                               child: new Column(
                                   children: new List <Widget> {
                this._buildSearchBar(context),
                new Flexible(
                    child: child
                    )
            }
                                   )
                               )
                           )
                       ));
        }
Beispiel #4
0
        Widget _buildRelatedArticles()
        {
            if (this._article.projectIds == null || this._article.projectIds.Count == 0)
            {
                return(new Container());
            }

            var widgets = new List <Widget>();

            this._article.projectIds.ForEach(articleId => {
                var article = this.widget.viewModel.articleDict[key: articleId];
                //对文章进行过滤
                if (article.id != this._article.id)
                {
                    var fullName = "";
                    if (article.ownerType == OwnerType.user.ToString())
                    {
                        fullName = this._user.fullName ?? this._user.name;
                    }

                    if (article.ownerType == OwnerType.team.ToString())
                    {
                        fullName = this._team.name;
                    }

                    Widget card = new RelatedArticleCard(
                        article: article,
                        fullName: fullName,
                        () => {
                        AnalyticsManager.ClickEnterArticleDetail(
                            "ArticleDetail_Related",
                            articleId: article.id,
                            articleTitle: article.title
                            );
                        this.widget.actionModel.pushToArticleDetail(obj: article.id);
                    },
                        key: new ObjectKey(value: article.id)
                        );
                    widgets.Add(item: card);
                }
            });
            if (widgets.isNotEmpty())
            {
                widgets.InsertRange(0, new List <Widget> {
                    new Container(
                        height: 1,
                        color: CColors.Separator2,
                        margin: EdgeInsets.only(16, 16, 16, 40)
                        ),
                    new Container(
                        margin: EdgeInsets.only(16, bottom: 16),
                        child: new Text(
                            "推荐阅读",
                            style: CTextStyle.PLargeMedium
                            )
                        )
                });
            }

            return(new Container(
                       color: CColors.White,
                       margin: EdgeInsets.only(bottom: 16),
                       child: new Column(
                           crossAxisAlignment: CrossAxisAlignment.start,
                           children: widgets
                           )
                       ));
        }