Skip to content

Commit

Permalink
refactor: add lightweight styling resources for ProgressRing control
Browse files Browse the repository at this point in the history
  • Loading branch information
Arieldelossantos committed Jun 5, 2023
1 parent 695c128 commit c2b90dd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
34 changes: 26 additions & 8 deletions src/library/Uno.Material/Styles/Controls/v2/ProgressRing.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,48 @@
mc:Ignorable="d not_win lottie_not_win">

<lottie_win:LottieVisualSource x:Key="M3MaterialDeterminateAnimation_Win"
UriSource="ms-appx:///Uno.Material/Assets/MaterialDeterminate.json" />
UriSource="ms-appx:///Uno.Material/Assets/MaterialDeterminate.json" />
<lottie_win:LottieVisualSource x:Key="M3MaterialIndeterminateAnimation_Win"
UriSource="ms-appx:///Uno.Material/Assets/MaterialIndeterminate.json" />
UriSource="ms-appx:///Uno.Material/Assets/MaterialIndeterminate.json" />

<lottie_not_win:LottieVisualSource x:Key="M3MaterialDeterminateAnimation_Uno"
UriSource="embedded://Uno.Material/Uno.Material.Assets.MaterialDeterminate.json" />
<lottie_not_win:LottieVisualSource x:Key="M3MaterialIndeterminateAnimation_Uno"
UriSource="embedded://Uno.Material/Uno.Material.Assets.MaterialIndeterminate.json" />

<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Default">
<!--MaterialProgressRingStyle-->
<StaticResource x:Key="ProgressRingForeground"
ResourceKey="PrimaryBrush" />
<StaticResource x:Key="ProgressRingBackground"
ResourceKey="SystemControlTransparentBrush" />
</ResourceDictionary>

<ResourceDictionary x:Key="Light">
<!--MaterialProgressRingStyle-->
<StaticResource x:Key="ProgressRingForeground"
ResourceKey="PrimaryBrush" />
<StaticResource x:Key="ProgressRingBackground"
ResourceKey="SystemControlTransparentBrush" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

<!-- WinUI 3 currently does not support the DeterminateSource and IndeterminateSource properties on Windows -->
<Style x:Key="MaterialProgressRingStyle"
TargetType="muxc:ProgressRing">
<win:Setter Property="DeterminateSource"
Value="{StaticResource M3MaterialDeterminateAnimation_Win}" />
Value="{StaticResource M3MaterialDeterminateAnimation_Win}" />
<win:Setter Property="IndeterminateSource"
Value="{StaticResource M3MaterialIndeterminateAnimation_Win}" />
Value="{StaticResource M3MaterialIndeterminateAnimation_Win}" />
<not_win:Setter Property="DeterminateSource"
Value="{StaticResource M3MaterialDeterminateAnimation_Uno}" />
Value="{StaticResource M3MaterialDeterminateAnimation_Uno}" />
<not_win:Setter Property="IndeterminateSource"
Value="{StaticResource M3MaterialIndeterminateAnimation_Uno}" />
Value="{StaticResource M3MaterialIndeterminateAnimation_Uno}" />
<Setter Property="Foreground"
Value="{ThemeResource PrimaryBrush}" />
Value="{ThemeResource ProgressRingForeground}" />
<Setter Property="Background"
Value="Transparent" />
Value="{ThemeResource ProgressRingBackground}" />
</Style>

</ResourceDictionary>
25 changes: 20 additions & 5 deletions src/library/Uno.Material/Styles/Controls/v2/ProgressRingWinUI.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,39 @@
</not_win:ResourceDictionary>
</ResourceDictionary.MergedDictionaries>

<ResourceDictionary x:Key="Default">
<!--MaterialProgressRingStyle-->
<StaticResource x:Key="ProgressRingForeground"
ResourceKey="PrimaryBrush" />
<StaticResource x:Key="ProgressRingBackground"
ResourceKey="SystemControlTransparentBrush" />
</ResourceDictionary>

<ResourceDictionary x:Key="Light">
<!--MaterialProgressRingStyle-->
<StaticResource x:Key="ProgressRingForeground"
ResourceKey="PrimaryBrush" />
<StaticResource x:Key="ProgressRingBackground"
ResourceKey="SystemControlTransparentBrush" />
</ResourceDictionary>

<not_win:Style x:Key="MaterialProgressRingStyle"
TargetType="muxc:ProgressRing">
<Setter Property="DeterminateSource"
Value="{StaticResource MaterialDeterminateAnimation_Uno}" />
<Setter Property="IndeterminateSource"
Value="{StaticResource MaterialIndeterminateAnimation_Uno}" />
<Setter Property="Foreground"
Value="{ThemeResource PrimaryBrush}" />
Value="{ThemeResource ProgressRingForeground}" />
<Setter Property="Background"
Value="Transparent" />
Value="{ThemeResource ProgressRingBackground}" />
</not_win:Style>

<win:Style x:Key="MaterialProgressRingStyle"
TargetType="muxc:ProgressRing">
<Setter Property="Foreground"
Value="{ThemeResource PrimaryBrush}" />
Value="{ThemeResource ProgressRingForeground}" />
<Setter Property="Background"
Value="Transparent" />
Value="{ThemeResource ProgressRingBackground}" />
</win:Style>

</ResourceDictionary>

0 comments on commit c2b90dd

Please sign in to comment.