Closed sk1llsh0t closed 1 month ago
workaround (or maybe possible solution, just not sure what the implication is of doing this), is in the FeakyEntryHandler class, surround the MapFreakyEntry method in a try...catch block to handle the invalidoperationexception...
private void MapFreakyEntry(IEntryHandler entryHandler, IEntry entry)
{
try
{
if (entry is FreakyEntry freakyEntry && entryHandler is FreakyEntryHandler freakyEntryHandler)
{
if (PlatformView is not null && VirtualView is not null)
{
if (freakyEntry.ImageSource != default(ImageSource))
{
freakyEntryHandler.HandleAndAlignImageSourceAsync(freakyEntry).RunConcurrently();
}
HandleAllowCopyPaste(freakyEntry);
}
}
}
catch (InvalidOperationException ex) { }
}
}
Doing this fixes the issue. When you have time, please add to the code base and release hotfix. Thanks for all your work!!!
Gonna be a while buddy unfortunately I am a bit busy for the last couple of months and its gonna stay this way for a while
The solution above fixes issue #1 listed in the original post. Issue #2 is a different solution when loading the style from a global styles file.
In the FreakyTextInputLayout class, modify OnOutlineTitleBackgroundColorProperty change event to make sure til.LabelTitle is not null. I guess the global styles are applying before all the controls are instantiated which is causing an issue in this case.
Fix:
private static void OnOutlineTitleBackgroundColorProperty(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is FreakyTextInputLayout til && newValue is Color color && til.LabelTitle is not null)
{
til.LabelTitle.BackgroundColor = til.BorderType ==
BorderType.Outlined ? color : Colors.Transparent;
}
}
With these 2 solutions, everything now works.
If i make the change in my fork and create a merge request, would you be able to do a new build? If not, no worries. I'll just grab the 0.4.12 tag and build a 0.4.13 nuget package locally.
@sk1llsh0t I am going to release a new version in October if you can add a quick fix for this it can be added
I added the fix and sent a pull request (https://github.com/FreakyAli/Maui.FreakyControls/pull/145). I'm hoping you are able to include that in the October build.
Description
1) When i use AppThemeBinding to apply light and dark mode to the FreakyTextInputLayout, it throws errors when switching between modes.
2) There is also an issue in OnOutlineTitleBackgroundColorProperty Changed if the styles are loaded from a global styles file
System.InvalidOperationException: PlatformView cannot be null here at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IEntry, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.AppCompat.Widget.AppCompatEditText, Xamarin.AndroidX.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].getPlatformView() in //src/Core/src/Handlers/View/ViewHandlerOfT.cs:line 36 at Maui.FreakyControls.FreakyEntryHandler.MapFreakyEntry(IEntryHandler entryHandler, IEntry entry)
Code
Expected Behavior
I can change between light and dark mode without crashing
Actual Behavior
App crashes
Basic Information
Latest version of Freaky running on Android 12 (net 8.0.8)