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))
                    )
            }
                                   )
                               )
                           )
                       ));
        }
예제 #2
0
        Widget _buildUserContent(BuildContext context)
        {
            var articleIds  = this.widget.viewModel.user.articleIds;
            var favoriteIds = this.widget.viewModel.favoriteTagIdDict.ContainsKey(key: this.widget.viewModel.user.id)
                ? this.widget.viewModel.favoriteTagIdDict[key : this.widget.viewModel.user.id]
                              : null;
            var articlesHasMore     = this.widget.viewModel.user.articlesHasMore ?? false;
            var userFavoriteHasMore = this.widget.viewModel.userFavoriteHasMore;
            var userArticleLoading  = this.widget.viewModel.userArticleLoading && articleIds == null;
            var userFavoriteLoading = this.widget.viewModel.userFavoriteLoading && favoriteIds == null;
            int itemCount;

            if (userArticleLoading && this._selectedIndex == 0)
            {
                itemCount = 3;
            }
            else if (userFavoriteLoading && this._selectedIndex == 1)
            {
                itemCount = 3;
            }
            else
            {
                if (articleIds == null && this._selectedIndex == 0)
                {
                    itemCount = 3;
                }
                else if (favoriteIds == null && this._selectedIndex == 1)
                {
                    itemCount = 3;
                }
                else
                {
                    if (this._selectedIndex == 0)
                    {
                        var articleCount = articlesHasMore ? articleIds.Count : articleIds.Count + 1;
                        itemCount = 2 + (articleIds.Count == 0 ? 1 : articleCount);
                    }
                    else
                    {
                        var favoriteCount = userFavoriteHasMore ? favoriteIds.Count : favoriteIds.Count + 1;
                        itemCount = 2 + (favoriteIds.Count == 0 ? 1 : favoriteCount);
                    }
                }
            }

            var headerHeight = imageBaseHeight + 44 + CCommonUtils.getSafeAreaTopPadding(context: context);

            return(new Container(
                       color: CColors.Background,
                       child: new CustomScrollbar(
                           new SmartRefresher(
                               controller: this._refreshController,
                               enablePullDown: false,
                               enablePullUp: this._selectedIndex == 0 ? articlesHasMore : userFavoriteHasMore,
                               onRefresh: this._onRefresh,
                               onNotification: this._onNotification,
                               child: ListView.builder(
                                   physics: new AlwaysScrollableScrollPhysics(),
                                   itemCount: itemCount,
                                   itemBuilder: (cxt, index) => {
                if (index == 0)
                {
                    return Transform.scale(
                        scale: this._factor,
                        child: this._buildUserInfo(context)
                        );
                }

                if (index == 1)
                {
                    return this._buildUserArticleTitle();
                }

                if (userArticleLoading && index == 2 && this._selectedIndex == 0)
                {
                    var height = MediaQuery.of(context: context).size.height - headerHeight;
                    return new Container(
                        height: height,
                        child: new GlobalLoading()
                        );
                }

                if (userFavoriteLoading && index == 2 && this._selectedIndex == 1)
                {
                    var height = MediaQuery.of(context: context).size.height - headerHeight;
                    return new Container(
                        height: height,
                        child: new GlobalLoading()
                        );
                }

                if ((articleIds == null || articleIds.Count == 0) && index == 2 &&
                    this._selectedIndex == 0)
                {
                    var height = MediaQuery.of(context: context).size.height - headerHeight;
                    return new Container(
                        height: height,
                        child: new BlankView(
                            "哎呀,暂无已发布的文章",
                            "image/default-article"
                            )
                        );
                }

                if ((favoriteIds == null || favoriteIds.Count == 0) && index == 2 &&
                    this._selectedIndex == 1)
                {
                    var height = MediaQuery.of(context: context).size.height - headerHeight;
                    return new Container(
                        height: height,
                        child: new BlankView(
                            "哎呀,暂无已收藏的文章",
                            "image/default-article"
                            )
                        );
                }

                if (index == itemCount - 1 && !articlesHasMore && this._selectedIndex == 0)
                {
                    return new EndView();
                }

                if (index == itemCount - 1 && !userFavoriteHasMore && this._selectedIndex == 1)
                {
                    return new EndView();
                }

                if (this._selectedIndex == 1)
                {
                    var favoriteId = favoriteIds[index - 2];
                    return this._buildFavoriteCard(favoriteId: favoriteId);
                }

                var articleId = articleIds[index - 2];
                if (!this.widget.viewModel.articleDict.ContainsKey(key: articleId))
                {
                    return new Container();
                }

                var article = this.widget.viewModel.articleDict[key: articleId];
                var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id);
                var fullName = "";
                if (article.ownerType == OwnerType.user.ToString())
                {
                    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())
                {
                    if (this.widget.viewModel.teamDict.ContainsKey(key: article.teamId))
                    {
                        fullName = this.widget.viewModel.teamDict[key: article.teamId].name;
                    }
                }

                return new ArticleCard(
                    article: article,
                    () => this.widget.actionModel.pushToArticleDetail(obj: article.id),
                    () => ShareManager.showArticleShareView(
                        this.widget.viewModel.currentUserId != article.userId,
                        isLoggedIn: this.widget.viewModel.isLoggedIn,
                        () => {
                    Clipboard.setData(new ClipboardData(text: linkUrl));
                    CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline);
                },
                        () => this.widget.actionModel.pushToLogin(),
                        () => this.widget.actionModel.pushToBlock(article.id),
                        () => this.widget.actionModel.pushToReport(article.id, 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());
                },
                        () => this.widget.actionModel.mainRouterPop()
                        ),
                    fullName,
                    key: new ObjectKey(value: article.id)
                    );
            }
                                   )
                               )
                           )
                       ));
        }
