Skip to content

Commit

Permalink
feat: Add one-line method to set native frame navigation styles
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjohnoliver committed Oct 1, 2020
1 parent 23970c0 commit b228b16
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Uno.UI/FeatureConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ public static class Style
/// <summary>
/// Determines if Uno.UI should be using native styles for controls that have
/// a native counterpart. (e.g. Button, Slider, ComboBox, ...)
///
/// By default this is true.
/// </summary>
public static bool UseUWPDefaultStyles { get; set; } = true;

Expand All @@ -283,6 +285,28 @@ public static class Style
/// appearance/comportment for a few particular controls, or vice versa.
/// </remarks>
public static IDictionary<Type, bool> UseUWPDefaultStylesOverride { get; } = new Dictionary<Type, bool>();

/// <summary>
/// This enables native frame navigation on Android and iOS by setting related classes (<see cref="Frame"/>, <see cref="CommandBar"/>
/// and <see cref="AppBarButton"/>) to use their native styles.
/// </summary>
public static void ConfigureNativeFrameNavigation()
{
SetUWPDefaultStylesOverride<Frame>(useUWPDefaultStyle: false);
SetUWPDefaultStylesOverride<CommandBar>(useUWPDefaultStyle: false);
SetUWPDefaultStylesOverride<AppBarButton>(useUWPDefaultStyle: false);
}

/// <summary>
/// Override the native styles useage for control type <typeparamref name="TControl"/>.
/// </summary>
/// <typeparam name="TControl"></typeparam>
/// <param name="useUWPDefaultStyle">
/// Whether instances of <typeparamref name="TControl"/> should use the UWP default style.
/// If false, the native default style (if one exists) will be used.
/// </param>
public static void SetUWPDefaultStylesOverride<TControl>(bool useUWPDefaultStyle) where TControl : Windows.UI.Xaml.Controls.Control
=> UseUWPDefaultStylesOverride[typeof(TControl)] = useUWPDefaultStyle;
}

public static class TextBlock
Expand Down

0 comments on commit b228b16

Please sign in to comment.