Skip to content

Commit

Permalink
Merge pull request #1324 from unoplatform/dev/doti/hide-systemthemehe…
Browse files Browse the repository at this point in the history
…lper-methods

chore: Mark SystemThemeHelper methods as obsolete
  • Loading branch information
MartinZikmund authored Jan 31, 2025
2 parents 57c1ba4 + 960f3b1 commit 06822e9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Uno.Toolkit.UI/Helpers/SystemThemeHelper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI;
using Windows.UI.ViewManagement;
using System.ComponentModel;

#if IS_WINUI
using Microsoft.UI.Xaml;
Expand Down Expand Up @@ -34,6 +31,7 @@ public static ApplicationTheme GetCurrentOsTheme()
/// <summary>
/// Get the current theme of the application.
/// </summary>
[Obsolete("GetApplicationTheme is obsolete. Use GetRootTheme(XamlRoot root) instead.")]
public static ApplicationTheme GetApplicationTheme()
=> GetRootTheme(GetWindowRoot()?.XamlRoot);

Expand All @@ -54,12 +52,14 @@ public static ApplicationTheme GetRootTheme(XamlRoot? root)
/// <summary>
/// Get if the application is currently in dark mode.
/// </summary>
[Obsolete("IsAppInDarkMode is obsolete. Use IsRootInDarkMode(XamlRoot root) instead.")]
public static bool IsAppInDarkMode()
=> GetRootTheme(GetWindowRoot().XamlRoot) == ApplicationTheme.Dark;

public static bool IsRootInDarkMode(XamlRoot root)
=> GetRootTheme(root) == ApplicationTheme.Dark;

[Obsolete("SetApplicationTheme(bool darkMode) is obsolete. Use SetApplicationTheme(XamlRoot? root, ElementTheme theme) instead.")]
public static void SetApplicationTheme(bool darkMode)
=> SetRootTheme(GetWindowRoot().XamlRoot, darkMode);

Expand All @@ -79,6 +79,7 @@ public static void SetApplicationTheme(XamlRoot? root, ElementTheme theme)
}
}

[Obsolete("ToggleApplicationTheme() is obsolete. Use SetApplicationTheme(XamlRoot? root, ElementTheme theme) instead.")]
public static void ToggleApplicationTheme()
=> SetApplicationTheme(darkMode: !IsAppInDarkMode());

Expand Down

0 comments on commit 06822e9

Please sign in to comment.