예제 #3
0
 Widget _buildContent()
 {
     return(new Flexible(
                child: new Container(
                    color: CColors.Background,
                    child: new ListView(
                        physics: new AlwaysScrollableScrollPhysics(),
                        children: new List <Widget> {
         this.widget.viewModel.hasReviewUrl || this.widget.viewModel.anonymous
                         ? _buildGapView()
                         : new Container(),
         this.widget.viewModel.hasReviewUrl
                         ? _buildCellView("评分",
                                          () => {
             AnalyticsManager.ClickSetGrade();
             this.widget.actionModel.openUrl(obj: this.widget.viewModel.reviewUrl);
         })
                         : new Container(),
         this.widget.viewModel.anonymous
                         ? _buildCellView("绑定 Unity ID",
                                          () => this.widget.actionModel.mainRouterPushTo(MainNavigatorRoutes.BindUnity))
                         : new Container(),
         _buildGapView(),
         _buildCellView("检查更新", () => {
             AnalyticsManager.ClickCheckUpdate();
             VersionManager.checkForUpdates(CheckVersionType.setting);
         }),
         _buildGapView(),
         _buildCellView("清理缓存", () => {
             AnalyticsManager.ClickClearCache();
             CustomDialogUtils.showCustomDialog(
                 child: new CustomLoadingDialog(
                     message: "正在清理缓存"
                     )
                 );
             this.widget.actionModel.clearCache();
             Window.instance.run(TimeSpan.FromSeconds(1), () => {
                 CustomDialogUtils.hiddenCustomDialog();
                 CustomDialogUtils.showToast("缓存已清除", Icons.check_circle_outline);
             }
                                 );
         }),
         CCommonUtils.isIPhone ? _buildGapView() : new Container(),
         CCommonUtils.isIPhone
                         ? _switchRow(
             "帧率监测",
             value: this.fpsLabelIsOpen,
             value => {
             LocalDataManager.setFPSLabelStatus(isOpen: value);
             this.fpsLabelIsOpen = value;
             this.setState(() => {});
             FPSLabelPlugin.SwitchFPSLabelShowStatus(isOpen: value);
         }
             )
                         : new Container(),
         this.widget.viewModel.isLoggedIn ? _buildGapView() : new Container(),
         this.widget.viewModel.isLoggedIn ? this._buildLogoutBtn() : new Container()
     }
                        )
                    )
                ));
 }
예제 #4
0
 public override Widget build(BuildContext context)
 {
     return(new StoreConnector <AppState, ArticlesScreenViewModel>(
                converter: state => {
         var currentUserId = state.loginState.loginInfo.userId ?? "";
         var followArticleIds = state.articleState.followArticleIdDict.ContainsKey(key: currentUserId)
                 ? state.articleState.followArticleIdDict[key: currentUserId]
                 : new List <string>();
         var hotArticleIds = state.articleState.hotArticleIdDict.ContainsKey(key: currentUserId)
                 ? state.articleState.hotArticleIdDict[key: currentUserId]
                 : new List <string>();
         var user = state.userState.userDict.ContainsKey(key: currentUserId)
                 ? state.userState.userDict[key: currentUserId]
                 : new User();
         var followings = user.followings ?? new List <Following>();
         var likeMap = state.likeState.likeDict.ContainsKey(key: currentUserId)
                 ? state.likeState.likeDict[key: currentUserId]
                 : new Dictionary <string, bool>();
         var followMap = state.followState.followDict.ContainsKey(key: currentUserId)
                 ? state.followState.followDict[key: currentUserId]
                 : new Dictionary <string, bool>();
         return new ArticlesScreenViewModel {
             followArticlesLoading = state.articleState.followArticlesLoading,
             followingLoading = state.userState.followingLoading,
             followArticleIds = followArticleIds,
             hotArticleIds = hotArticleIds,
             followings = followings,
             blockArticleList = state.articleState.blockArticleList,
             followArticleHasMore = state.articleState.followArticleHasMore,
             hotArticleHasMore = state.articleState.hotArticleHasMore,
             hotArticlePage = state.articleState.hotArticlePage,
             articleDict = state.articleState.articleDict,
             userDict = state.userState.userDict,
             userLicenseDict = state.userState.userLicenseDict,
             teamDict = state.teamState.teamDict,
             likeMap = likeMap,
             followMap = followMap,
             isLoggedIn = state.loginState.isLoggedIn,
             currentUserId = state.loginState.loginInfo.userId ?? "",
             beforeTime = state.articleState.beforeTime,
             afterTime = state.articleState.afterTime,
             selectedIndex = this.selectedIndex
         };
     },
                builder: (context1, viewModel, dispatcher) => {
         var actionModel = new ArticlesScreenActionModel {
             pushToLogin = () => dispatcher.dispatch(new MainNavigatorPushToAction {
                 routeName = MainNavigatorRoutes.Login
             }),
             pushToArticleDetail = id => dispatcher.dispatch(new MainNavigatorPushToArticleDetailAction {
                 articleId = id
             }),
             pushToReport = (reportId, reportType) => dispatcher.dispatch(
                 new MainNavigatorPushToReportAction {
                 reportId = reportId,
                 reportType = reportType
             }
                 ),
             pushToBlock = articleId => {
                 dispatcher.dispatch(new BlockArticleAction {
                     articleId = articleId
                 });
                 dispatcher.dispatch(new DeleteArticleHistoryAction {
                     articleId = articleId
                 });
             },
             pushToUserFollowing = userId => dispatcher.dispatch(
                 new MainNavigatorPushToUserFollowingAction {
                 userId = userId
             }
                 ),
             pushToUserDetail = userId => dispatcher.dispatch(new MainNavigatorPushToUserDetailAction {
                 userId = userId
             }),
             pushToTeamDetail = teamId => dispatcher.dispatch(new MainNavigatorPushToTeamDetailAction {
                 teamId = teamId
             }),
             startFollowUser = userId =>
                               dispatcher.dispatch(new StartFollowUserAction {
                 followUserId = userId
             }),
             followUser = userId =>
                          dispatcher.dispatch <IPromise>(Actions.fetchFollowUser(followUserId: userId)),
             startUnFollowUser = userId =>
                                 dispatcher.dispatch(new StartUnFollowUserAction {
                 unFollowUserId = userId
             }),
             unFollowUser = userId => dispatcher.dispatch <IPromise>(Actions.fetchUnFollowUser(userId)),
             startFollowTeam = teamId =>
                               dispatcher.dispatch(new StartFetchFollowTeamAction {
                 followTeamId = teamId
             }),
             followTeam = teamId => dispatcher.dispatch <IPromise>(Actions.fetchFollowTeam(teamId)),
             startUnFollowTeam = teamId =>
                                 dispatcher.dispatch(new StartFetchUnFollowTeamAction {
                 unFollowTeamId = teamId
             }),
             unFollowTeam = teamId => dispatcher.dispatch <IPromise>(Actions.fetchUnFollowTeam(teamId)),
             sendComment = (articleId, channelId, content, nonce, parentMessageId, upperMessageId) => {
                 CustomDialogUtils.showCustomDialog(child: new CustomLoadingDialog());
                 return dispatcher.dispatch <IPromise>(
                     Actions.sendComment(articleId, channelId, content, nonce, parentMessageId,
                                         upperMessageId));
             },
             likeArticle = articleId =>
                           dispatcher.dispatch <IPromise>(Actions.likeArticle(articleId: articleId)),
             startFetchFollowing = () => dispatcher.dispatch(new StartFetchFollowingAction()),
             fetchFollowing = (userId, offset) =>
                              dispatcher.dispatch <IPromise>(Actions.fetchFollowing(userId: userId, offset: offset)),
             startFetchFollowArticles = () => dispatcher.dispatch(new StartFetchFollowArticlesAction()),
             fetchFollowArticles = (pageNumber, isFirst, isHot) =>
                                   dispatcher.dispatch <IPromise>(Actions.fetchFollowArticles(pageNumber, viewModel.beforeTime,
                                                                                              viewModel.afterTime, isFirst, isHot)),
             shareToWechat = (type, title, description, linkUrl, imageUrl) => dispatcher.dispatch <IPromise>(
                 Actions.shareToWechat(type, title, description, linkUrl, imageUrl))
         };
         return new FollowArticleScreen(viewModel: viewModel, actionModel: actionModel);
     }
                ));
 }
예제 #5
0
        Widget _buildArticleCard(BuildContext context, int index)
        {
            var recommendArticleIds = this.widget.viewModel.recommendArticleIds;

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

            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(imageUrl: 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,
                       new ObjectKey(value: article.id)
                       ));
        }
        Widget _buildHeadTop(IEvent eventObj, BuildContext context)
        {
            Widget shareWidget = new CustomButton(
                onPressed: () => ActionSheetUtils.showModalActionSheet(new ShareView(
                                                                           projectType: ProjectType.iEvent,
                                                                           onPressed: type => {
                AnalyticsManager.ClickShare(type, "Event", "Event_" + eventObj.id, eventObj.title);

                var linkUrl =
                    $"{Config.unity_cn_url}/events/{eventObj.id}";
                if (type == ShareType.clipBoard)
                {
                    this.widget.actionModel.copyText(linkUrl);
                    CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline);
                }
                else
                {
                    var imageUrl = CImageUtils.SizeTo200ImageUrl(eventObj.avatar);
                    CustomDialogUtils.showCustomDialog(
                        child: new CustomLoadingDialog()
                        );
                    this.widget.actionModel.shareToWechat(type, eventObj.title, eventObj.shortDescription,
                                                          linkUrl,
                                                          imageUrl, null).Then(CustomDialogUtils.hiddenCustomDialog)
                    .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
                }
            })),
                child: new Container(
                    color: CColors.Transparent,
                    child: new Icon(Icons.share, size: 24,
                                    color: this._showNavBarShadow ? CColors.White : CColors.Icon))
                );

            Widget titleWidget = new Container();

            if (this._isHaveTitle)
            {
                titleWidget = new Text(
                    eventObj.title,
                    style: CTextStyle.PXLargeMedium,
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                    textAlign: TextAlign.center
                    );
            }

            return(new AnimatedContainer(
                       height: 44 + CCommonUtils.getSafeAreaTopPadding(context: context),
                       duration: TimeSpan.Zero,
                       padding: EdgeInsets.only(8, right: 8, top: CCommonUtils.getSafeAreaTopPadding(context: context)),
                       decoration: new BoxDecoration(
                           CColors.White,
                           border: new Border(
                               bottom: new BorderSide(this._isHaveTitle ? CColors.Separator2 : CColors.Transparent)),
                           gradient: this._showNavBarShadow
                        ? new LinearGradient(
                               colors: new List <Color> {
                new Color(0x80000000),
                new Color(0x0)
            },
                               begin: Alignment.topCenter,
                               end: Alignment.bottomCenter
                               )
                        : null
                           ),
                       child: new Row(
                           mainAxisAlignment: MainAxisAlignment.spaceBetween,
                           children: new List <Widget> {
                new CustomButton(
                    onPressed: () => this.widget.actionModel.mainRouterPop(),
                    child: new Icon(
                        Icons.arrow_back,
                        size: 24,
                        color: this._showNavBarShadow ? CColors.White : CColors.Icon
                        )
                    ),
                new Expanded(
                    child: new Stack(
                        fit: StackFit.expand,
                        children: new List <Widget> {
                    new PositionedTransition(
                        rect: this._animation,
                        child: titleWidget
                        )
                }
                        )
                    ),
                shareWidget
            }
                           )
                       ));
        }
