void SetupMessaging()
        {
            // Is is for when the user flags a crime news article.  Since DisplayActionSheet is only accessible
            // from page classes, this message will be sent up by a NewsCard that wants to ask the user why
            // a news article should be flagged.
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void
            MessagingCenter.Subscribe <object, NewsFlagConcern>(this, "FlagArticle", async(sender, arg) =>
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void
            {
                var action = await DisplayActionSheet("What's wrong with the article?", "Cancel", null, "Story is not about this crime", "Spam or advertising", "Duplicate", "Opinion column or blog");
                if (action != "Cancel")
                {
                    var concern    = new NewsFlagConcern();
                    concern.Reason = action;
                    concern.URL    = arg.URL;
                    concern.DCN    = arg.DCN;
                    // Send a message back to the listening news card.
                    MessagingCenter.Send <object, NewsFlagConcern>(sender, "SubmitFlaggedArticle", concern);
                }
            });

            // This is in case a user flags a news article but that fails.
            MessagingCenter.Subscribe <object, string>(this, "FlagFailed", (sender, arg) =>
            {
                DisplayAlert("Problem flagging this article", arg, "OK");
            });
        }
示例#2
0
        void ArticleFlagged(object sender, System.EventArgs e)
        {
            var concern = new NewsFlagConcern();

            concern.DCN = _dcn;
            concern.URL = _url;
            // User has identified this as a bad article.  Ask the parent page to display a dialog asking why.
            MessagingCenter.Send <object, NewsFlagConcern>(this, "FlagArticle", concern);
        }