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
{{ message }}
This repository was archived by the owner on Jul 11, 2025. It is now read-only.
Styles with ControlState don't seem to actually apply. For example:
publicclassAppStyle:Style{publicAppStyle(){Button=newButtonStyle{BackgroundColor=newStyleAwareValue<ControlState,Color>{[ControlState.Disabled]=Color.Grey,[ControlState.Default]=Color.Green,[ControlState.Hovered]=Colors.Red,[ControlState.Pressed]=Color.Black,}};}}// Then using it:Viewbody()=>newVStack{newButton("Enabled"),newButton("Disabled").Enabled(false),}.ApplyStyle(newAppStyle());
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;
ControlState VisualState {get{// not sure if order matters hereif(IsPressed){returnControlState.IsPressed;}if(IsFocused){returnControlState.Hovered;}if(IsEnabled){returnControlState.Default;}returnControlState.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
Styles with
ControlStatedon'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, andHoveredstates butITextButtonneeds to specify it also supportsPressed.ITextButtonwould need to generate abool IsPressedwhich is updated based onPressed/Releasedactions. Not sure how to best model this in theCometGenerateAttribute. Is this a one off case? Is it better to omitPressed/Releasedfrom being generated and create aButton.cswith this logic?VisualStateproperty. For example, if theITextButtonhas 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
GetEnvironmentcall. This would support the IsFocused/IsEnabled states but not sure how that would supportIsPressed