예제 #7
0
 public override Widget build(BuildContext context)
 {
     return(new StoreConnector <AppState, ArticleDetailScreenViewModel>(
                converter: state => new ArticleDetailScreenViewModel {
         articleId = this.articleId,
         loginUserId = state.loginState.loginInfo.userId,
         isLoggedIn = state.loginState.isLoggedIn,
         articleDetailLoading = state.articleState.articleDetailLoading,
         articleDict = state.articleState.articleDict,
         channelMessageList = state.messageState.channelMessageList,
         channelMessageDict = state.messageState.channelMessageDict,
         userDict = state.userState.userDict,
         userLicenseDict = state.userState.userLicenseDict,
         teamDict = state.teamState.teamDict,
         followMap = state.followState.followDict.ContainsKey(state.loginState.loginInfo.userId ?? "")
                 ? state.followState.followDict[state.loginState.loginInfo.userId ?? ""]
                 : new Dictionary <string, bool>()
     },
                builder: (context1, viewModel, dispatcher) => {
         var actionModel = new ArticleDetailScreenActionModel {
             mainRouterPop = () => dispatcher.dispatch(new MainNavigatorPopAction()),
             pushToLogin = () => dispatcher.dispatch(new MainNavigatorPushToAction {
                 routeName = MainNavigatorRoutes.Login
             }),
             openUrl = url => OpenUrlUtil.OpenUrl(url, dispatcher),
             playVideo = (url, needUpdate, limitSeconds) => {
                 dispatcher.dispatch(new MainNavigatorPushToVideoPlayerAction {
                     url = url,
                     needUpdate = needUpdate,
                     limitSeconds = limitSeconds
                 });
             },
             browserImage = url => {
                 dispatcher.dispatch(new MainNavigatorPushToPhotoViewAction {
                     urls = ContentDescription.imageUrls,
                     url = url
                 });
             },
             pushToArticleDetail = id => dispatcher.dispatch(
                 new MainNavigatorPushToArticleDetailAction {
                 articleId = id
             }
                 ),
             pushToUserDetail = userId => dispatcher.dispatch(
                 new MainNavigatorPushToUserDetailAction {
                 userId = userId
             }
                 ),
             pushToTeamDetail = teamId => dispatcher.dispatch(
                 new MainNavigatorPushToTeamDetailAction {
                 teamId = teamId
             }
                 ),
             pushToReport = (reportId, reportType) => dispatcher.dispatch(
                 new MainNavigatorPushToReportAction {
                 reportId = reportId,
                 reportType = reportType
             }
                 ),
             pushToBlock = articleId => {
                 dispatcher.dispatch(new BlockArticleAction {
                     articleId = articleId
                 });
                 dispatcher.dispatch(new DeleteArticleHistoryAction {
                     articleId = articleId
                 });
             },
             startFetchArticleDetail = () => dispatcher.dispatch(new StartFetchArticleDetailAction()),
             fetchArticleDetail = id =>
                                  dispatcher.dispatch <IPromise>(
                 Actions.FetchArticleDetail(articleId: id, isPush: this.isPush)),
             fetchArticleComments = (channelId, currOldestMessageId) =>
                                    dispatcher.dispatch <IPromise>(
                 Actions.fetchArticleComments(channelId: channelId,
                                              currOldestMessageId: currOldestMessageId)
                 ),
             likeArticle = id => {
                 AnalyticsManager.ClickLike("Article", articleId: this.articleId);
                 return dispatcher.dispatch <IPromise>(Actions.likeArticle(articleId: id));
             },
             likeComment = message => {
                 AnalyticsManager.ClickLike("Article_Comment", articleId: this.articleId,
                                            commentId: message.id);
                 return dispatcher.dispatch <IPromise>(Actions.likeComment(message: message));
             },
             removeLikeComment = message => {
                 AnalyticsManager.ClickLike("Article_Remove_Comment", articleId: this.articleId,
                                            commentId: message.id);
                 return dispatcher.dispatch <IPromise>(Actions.removeLikeComment(message: message));
             },
             sendComment = (channelId, content, nonce, parentMessageId, upperMessageId) => {
                 AnalyticsManager.ClickPublishComment(
                     parentMessageId == null ? "Article" : "Article_Comment", channelId: channelId,
                     commentId: parentMessageId);
                 CustomDialogUtils.showCustomDialog(child: new CustomLoadingDialog());
                 return dispatcher.dispatch <IPromise>(
                     Actions.sendComment(articleId: this.articleId, channelId: channelId, content: content,
                                         nonce: nonce, parentMessageId: parentMessageId, upperMessageId: upperMessageId));
             },
             startFollowUser = userId =>
                               dispatcher.dispatch(new StartFollowUserAction {
                 followUserId = userId
             }),
             followUser = userId =>
                          dispatcher.dispatch <IPromise>(Actions.fetchFollowUser(followUserId: userId)),
             startUnFollowUser = userId =>
                                 dispatcher.dispatch(new StartUnFollowUserAction {
                 unFollowUserId = userId
             }),
             unFollowUser = userId =>
                            dispatcher.dispatch <IPromise>(Actions.fetchUnFollowUser(unFollowUserId: userId)),
             startFollowTeam = teamId =>
                               dispatcher.dispatch(new StartFetchFollowTeamAction {
                 followTeamId = teamId
             }),
             followTeam = teamId =>
                          dispatcher.dispatch <IPromise>(Actions.fetchFollowTeam(followTeamId: teamId)),
             startUnFollowTeam = teamId =>
                                 dispatcher.dispatch(new StartFetchUnFollowTeamAction {
                 unFollowTeamId = teamId
             }),
             unFollowTeam = teamId =>
                            dispatcher.dispatch <IPromise>(Actions.fetchUnFollowTeam(unFollowTeamId: teamId)),
             shareToWechat = (type, title, description, linkUrl, imageUrl) => dispatcher.dispatch <IPromise>(
                 Actions.shareToWechat(type: type, title: title, description: description, linkUrl: linkUrl,
                                       imageUrl: imageUrl))
         };
         return new ArticleDetailScreen(viewModel: viewModel, actionModel: actionModel);
     }
                ));
 }
