Esempio n. 1
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()
     }
                        )
                    )
                ));
 }
Esempio n. 2
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);
                });
            }));
        }
Esempio n. 3
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);
                });
            }));
        }
Esempio n. 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);
                });
            }
        }
Esempio n. 5
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);
                });
            }));
        }
Esempio n. 6
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);
         });
     }));
 }
Esempio n. 7
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);
         });
     }));
 }
 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());
         }
     }
             )
         );
 }
Esempio n. 9
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);
                });
            }));
        }
Esempio n. 10
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);
                });
            }));
        }
Esempio n. 11
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);
                });
            }));
        }
 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());
         }
     }
             )
         );
 }
Esempio n. 13
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());
            }
                );
        }
Esempio n. 14
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);
         });
     });
 }
        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
                       ));
        }
        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)
                       ));
        }
Esempio n. 17
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()
     }
                        )
                    )
                ));
 }
Esempio n. 18
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
                    )
            }
                               )
                           )
                       ));
        }
Esempio n. 19
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());
         });
     }));
 }
Esempio n. 20
0
 public static object sendComment(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();
             CustomDialogUtils.showToast("发送成功", Icons.sentiment_satisfied);
             dispatcher.dispatch(new SendCommentSuccessAction {
                 message = message
             });
         })
         .Catch(error => {
             CustomDialogUtils.hiddenCustomDialog();
             CustomDialogUtils.showToast("发送失败", Icons.sentiment_dissatisfied);
         });
     }));
 }
 void _editPersonalInfo()
 {
     CustomDialogUtils.showCustomDialog(
         child: new CustomLoadingDialog(
             message: "保存中"
             )
         );
     this.widget.actionModel.editPersonalInfo(
         this.widget.viewModel.fullName,
         this.widget.viewModel.title,
         this.widget.viewModel.jobRole.id,
         this.widget.viewModel.place
         ).Then(() => {
         CustomDialogUtils.hiddenCustomDialog();
         this.widget.actionModel.mainRouterPop();
     }).Catch(error => CustomDialogUtils.hiddenCustomDialog());
 }
        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("复制链接成功", iconData: Icons.check_circle_outline);
            },
                               () => this.actionModel.pushToLogin(),
                               () => this.actionModel.pushToBlock(obj: article.id),
                               () => this.actionModel.pushToReport(arg1: article.id, arg2: ReportType.article),
                               type => {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog()
                    );
                string imageUrl = CImageUtils.SizeTo200ImageUrl(imageUrl: 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,
                           new ObjectKey(value: article.id)
                           ),
                       new CustomDismissibleDrawerDelegate(),
                       secondaryActions: new List <Widget> {
                new DeleteActionButton(
                    80,
                    onTap: () => this.actionModel.deleteArticleHistory(obj: article.id)
                    )
            },
                       controller: this._controller
                       ));
        }
Esempio n. 23
0
        public static object joinChannel(string channelId, string groupId = null, bool loading = false)
        {
            if (HttpManager.isNetWorkError())
            {
                CustomDialogUtils.showToast("请检查网络", iconData: Icons.sentiment_dissatisfied);
                return(null);
            }

            if (loading)
            {
                CustomDialogUtils.showCustomDialog(child: new CustomLoadingDialog(message: "正在加入群聊"));
            }

            return(new ThunkAction <AppState>((dispatcher, getState) => {
                return ChannelApi.JoinChannel(channelId: channelId, groupId: groupId)
                .Then(joinChannelResponse => {
                    if (loading)
                    {
                        CustomDialogUtils.hiddenCustomDialog();
                    }

                    dispatcher.dispatch(new JoinChannelSuccessAction {
                        channelId = channelId,
                        member = joinChannelResponse.member
                    });
                    dispatcher.dispatch(fetchChannelMessages(channelId: channelId));
                    dispatcher.dispatch(new FetchChannelMemberSuccessAction {
                        channelId = channelId,
                        member = joinChannelResponse.member
                    });
                })
                .Catch(error => {
                    if (loading)
                    {
                        CustomDialogUtils.hiddenCustomDialog();
                    }

                    dispatcher.dispatch(new JoinChannelFailureAction {
                        channelId = channelId
                    });
                    Debuger.LogError(message: error);
                });
            }));
        }
        void _onPressBack()
        {
            if (!this._enableSubmit)
            {
                this.widget.actionModel.mainRouterPop();
                return;
            }

            var title = this.widget.viewModel.tagId.isNotEmpty() ? "编辑收藏夹" : "新建收藏夹";

            CustomDialogUtils.showCustomDialog(
                barrierColor: Color.fromRGBO(0, 0, 0, 0.5f),
                child: new CustomAlertDialog(
                    $"您正在{title},是否退出",
                    actions: 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();
                    this.widget.actionModel.mainRouterPop();
                }
                    )
            }
                    )
                );
        }
