Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Microsoft.Toolkit.Uwp.Notifications linker-friendly #4553

Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,21 @@ public enum AdaptiveImageAlign
/// <summary>
/// Image stretches to fill available width (and potentially available height too, depending on where the image is).
/// </summary>
[EnumString("stretch")]
Stretch,

/// <summary>
/// Align the image to the left, displaying the image at its native resolution.
/// </summary>
[EnumString("left")]
Left,

/// <summary>
/// Align the image in the center horizontally, displaying the image at its native resolution.
/// </summary>
[EnumString("center")]
Center,

/// <summary>
/// Align the image to the right, displaying the image at its native resolution.
/// </summary>
[EnumString("right")]
Right
}

Expand All @@ -52,13 +48,11 @@ public enum AdaptiveImageCrop
/// <summary>
/// Image is not cropped.
/// </summary>
[EnumString("none")]
None,

/// <summary>
/// Image is cropped to a circle shape.
/// </summary>
[EnumString("circle")]
Circle
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,16 @@ public enum AdaptiveSubgroupTextStacking
/// <summary>
/// Vertical align to the top.
/// </summary>
[EnumString("top")]
Top,

/// <summary>
/// Vertical align to the center.
/// </summary>
[EnumString("center")]
Center,

/// <summary>
/// Vertical align to the bottom.
/// </summary>
[EnumString("bottom")]
Bottom
}
}
23 changes: 0 additions & 23 deletions Microsoft.Toolkit.Uwp.Notifications/Adaptive/AdaptiveTextEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,103 +17,86 @@ public enum AdaptiveTextStyle
/// <summary>
/// Default value. Paragraph font size, normal weight and opacity.
/// </summary>
[EnumString("caption")]
Caption,

/// <summary>
/// Same as Caption but with subtle opacity.
/// </summary>
[EnumString("captionSubtle")]
CaptionSubtle,

/// <summary>
/// H5 font size.
/// </summary>
[EnumString("body")]
Body,

/// <summary>
/// Same as Body but with subtle opacity.
/// </summary>
[EnumString("bodySubtle")]
BodySubtle,

/// <summary>
/// H5 font size, bold weight. Essentially the bold version of Body.
/// </summary>
[EnumString("base")]
Base,

/// <summary>
/// Same as Base but with subtle opacity.
/// </summary>
[EnumString("baseSubtle")]
BaseSubtle,

/// <summary>
/// H4 font size.
/// </summary>
[EnumString("subtitle")]
Subtitle,

/// <summary>
/// Same as Subtitle but with subtle opacity.
/// </summary>
[EnumString("subtitleSubtle")]
SubtitleSubtle,

/// <summary>
/// H3 font size.
/// </summary>
[EnumString("title")]
Title,

/// <summary>
/// Same as Title but with subtle opacity.
/// </summary>
[EnumString("titleSubtle")]
TitleSubtle,

/// <summary>
/// Same as Title but with top/bottom padding removed.
/// </summary>
[EnumString("titleNumeral")]
TitleNumeral,

/// <summary>
/// H2 font size.
/// </summary>
[EnumString("subheader")]
Subheader,

/// <summary>
/// Same as Subheader but with subtle opacity.
/// </summary>
[EnumString("subheaderSubtle")]
SubheaderSubtle,

/// <summary>
/// Same as Subheader but with top/bottom padding removed.
/// </summary>
[EnumString("subheaderNumeral")]
SubheaderNumeral,

/// <summary>
/// H1 font size.
/// </summary>
[EnumString("header")]
Header,

/// <summary>
/// Same as Header but with subtle opacity.
/// </summary>
[EnumString("headerSubtle")]
HeaderSubtle,

/// <summary>
/// Same as Header but with top/bottom padding removed.
/// </summary>
[EnumString("headerNumeral")]
HeaderNumeral
}

Expand All @@ -130,25 +113,21 @@ public enum AdaptiveTextAlign
/// <summary>
/// The system automatically decides the alignment based on the language and culture.
/// </summary>
[EnumString("auto")]
Auto,

/// <summary>
/// Horizontally align the text to the left.
/// </summary>
[EnumString("left")]
Left,

/// <summary>
/// Horizontally align the text in the center.
/// </summary>
[EnumString("center")]
Center,

/// <summary>
/// Horizontally align the text to the right.
/// </summary>
[EnumString("right")]
Right
}

Expand All @@ -158,8 +137,6 @@ internal enum AdaptiveTextPlacement
/// Default value
/// </summary>
Inline,

[EnumString("attribution")]
Attribution
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
{
[NotificationXmlElement("group")]
internal sealed class Element_AdaptiveGroup : IElement_TileBindingChild, IElement_ToastBindingChild, IElementWithDescendants
internal sealed class Element_AdaptiveGroup : IElement_TileBindingChild, IElement_ToastBindingChild, IElementWithDescendants, IHaveXmlName, IHaveXmlChildren
{
public IList<Element_AdaptiveSubgroup> Children { get; private set; } = new List<Element_AdaptiveSubgroup>();

Expand All @@ -25,5 +24,11 @@ public IEnumerable<object> Descendants()
}
}
}

/// <inheritdoc/>
string IHaveXmlName.Name => "group";

/// <inheritdoc/>
IEnumerable<object> IHaveXmlChildren.Children => Children;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,34 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;

namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
{
[NotificationXmlElement("image")]
internal sealed class Element_AdaptiveImage : IElement_TileBindingChild, IElement_ToastBindingChild, IElement_AdaptiveSubgroupChild
internal sealed class Element_AdaptiveImage : IElement_TileBindingChild, IElement_ToastBindingChild, IElement_AdaptiveSubgroupChild, IHaveXmlName, IHaveXmlNamedProperties
{
internal const AdaptiveImagePlacement DEFAULT_PLACEMENT = AdaptiveImagePlacement.Inline;
internal const AdaptiveImageCrop DEFAULT_CROP = AdaptiveImageCrop.Default;
internal const AdaptiveImageAlign DEFAULT_ALIGN = AdaptiveImageAlign.Default;

[NotificationXmlAttribute("id")]
public int? Id { get; set; }

[NotificationXmlAttribute("src")]
public string Src { get; set; }

[NotificationXmlAttribute("alt")]
public string Alt { get; set; }

[NotificationXmlAttribute("addImageQuery")]
public bool? AddImageQuery { get; set; }

[NotificationXmlAttribute("placement", DEFAULT_PLACEMENT)]
public AdaptiveImagePlacement Placement { get; set; } = DEFAULT_PLACEMENT;

[NotificationXmlAttribute("hint-align", DEFAULT_ALIGN)]
public AdaptiveImageAlign Align { get; set; } = DEFAULT_ALIGN;

[NotificationXmlAttribute("hint-crop", DEFAULT_CROP)]
public AdaptiveImageCrop Crop { get; set; } = DEFAULT_CROP;

[NotificationXmlAttribute("hint-removeMargin")]
public bool? RemoveMargin { get; set; }

private int? _overlay;

[NotificationXmlAttribute("hint-overlay")]
public int? Overlay
{
get
Expand All @@ -56,16 +48,46 @@ public int? Overlay
}
}

[NotificationXmlAttribute("spritesheet-src")]
public string SpriteSheetSrc { get; set; }

[NotificationXmlAttribute("spritesheet-height")]
public uint? SpriteSheetHeight { get; set; }

[NotificationXmlAttribute("spritesheet-fps")]
public uint? SpriteSheetFps { get; set; }

[NotificationXmlAttribute("spritesheet-startingFrame")]
public uint? SpriteSheetStartingFrame { get; set; }

/// <inheritdoc/>
string IHaveXmlName.Name => "image";

/// <inheritdoc/>
IEnumerable<KeyValuePair<string, object>> IHaveXmlNamedProperties.EnumerateNamedProperties()
{
yield return new("id", Id);
yield return new("src", Src);
yield return new("alt", Alt);
yield return new("addImageQuery", AddImageQuery);

if (Placement != DEFAULT_PLACEMENT)
{
yield return new("placement", Placement.ToPascalCaseString());
}

if (Align != DEFAULT_ALIGN)
{
yield return new("hint-align", Align.ToPascalCaseString());
}

if (Crop != DEFAULT_CROP)
{
yield return new("hint-crop", Crop.ToPascalCaseString());
}

yield return new("hint-removeMargin", RemoveMargin);
yield return new("hint-overlay", Overlay);
yield return new("spritesheet-src", SpriteSheetSrc);
yield return new("spritesheet-height", SpriteSheetHeight);
yield return new("spritesheet-fps", SpriteSheetFps);
yield return new("spritesheet-startingFrame", SpriteSheetStartingFrame);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,10 @@ namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
{
internal enum AdaptiveImagePlacement
{
[EnumString("inline")]
Inline,

[EnumString("background")]
Background,

[EnumString("peek")]
Peek,

[EnumString("hero")]
Hero,

[EnumString("appLogoOverride")]
AppLogoOverride
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;

namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
{
[NotificationXmlElement("progress")]
internal sealed class Element_AdaptiveProgressBar : IElement_ToastBindingChild
internal sealed class Element_AdaptiveProgressBar : IElement_ToastBindingChild, IHaveXmlName, IHaveXmlNamedProperties
{
[NotificationXmlAttribute("value")]
public string Value { get; set; }

[NotificationXmlAttribute("title")]
public string Title { get; set; }

[NotificationXmlAttribute("valueStringOverride")]
public string ValueStringOverride { get; set; }

[NotificationXmlAttribute("status")]
public string Status { get; set; }

/// <inheritdoc/>
string IHaveXmlName.Name => "progress";

/// <inheritdoc/>
IEnumerable<KeyValuePair<string, object>> IHaveXmlNamedProperties.EnumerateNamedProperties()
{
yield return new("value", Value);
yield return new("title", Title);
yield return new("valueStringOverride", ValueStringOverride);
yield return new("status", Status);
}
}
}
Loading