You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Styles with ControlState don't seem to actually apply. For example:
publicclassAppStyle:Style{publicAppStyle(){Button=new ButtonStyle
{BackgroundColor=newStyleAwareValue<ControlState,Color>{[ControlState.Disabled]= Color.Grey,[ControlState.Default]= Color.Green,[ControlState.Hovered]= Colors.Red,[ControlState.Pressed]= Color.Black,}};}}// Then using it:
View body()=>new VStack
{new Button("Enabled"),new Button("Disabled").Enabled(false),}.ApplyStyle(new AppStyle());
The second button should be grey. The first button should be red/black when hovered/pressed. The source generators are just getting the default value and doesn't seem like they apply the control state:
I can look at helping PR a change to implement this but would need some guidance on how to implement it. What I am thinking:
CometGenerator attribute needs a list of states supported by each control. I believe by default every control supports at least Disabled, Default, and Hovered states but ITextButton needs to specify it also supports Pressed.
ITextButton would need to generate a bool IsPressed which is updated based on Pressed/Released actions. Not sure how to best model this in the CometGenerateAttribute. Is this a one off case? Is it better to omit Pressed/Released from being generated and create a Button.cs with this logic?
Source generator would emit a switch statement to fetch the correct value based on state. This could be done in a VisualState property. For example, if the ITextButton has states [ Pressed ] (default/hovered/disabled don't need to be specified) then the following switch would be created:
Microsoft.Maui.Graphics.Color Microsoft.Maui.ITextStyle.TextColor =>this.GetEnvironment<Microsoft.Maui.Graphics.Color>("Color", VisualState)??default;ControlStateVisualState{
get {// not sure if order matters hereif(IsPressed){return ControlState.IsPressed;}if(IsFocused){return ControlState.Hovered;}if(IsEnabled){return ControlState.Default;}return ControlState.Disabled;}}
Another option would be to add the switch inside of the GetEnvironment call. This would support the IsFocused/IsEnabled states but not sure how that would support IsPressed
The text was updated successfully, but these errors were encountered:
Styles with
ControlState
don't seem to actually apply. For example:The second button should be grey. The first button should be red/black when hovered/pressed. The source generators are just getting the default value and doesn't seem like they apply the control state:
I can look at helping PR a change to implement this but would need some guidance on how to implement it. What I am thinking:
Disabled
,Default
, andHovered
states butITextButton
needs to specify it also supportsPressed
.ITextButton
would need to generate abool IsPressed
which is updated based onPressed/Released
actions. Not sure how to best model this in theCometGenerateAttribute
. Is this a one off case? Is it better to omitPressed/Released
from being generated and create aButton.cs
with this logic?VisualState
property. For example, if theITextButton
has states[ Pressed ]
(default/hovered/disabled don't need to be specified) then the following switch would be created:Another option would be to add the switch inside of the
GetEnvironment
call. This would support the IsFocused/IsEnabled states but not sure how that would supportIsPressed
The text was updated successfully, but these errors were encountered: