Skip to content

Don't extract native defaults, meaning users can no longer reset a color back to a platform theme - #1485

Merged
Redth merged 2 commits into
mainfrom
remove_auto_defaults
Jul 2, 2021
Merged

Redth merged 2 commits into
mainfrom
remove_auto_defaults

Conversation

@PureWeen

@PureWeen PureWeen commented Jun 28, 2021 •

Copy link
Copy Markdown
Member

Description of Change

The change to Maui.Graphics caused us to get rid of Color.Default . Since that point we've been discussing what should be the behavior of setting a Color to null.

This PR gets rid of the ability for a user to reset a color back to whatever the platform theme defines

Xamarin.Forms Behavior

button.BackgroundColor = Color.Green
button.BackgroundColor = Color.Default

// At this point the buttons back ground color would change back to whatever the native platform theme defined that backgroundColor to be

MAUI Behavior

button.BackgroundColor = Color.Green
button.BackgroundColor = null //Color.Default no longer exists

// Null will be considered a NOOP and the background color will still be green

Reading the platform defaults can be problematic for some cases and difficult to extract correctly. For example,

public static ColorStateList GetDefaultSwitchTrackColorStateList(this ASwitch aSwitch)

For now we are going to operate on the premise that users don't use the behavior of Color.Default enough to warrant the effort of implementation and the performance implications of pulling those values during startup.

With .NET MAUI and multi-targeting it is also much easier to read values from the native platform so if a user wants the native defaults then they can tap into the handler property for that color and save off the default themselves

NOTE

Currently I've left the methods that we implemented to pull and set defaults. We can clean this up a later date. I didn't want to just remove that code in case parts of it are still useful. It's not reachable by the user so we don't need to worry about API breaks

@PureWeen PureWeen changed the title Don't setup native defaults by default Don't extract native defaults which means users can no longer reset a color back to a platform theme Jun 28, 2021
@PureWeen PureWeen changed the title Don't extract native defaults which means users can no longer reset a color back to a platform theme Don't extract native defaults, meaning users can no longer reset a color back to a platform theme Jun 28, 2021
@PureWeen
PureWeen force-pushed the remove_auto_defaults branch from 79c207a to 19133bc Compare July 1, 2021 20:07
@Redth
Redth merged commit e7dbda8 into main Jul 2, 2021
@Redth
Redth deleted the remove_auto_defaults branch July 2, 2021 16:33
rookiejava added a commit to rookiejava/maui that referenced this pull request Jul 8, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Jul 14, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Jul 16, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Jul 20, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 4, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 4, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 9, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 11, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
shyunMin pushed a commit to shyunMin/maui that referenced this pull request Aug 22, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
shyunMin pushed a commit to shyunMin/maui that referenced this pull request Aug 22, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 23, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 26, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Aug 31, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Sep 1, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Sep 2, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Sep 3, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
Csaba8472 added a commit to Csaba8472/maui that referenced this pull request Sep 6, 2021
* upstream/main: (270 commits)
  Automated dotnet-format update (dotnet#1533)
  Add tests for default colors (dotnet#1532)
  Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
  Avoid show the virtual keyboard in the Android TimePicker (dotnet#1428)
  Implement VerticalTextAlignment in WinUI Label (dotnet#1479)
  Changes in the Gallery: include custom fonts, reorganize some pages, etc. (dotnet#1526)
  Don't pack and force a signing failure (dotnet#1527)
  [main] Update dependencies from xamarin/xamarin-android (dotnet#1443)
  Implements EntryHandler IsPassword in WinUI (dotnet#802)
  Automated dotnet-format update (dotnet#1523)
  [Build] Fix net6 Microsoft.Maui.Handlers.Benchmarks assembly (dotnet#1525)
  Update WinUI to 0.8 stable (dotnet#1522)
  Implement the basic WindowHandler (dotnet#1468)
  Automated dotnet-format update (dotnet#1510)
  Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
  Avoid create a drawable to set the Background if is not necessary (dotnet#1504)
  Android Gestures (dotnet#1489)
  Revert to using Navigation Page Shims (dotnet#1495)
  Allow to navigate to the same item after navigate back (dotnet#1503)
  Automated dotnet-format update (dotnet#1499)
  ...
rookiejava added a commit to rookiejava/maui that referenced this pull request Sep 7, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Sep 10, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Sep 23, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Sep 24, 2021
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Jan 19, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Jan 21, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Jan 27, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 4, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 8, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 10, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 21, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 23, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 25, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 28, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 2, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 2, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 3, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 4, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 7, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 8, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 8, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 9, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 11, 2022
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
@cshung cshung mentioned this pull request Mar 17, 2022
@ivan-todorov-progress

ivan-todorov-progress commented Apr 18, 2022 •

Copy link
Copy Markdown

I seriously hope this change is just temporary and would be resolved in a better way before we hit general availability. Please, check the issue I have logged: #6183. The change introduces a major inconsistency between the platforms and the new behavior is rather unexpected, breaking dynamic style changes, VisualStateManager etc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants