Baseflow / Baseflow/XF-Material-Library

XamlParseException because of custom MaterialConfiguration

Open
#457 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
633
Forks
150
PR merge metrics
No merged PRs in 30d

Description

## 🐛 Bug Report

Whenever I set a custom `MaterialConfiguration`, sizes are broken. The MaterialLabel font sizes are all default sizes, and when I open an alert, I get this exception:
```
Xamarin.Forms.Xaml.XamlParseException: Position 19:32. StaticResource not found for key Material.Dialog.Width
at Xamarin.Forms.Xaml.StaticResourceExtension.ProvideValue (System.IServiceProvider serviceProvider) [0x0008f] in D:\a\1\s\Xamarin.Forms.Xaml\MarkupExtensions\StaticResourceExtension.cs:27
at XF.Material.Forms.UI.Dialogs.MaterialAlertDialog.InitializeComponent () [0x00066] in Z:\Documents\OpenSource\XF-Material-Library\XF.Material\obj\Release\monoandroid10.0\UI\Dialogs\MaterialAlertDialog.xaml.g.cs:42
at XF.Material.Forms.UI.Dialogs.MaterialAlertDialog..ctor (XF.Material.Forms.UI.Dialogs.Configurations.MaterialAlertDialogConfiguration configuration) [0x00006] in Z:\Documents\OpenSource\XF-Material-Library\XF.Material\UI\Dialogs\MaterialAlertDialog.xaml.cs:32
at XF.Material.Forms.UI.Dialogs.MaterialAlertDialog..ctor (System.String message, System.String title, System.String action1Text, System.String action2Text, XF.Material.Forms.UI.Dialogs.Configurations.MaterialAlertDialogConfiguration configuration) [0x00000] in Z:\Documents\OpenSource\XF-Material-Library\XF.Material\UI\Dialogs\MaterialAlertDialog.xaml.cs:12
...
```

This is due to the "addDefaults" parameter to the Material class' constructor. It stops the flow from setting up size resources whenever a custom config is provided.

https://github.com/Baseflow/XF-Material-Library/blob/fef56fb66de1ff7fc198745f200883f6ac489c20/XF.Material/Material.cs#L128-L140

### Expected behavior

`XF.Material.Forms.Material.Init` should setup sizes correctly when custom configs are set.

### Reproduction steps

Add this to app resources:
```xml



```

And init the package like this:
```cs
XF.Material.Forms.Material.Init(this, (MaterialConfiguration)Resources["Material.Configuration"]);
```

### Configuration

**Version:** 1.8.0

**Platform:**
- [ ] :iphone: iOS
- [X] :robot: Android
- [ ] :checkered_flag: WPF
- [ ] :earth_americas: UWP
- [ ] :apple: MacOS
- [ ] :tv: tvOS
- [X] :monkey: Xamarin.Forms

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.