Added support for IsColorPrevalence background system accent color
This commit is contained in:
+22
-9
@@ -8,6 +8,7 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
||||
{
|
||||
private NotificationFlyoutContentPresenter _contentPresenter;
|
||||
|
||||
private bool _isColorPrevalence;
|
||||
private ElementTheme _systemTheme;
|
||||
|
||||
public NotificationFlyoutPresenter()
|
||||
@@ -15,11 +16,9 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
||||
DefaultStyleKey = typeof(NotificationFlyoutPresenter);
|
||||
RegisterPropertyChangedCallback(RequestedThemeProperty, RequestedThemePropertyChanged);
|
||||
}
|
||||
|
||||
public void SetBackground(string theme)
|
||||
public void UpdateFlyoutTheme(string theme, bool isColorPrevalence)
|
||||
{
|
||||
if (_contentPresenter == null) return;
|
||||
|
||||
_isColorPrevalence = isColorPrevalence;
|
||||
switch (theme)
|
||||
{
|
||||
case "Dark":
|
||||
@@ -30,18 +29,21 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
||||
break;
|
||||
}
|
||||
|
||||
if (RequestedTheme == ElementTheme.Default)
|
||||
{
|
||||
_contentPresenter.SetValue(RequestedThemeProperty, _systemTheme);
|
||||
}
|
||||
UpdateThemeVisualState();
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
_contentPresenter = GetTemplateChild("ContentPresenter") as NotificationFlyoutContentPresenter;
|
||||
Loaded += OnLoaded;
|
||||
}
|
||||
|
||||
private void RequestedThemePropertyChanged(DependencyObject sender, DependencyProperty dp)
|
||||
private void OnLoaded(object sender, RoutedEventArgs args)
|
||||
{
|
||||
UpdateThemeVisualState();
|
||||
}
|
||||
|
||||
private void RequestedThemePropertyChanged(DependencyObject sender, DependencyProperty dependencyProperty)
|
||||
{
|
||||
if (RequestedTheme == ElementTheme.Default)
|
||||
{
|
||||
@@ -52,5 +54,16 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
||||
_contentPresenter.SetValue(RequestedThemeProperty, RequestedTheme);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateThemeVisualState()
|
||||
{
|
||||
if (_contentPresenter == null) return;
|
||||
if (RequestedTheme == ElementTheme.Default)
|
||||
{
|
||||
_contentPresenter.SetValue(RequestedThemeProperty, _systemTheme);
|
||||
}
|
||||
|
||||
VisualStateManager.GoToState(_contentPresenter, _isColorPrevalence ? "ColorPrevalenceTheme" : "DefaultTheme", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user