-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #222 from AvaloniaCommunity/supportAvaloniaTheming
Support Avalonia RequestedTheme
Showing
15 changed files
with
717 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ResourceDictionary xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<ControlTheme x:Key="{x:Type ThemeVariantScope}" | ||
TargetType="ThemeVariantScope"> | ||
<Setter Property="TextElement.Foreground" Value="{DynamicResource MaterialDesignBody}" /> | ||
</ControlTheme> | ||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
using Avalonia.Media; | ||
|
||
namespace Material.Styles.Themes.Base | ||
{ | ||
public class MaterialDesignDarkTheme : IBaseTheme | ||
{ | ||
public Color ValidationErrorColor { get; } = Color.Parse("#f44336"); | ||
public Color MaterialDesignBackground { get; } = Color.Parse("#FF000000"); | ||
public Color MaterialDesignPaper { get; } = Color.Parse("#FF303030"); | ||
public Color MaterialDesignCardBackground { get; } = Color.Parse("#FF424242"); | ||
public Color MaterialDesignToolBarBackground { get; } = Color.Parse("#FF212121"); | ||
public Color MaterialDesignBody { get; } = Color.Parse("#DDFFFFFF"); | ||
public Color MaterialDesignBodyLight { get; } = Color.Parse("#89FFFFFF"); | ||
public Color MaterialDesignColumnHeader { get; } = Color.Parse("#BCFFFFFF"); | ||
public Color MaterialDesignCheckBoxOff { get; } = Color.Parse("#89FFFFFF"); | ||
public Color MaterialDesignCheckBoxDisabled { get; } = Color.Parse("#FF647076"); | ||
public Color MaterialDesignTextBoxBorder { get; } = Color.Parse("#89FFFFFF"); | ||
public Color MaterialDesignDivider { get; } = Color.Parse("#1FFFFFFF"); | ||
public Color MaterialDesignSelection { get; } = Color.Parse("#757575"); | ||
public Color MaterialDesignToolForeground { get; } = Color.Parse("#FF616161"); | ||
public Color MaterialDesignToolBackground { get; } = Color.Parse("#FFe0e0e0"); | ||
public Color MaterialDesignFlatButtonClick { get; } = Color.Parse("#19757575"); | ||
public Color MaterialDesignFlatButtonRipple { get; } = Color.Parse("#FFB6B6B6"); | ||
public Color MaterialDesignToolTipBackground { get; } = Color.Parse("#eeeeee"); | ||
public Color MaterialDesignChipBackground { get; } = Color.Parse("#FF2E3C43"); | ||
public Color MaterialDesignSnackbarBackground { get; } = Color.Parse("#FFCDCDCD"); | ||
public Color MaterialDesignSnackbarMouseOver { get; } = Color.Parse("#FFB9B9BD"); | ||
public Color MaterialDesignSnackbarRipple { get; } = Color.Parse("#FF494949"); | ||
public Color MaterialDesignTextFieldBoxBackground { get; } = Color.Parse("#1AFFFFFF"); | ||
public Color MaterialDesignTextFieldBoxHoverBackground { get; } = Color.Parse("#1FFFFFFF"); | ||
public Color MaterialDesignTextFieldBoxDisabledBackground { get; } = Color.Parse("#0DFFFFFF"); | ||
public Color MaterialDesignTextAreaBorder { get; } = Color.Parse("#BCFFFFFF"); | ||
public Color MaterialDesignTextAreaInactiveBorder { get; } = Color.Parse("#1AFFFFFF"); | ||
public Color MaterialDesignDataGridRowHoverBackground { get; } = Color.Parse("#14FFFFFF"); | ||
} | ||
} | ||
namespace Material.Styles.Themes.Base; | ||
|
||
internal sealed class MaterialDesignDarkTheme : IBaseTheme { | ||
public static IBaseTheme Instance { get; } = new MaterialDesignDarkTheme(); | ||
|
||
public Color ValidationErrorColor { get; } = Color.Parse("#f44336"); | ||
public Color MaterialDesignBackground { get; } = Color.Parse("#FF000000"); | ||
public Color MaterialDesignPaper { get; } = Color.Parse("#FF303030"); | ||
public Color MaterialDesignCardBackground { get; } = Color.Parse("#FF424242"); | ||
public Color MaterialDesignToolBarBackground { get; } = Color.Parse("#FF212121"); | ||
public Color MaterialDesignBody { get; } = Color.Parse("#DDFFFFFF"); | ||
public Color MaterialDesignBodyLight { get; } = Color.Parse("#89FFFFFF"); | ||
public Color MaterialDesignColumnHeader { get; } = Color.Parse("#BCFFFFFF"); | ||
public Color MaterialDesignCheckBoxOff { get; } = Color.Parse("#89FFFFFF"); | ||
public Color MaterialDesignCheckBoxDisabled { get; } = Color.Parse("#FF647076"); | ||
public Color MaterialDesignTextBoxBorder { get; } = Color.Parse("#89FFFFFF"); | ||
public Color MaterialDesignDivider { get; } = Color.Parse("#1FFFFFFF"); | ||
public Color MaterialDesignSelection { get; } = Color.Parse("#757575"); | ||
public Color MaterialDesignToolForeground { get; } = Color.Parse("#FF616161"); | ||
public Color MaterialDesignToolBackground { get; } = Color.Parse("#FFe0e0e0"); | ||
public Color MaterialDesignFlatButtonClick { get; } = Color.Parse("#19757575"); | ||
public Color MaterialDesignFlatButtonRipple { get; } = Color.Parse("#FFB6B6B6"); | ||
public Color MaterialDesignToolTipBackground { get; } = Color.Parse("#eeeeee"); | ||
public Color MaterialDesignChipBackground { get; } = Color.Parse("#FF2E3C43"); | ||
public Color MaterialDesignSnackbarBackground { get; } = Color.Parse("#FFCDCDCD"); | ||
public Color MaterialDesignSnackbarMouseOver { get; } = Color.Parse("#FFB9B9BD"); | ||
public Color MaterialDesignSnackbarRipple { get; } = Color.Parse("#FF494949"); | ||
public Color MaterialDesignTextFieldBoxBackground { get; } = Color.Parse("#1AFFFFFF"); | ||
public Color MaterialDesignTextFieldBoxHoverBackground { get; } = Color.Parse("#1FFFFFFF"); | ||
public Color MaterialDesignTextFieldBoxDisabledBackground { get; } = Color.Parse("#0DFFFFFF"); | ||
public Color MaterialDesignTextAreaBorder { get; } = Color.Parse("#BCFFFFFF"); | ||
public Color MaterialDesignTextAreaInactiveBorder { get; } = Color.Parse("#1AFFFFFF"); | ||
public Color MaterialDesignDataGridRowHoverBackground { get; } = Color.Parse("#14FFFFFF"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
using Avalonia.Media; | ||
|
||
namespace Material.Styles.Themes.Base | ||
{ | ||
public class MaterialDesignLightTheme : IBaseTheme | ||
{ | ||
public Color ValidationErrorColor { get; } = Color.Parse("#F44336"); | ||
public Color MaterialDesignBackground { get; } = Color.Parse("#FFFFFFFF"); | ||
public Color MaterialDesignPaper { get; } = Color.Parse("#FFFAFAFA"); | ||
public Color MaterialDesignCardBackground { get; } = Color.Parse("#FFFFFFFF"); | ||
public Color MaterialDesignToolBarBackground { get; } = Color.Parse("#FFF5F5F5"); | ||
public Color MaterialDesignBody { get; } = Color.Parse("#DD000000"); | ||
public Color MaterialDesignBodyLight { get; } = Color.Parse("#89000000"); | ||
public Color MaterialDesignColumnHeader { get; } = Color.Parse("#BC000000"); | ||
public Color MaterialDesignCheckBoxOff { get; } = Color.Parse("#89000000"); | ||
public Color MaterialDesignCheckBoxDisabled { get; } = Color.Parse("#FFBDBDBD"); | ||
public Color MaterialDesignTextBoxBorder { get; } = Color.Parse("#89000000"); | ||
public Color MaterialDesignDivider { get; } = Color.Parse("#1F000000"); | ||
public Color MaterialDesignSelection { get; } = Color.Parse("#FFDEDEDE"); | ||
public Color MaterialDesignToolForeground { get; } = Color.Parse("#FF616161"); | ||
public Color MaterialDesignToolBackground { get; } = Color.Parse("#FFE0E0E0"); | ||
public Color MaterialDesignFlatButtonClick { get; } = Color.Parse("#FFDEDEDE"); | ||
public Color MaterialDesignFlatButtonRipple { get; } = Color.Parse("#FFB6B6B6"); | ||
public Color MaterialDesignToolTipBackground { get; } = Color.Parse("#757575"); | ||
public Color MaterialDesignChipBackground { get; } = Color.Parse("#12000000"); | ||
public Color MaterialDesignSnackbarBackground { get; } = Color.Parse("#FF323232"); | ||
public Color MaterialDesignSnackbarMouseOver { get; } = Color.Parse("#FF464642"); | ||
public Color MaterialDesignSnackbarRipple { get; } = Color.Parse("#FFB6B6B6"); | ||
public Color MaterialDesignTextFieldBoxBackground { get; } = Color.Parse("#0F000000"); | ||
public Color MaterialDesignTextFieldBoxHoverBackground { get; } = Color.Parse("#14000000"); | ||
public Color MaterialDesignTextFieldBoxDisabledBackground { get; } = Color.Parse("#08000000"); | ||
public Color MaterialDesignTextAreaBorder { get; } = Color.Parse("#BC000000"); | ||
public Color MaterialDesignTextAreaInactiveBorder { get; } = Color.Parse("#0F000000"); | ||
public Color MaterialDesignDataGridRowHoverBackground { get; } = Color.Parse("#0A000000"); | ||
} | ||
} | ||
namespace Material.Styles.Themes.Base; | ||
|
||
internal sealed class MaterialDesignLightTheme : IBaseTheme { | ||
public static IBaseTheme Instance { get; } = new MaterialDesignLightTheme(); | ||
|
||
public Color ValidationErrorColor { get; } = Color.Parse("#F44336"); | ||
public Color MaterialDesignBackground { get; } = Color.Parse("#FFFFFFFF"); | ||
public Color MaterialDesignPaper { get; } = Color.Parse("#FFFAFAFA"); | ||
public Color MaterialDesignCardBackground { get; } = Color.Parse("#FFFFFFFF"); | ||
public Color MaterialDesignToolBarBackground { get; } = Color.Parse("#FFF5F5F5"); | ||
public Color MaterialDesignBody { get; } = Color.Parse("#DD000000"); | ||
public Color MaterialDesignBodyLight { get; } = Color.Parse("#89000000"); | ||
public Color MaterialDesignColumnHeader { get; } = Color.Parse("#BC000000"); | ||
public Color MaterialDesignCheckBoxOff { get; } = Color.Parse("#89000000"); | ||
public Color MaterialDesignCheckBoxDisabled { get; } = Color.Parse("#FFBDBDBD"); | ||
public Color MaterialDesignTextBoxBorder { get; } = Color.Parse("#89000000"); | ||
public Color MaterialDesignDivider { get; } = Color.Parse("#1F000000"); | ||
public Color MaterialDesignSelection { get; } = Color.Parse("#FFDEDEDE"); | ||
public Color MaterialDesignToolForeground { get; } = Color.Parse("#FF616161"); | ||
public Color MaterialDesignToolBackground { get; } = Color.Parse("#FFE0E0E0"); | ||
public Color MaterialDesignFlatButtonClick { get; } = Color.Parse("#FFDEDEDE"); | ||
public Color MaterialDesignFlatButtonRipple { get; } = Color.Parse("#FFB6B6B6"); | ||
public Color MaterialDesignToolTipBackground { get; } = Color.Parse("#757575"); | ||
public Color MaterialDesignChipBackground { get; } = Color.Parse("#12000000"); | ||
public Color MaterialDesignSnackbarBackground { get; } = Color.Parse("#FF323232"); | ||
public Color MaterialDesignSnackbarMouseOver { get; } = Color.Parse("#FF464642"); | ||
public Color MaterialDesignSnackbarRipple { get; } = Color.Parse("#FFB6B6B6"); | ||
public Color MaterialDesignTextFieldBoxBackground { get; } = Color.Parse("#0F000000"); | ||
public Color MaterialDesignTextFieldBoxHoverBackground { get; } = Color.Parse("#14000000"); | ||
public Color MaterialDesignTextFieldBoxDisabledBackground { get; } = Color.Parse("#08000000"); | ||
public Color MaterialDesignTextAreaBorder { get; } = Color.Parse("#BC000000"); | ||
public Color MaterialDesignTextAreaInactiveBorder { get; } = Color.Parse("#0F000000"); | ||
public Color MaterialDesignDataGridRowHoverBackground { get; } = Color.Parse("#0A000000"); | ||
} |
149 changes: 149 additions & 0 deletions
149
Material.Styles/Themes/Base/MaterialPredefinedBaseColors.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<ResourceDictionary xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:themes="clr-namespace:Material.Styles.Themes"> | ||
<ResourceDictionary.ThemeDictionaries> | ||
<ResourceDictionary x:Key="{x:Static themes:Theme.MaterialLight}"> | ||
<Color x:Key="ValidationErrorColor">#F44336</Color> | ||
<Color x:Key="MaterialDesignBackground">#FFFFFFFF</Color> | ||
<Color x:Key="MaterialDesignPaper">#FFFAFAFA</Color> | ||
<Color x:Key="MaterialDesignCardBackground">#FFFFFFFF</Color> | ||
<Color x:Key="MaterialDesignToolBarBackground">#FFF5F5F5</Color> | ||
<Color x:Key="MaterialDesignBody">#DD000000</Color> | ||
<Color x:Key="MaterialDesignBodyLight">#89000000</Color> | ||
<Color x:Key="MaterialDesignColumnHeader">#BC000000</Color> | ||
<Color x:Key="MaterialDesignCheckBoxOff">#89000000</Color> | ||
<Color x:Key="MaterialDesignCheckBoxDisabled">#FFBDBDBD</Color> | ||
<Color x:Key="MaterialDesignTextBoxBorder">#89000000</Color> | ||
<Color x:Key="MaterialDesignDivider">#1F000000</Color> | ||
<Color x:Key="MaterialDesignSelection">#FFDEDEDE</Color> | ||
<Color x:Key="MaterialDesignToolForeground">#FF616161</Color> | ||
<Color x:Key="MaterialDesignToolBackground">#FFE0E0E0</Color> | ||
<Color x:Key="MaterialDesignFlatButtonClick">#FFDEDEDE</Color> | ||
<Color x:Key="MaterialDesignFlatButtonRipple">#FFB6B6B6</Color> | ||
<Color x:Key="MaterialDesignToolTipBackground">#757575</Color> | ||
<Color x:Key="MaterialDesignChipBackground">#12000000</Color> | ||
<Color x:Key="MaterialDesignSnackbarBackground">#FF323232</Color> | ||
<Color x:Key="MaterialDesignSnackbarMouseOver">#FF464642</Color> | ||
<Color x:Key="MaterialDesignSnackbarRipple">#FFB6B6B6</Color> | ||
<Color x:Key="MaterialDesignTextFieldBoxBackground">#0F000000</Color> | ||
<Color x:Key="MaterialDesignTextFieldBoxHoverBackground">#14000000</Color> | ||
<Color x:Key="MaterialDesignTextFieldBoxDisabledBackground">#08000000</Color> | ||
<Color x:Key="MaterialDesignTextAreaBorder">#BC000000</Color> | ||
<Color x:Key="MaterialDesignTextAreaInactiveBorder">#0F000000</Color> | ||
<Color x:Key="MaterialDesignDataGridRowHoverBackground">#0A000000</Color> | ||
|
||
<SolidColorBrush x:Key="ValidationErrorColorBrush" Color="{StaticResource ValidationErrorColor}" /> | ||
<SolidColorBrush x:Key="MaterialDesignBackgroundBrush" Color="{StaticResource MaterialDesignBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignPaperBrush" Color="{StaticResource MaterialDesignPaper}" /> | ||
<SolidColorBrush x:Key="MaterialDesignCardBackgroundBrush" Color="{StaticResource MaterialDesignCardBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignToolBarBackgroundBrush" | ||
Color="{StaticResource MaterialDesignToolBarBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignBodyBrush" Color="{StaticResource MaterialDesignBody}" /> | ||
<SolidColorBrush x:Key="MaterialDesignBodyLightBrush" Color="{StaticResource MaterialDesignBodyLight}" /> | ||
<SolidColorBrush x:Key="MaterialDesignColumnHeaderBrush" Color="{StaticResource MaterialDesignColumnHeader}" /> | ||
<SolidColorBrush x:Key="MaterialDesignCheckBoxOffBrush" Color="{StaticResource MaterialDesignCheckBoxOff}" /> | ||
<SolidColorBrush x:Key="MaterialDesignCheckBoxDisabledBrush" | ||
Color="{StaticResource MaterialDesignCheckBoxDisabled}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextBoxBorderBrush" Color="{StaticResource MaterialDesignTextBoxBorder}" /> | ||
<SolidColorBrush x:Key="MaterialDesignDividerBrush" Color="{StaticResource MaterialDesignDivider}" /> | ||
<SolidColorBrush x:Key="MaterialDesignSelectionBrush" Color="{StaticResource MaterialDesignSelection}" /> | ||
<SolidColorBrush x:Key="MaterialDesignToolForegroundBrush" Color="{StaticResource MaterialDesignToolForeground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignToolBackgroundBrush" Color="{StaticResource MaterialDesignToolBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignFlatButtonClickBrush" | ||
Color="{StaticResource MaterialDesignFlatButtonClick}" /> | ||
<SolidColorBrush x:Key="MaterialDesignFlatButtonRippleBrush" | ||
Color="{StaticResource MaterialDesignFlatButtonRipple}" /> | ||
<SolidColorBrush x:Key="MaterialDesignToolTipBackgroundBrush" | ||
Color="{StaticResource MaterialDesignToolTipBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignChipBackgroundBrush" Color="{StaticResource MaterialDesignChipBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignSnackbarBackgroundBrush" | ||
Color="{StaticResource MaterialDesignSnackbarBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignSnackbarMouseOverBrush" | ||
Color="{StaticResource MaterialDesignSnackbarMouseOver}" /> | ||
<SolidColorBrush x:Key="MaterialDesignSnackbarRippleBrush" Color="{StaticResource MaterialDesignSnackbarRipple}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextFieldBoxBackgroundBrush" | ||
Color="{StaticResource MaterialDesignTextFieldBoxBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextFieldBoxHoverBackgroundBrush" | ||
Color="{StaticResource MaterialDesignTextFieldBoxHoverBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextFieldBoxDisabledBackgroundBrush" | ||
Color="{StaticResource MaterialDesignTextFieldBoxDisabledBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextAreaBorderBrush" Color="{StaticResource MaterialDesignTextAreaBorder}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextAreaInactiveBorderBrush" | ||
Color="{StaticResource MaterialDesignTextAreaInactiveBorder}" /> | ||
<SolidColorBrush x:Key="MaterialDesignDataGridRowHoverBackgroundBrush" | ||
Color="{StaticResource MaterialDesignDataGridRowHoverBackground}" /> | ||
</ResourceDictionary> | ||
|
||
<ResourceDictionary x:Key="{x:Static themes:Theme.MaterialDark}"> | ||
<Color x:Key="ValidationErrorColor">#f44336</Color> | ||
<Color x:Key="MaterialDesignBackground">#FF000000</Color> | ||
<Color x:Key="MaterialDesignPaper">#FF303030</Color> | ||
<Color x:Key="MaterialDesignCardBackground">#FF424242</Color> | ||
<Color x:Key="MaterialDesignToolBarBackground">#FF212121</Color> | ||
<Color x:Key="MaterialDesignBody">#DDFFFFFF</Color> | ||
<Color x:Key="MaterialDesignBodyLight">#89FFFFFF</Color> | ||
<Color x:Key="MaterialDesignColumnHeader">#BCFFFFFF</Color> | ||
<Color x:Key="MaterialDesignCheckBoxOff">#89FFFFFF</Color> | ||
<Color x:Key="MaterialDesignCheckBoxDisabled">#FF647076</Color> | ||
<Color x:Key="MaterialDesignTextBoxBorder">#89FFFFFF</Color> | ||
<Color x:Key="MaterialDesignDivider">#1FFFFFFF</Color> | ||
<Color x:Key="MaterialDesignSelection">#757575</Color> | ||
<Color x:Key="MaterialDesignToolForeground">#FF616161</Color> | ||
<Color x:Key="MaterialDesignToolBackground">#FFe0e0e0</Color> | ||
<Color x:Key="MaterialDesignFlatButtonClick">#19757575</Color> | ||
<Color x:Key="MaterialDesignFlatButtonRipple">#FFB6B6B6</Color> | ||
<Color x:Key="MaterialDesignToolTipBackground">#eeeeee</Color> | ||
<Color x:Key="MaterialDesignChipBackground">#FF2E3C43</Color> | ||
<Color x:Key="MaterialDesignSnackbarBackground">#FFCDCDCD</Color> | ||
<Color x:Key="MaterialDesignSnackbarMouseOver">#FFB9B9BD</Color> | ||
<Color x:Key="MaterialDesignSnackbarRipple">#FF494949</Color> | ||
<Color x:Key="MaterialDesignTextFieldBoxBackground">#1AFFFFFF</Color> | ||
<Color x:Key="MaterialDesignTextFieldBoxHoverBackground">#1FFFFFFF</Color> | ||
<Color x:Key="MaterialDesignTextFieldBoxDisabledBackground">#0DFFFFFF</Color> | ||
<Color x:Key="MaterialDesignTextAreaBorder">#BCFFFFFF</Color> | ||
<Color x:Key="MaterialDesignTextAreaInactiveBorder">#1AFFFFFF</Color> | ||
<Color x:Key="MaterialDesignDataGridRowHoverBackground">#14FFFFFF</Color> | ||
|
||
<SolidColorBrush x:Key="ValidationErrorColorBrush" Color="{StaticResource ValidationErrorColor}" /> | ||
<SolidColorBrush x:Key="MaterialDesignBackgroundBrush" Color="{StaticResource MaterialDesignBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignPaperBrush" Color="{StaticResource MaterialDesignPaper}" /> | ||
<SolidColorBrush x:Key="MaterialDesignCardBackgroundBrush" Color="{StaticResource MaterialDesignCardBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignToolBarBackgroundBrush" | ||
Color="{StaticResource MaterialDesignToolBarBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignBodyBrush" Color="{StaticResource MaterialDesignBody}" /> | ||
<SolidColorBrush x:Key="MaterialDesignBodyLightBrush" Color="{StaticResource MaterialDesignBodyLight}" /> | ||
<SolidColorBrush x:Key="MaterialDesignColumnHeaderBrush" Color="{StaticResource MaterialDesignColumnHeader}" /> | ||
<SolidColorBrush x:Key="MaterialDesignCheckBoxOffBrush" Color="{StaticResource MaterialDesignCheckBoxOff}" /> | ||
<SolidColorBrush x:Key="MaterialDesignCheckBoxDisabledBrush" | ||
Color="{StaticResource MaterialDesignCheckBoxDisabled}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextBoxBorderBrush" Color="{StaticResource MaterialDesignTextBoxBorder}" /> | ||
<SolidColorBrush x:Key="MaterialDesignDividerBrush" Color="{StaticResource MaterialDesignDivider}" /> | ||
<SolidColorBrush x:Key="MaterialDesignSelectionBrush" Color="{StaticResource MaterialDesignSelection}" /> | ||
<SolidColorBrush x:Key="MaterialDesignToolForegroundBrush" Color="{StaticResource MaterialDesignToolForeground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignToolBackgroundBrush" Color="{StaticResource MaterialDesignToolBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignFlatButtonClickBrush" | ||
Color="{StaticResource MaterialDesignFlatButtonClick}" /> | ||
<SolidColorBrush x:Key="MaterialDesignFlatButtonRippleBrush" | ||
Color="{StaticResource MaterialDesignFlatButtonRipple}" /> | ||
<SolidColorBrush x:Key="MaterialDesignToolTipBackgroundBrush" | ||
Color="{StaticResource MaterialDesignToolTipBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignChipBackgroundBrush" Color="{StaticResource MaterialDesignChipBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignSnackbarBackgroundBrush" | ||
Color="{StaticResource MaterialDesignSnackbarBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignSnackbarMouseOverBrush" | ||
Color="{StaticResource MaterialDesignSnackbarMouseOver}" /> | ||
<SolidColorBrush x:Key="MaterialDesignSnackbarRippleBrush" Color="{StaticResource MaterialDesignSnackbarRipple}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextFieldBoxBackgroundBrush" | ||
Color="{StaticResource MaterialDesignTextFieldBoxBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextFieldBoxHoverBackgroundBrush" | ||
Color="{StaticResource MaterialDesignTextFieldBoxHoverBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextFieldBoxDisabledBackgroundBrush" | ||
Color="{StaticResource MaterialDesignTextFieldBoxDisabledBackground}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextAreaBorderBrush" Color="{StaticResource MaterialDesignTextAreaBorder}" /> | ||
<SolidColorBrush x:Key="MaterialDesignTextAreaInactiveBorderBrush" | ||
Color="{StaticResource MaterialDesignTextAreaInactiveBorder}" /> | ||
<SolidColorBrush x:Key="MaterialDesignDataGridRowHoverBackgroundBrush" | ||
Color="{StaticResource MaterialDesignDataGridRowHoverBackground}" /> | ||
</ResourceDictionary> | ||
</ResourceDictionary.ThemeDictionaries> | ||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,279 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using Avalonia; | ||
using Avalonia.Collections; | ||
using Avalonia.Controls; | ||
using Avalonia.Styling; | ||
|
||
namespace Material.Styles.Themes; | ||
|
||
/// <remarks> | ||
/// Copy of <see cref="Styles"/>, with exposing first resources lookup to inheritors | ||
/// </remarks> | ||
public abstract class InternalStylesCollection : AvaloniaObject, | ||
IAvaloniaList<IStyle>, | ||
IStyle, | ||
IResourceProvider { | ||
private readonly AvaloniaList<IStyle> _styles = new(); | ||
private bool _isResourcedAccessed; | ||
private IResourceHost? _owner; | ||
private IResourceDictionary? _resources; | ||
|
||
public InternalStylesCollection() { | ||
_styles.ResetBehavior = ResetBehavior.Remove; | ||
_styles.CollectionChanged += OnCollectionChanged; | ||
_styles.Validate = i => { | ||
if (i is ControlTheme) | ||
throw new InvalidOperationException("ControlThemes cannot be added to a Styles collection."); | ||
}; | ||
} | ||
|
||
public InternalStylesCollection(IResourceHost owner) | ||
: this() { | ||
Owner = owner; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a dictionary of style resources. | ||
/// </summary> | ||
public IResourceDictionary Resources { | ||
get { | ||
var resources = _resources ?? (Resources = new ResourceDictionary()); | ||
EnsureCallToOnResourcedAccessed(); | ||
return resources; | ||
} | ||
set { | ||
value = value ?? throw new ArgumentNullException(nameof(Resources)); | ||
|
||
var currentOwner = Owner; | ||
|
||
if (currentOwner is not null) _resources?.RemoveOwner(currentOwner); | ||
|
||
_resources = value; | ||
|
||
if (currentOwner is not null) _resources.AddOwner(currentOwner); | ||
} | ||
} | ||
|
||
public event NotifyCollectionChangedEventHandler? CollectionChanged; | ||
|
||
public int Count => _styles.Count; | ||
|
||
bool ICollection<IStyle>.IsReadOnly => false; | ||
|
||
IStyle IReadOnlyList<IStyle>.this[int index] => _styles[index]; | ||
|
||
public IStyle this[int index] { | ||
get => _styles[index]; | ||
set => _styles[index] = value; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void AddRange(IEnumerable<IStyle> items) { | ||
_styles.AddRange(items); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void InsertRange(int index, IEnumerable<IStyle> items) { | ||
_styles.InsertRange(index, items); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Move(int oldIndex, int newIndex) { | ||
_styles.Move(oldIndex, newIndex); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void MoveRange(int oldIndex, int count, int newIndex) { | ||
_styles.MoveRange(oldIndex, count, newIndex); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void RemoveAll(IEnumerable<IStyle> items) { | ||
_styles.RemoveAll(items); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void RemoveRange(int index, int count) { | ||
_styles.RemoveRange(index, count); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public int IndexOf(IStyle item) { | ||
return _styles.IndexOf(item); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Insert(int index, IStyle item) { | ||
_styles.Insert(index, item); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void RemoveAt(int index) { | ||
_styles.RemoveAt(index); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Add(IStyle item) { | ||
_styles.Add(item); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Clear() { | ||
_styles.Clear(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public bool Contains(IStyle item) { | ||
return _styles.Contains(item); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void CopyTo(IStyle[] array, int arrayIndex) { | ||
_styles.CopyTo(array, arrayIndex); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public bool Remove(IStyle item) { | ||
return _styles.Remove(item); | ||
} | ||
|
||
/// <inheritdoc/> | ||
IEnumerator<IStyle> IEnumerable<IStyle>.GetEnumerator() { | ||
return _styles.GetEnumerator(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
IEnumerator IEnumerable.GetEnumerator() { | ||
return _styles.GetEnumerator(); | ||
} | ||
public event EventHandler? OwnerChanged; | ||
|
||
public IResourceHost? Owner { | ||
get => _owner; | ||
private set { | ||
if (_owner != value) { | ||
_owner = value; | ||
OwnerChanged?.Invoke(this, EventArgs.Empty); | ||
} | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
void IResourceProvider.AddOwner(IResourceHost owner) { | ||
owner = owner ?? throw new ArgumentNullException(nameof(owner)); | ||
|
||
if (Owner is not null) throw new InvalidOperationException("The Styles already has a owner."); | ||
|
||
Owner = owner; | ||
_resources?.AddOwner(owner); | ||
|
||
foreach (var child in this) | ||
if (child is IResourceProvider r) | ||
r.AddOwner(owner); | ||
} | ||
|
||
/// <inheritdoc/> | ||
void IResourceProvider.RemoveOwner(IResourceHost owner) { | ||
owner = owner ?? throw new ArgumentNullException(nameof(owner)); | ||
|
||
if (Owner == owner) { | ||
Owner = null; | ||
_resources?.RemoveOwner(owner); | ||
|
||
foreach (var child in this) | ||
if (child is IResourceProvider r) | ||
r.RemoveOwner(owner); | ||
} | ||
} | ||
|
||
bool IResourceNode.HasResources { | ||
get { | ||
if (_resources?.Count > 0) return true; | ||
|
||
foreach (var i in this) | ||
if (i is IResourceProvider { HasResources: true }) | ||
return true; | ||
|
||
return false; | ||
} | ||
} | ||
|
||
IReadOnlyList<IStyle> IStyle.Children => this; | ||
|
||
/// <inheritdoc/> | ||
public bool TryGetResource(object key, ThemeVariant? theme, out object? value) { | ||
EnsureCallToOnResourcedAccessed(); | ||
if (_resources != null && _resources.TryGetResource(key, theme, out value)) return true; | ||
|
||
for (var i = Count - 1; i >= 0; --i) | ||
if (this[i].TryGetResource(key, theme, out value)) | ||
return true; | ||
|
||
value = null; | ||
return false; | ||
} | ||
|
||
private void EnsureCallToOnResourcedAccessed() { | ||
if (_isResourcedAccessed) return; | ||
_isResourcedAccessed = true; | ||
OnResourcedAccessed(); | ||
} | ||
|
||
protected abstract void OnResourcedAccessed(); | ||
|
||
public AvaloniaList<IStyle>.Enumerator GetEnumerator() { | ||
return _styles.GetEnumerator(); | ||
} | ||
|
||
private static IReadOnlyList<T> ToReadOnlyList<T>(ICollection list) { | ||
if (list is IReadOnlyList<T> readOnlyList) return readOnlyList; | ||
|
||
var result = new T[list.Count]; | ||
list.CopyTo(result, 0); | ||
return result; | ||
} | ||
|
||
private static void InternalAdd(IList items, IResourceHost? owner) { | ||
if (owner is not null) { | ||
for (var i = 0; i < items.Count; ++i) | ||
if (items[i] is IResourceProvider provider) | ||
provider.AddOwner(owner); | ||
|
||
(owner as IStyleHost)?.StylesAdded(ToReadOnlyList<IStyle>(items)); | ||
} | ||
} | ||
|
||
private static void InternalRemove(IList items, IResourceHost? owner) { | ||
if (owner is not null) { | ||
for (var i = 0; i < items.Count; ++i) | ||
if (items[i] is IResourceProvider provider) | ||
provider.RemoveOwner(owner); | ||
|
||
(owner as IStyleHost)?.StylesRemoved(ToReadOnlyList<IStyle>(items)); | ||
} | ||
} | ||
|
||
private void OnCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) { | ||
if (e.Action == NotifyCollectionChangedAction.Reset) throw new InvalidOperationException("Reset should not be called on Styles."); | ||
|
||
var currentOwner = Owner; | ||
|
||
switch (e.Action) { | ||
case NotifyCollectionChangedAction.Add: | ||
InternalAdd(e.NewItems!, currentOwner); | ||
break; | ||
case NotifyCollectionChangedAction.Remove: | ||
InternalRemove(e.OldItems!, currentOwner); | ||
break; | ||
case NotifyCollectionChangedAction.Replace: | ||
InternalRemove(e.OldItems!, currentOwner); | ||
InternalAdd(e.NewItems!, currentOwner); | ||
break; | ||
} | ||
|
||
CollectionChanged?.Invoke(this, e); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<themes:MaterialThemeBase xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:themes="clr-namespace:Material.Styles.Themes" | ||
x:Class="Material.Styles.Themes.MaterialThemeBase"> | ||
<themes:MaterialThemeBase.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<MergeResourceInclude Source="avares://Material.Styles/Themes/Base/MaterialPredefinedBaseColors.axaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary.ThemeDictionaries> | ||
<!-- This dictionary for changeable colors --> | ||
<ResourceDictionary x:Key="Default" /> | ||
</ResourceDictionary.ThemeDictionaries> | ||
</ResourceDictionary> | ||
</themes:MaterialThemeBase.Resources> | ||
|
||
<StyleInclude Source="avares://Material.Styles/MaterialToolKit.xaml" /> | ||
<StyleInclude Source="avares://Material.Styles/Resources/Compatibility/Index.axaml" /> | ||
</themes:MaterialThemeBase> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters