Archived
1
0
This repository has been archived on 2026-04-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Michael Gordeev 787a6e9f48 Refactored core
UI navigation framework

Related Work Items: #408, #414, #416
2020-06-15 15:46:38 +03:00

52 lines
1.2 KiB
C#

using System.Linq;
using Microsoft.Toolkit.Uwp.Notifications;
using Google.Apis.Blogger.v3.Data;
using Windows.UI.Notifications;
using AngleSharp.Html.Parser;
namespace FoxTube.Utils
{
public static class ToastTemplates
{
public static ToastNotification GetBlogpostToast(Post post)
{
ToastContent toastContent = new ToastContent
{
Visual = new ToastVisual
{
BindingGeneric = new ToastBindingGeneric
{
Children =
{
new AdaptiveText
{
Text = new BindableString(post.Title)
},
new AdaptiveText()
{
Text = new BindableString(new HtmlParser().ParseDocument(post.Content).QuerySelector("p").TextContent),
HintMaxLines = 2
}
},
AppLogoOverride = new ToastGenericAppLogo
{
Source = post.Author.Image.Url,
HintCrop = ToastGenericAppLogoCrop.Circle
}
}
},
Launch = $"Settings/Inbox/{post.Id}",
ActivationType = ToastActivationType.Foreground
};
if (post.Images.Count > 0)
toastContent.Visual.BindingGeneric.HeroImage = new ToastGenericHeroImage
{
Source = post.Images.FirstOrDefault()?.Url
};
return new ToastNotification(toastContent.GetXml());
}
}
}