Esempio n. 25
0
 Widget _buildShareWidget(RankData game)
 {
     return(new CustomButton(
                onPressed: () => ActionSheetUtils.showModalActionSheet(
                    new ShareView(
                        projectType: ProjectType.iEvent,
                        onPressed: type => {
         // AnalyticsManager.ClickShare(type, "Event", "Event_" + eventObj.id, eventObj.title);
         var linkUrl = CStringUtils.JointTinyGameShareLink(gameId: game.id);;
         if (type == ShareType.clipBoard)
         {
             this.widget.actionModel.copyText(obj: linkUrl);
             CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline);
         }
         else
         {
             var imageUrl = CImageUtils.SizeTo200ImageUrl(imageUrl: game.image);
             CustomDialogUtils.showCustomDialog(
                 child: new CustomLoadingDialog()
                 );
             this.widget.actionModel.shareToWechat(
                 arg1: type,
                 arg2: game.resetTitle,
                 arg3: game.resetSubLabel,
                 arg4: linkUrl,
                 arg5: imageUrl
                 , null)
             .Then(onResolved: CustomDialogUtils.hiddenCustomDialog)
             .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
         }
     }
                        )
                    ),
                child: new Container(
                    color: CColors.Transparent,
                    child: new Icon(
                        icon: Icons.outline_share,
                        size: 24,
                        color: CColors.Icon
                        )
                    )
                ));
 }
Esempio n. 26
0
 void _share(Article article)
 {
     ActionSheetUtils.showModalActionSheet(new ShareView(
                                               projectType: ProjectType.article,
                                               onPressed: type => {
         var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id);
         if (type == ShareType.clipBoard)
         {
             Clipboard.setData(new ClipboardData(text: linkUrl));
             CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline);
         }
         else if (type == ShareType.block)
         {
             ReportManager.block(
                 isLoggedIn: this.widget.viewModel.isLoggedIn,
                 () => this.widget.actionModel.pushToLogin(),
                 () => this.widget.actionModel.pushToBlock(article.id),
                 () => this.widget.actionModel.mainRouterPop()
                 );
         }
         else if (type == ShareType.report)
         {
             ReportManager.report(
                 isLoggedIn: this.widget.viewModel.isLoggedIn,
                 () => this.widget.actionModel.pushToLogin(),
                 () => this.widget.actionModel.pushToReport(arg1: article.id, arg2: ReportType.article)
                 );
         }
         else
         {
             CustomDialogUtils.showCustomDialog(
                 child: new CustomLoadingDialog()
                 );
             string imageUrl = CImageUtils.SizeTo200ImageUrl(article.thumbnail.url);
             this.widget.actionModel.shareToWechat(type, article.title, article.subTitle,
                                                   linkUrl,
                                                   imageUrl).Then(CustomDialogUtils.hiddenCustomDialog)
             .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
         }
     }
                                               ));
 }
