public override Widget build(BuildContext context)
        {
            base.build(context: context);
            var completedEvents = this.widget.viewModel.completedEvents;

            if (!this._hasBeenLoadedData || this.widget.viewModel.eventCompletedLoading && completedEvents.isEmpty())
            {
                return(new Container(
                           padding: EdgeInsets.only(bottom: CConstant.TabBarHeight +
                                                    CCommonUtils.getSafeAreaBottomPadding(context: context)),
                           child: new GlobalLoading()
                           ));
            }

            if (0 == completedEvents.Count)
            {
                return(new Container(
                           padding: EdgeInsets.only(bottom: CConstant.TabBarHeight +
                                                    CCommonUtils.getSafeAreaBottomPadding(context: context)),
                           child: new BlankView(
                               "暂无往期活动,看看新活动吧",
                               "image/default-event",
                               true,
                               () => {
                    this.widget.actionModel.startFetchEventCompleted();
                    this.widget.actionModel.fetchEvents(arg1: firstPageNumber, arg2: eventTab);
                }
                               )
                           ));
            }

            var enablePullUp = completedEvents.Count < this.widget.viewModel.completedEventTotal;
            var itemCount    = enablePullUp ? completedEvents.Count : completedEvents.Count + 1;

            return(new Container(
                       color: CColors.Background,
                       child: new CustomScrollbar(
                           new SmartRefresher(
                               controller: this._completedRefreshController,
                               enablePullDown: true,
                               enablePullUp: enablePullUp,
                               onRefresh: this._completedRefresh,
                               hasBottomMargin: true,
                               child: ListView.builder(
                                   physics: new AlwaysScrollableScrollPhysics(),
                                   itemCount: itemCount,
                                   itemBuilder: this._buildEventCard
                                   )
                               )
                           )
                       ));
        }
        Widget _buildArticleList(BuildContext context)
        {
            Widget content;
            var    recommendArticleIds = this.widget.viewModel.recommendArticleIds;

            if (!this._hasBeenLoadedData || this.widget.viewModel.articlesLoading && recommendArticleIds.isEmpty())
            {
                content = ListView.builder(
                    physics: new NeverScrollableScrollPhysics(),
                    itemCount: 6,
                    itemBuilder: (cxt, index) => new ArticleLoading()
                    );
            }
            else if (0 == recommendArticleIds.Count)
            {
                content = new Container(
                    padding: EdgeInsets.only(bottom: CConstant.TabBarHeight +
                                             CCommonUtils.getSafeAreaBottomPadding(context: context)),
                    child: new BlankView(
                        "哎呀,暂无推荐文章",
                        "image/default-article",
                        true,
                        () => {
                    this.widget.actionModel.startFetchArticles();
                    this.widget.actionModel.fetchArticles(arg1: this.widget.viewModel.currentUserId,
                                                          arg2: initOffset);
                }
                        )
                    );
            }
            else
            {
                var enablePullUp = this.widget.viewModel.hottestHasMore;
                content = new CustomListView(
                    controller: this._refreshController,
                    enablePullDown: true,
                    enablePullUp: enablePullUp,
                    onRefresh: this._onRefresh,
                    hasBottomMargin: true,
                    itemCount: recommendArticleIds.Count,
                    itemBuilder: this._buildArticleCard,
                    footerWidget: enablePullUp ? null : new EndView(hasBottomMargin: true),
                    hasScrollBar: false
                    );
            }

            return(new CustomScrollbar(child: content));
        }
