Closed MattePozzy closed 1 year ago
SetAppThemeColor works on native MAUI Controls so you can't call it on MauiReactor label (that is wrapper around MauiControls.Label): you need a reference to the nativecontrol first:
new MauiReactor(labelRef => labelRef?.SetAppThemeColor(...))
BUT it's not recommended even in classic Maui app. You should instead use a xaml resource dictionary like this:
<Setter Property="Label.TextColor"
Value="{AppThemeBinding
Light={StaticResource LightGray},
Dark={StaticResource Background_Mid}}" />
See https://github.com/adospace/reactorui-maui/tree/main/samples/MauiReactor.WeatherTwentyOne
Said that in MauiReactor the recommended approach is something like this:
public static bool IsDarkTheme => MauiControls.Application.Current?.UserAppTheme == Microsoft.Maui.ApplicationModel.AppTheme.Dark;
new MauiReactor.Label()
.TextColor(IsDarkTheme ? Colors.White : Colors.Black)
SetAppThemeColor works on native MAUI Controls so you can't call it on MauiReactor label (that is wrapper around MauiControls.Label): you need a reference to the nativecontrol first:
new MauiReactor(labelRef => labelRef?.SetAppThemeColor(...))
BUT it's not recommended even in classic Maui app. You should instead use a xaml resource dictionary like this:
<Setter Property="Label.TextColor" Value="{AppThemeBinding Light={StaticResource LightGray}, Dark={StaticResource Background_Mid}}" />
See https://github.com/adospace/reactorui-maui/tree/main/samples/MauiReactor.WeatherTwentyOne
Said that in MauiReactor the recommended approach is something like this:
public static bool IsDarkTheme => MauiControls.Application.Current?.UserAppTheme == Microsoft.Maui.ApplicationModel.AppTheme.Dark; new MauiReactor.Label() .TextColor(IsDarkTheme ? Colors.White : Colors.Black)
Thank you, I have solved using this code:
lblTitolo.TextColor(Utility.GetResources<Color>(Utility.IsDarkTheme() ? "White" : "Black"));
Hi, I'm trying to uset the method SetAppThemeColor from here https://learn.microsoft.com/en-us/dotnet/maui/user-interface/system-theme-changes#extension-methods but the control from MauiReactor doesn't have it.
it's possible to implement it or there is a way to use this method?
Thank you.