787a6e9f48
UI navigation framework Related Work Items: #408, #414, #416
52 lines
1.2 KiB
C#
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());
|
|
}
|
|
}
|
|
}
|