示例#3
0
        public override Widget build(BuildContext context)
        {
            base.build(context: context);
            var ongoingEvents = this.widget.viewModel.ongoingEvents;

            if (!this._hasBeenLoadedData || this.widget.viewModel.eventOngoingLoading && ongoingEvents.isEmpty())
            {
                return(new Container(
                           padding: EdgeInsets.only(bottom: CConstant.TabBarHeight +
                                                    CCommonUtils.getSafeAreaBottomPadding(context: context)),
                           child: new GlobalLoading()
                           ));
            }

            if (0 == ongoingEvents.Count)
            {
                return(new Container(
                           padding: EdgeInsets.only(bottom: CConstant.TabBarHeight +
                                                    CCommonUtils.getSafeAreaBottomPadding(context: context)),
                           child: new BlankView(
                               "暂无新活动,看看往期活动吧",
                               "image/default-event",
                               true,
                               () => {
                    this.widget.actionModel.startFetchEventOngoing();
                    this.widget.actionModel.fetchEvents(arg1: firstPageNumber, arg2: eventTab);
                }
                               )
                           ));
            }

            var enablePullUp = ongoingEvents.Count < this.widget.viewModel.ongoingEventTotal;

            return(new Container(
                       color: CColors.Background,
                       child: new CustomListView(
                           controller: this._ongoingRefreshController,
                           enablePullDown: true,
                           enablePullUp: enablePullUp,
                           onRefresh: this._ongoingRefresh,
                           hasBottomMargin: true,
                           itemCount: ongoingEvents.Count,
                           itemBuilder: this._buildEventCard,
                           headerWidget: CustomListViewConstant.defaultHeaderWidget,
                           footerWidget: enablePullUp ? null : new EndView(hasBottomMargin: true)
                           )
                       ));
        }
        Widget _buildOfflineRegisterNow(IEvent eventObj, bool isLoggedIn, EventStatus eventStatus,
                                        BuildContext context)
        {
            if (eventObj.type.isNotEmpty() && !(eventObj.type == "bagevent" || eventObj.type == "customize"))
            {
                return(new Container());
            }

            var buttonText      = "立即报名";
            var backgroundColor = CColors.PrimaryBlue;
            var isEnabled       = true;

            if (eventStatus == EventStatus.past)
            {
                buttonText      = "已结束";
                backgroundColor = CColors.Disable;
                isEnabled       = false;
            }

            return(new Container(
                       height: 56 + CCommonUtils.getSafeAreaBottomPadding(context: context),
                       padding: EdgeInsets.only(16, 8, 16, 8 + CCommonUtils.getSafeAreaBottomPadding(context: context)),
                       decoration: new BoxDecoration(
                           CColors.White,
                           border: new Border(new BorderSide(CColors.Separator))
                           ),
                       child: new CustomButton(
                           onPressed: () => {
                if (!isEnabled)
                {
                    return;
                }

                if (isLoggedIn && eventObj.type.isNotEmpty())
                {
                    if (eventObj.type == "bagevent")
                    {
                        this.widget.actionModel.openUrl(
                            $"{Config.unity_com_url}/events/{eventObj.id}/purchase");
                    }
                    else if (eventObj.type == "customize" && eventObj.typeParam.isNotEmpty())
                    {
                        this.widget.actionModel.openUrl(eventObj.typeParam);
                    }
                }
                else
                {
                    this.widget.actionModel.pushToLogin();
                }
            },
                           padding: EdgeInsets.zero,
                           child: new Container(
                               decoration: new BoxDecoration(
                                   backgroundColor,
                                   borderRadius: BorderRadius.all(4)
                                   ),
                               child: new Row(
                                   mainAxisAlignment: MainAxisAlignment.center,
                                   children: new List <Widget> {
                new Text(
                    buttonText,
                    style: CTextStyle.PLargeMediumWhite
                    )
            }
                                   )
                               )
                           )
                       ));
        }
        Widget _buildEventBottom(IEvent eventObj, EventType eventType, EventStatus eventStatus,
                                 bool isLoggedIn, BuildContext context)
        {
            if (!WechatPlugin.instance().isInstalled() || eventType == EventType.offline)
            {
                return(new Container());
            }

            return(new Container(
                       height: 56 + CCommonUtils.getSafeAreaBottomPadding(context: context),
                       padding: EdgeInsets.only(16, 8, 16, 8 + CCommonUtils.getSafeAreaBottomPadding(context: context)),
                       decoration: new BoxDecoration(
                           color: CColors.White,
                           border: new Border(new BorderSide(color: CColors.Separator))
                           ),
                       child: new CustomButton(
                           onPressed: () => {
                CustomDialogUtils.showCustomDialog(
                    barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                    child: new CustomAlertDialog(
                        "即将前往微信小程序开始观看",
                        null,
                        new List <Widget> {
                    new CustomButton(
                        child: new Text(
                            "稍后再说",
                            style: new TextStyle(
                                height: 1.33f,
                                fontSize: 16,
                                fontFamily: "Roboto-Regular",
                                color: new Color(0xFF959595)
                                ),
                            textAlign: TextAlign.center
                            ),
                        onPressed: CustomDialogUtils.hiddenCustomDialog
                        ),
                    new CustomButton(
                        child: new Text(
                            "立即前往",
                            style: CTextStyle.PLargeBlue,
                            textAlign: TextAlign.center
                            ),
                        onPressed: () => {
                        CustomDialogUtils.hiddenCustomDialog();
                        WechatPlugin.instance().context = this.context;
                        WechatPlugin.instance().currentEventId = eventObj.id;
                        var path = CStringUtils.CreateMiniPath(id: eventObj.id,
                                                               title: eventObj.title);
                        if (path.isNotEmpty())
                        {
                            WechatPlugin.instance().toOpenMiNi(path);
                        }
                    }
                        )
                }
                        )
                    );
            },
                           padding: EdgeInsets.zero,
                           child: new Container(
                               decoration: new BoxDecoration(
                                   color: CColors.PrimaryBlue,
                                   borderRadius: BorderRadius.all(4)
                                   ),
                               child: new Row(
                                   mainAxisAlignment: MainAxisAlignment.center,
                                   children: new List <Widget> {
                new Text(
                    "进入微信小程序",
                    style: CTextStyle.PLargeMediumWhite.merge(new TextStyle(height: 1))
                    )
            }
                                   )
                               )
                           )
                       ));
        }
        Widget _buildArticleList(BuildContext context)
        {
            Widget content;
            var    recommendArticleIds = this.widget.viewModel.recommendArticleIds;

            if (!this._hasBeenLoadedData || this.widget.viewModel.articlesLoading && recommendArticleIds.isEmpty())
            {
                content = ListView.builder(
                    physics: new NeverScrollableScrollPhysics(),
                    itemCount: 6,
                    itemBuilder: (cxt, index) => new ArticleLoading()
                    );
            }
            else if (0 == recommendArticleIds.Count)
            {
                content = new Container(
                    padding: EdgeInsets.only(bottom: CConstant.TabBarHeight +
                                             CCommonUtils.getSafeAreaBottomPadding(context: context)),
                    child: new BlankView(
                        "哎呀,暂无推荐文章",
                        "image/default-article",
                        true,
                        () => {
                    this.widget.actionModel.startFetchArticles();
                    this.widget.actionModel.fetchArticles(arg: initOffset);
                }
                        )
                    );
            }
            else
            {
                content = new SmartRefresher(
                    controller: this._refreshController,
                    enablePullDown: true,
                    enablePullUp: this.widget.viewModel.hottestHasMore,
                    onRefresh: this._onRefresh,
                    hasBottomMargin: true,
                    child: ListView.builder(
                        physics: new AlwaysScrollableScrollPhysics(),
                        itemCount: recommendArticleIds.Count,
                        itemBuilder: (cxt, index) => {
                    var articleId = recommendArticleIds[index: index];
                    if (this.widget.viewModel.blockArticleList.Contains(item: articleId))
                    {
                        return(new Container());
                    }

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

                    if (!this.widget.viewModel.hottestHasMore && recommendArticleIds.Count > 0 &&
                        index + 1 == recommendArticleIds.Count)
                    {
                        return(new EndView(hasBottomMargin: true));
                    }

                    var article  = this.widget.viewModel.articleDict[key: articleId];
                    var fullName = "";
                    var userId   = "";
                    if (article.ownerType == OwnerType.user.ToString())
                    {
                        userId = article.userId;
                        if (this.widget.viewModel.userDict.ContainsKey(key: article.userId))
                        {
                            fullName = this.widget.viewModel.userDict[key: article.userId].fullName
                                       ?? this.widget.viewModel.userDict[key: article.userId].name;
                        }
                    }

                    if (article.ownerType == OwnerType.team.ToString())
                    {
                        userId = article.teamId;
                        if (this.widget.viewModel.teamDict.ContainsKey(key: article.teamId))
                        {
                            fullName = this.widget.viewModel.teamDict[key: article.teamId].name;
                        }
                    }

                    var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id);
                    return(new ArticleCard(
                               article: article,
                               () => {
                        this.widget.actionModel.pushToArticleDetail(obj: articleId);
                        AnalyticsManager.ClickEnterArticleDetail("Home_Article", articleId: article.id,
                                                                 articleTitle: article.title);
                    },
                               () => ShareManager.showArticleShareView(
                                   this.widget.viewModel.currentUserId != userId,
                                   isLoggedIn: this.widget.viewModel.isLoggedIn,
                                   () => {
                        Clipboard.setData(new ClipboardData(text: linkUrl));
                        CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline);
                    },
                                   () => this.widget.actionModel.pushToLogin(),
                                   () => this.widget.actionModel.pushToBlock(obj: article.id),
                                   () => this.widget.actionModel.pushToReport(arg1: article.id,
                                                                              arg2: ReportType.article),
                                   type => {
                        CustomDialogUtils.showCustomDialog(
                            child: new CustomLoadingDialog()
                            );
                        string imageUrl = CImageUtils.SizeTo200ImageUrl(article.thumbnail.url);
                        this.widget.actionModel.shareToWechat(arg1: type, arg2: article.title,
                                                              arg3: article.subTitle, arg4: linkUrl, arg5: imageUrl)
                        .Then(onResolved: CustomDialogUtils.hiddenCustomDialog)
                        .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
                    }
                                   ),
                               fullName: fullName,
                               key: new ObjectKey(value: article.id)
                               ));
                }
                        )
                    );
            }

            if (this.widget.viewModel.isLoggedIn)
            {
                return(new Container(
                           color: CColors.Background,
                           child: new CustomScrollbar(child: content)
                           ));
            }

            return(new NotificationListener <ScrollNotification>(
                       onNotification: this._onNotification,
                       child: new Container(
                           color: CColors.Background,
                           child: new CustomScrollbar(child: content)
                           )
                       ));
        }
