Example #1
0
        public static object leaveChannel(string channelId, string memberId = null, string groupId = null)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            CustomDialogUtils.showCustomDialog(child: new CustomLoadingDialog(message: "正在退出群聊"));

            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return ChannelApi.LeaveChannel(channelId: channelId, memberId: memberId, groupId: groupId)
                .Then(leaveChannelResponse => {
                    dispatcher.dispatch(new LeaveChannelSuccessAction {
                        channelId = channelId
                    });
                    CustomDialogUtils.hiddenCustomDialog();
                    dispatcher.dispatch(new MainNavigatorPopAction());
                    dispatcher.dispatch(new MainNavigatorPopAction());
                })
                .Catch(error => {
                    dispatcher.dispatch(new LeaveChannelFailureAction());
                    CustomDialogUtils.hiddenCustomDialog();
                    Debuger.LogError(message: error);
                });
            }));
        }
Example #2
0
 public static object loginByQr(string token, string action)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return LoginApi.LoginByQr(token: token, action: action)
         .Then(success => {
             if (action != "confirm")
             {
                 return;
             }
             CustomDialogUtils.hiddenCustomDialog();
             dispatcher.dispatch(new MainNavigatorPopAction());
             CustomDialogUtils.showToast(
                 success ? "扫码成功" : "扫码失败",
                 success ? Icons.sentiment_satisfied : Icons.sentiment_dissatisfied
                 );
         })
         .Catch(error => {
             if (action != "confirm")
             {
                 return;
             }
             CustomDialogUtils.hiddenCustomDialog();
             dispatcher.dispatch(new MainNavigatorPopAction());
             CustomDialogUtils.showToast("扫码失败", iconData: Icons.sentiment_dissatisfied);
         });
     }));
 }
Example #3
0
        public static object createFavoriteTag(IconStyle iconStyle, string name, string description = "")
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            CustomDialogUtils.showCustomDialog(
                child: new CustomLoadingDialog(
                    message: "新建收藏夹中"
                    )
                );
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return FavoriteApi.CreateFavoriteTag(iconStyle: iconStyle, name: name, description: description)
                .Then(createFavoriteTagResponse => {
                    CustomDialogUtils.hiddenCustomDialog();
                    dispatcher.dispatch(new CreateFavoriteTagSuccessAction {
                        favoriteTag = createFavoriteTagResponse
                    });
                    dispatcher.dispatch(new MainNavigatorPopAction());
                })
                .Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    Debug.Log(error);
                });
            }));
        }