예제 #8
0
        Widget _buildArticleList()
        {
            Widget content;
            var    recommendArticleIds = this.widget.viewModel.recommendArticleIds;

            if (this.widget.viewModel.articlesLoading && recommendArticleIds.isEmpty())
            {
                content = ListView.builder(
                    physics: new NeverScrollableScrollPhysics(),
                    itemCount: 6,
                    itemBuilder: (cxt, index) => new ArticleLoading()
                    );
            }
            else if (recommendArticleIds.Count <= 0)
            {
                content = 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,
                    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());
                    }

                    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 = $"{article.thumbnail.url}.200x0x1.jpg";
                        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)
                           )
                       ));
        }
예제 #9
0
        public static void checkForUpdates(CheckVersionType type)
        {
            if (type == CheckVersionType.setting)
            {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog(message: "正在检查更新")
                    );
            }

            SettingApi.CheckNewVersion(platform: Config.platform, store: Config.store, $"{Config.versionCode}")
            .Then(versionResponse => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }

                var status = versionResponse.status;
                if (status == "NEED_UPDATE" && versionResponse.url.isNotEmpty())
                {
                    if (type == CheckVersionType.initialize && !needNoticeNewVersion() || needForceUpdate())
                    {
                        return;
                    }
                    markUpdateNoticeTime();
                    CustomDialogUtils.showCustomDialog(
                        barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                        child: new CustomAlertDialog(
                            null,
                            message: versionResponse.changeLog,
                            new List <Widget> {
                        new CustomButton(
                            child: new Center(
                                child: new Text(
                                    "稍后再说",
                                    style: CTextStyle.PLargeBody5.defaultHeight(),
                                    textAlign: TextAlign.center
                                    )
                                ),
                            onPressed: CustomDialogUtils.hiddenCustomDialog
                            ),
                        new CustomButton(
                            child: new Center(
                                child: new Text(
                                    "立即更新",
                                    style: CTextStyle.PLargeBlue.defaultHeight(),
                                    textAlign: TextAlign.center
                                    )
                                ),
                            onPressed: () => {
                            CustomDialogUtils.hiddenCustomDialog();
                            Application.OpenURL(url: versionResponse.url);
                        }
                            )
                    },
                            new Stack(
                                children: new List <Widget> {
                        Image.asset("image/updaterBg"),
                        new Align(
                            alignment: Alignment.bottomCenter,
                            child: new Container(height: 1, color: CColors.White)
                            )
                    }
                                )
                            )
                        );
                }
                else
                {
                    if (type == CheckVersionType.setting)
                    {
                        var customSnackBar = new CustomSnackBar(
                            "当前是最新版本",
                            color: CColors.TextBody
                            );
                        customSnackBar.show();
                    }
                }
            })
            .Catch(error => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }
            });
        }
