Esempio n. 1
0
 protected override bool OnBackButtonPressed()
 {
     if (popupPage != null)
     {
         Navigation.RemovePopupPageAsync(popupPage);
         popupPage = null;
         return(true);
     }
     return(base.OnBackButtonPressed());
 }
Esempio n. 2
0
 async void OnShowComment(object sender, EventArgs args)
 {
     if (UserTokenSettings.Current.HasExpiresIn())
     {
         MessagingService.Current.SendMessage(MessageKeys.NavigateLogin);
     }
     else
     {
         var page = new NewsCommentPopupPage(news, new Action <NewsComments>(OnResult));
         await Navigation.PushPopupAsync(page);
     }
 }
Esempio n. 3
0
        public NewsDetailsPage(News news)
        {
            InitializeComponent();
            Xamarin.Forms.PlatformConfiguration.iOSSpecific.Page.SetUseSafeArea(this, true);
            this.news      = news;
            BindingContext = new NewsDetailsViewModel(news);

            var cancel = new ToolbarItem
            {
                Text    = "Share",
                Command = new Command(() =>
                {
                    DependencyService.Get <IShares>().SharesIcon("https://news.cnblogs.com/n/" + news.Id + "/", news.Title, news.TopicIcon);
                })
            };

            ToolbarItems.Add(cancel);

            if (Device.Android == Device.RuntimePlatform)
            {
                cancel.Icon = "toolbar_share.png";
            }

            formsWebView.OnContentLoaded += delegate(object sender, EventArgs e)
            {
                RefreshNews();
            };
            formsWebView.AddLocalCallback("reload", async delegate(string obj)
            {
                if (formsWebView.LoadStatus == LoadMoreStatus.StausDefault || formsWebView.LoadStatus == LoadMoreStatus.StausError || formsWebView.LoadStatus == LoadMoreStatus.StausFail)
                {
                    var newsComments = JsonConvert.SerializeObject(await ViewModel.ReloadCommentsAsync());
                    await formsWebView.InjectJavascriptAsync("updateComments(" + newsComments + ");");
                }
            });
            formsWebView.AddLocalCallback("editItem", delegate(string id)
            {
                var newsComments = ViewModel.NewsComments.Where(n => n.CommentID == int.Parse(id)).FirstOrDefault();
                Device.BeginInvokeOnMainThread(async() =>
                {
                    var page = new NewsCommentPopupPage(news, new Action <NewsComments>(OnResult), newsComments);
                    await Navigation.PushPopupAsync(page);
                });
            });
            formsWebView.AddLocalCallback("deleteItem", async delegate(string id)
            {
                var result = await ViewModel.DeleteCommentAsync(int.Parse(id));
                await formsWebView.InjectJavascriptAsync("deleteComment(" + id + "," + result.ToString().ToLower() + ");");
            });
        }