Example #4
0
        void updateAvatar(bool editSuccess)
        {
            if (!editSuccess)
            {
                CustomDialogUtils.hiddenCustomDialog();
                CustomDialogUtils.showToast("提交失败", iconData: Icons.sentiment_dissatisfied);
                return;
            }

            if (this._pickedImage.isEmpty())
            {
                CustomDialogUtils.hiddenCustomDialog();
                this.widget.actionModel.mainRouterPop();
            }
            else
            {
                this.widget.actionModel.updateAvatar(arg: this._pickedImage).Then(() => {
                    CustomDialogUtils.hiddenCustomDialog();
                    this.widget.actionModel.mainRouterPop();
                }).Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    CustomDialogUtils.showToast("提交失败", iconData: Icons.sentiment_dissatisfied);
                });
            }
        }
 void _showShareView(IEvent eventObj)
 {
     ShareUtils.showShareView(
         new ShareView(
             projectType: ProjectType.iEvent,
             onPressed: type => {
         var linkUrl =
             $"{Config.apiAddress}/events/{eventObj.id}";
         if (type == ShareType.clipBoard)
         {
             this.widget.actionModel.copyText(linkUrl);
             CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline);
         }
         else
         {
             var imageUrl = $"{eventObj.avatar}.200x0x1.jpg";
             CustomDialogUtils.showCustomDialog(
                 child: new CustomLoadingDialog()
                 );
             this.widget.actionModel.shareToWechat(type, eventObj.title, eventObj.shortDescription,
                                                   linkUrl,
                                                   imageUrl).Then(CustomDialogUtils.hiddenCustomDialog)
             .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
         }
     }
             )
         );
 }
 void _showShareView(IEvent eventObj)
 {
     ActionSheetUtils.showModalActionSheet(
         new ShareView(
             projectType: ProjectType.iEvent,
             onPressed: type => {
         AnalyticsManager.ClickShare(shareType: type, "Event", "Event_" + eventObj.id,
                                     title: eventObj.title);
         var linkUrl = $"{Config.unity_cn_url}/events/{eventObj.id}";
         var path    = CStringUtils.CreateMiniPath(id: eventObj.id, title: eventObj.title);
         if (type == ShareType.clipBoard)
         {
             this.widget.actionModel.copyText(obj: linkUrl);
             CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline);
         }
         else
         {
             var imageUrl = CImageUtils.SizeTo200ImageUrl(imageUrl: eventObj.avatar);
             CustomDialogUtils.showCustomDialog(
                 child: new CustomLoadingDialog()
                 );
             this.widget.actionModel.shareToWechat(
                 arg1: type,
                 arg2: eventObj.title,
                 arg3: eventObj.shortDescription,
                 arg4: linkUrl,
                 arg5: imageUrl,
                 arg6: path)
             .Then(onResolved: CustomDialogUtils.hiddenCustomDialog)
             .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
         }
     }
             )
         );
 }
 void _handleSubmitted(string text)
 {
     this.widget.actionModel.startSendMessage();
     this.widget.actionModel.sendMessage(this.widget.viewModel.channelId, text, Snowflake.CreateNonce(), "")
     .Catch(_ => { CustomDialogUtils.showToast("消息发送失败", Icons.error_outline); });
     this._refreshController.scrollTo(0);
 }
Example #8
0
        public static object deleteFavoriteTag(string tagId)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            CustomDialogUtils.showCustomDialog(
                child: new CustomLoadingDialog(
                    message: "删除收藏夹中"
                    )
                );
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return FavoriteApi.DeleteFavoriteTag(tagId: tagId)
                .Then(deleteFavoriteTagResponse => {
                    CustomDialogUtils.hiddenCustomDialog();
                    dispatcher.dispatch(new DeleteFavoriteTagSuccessAction {
                        favoriteTag = deleteFavoriteTagResponse
                    });
                    AnalyticsManager.AnalyticsHandleFavoriteTag(type: FavoriteTagType.delete);
                })
                .Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    Debuger.LogError(message: error);
                });
            }));
        }
Example #9
0
        public static object editFavoriteTag(IconStyle iconStyle, string tagId, string name, string description = "")
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            CustomDialogUtils.showCustomDialog(
                child: new CustomLoadingDialog(
                    message: "编辑收藏夹中"
                    )
                );
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return FavoriteApi
                .EditFavoriteTag(tagId: tagId, iconStyle: iconStyle, name: name, description: description)
                .Then(editFavoriteTagResponse => {
                    CustomDialogUtils.hiddenCustomDialog();
                    dispatcher.dispatch(new EditFavoriteTagSuccessAction {
                        favoriteTag = editFavoriteTagResponse
                    });
                    dispatcher.dispatch(new MainNavigatorPopAction());
                    AnalyticsManager.AnalyticsHandleFavoriteTag(type: FavoriteTagType.edit);
                })
                .Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    Debuger.LogError(message: error);
                });
            }));
        }
