CommunityToolkit/Maui.Markup

[Proposal] Extension bindings for AppTheme and AppThemeColor

fredericoregateiro opened this issue · 1 comments

Extension bindings for AppTheme and AppThemeColor

Link to Discussion

AppThemeBinding in Markup #627

Summary

Create binding extensions for SetAppTheme and SetAppThemeColor

Motivation

Detailed Design

Usage Syntax

new Button().AppThemeBinding(Button.TextColorProperty, Colors.Green, Colors.Orange)

C# Usage

public static TBindable AppThemeBinding<TBindable, T>(this TBindable bindable, BindableProperty bindableProperty, T light, T dark) where TBindable : BindableObject
{
    bindable.SetAppTheme(bindableProperty, light, dark);

    return bindable;
}
public static TBindable AppThemeColorBinding<TBindable>(this TBindable bindable, BindableProperty bindableProperty, Color light, Color dark) where TBindable : BindableObject
{
    bindable.SetAppThemeColor(bindableProperty, light, dark);

    return bindable;
}

Drawbacks

Alternatives

Unresolved Questions

Thanks @fredericoregateiro!

@bijington has volunteered to Champion this PR. The next step before we can review/merge a PR is to vote on this Proposal.

To learn more about our process for new features, you can read the “Submitting a New Feature” section here: https://github.com/CommunityToolkit/Maui.Markup#submitting-a-new-feature