diff --git a/src/Comet.Skia/Handlers/ButtonHandler.cs b/src/Comet.Skia/Handlers/ButtonHandler.cs index 7d7b6cd7..e5500695 100644 --- a/src/Comet.Skia/Handlers/ButtonHandler.cs +++ b/src/Comet.Skia/Handlers/ButtonHandler.cs @@ -67,9 +67,9 @@ namespace Comet.Skia protected override void ControlStateChanged() { - var endBackground = TypedVirtualView.GetBackgroundColor(state: CurrentState); - //If null, get the normal state and lerp that puppy - //?? TypedVirtualView.GetBackgroundColor(Color.Transparent, state: ControlState.Default).Lerp(Color.Grey, .1).WithAlpha(.5f); + var endBackground = TypedVirtualView.GetBackgroundColor(state: CurrentState) + //If null, get the normal state and lerp that puppy + ?? TypedVirtualView.GetBackgroundColor(Color.Transparent, state: ControlState.Default).Lerp(Color.Grey, .1).WithAlpha(.5f); var endPadding = (CurrentState == ControlState.Pressed) ? new Thickness(.5f) : new Thickness(); diff --git a/src/Comet/Styles/Material/MaterialStyle.cs b/src/Comet/Styles/Material/MaterialStyle.cs index be14ec22..8f5ffdd9 100644 --- a/src/Comet/Styles/Material/MaterialStyle.cs +++ b/src/Comet/Styles/Material/MaterialStyle.cs @@ -21,6 +21,15 @@ namespace Comet.Styles.Material public ButtonStyle ContainedButton { get; set; } public ButtonStyle TextButton { get; set; } + static Color GetHoverColor(Color color) => + color == Color.Black ? Color.White.WithAlpha(.2f) : + Color.Black.WithAlpha(.2f); + + static Color GetPressedColor(Color color) => + color == Color.Black ? Color.White.WithAlpha(.1f) : + Color.Black.WithAlpha(.1f); + + public MaterialStyle(ColorPalette colorPalette) { PrimaryColorPalette = colorPalette; @@ -30,7 +39,12 @@ namespace Comet.Styles.Material { TextColor = colorPalette.P900, Border = new RoundedRectangle(4f).Stroke(Color.Grey, 1f, true), - BackgroundColor = colorPalette.PD900, + BackgroundColor = new StyleAwareValue + { + [ControlState.Default] = colorPalette.PD900, + [ControlState.Hovered] = GetHoverColor(colorPalette.PD900), + [ControlState.Pressed] = GetPressedColor(colorPalette.PD900), + }, Padding = new Thickness(16, 0, 16, 0), Shadow = null, }; @@ -39,7 +53,12 @@ namespace Comet.Styles.Material { TextColor = colorPalette.PD900, Border = new RoundedRectangle(4f).Stroke(Color.Grey, 1f, true), - BackgroundColor = colorPalette.P900, + BackgroundColor = new StyleAwareValue + { + [ControlState.Default] = colorPalette.P900, + [ControlState.Hovered] = colorPalette.P800, + [ControlState.Pressed] = colorPalette.P700, + }, Shadow = new Graphics.Shadow().WithColor(Color.Grey).WithRadius(1).WithOffset(new SizeF(1, 1)), Padding = new Thickness(16, 0, 16, 0), }; @@ -48,7 +67,12 @@ namespace Comet.Styles.Material { TextColor = colorPalette.P900, Padding = new Thickness(16, 0, 16, 0), - BackgroundColor = Color.Transparent, + BackgroundColor = new StyleAwareValue + { + [ControlState.Default] = Color.Transparent, + [ControlState.Hovered] = GetHoverColor(colorPalette.PD900), + [ControlState.Pressed] = GetPressedColor(colorPalette.PD900), + }, Shadow = null, Border = null, };