Example #10
0
        public static object collectFavoriteTag(string itemId, string rankDataId = "", string tagId = "")
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            return(new ThunkAction <AppState>((dispatcher, getState) => {
                dispatcher.dispatch(new ChangeFavoriteTagStateAction {
                    isLoading = true
                });
                return FavoriteApi.CollectFavoriteTag(tagId: itemId)
                .Then(collectFavoriteTagResponse => {
                    dispatcher.dispatch(new CreateFavoriteTagSuccessAction {
                        favoriteTag = collectFavoriteTagResponse.favoriteTag,
                        isCollection = true
                    });
                    dispatcher.dispatch(new CollectFavoriteTagSuccessAction {
                        myFavoriteTagId = collectFavoriteTagResponse.favoriteTag.id,
                        rankDataId = rankDataId,
                        itemId = itemId,
                        tagId = tagId
                    });


                    AnalyticsManager.AnalyticsHandleFavoriteTag(type: FavoriteTagType.collect);
                })
                .Catch(error => {
                    dispatcher.dispatch(new ChangeFavoriteTagStateAction());
                    Debuger.LogError(message: error);
                });
            }));
        }
Example #11
0
        public static object cancelCollectFavoriteTag(string tagId, string itemId)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            return(new ThunkAction <AppState>((dispatcher, getState) => {
                dispatcher.dispatch(new ChangeFavoriteTagStateAction {
                    isLoading = true
                });
                return FavoriteApi.DeleteFavoriteTag(tagId: tagId, itemId.isNotEmpty() ? "" : tagId)
                .Then(deleteFavoriteTagResponse => {
                    dispatcher.dispatch(new DeleteFavoriteTagSuccessAction {
                        favoriteTag = deleteFavoriteTagResponse
                    });
                    dispatcher.dispatch(new CancelCollectFavoriteTagSuccessAction
                    {
                        itemId = itemId.isEmpty() ? tagId : itemId
                    });
                    AnalyticsManager.AnalyticsHandleFavoriteTag(type: FavoriteTagType.cancelCollect);
                })
                .Catch(error => {
                    dispatcher.dispatch(new ChangeFavoriteTagStateAction());
                    Debuger.LogError(message: error);
                });
            }));
        }
Example #12
0
        public static object favoriteArticle(string articleId, List <string> tagIds)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            CustomDialogUtils.showCustomDialog(
                child: new CustomLoadingDialog(
                    message: "操作中"
                    )
                );
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return ArticleApi.FavoriteArticle(articleId: articleId, tagIds: tagIds)
                .Then(favoriteArticleResponse => {
                    CustomDialogUtils.hiddenCustomDialog();
                    CustomDialogUtils.showToast("操作成功", iconData: Icons.sentiment_satisfied);
                    dispatcher.dispatch(new FavoriteArticleSuccessAction {
                        favorites = favoriteArticleResponse,
                        articleId = articleId
                    });
                    AnalyticsManager.AnalyticsFavoriteArticle(articleId: articleId, favoriteTagIds: tagIds);
                })
                .Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    Debuger.LogError(message: error);
                });
            }));
        }
Example #13
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);
             }
                                 );
         }),
         _buildGapView(),
         _switchRow(
             CCommonUtils.isIPhone ? "帧率监测" : "帧率监测 (暂仅支持 TinyGame)",
             value: this.fpsLabelIsOpen,
             value => {
             LocalDataManager.setFPSLabelStatus(isOpen: value);
             this.fpsLabelIsOpen = value;
             this.setState(() => {});
             FPSLabelPlugin.SwitchFPSLabelShowStatus(isOpen: value);
         }
             ),
         this.widget.viewModel.isLoggedIn ? _buildGapView() : new Container(),
         this.widget.viewModel.isLoggedIn ? this._buildLogoutBtn() : new Container()
     }
                        )
                    )
                ));
 }
Example #14
0
        void _onShare(Article article)
        {
            var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id);

            ShareManager.showArticleShareView(
                true,
                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());
            }
                );
        }
Example #15
0
 public static object sendComment(string articleId, string channelId, string content, string nonce,
                                  string parentMessageId)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.SendComment(channelId, content, nonce, parentMessageId)
         .Then(message => {
             CustomDialogUtils.hiddenCustomDialog();
             if (message.deleted)
             {
                 if (parentMessageId.isNotEmpty())
                 {
                     CustomDialogUtils.showToast("此条评论已被删除", iconData: Icons.sentiment_dissatisfied);
                 }
             }
             else
             {
                 CustomDialogUtils.showToast("发送成功", iconData: Icons.sentiment_satisfied);
             }
             dispatcher.dispatch(new SendCommentSuccessAction {
                 message = message,
                 articleId = articleId,
                 channelId = channelId,
                 parentMessageId = parentMessageId
             });
         })
         .Catch(error => {
             CustomDialogUtils.hiddenCustomDialog();
             CustomDialogUtils.showToast("发送失败", iconData: Icons.sentiment_dissatisfied);
         });
     }));
 }
Example #16
0
 static void checkToken(string token)
 {
     CustomDialogUtils.showCustomDialog(
         child: new CustomLoadingDialog(
             message: "验证中"
             )
         );
     LoginApi.LoginByQr(token: token, "check").Then(success => {
         CustomDialogUtils.hiddenCustomDialog();
         StoreProvider.store.dispatcher.dispatch(
             new MainNavigatorPushToQRScanLoginAction {
             token = token
         }
             );
         CustomDialogUtils.showToast("验证成功", iconData: Icons.sentiment_satisfied);
         AnalyticsManager.AnalyticsQRScan(state: QRState.check);
     }).Catch(error => {
         CustomDialogUtils.hiddenCustomDialog();
         CustomDialogUtils.showToast("验证失败", iconData: Icons.sentiment_dissatisfied);
         Promise.Delayed(new TimeSpan(0, 0, 1))
         .Then(() => {
             PushToQRScan();
             AnalyticsManager.AnalyticsQRScan(state: QRState.check, false);
         });
     });
 }
Example #17
0
        public static object unFavoriteArticle(string articleId, string favoriteId)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            CustomDialogUtils.showCustomDialog(
                child: new CustomLoadingDialog(
                    message: "取消收藏中"
                    )
                );
            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return ArticleApi.UnFavoriteArticle(favoriteId: favoriteId)
                .Then(unFavoriteArticleResponse => {
                    CustomDialogUtils.hiddenCustomDialog();
                    CustomDialogUtils.showToast("取消收藏成功", iconData: Icons.sentiment_satisfied);
                    dispatcher.dispatch(new UnFavoriteArticleSuccessAction {
                        favorite = unFavoriteArticleResponse,
                        articleId = articleId
                    });
                    AnalyticsManager.AnalyticsUnFavoriteArticle(favoriteId: favoriteId);
                })
                .Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    Debuger.LogError(message: error);
                });
            }));
        }
        Widget _buildUserCard(BuildContext context, int index)
        {
            var articleId   = this.widget.viewModel.likeArticleIds[index : index];
            var articleDict = this.widget.viewModel.articleDict;

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

            var article  = 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(
                           false,
                           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(obj: article.id),
                           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 _buildArticleCard(BuildContext context, int index)
        {
            var article = this.viewModel.articleHistory[index : index];
            var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id);

            return(CustomDismissible.builder(
                       Key.key(value: article.id),
                       new ArticleCard(
                           article: article,
                           () => this.actionModel.pushToArticleDetail(obj: article.id),
                           () => ShareManager.showArticleShareView(
                               true,
                               isLoggedIn: this.viewModel.isLoggedIn,
                               () => {
                Clipboard.setData(new ClipboardData(text: linkUrl));
                CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline);
            },
                               () => this.actionModel.pushToLogin(),
                               () => this.actionModel.pushToBlock(article.id),
                               () => this.actionModel.pushToReport(article.id, ReportType.article),
                               type => {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog()
                    );
                string imageUrl = CImageUtils.SizeTo200ImageUrl(article.thumbnail.url);
                this.actionModel.shareToWechat(arg1: type, arg2: article.title,
                                               arg3: article.subTitle, arg4: linkUrl, arg5: imageUrl)
                .Then(onResolved: CustomDialogUtils.hiddenCustomDialog)
                .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
            }
                               ),
                           fullName: article.fullName,
                           index == 0,
                           new ObjectKey(value: article.id)
                           ),
                       new CustomDismissibleDrawerDelegate(),
                       secondaryActions: new List <Widget> {
                new GestureDetector(
                    onTap: () => this.actionModel.deleteArticleHistory(obj: article.id),
                    child: new Container(
                        color: CColors.Separator2,
                        width: 80,
                        alignment: Alignment.center,
                        child: new Container(
                            width: 44,
                            height: 44,
                            alignment: Alignment.center,
                            decoration: new BoxDecoration(
                                CColors.White,
                                borderRadius: BorderRadius.circular(22)
                                ),
                            child: new Icon(Icons.delete_outline, size: 28, color: CColors.Error)
                            )
                        )
                    )
            },
                       controller: this._controller
                       ));
        }