示例#7
0
        public override Widget build(BuildContext context)
        {
            this._context = context;
            if (!this._isShow)
            {
                return(new MainScreen());
            }

            var topPadding = Application.platform != RuntimePlatform.Android
                ? MediaQuery.of(context: context).padding.top
                : 0f;

            var    isShowLogo = SplashManager.getSplash()?.isShowLogo ?? false;
            Widget logoWidget;

            if (isShowLogo)
            {
                logoWidget = new Positioned(
                    top: topPadding + 24,
                    left: 16,
                    child: new Icon(
                        icon: Icons.LogoWithUnity,
                        size: 35,
                        color: new Color(value: this.hexColor)
                        )
                    );
            }
            else
            {
                logoWidget = new Container();
            }

            return(new Container(
                       color: CColors.White,
                       child: new CustomSafeArea(
                           top: false,
                           child: new Stack(
                               children: new List <Widget> {
                new Column(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: new List <Widget> {
                    new GestureDetector(
                        child: new Container(
                            width: MediaQuery.of(context).size.width,
                            height: MediaQuery.of(context).size.height - 116 -
                            CCommonUtils.getSafeAreaBottomPadding(context: context),
                            child: Image.memory(SplashManager.readImage(), fit: BoxFit.cover)
                            ),
                        onTap: this.pushPage
                        ),
                    new Container(
                        width: 182,
                        height: 32,
                        margin: EdgeInsets.only(top: 36),
                        child: Image.asset("image/iOS/unityConnectBlack.imageset/unityConnectBlack")
                        ),
                    new Container(
                        width: 101,
                        height: 22,
                        margin: EdgeInsets.only(top: 6, bottom: 20),
                        child: Image.asset("image/iOS/madeWithUnity.imageset/madeWithUnity")
                        )
                }
                    ),
                new Positioned(
                    top: topPadding + 24,
                    right: 16,
                    child: new GestureDetector(
                        child: new Container(
                            decoration: new BoxDecoration(
                                Color.fromRGBO(0, 0, 0, 0.5f),
                                borderRadius: BorderRadius.all(16)
                                ),
                            width: 65,
                            height: 32,
                            alignment: Alignment.center,
                            child: new Text($"跳过 {this._lastSecond}", style: new TextStyle(
                                                fontSize: 14,
                                                fontFamily: "Roboto-Regular",
                                                color: CColors.White
                                                ))
                            ),
                        onTap: this.pushCallback
                        )
                    ),
                logoWidget
            }
                               ))
                       ));
        }
        public override Widget build(BuildContext context)
        {
            base.build(context: context);
            Widget content;
            var    notifications = this.widget.viewModel.notifications;

            if (!this._hasBeenLoadedData || this.widget.viewModel.notificationLoading && 0 == notifications.Count)
            {
                content = new Container(
                    padding: EdgeInsets.only(bottom: CConstant.TabBarHeight +
                                             CCommonUtils.getSafeAreaBottomPadding(context: context)),
                    child: new GlobalLoading()
                    );
            }
            else if (0 == notifications.Count)
            {
                content = new Container(
                    padding: EdgeInsets.only(bottom: CConstant.TabBarHeight +
                                             CCommonUtils.getSafeAreaBottomPadding(context: context)),
                    child: new BlankView(
                        "好冷清,多和小伙伴们互动呀",
                        "image/default-notification",
                        true,
                        () => {
                    this.widget.actionModel.startFetchNotifications();
                    this.widget.actionModel.fetchNotifications(arg: firstPageNumber);
                }
                        )
                    );
            }
            else
            {
                var enablePullUp = this.widget.viewModel.page < this.widget.viewModel.pageTotal;
                var itemCount    = enablePullUp ? notifications.Count : notifications.Count + 1;
                content = new Container(
                    color: CColors.Background,
                    child: new SmartRefresher(
                        controller: this._refreshController,
                        enablePullDown: true,
                        enablePullUp: enablePullUp,
                        onRefresh: this._onRefresh,
                        hasBottomMargin: true,
                        child: ListView.builder(
                            physics: new AlwaysScrollableScrollPhysics(),
                            itemCount: itemCount,
                            itemBuilder: this._buildNotificationCard
                            )
                        )
                    );
            }

            return(new Container(
                       color: CColors.White,
                       child: new Column(
                           children: new List <Widget> {
                this._buildNavigationBar(),
                new CustomDivider(
                    color: CColors.Separator2,
                    height: 1
                    ),
                new Flexible(
                    child: new NotificationListener <ScrollNotification>(
                        onNotification: this._onNotification,
                        child: new CustomScrollbar(child: content)
                        )
                    )
            }
                           )
                       ));
        }
        Widget _buildArticleList(BuildContext context)
        {
            Widget content;
            var    recommendArticleIds = this.widget.viewModel.recommendArticleIds;

            if (!this._hasBeenLoadedData || this.widget.viewModel.articlesLoading && recommendArticleIds.isEmpty())
            {
                content = ListView.builder(
                    physics: new NeverScrollableScrollPhysics(),
                    itemCount: 6,
                    itemBuilder: (cxt, index) => new ArticleLoading()
                    );
            }
            else if (recommendArticleIds.isEmpty())
            {
                content = new Container(
                    padding: EdgeInsets.only(bottom: CConstant.TabBarHeight +
                                             CCommonUtils.getSafeAreaBottomPadding(context: context)),
                    child: new BlankView(
                        "哎呀,暂无推荐文章",
                        "image/default-article",
                        true,
                        () => {
                    this.widget.actionModel.startFetchArticles();
                    this.widget.actionModel.fetchArticles(arg1: this.widget.viewModel.currentUserId,
                                                          arg2: initOffset);
                }
                        )
                    );
            }
            else
            {
                var items        = this._buildItems(recommendArticleIds);
                var enablePullUp = this.widget.viewModel.hottestHasMore;
                content = new CustomListView(
                    controller: this._refreshController,
                    enablePullDown: true,
                    enablePullUp: enablePullUp,
                    onRefresh: this._onRefresh,
                    hasBottomMargin: true,
                    itemCount: items.Count,
                    itemBuilder: (cxt, index) => items[index],
                    headerWidget: new Column(
                        children: new List <Widget> {
                    this._buildSwiper(),
                    new KingKongView(
                        leaderBoardUpdatedTime: this.widget.viewModel.leaderBoardUpdatedTime,
                        type => {
                        if (type == KingKongType.dailyCollection)
                        {
                            var articleId = this.widget.viewModel.dailySelectionId;
                            this.widget.actionModel.pushToArticleDetail(obj: articleId);
                        }

                        if (type == KingKongType.leaderBoard)
                        {
                            this.widget.actionModel.pushToLeaderBoard();
                        }

                        if (type == KingKongType.activity)
                        {
                            this.widget.actionModel.pushToHomeEvent();
                        }

                        if (type == KingKongType.blogger)
                        {
                            this.widget.actionModel.pushToBlogger();
                        }
                    }
                        )
                }
                        ),
                    footerWidget: enablePullUp?null: new EndView(hasBottomMargin: true),
                    hasScrollBar: false
                    );
            }

            return(new CustomScrollbar(child: content));
        }