Esempio n. 27
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 == "cancel")
                    {
                        AnalyticsManager.AnalyticsQRScan(state: QRState.cancel);
                        return;
                    }

                    CustomDialogUtils.hiddenCustomDialog();
                    dispatcher.dispatch(new MainNavigatorPopAction());
                    CustomDialogUtils.showToast(
                        success ? "登录成功" : "登录失败",
                        success ? Icons.sentiment_satisfied : Icons.sentiment_dissatisfied
                        );
                    if (success)
                    {
                        AnalyticsManager.AnalyticsQRScan(state: QRState.confirm);
                    }
                    else
                    {
                        AnalyticsManager.AnalyticsQRScan(state: QRState.confirm, false);
                    }
                }).Catch(error => {
                    Debuger.LogError($"confirm api error: {error}, action: {action}");
                    if (action == "cancel")
                    {
                        AnalyticsManager.AnalyticsQRScan(state: QRState.cancel, false);
                        return;
                    }

                    CustomDialogUtils.hiddenCustomDialog();
                    dispatcher.dispatch(new MainNavigatorPopAction());
                    CustomDialogUtils.showToast("登录失败", iconData: Icons.sentiment_dissatisfied);
                    AnalyticsManager.AnalyticsQRScan(state: QRState.confirm, false);
                }
                         );
            }));
        }
Esempio n. 28
0
        void share()
        {
            var userId = "";

            if (this._article.ownerType == OwnerType.user.ToString())
            {
                userId = this._article.userId;
            }

            if (this._article.ownerType == OwnerType.team.ToString())
            {
                userId = this._article.teamId;
            }

            var linkUrl = CStringUtils.JointProjectShareLink(projectId: this._article.id);

            ShareManager.showArticleShareView(
                this.widget.viewModel.loginUserId != 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(this._article.id),
                () => this.widget.actionModel.pushToReport(this._article.id, ReportType.article),
                type => {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog()
                    );
                string imageUrl = CImageUtils.SizeTo200ImageUrl(this._article.thumbnail.url);
                this.widget.actionModel.shareToWechat(arg1: type, arg2: this._article.title,
                                                      arg3: this._article.subTitle, arg4: linkUrl, arg5: imageUrl)
                .Then(onResolved: CustomDialogUtils.hiddenCustomDialog)
                .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
            },
                () => this.widget.actionModel.mainRouterPop()
                );
        }
Esempio n. 29
0
 void share()
 {
     ShareUtils.showShareView(new ShareView(
                                  projectType: ProjectType.article,
                                  onPressed: type => {
         string linkUrl = $"{Config.apiAddress}/p/{this._article.id}";
         if (type == ShareType.clipBoard)
         {
             Clipboard.setData(new ClipboardData(linkUrl));
             CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline);
         }
         else if (type == ShareType.block)
         {
             ReportManager.block(this.widget.viewModel.isLoggedIn, this._article.id,
                                 this.widget.actionModel.pushToLogin, this.widget.actionModel.pushToBlock,
                                 this.widget.actionModel.mainRouterPop
                                 );
         }
         else if (type == ShareType.report)
         {
             ReportManager.report(this.widget.viewModel.isLoggedIn, this._article.id,
                                  ReportType.article, this.widget.actionModel.pushToLogin,
                                  this.widget.actionModel.pushToReport
                                  );
         }
         else
         {
             CustomDialogUtils.showCustomDialog(
                 child: new CustomLoadingDialog()
                 );
             string imageUrl = $"{this._article.thumbnail.url}.200x0x1.jpg";
             this.widget.actionModel.shareToWechat(type, this._article.title, this._article.subTitle,
                                                   linkUrl,
                                                   imageUrl).Then(CustomDialogUtils.hiddenCustomDialog)
             .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
         }
     }
                                  ));
 }
Esempio n. 30
0
        public static object fetchUnStickChannel(string channelId)
        {
            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.FetchUnStickChannel(channelId: channelId)
                .Then(unStickChannelResponse => {
                    CustomDialogUtils.hiddenCustomDialog();
                    dispatcher.dispatch(new FetchUnStickChannelSuccessAction {
                        channelId = channelId
                    });
                })
                .Catch(error => {
                    CustomDialogUtils.hiddenCustomDialog();
                    Debuger.LogError(message: error);
                });
            }));
        }