예제 #10
0
        public static void checkForUpdates(CheckVersionType type)
        {
            if (type == CheckVersionType.setting)
            {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog(message: "正在检查更新")
                    );
            }

            SettingApi.FetchVersion(Config.platform, Config.store, $"{Config.versionCode}")
            .Then(versionResponse => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }

                var status = versionResponse["status"];
                if (status.ToLower() == "need_update" && versionResponse.ContainsKey("url"))
                {
                    CustomDialogUtils.showCustomDialog(
                        barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                        child: new CustomAlertDialog(
                            "版本更新",
                            "发现新版本,立即更新体验吧!",
                            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: _ignoreUpdater
                            ),
                        new CustomButton(
                            child: new Text(
                                "立即更新",
                                style: CTextStyle.PLargeBlue,
                                textAlign: TextAlign.center
                                ),
                            onPressed: () => {
                            _ignoreUpdater();
                            var url = versionResponse["url"];
                            Application.OpenURL(url);
                        }
                            )
                    }
                            )
                        );
                }
                else
                {
                    if (type == CheckVersionType.setting)
                    {
                        var customSnackBar = new CustomSnackBar(
                            "当前是最新版本",
                            color: CColors.TextBody
                            );
                        customSnackBar.show();
                    }
                }
            })
            .Catch(error => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }
            });
        }
예제 #11
0
        public static void checkForUpdates(CheckVersionType type)
        {
            if (type == CheckVersionType.setting)
            {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog(message: "正在检查更新")
                    );
            }

            SettingApi.CheckNewVersion(platform: Config.platform, store: Config.store, $"{Config.versionCode}")
            .Then(versionResponse => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }

                var status = versionResponse.status;
                if (status == "NEED_UPDATE" && versionResponse.url.isNotEmpty())
                {
                    if (type == CheckVersionType.initialize && !needNoticeNewVersion())
                    {
                        return;
                    }

                    markUpdateNoticeTime();
                    CustomDialogUtils.showCustomDialog(
                        barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                        child: new CustomAlertDialog(
                            "版本更新",
                            message: versionResponse.changeLog,
                            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();
                            Application.OpenURL(url: versionResponse.url);
                        }
                            )
                    }
                            )
                        );
                }
                else
                {
                    if (type == CheckVersionType.setting)
                    {
                        var customSnackBar = new CustomSnackBar(
                            "当前是最新版本",
                            color: CColors.TextBody
                            );
                        customSnackBar.show();
                    }
                }
            })
            .Catch(error => {
                if (type == CheckVersionType.setting)
                {
                    CustomDialogUtils.hiddenCustomDialog();
                }
            });
        }