Example #20
0
 Widget _buildContent()
 {
     return(new Flexible(
                child: new Container(
                    decoration: new BoxDecoration(
                        CColors.BgGrey
                        ),
                    child: new ListView(
                        physics: new AlwaysScrollableScrollPhysics(),
                        children: new List <Widget> {
         _buildGapView(),
         this.widget.viewModel.hasReviewUrl
                         ? _buildCellView("评分",
                                          () => {
             AnalyticsManager.ClickSetGrade();
             this.widget.actionModel.openUrl(this.widget.viewModel.reviewUrl);
         })
                         : new Container(),
         this.widget.viewModel.anonymous
                         ? _buildCellView("绑定 Unity ID",
                                          () => this.widget.actionModel.mainRouterPushTo(MainNavigatorRoutes.BindUnity))
                         : new Container(),
         _buildCellView("意见反馈",
                        () => {
             this.widget.actionModel.mainRouterPushTo(MainNavigatorRoutes.Feedback);
         }),
         _buildCellView("关于我们",
                        () => {
             AnalyticsManager.ClickEnterAboutUs();
             this.widget.actionModel.mainRouterPushTo(MainNavigatorRoutes.AboutUs);
         }),
         _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);
             }
                                 );
         }),
         this.widget.viewModel.isLoggedIn ? _buildGapView() : new Container(),
         this.widget.viewModel.isLoggedIn ? this._buildLogoutBtn() : new Container()
     }
                        )
                    )
                ));
 }
Example #21
0
        Widget _buildWechatButton(BuildContext context)
        {
            if (!WechatPlugin.instance().inInstalled())
            {
                return(new Container());
            }

            WechatPlugin.instance().context = context;
            return(new CustomButton(
                       onPressed: () => {
                WechatPlugin.instance(code => {
                    CustomDialogUtils.showCustomDialog(
                        child: new CustomLoadingDialog()
                        );
                    this.actionModel.loginByWechatAction(code).Then(() => {
                        CustomDialogUtils.hiddenCustomDialog();
                        if (this.anonymous)
                        {
                            LoginScreen.navigator.pushReplacementNamed(LoginNavigatorRoutes
                                                                       .WechatBindUnity);
                        }
                        else
                        {
                            this.actionModel.mainRouterPop();
                        }
                    })
                    .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
                })
                .login(Guid.NewGuid().ToString());
            },
                       padding: EdgeInsets.zero,
                       child: new Container(
                           height: 48,
                           decoration: new BoxDecoration(
                               CColors.PrimaryBlue,
                               borderRadius: BorderRadius.all(24)
                               ),
                           child: new Row(
                               mainAxisAlignment: MainAxisAlignment.center,
                               children: new List <Widget> {
                new Icon(
                    Icons.WechatIcon,
                    size: 24,
                    color: CColors.White
                    ),
                new Container(width: 8),
                new Text(
                    "使用微信账号登录",
                    maxLines: 1,
                    style: CTextStyle.PLargeWhite
                    )
            }
                               )
                           )
                       ));
        }
Example #22
0
        static void _handleMethodCall(string method, List <JSONNode> args)
        {
            if (GlobalContext.context != null)
            {
                using (WindowProvider.of(context: GlobalContext.context).getScope()) {
                    switch (method)
                    {
                    case "OnReceiveQRCode": {
                        string qrCode = args[0];
                        if (qrCode.StartsWith("http://") || qrCode.StartsWith("https://"))
                        {
                            var uri = new Uri(uriString: qrCode);
                            if (uri.AbsoluteUri.StartsWith("https://connect"))
                            {
                                var token = HttpUtility.ParseQueryString(query: uri.Query).Get("token");
                                if (token.isNotEmpty())
                                {
                                    var isLoggedIn = StoreProvider.store.getState().loginState.isLoggedIn;
                                    if (isLoggedIn)
                                    {
                                        checkToken(token: token);
                                    }
                                    else
                                    {
                                        qrCodeToken = token;
                                        StoreProvider.store.dispatcher.dispatch(new MainNavigatorPushToAction {
                                                routeName = MainNavigatorRoutes.Login
                                            });
                                    }
                                }
                                else
                                {
                                    CustomDialogUtils.showToast("暂不支持该二维码类型", Icons.sentiment_dissatisfied);
                                }
                            }
                            else
                            {
                                CustomDialogUtils.showToast("暂不支持该二维码类型", Icons.sentiment_dissatisfied);
                            }
                        }
                        else if (!qrCode.Equals("pop"))
                        {
                            CustomDialogUtils.showToast("暂不支持该二维码类型", Icons.sentiment_dissatisfied);
                        }

                        StatusBarManager.hideStatusBar(false);
                        StatusBarManager.statusBarStyle(isLight: StoreProvider.store.getState().loginState
                                                        .isLoggedIn);
                        removeListener();
                    }
                    break;
                    }
                }
            }
        }
Example #23
0
 public static object likeArticle(string articleId)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.LikeArticle(articleId)
         .Then(() => {
             CustomDialogUtils.showToast("点赞成功", Icons.sentiment_satisfied);
             dispatcher.dispatch(new LikeArticleSuccessAction {
                 articleId = articleId
             });
         })
         .Catch(_ => CustomDialogUtils.showToast("点赞失败", Icons.sentiment_dissatisfied));
     }));
 }
Example #24
0
 Widget _buildBottomView()
 {
     return(new Container(
                padding: EdgeInsets.only(bottom: 120),
                child: new Column(
                    children: new List <Widget> {
         new CustomButton(
             padding: EdgeInsets.zero,
             onPressed: () => {
             this._needCancel = false;
             CustomDialogUtils.showCustomDialog(
                 child: new CustomLoadingDialog(
                     message: "登录中"
                     )
                 );
             this.widget.loginByQr();
         },
             child: new Container(
                 height: 48,
                 margin: EdgeInsets.only(16, right: 16),
                 alignment: Alignment.center,
                 decoration: new BoxDecoration(
                     color: CColors.PrimaryBlue,
                     borderRadius: BorderRadius.all(24)
                     ),
                 child: new Text(
                     "确定登录",
                     style: CTextStyle.PLargeWhite
                     )
                 )
             ),
         new Container(height: 12),
         new CustomButton(
             padding: EdgeInsets.zero,
             onPressed: () => this.widget.mainRouterPop(),
             child: new Container(
                 color: CColors.Transparent,
                 height: 48,
                 margin: EdgeInsets.only(16, right: 16),
                 alignment: Alignment.center,
                 child: new Text(
                     "取消",
                     style: CTextStyle.PLargeBody5
                     )
                 )
             )
     }
                    )
                ));
 }
Example #25
0
 void _editPersonalInfo()
 {
     CustomDialogUtils.showCustomDialog(
         child: new CustomLoadingDialog(
             message: "保存中"
             )
         );
     this.widget.actionModel.editPersonalInfo(
         arg1: this.widget.viewModel.fullName,
         arg2: this.widget.viewModel.title,
         arg3: this.widget.viewModel.jobRole.id,
         arg4: this.widget.viewModel.place
         ).Then(() => this.updateAvatar(true)).Catch(error => this.updateAvatar(false));
 }
Example #26
0
 public static object feedback(FeedbackType type, string content, string name = "", string contact = "")
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ReportApi.Feedback(type, content, name, contact)
         .Then(() => {
             dispatcher.dispatch(new MainNavigatorPopAction());
             CustomDialogUtils.showToast("反馈成功", Icons.sentiment_satisfied);
             dispatcher.dispatch(new FeedbackSuccessAction());
         })
         .Catch(error => {
             CustomDialogUtils.showToast("发送失败", Icons.sentiment_dissatisfied);
             dispatcher.dispatch(new FeedbackFailureAction());
         });
     }));
 }
Example #27
0
 public static object loginByWechat(string code)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return LoginApi.LoginByWechat(code: code)
         .Then(loginInfo => {
             CustomDialogUtils.hiddenCustomDialog();
             var user = new User {
                 id = loginInfo.userId,
                 fullName = loginInfo.userFullName,
                 avatar = loginInfo.userAvatar,
                 title = loginInfo.title,
                 coverImage = loginInfo.coverImageWithCDN
             };
             var dict = new Dictionary <string, User> {
                 { user.id, user }
             };
             dispatcher.dispatch(new UserMapAction {
                 userMap = dict
             });
             dispatcher.dispatch(new LoginByWechatSuccessAction {
                 loginInfo = loginInfo
             });
             dispatcher.dispatch(fetchChannels(1));
             dispatcher.dispatch(fetchCreateChannelFilter());
             UserInfoManager.saveUserInfo(loginInfo);
             AnalyticsManager.LoginEvent("wechat");
             AnalyticsManager.AnalyticsLogin("wechat", loginInfo.userId);
             JPushPlugin.setJPushAlias(loginInfo.userId);
             if (loginInfo.anonymous)
             {
                 LoginScreen.navigator.pushReplacementNamed(routeName: LoginNavigatorRoutes
                                                            .WechatBindUnity);
             }
             else
             {
                 dispatcher.dispatch(new MainNavigatorPopAction());
                 EventBus.publish(sName: EventBusConstant.login_success,
                                  new List <object> {
                     loginInfo.userId
                 });
             }
         })
         .Catch(error => {
             CustomDialogUtils.hiddenCustomDialog();
             dispatcher.dispatch(new LoginByWechatFailureAction());
         });
     }));
 }
Example #28
0
 public static object likeComment(string messageId)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.LikeComment(messageId)
         .Then(message => {
             CustomDialogUtils.showToast("点赞成功", Icons.sentiment_satisfied);
             dispatcher.dispatch(new LikeCommentSuccessAction {
                 message = message
             });
         })
         .Catch(error => {
             CustomDialogUtils.showToast("点赞失败", Icons.sentiment_dissatisfied);
             dispatcher.dispatch(new LikeCommentFailureAction());
         });
     }));
 }
Example #29
0
 public static object removeLikeComment(string messageId)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ArticleApi.RemoveLikeComment(messageId)
         .Then(message => {
             CustomDialogUtils.showToast("已取消点赞", Icons.sentiment_satisfied);
             dispatcher.dispatch(new RemoveLikeCommentSuccessAction {
                 message = message
             });
         })
         .Catch(error => {
             CustomDialogUtils.showToast("取消点赞失败", Icons.sentiment_dissatisfied);
             Debug.Log(error);
         });
     }));
 }
Example #30
0
 public static object reportItem(string itemId, string itemType, string reportContext)
 {
     return(new ThunkAction <AppState>((dispatcher, getState) => {
         return ReportApi.ReportItem(itemId, itemType, reportContext)
         .Then(() => {
             dispatcher.dispatch(new MainNavigatorPopAction());
             CustomDialogUtils.showToast("举报成功", Icons.sentiment_satisfied);
             dispatcher.dispatch(new ReportItemSuccessAction());
         })
         .Catch(error => {
             CustomDialogUtils.showToast("举报失败", Icons.sentiment_dissatisfied);
             dispatcher.dispatch(new ReportItemFailureAction());
             Debug.Log(error);
         });
     }));
 }