Exemplo n.º 1
0
        public async Task RenderComments()
        {
            var comments = new List <Comment>();

            foreach (var x in ViewModel.Comments)
            {
                var body = await _markdownService.Convert(x.Body);

                comments.Add(new Comment(x.User.AvatarUrl, x.User.Login, body, x.CreatedAt));
            }

            var events = ViewModel
                         .Events
                         .Select(x => new Comment(x.Actor.AvatarUrl, x.Actor.Login, CreateEventBody(x.Event.StringValue, x.CommitId), x.CreatedAt));

            var items = comments
                        .Concat(events)
                        .Where(x => !string.IsNullOrEmpty(x.Body))
                        .OrderBy(x => x.Date)
                        .ToList();

            var commentModel = new CommentsModel(items, (int)UIFont.PreferredSubheadline.PointSize);
            var razorView    = new CommentsWebView {
                Model = commentModel
            };
            var html = razorView.GenerateString();

            InvokeOnMainThread(() => {
                _commentsElement.SetValue(!comments.Any() ? null : html);
                Render();
            });
        }
Exemplo n.º 2
0
        private async void WebView_NewWindowRequested(WebView sender, WebViewNewWindowRequestedEventArgs args)
        {
            args.Handled = true;

            var uri = args.Uri.ToString();

            if (!uri.StartsWith("https://oauth.vk.com/authorize") && !uri.StartsWith("https://vk.com/widget_comments.php") && !uri.StartsWith("https://vk.com/id"))
            {
                await Launcher.LaunchUriAsync(args.Uri);

                return;
            }

            if (uri.StartsWith("https://oauth.vk.com/authorize") && m_CurrentUri != null)
            {
                uri = uri.Replace("close.html", WebUtility.UrlEncode(m_CurrentUri.ToString()));
            }

            if (uri.StartsWith("https://vk.com/id"))
            {
                uri = uri.Replace("vk.com", "m.vk.com");
            }

            CommentsWebView.Navigate(new Uri(uri));
        }
Exemplo n.º 3
0
        public void RenderComments()
        {
            var comments = ViewModel.Comments
                           .Select(x => new Comment(x.User.AvatarUrl, x.User.Login, ViewModel.ConvertToMarkdown(x.Body), x.CreatedAt))
                           .Concat(ViewModel.Events.Select(x => new Comment(x.Actor.AvatarUrl, x.Actor.Login, CreateEventBody(x.Event, x.CommitId), x.CreatedAt)))
                           .Where(x => !string.IsNullOrEmpty(x.Body))
                           .OrderBy(x => x.Date)
                           .ToList();
            var commentModel = new CommentsModel(comments, (int)UIFont.PreferredSubheadline.PointSize);
            var razorView    = new CommentsWebView {
                Model = commentModel
            };
            var html = razorView.GenerateString();

            InvokeOnMainThread(() => {
                _commentsElement.SetValue(!comments.Any() ? null : html);
                Render();
            });
        }
Exemplo n.º 4
0
 private void SetCommentsUrl(Uri newUrl)
 {
     CommentsWebView.Navigate(newUrl);
 }