Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.NullReferenceException: MaterialLabel with TypeScale #67

Closed
PaulP92 opened this issue Feb 18, 2019 · 1 comment
Closed

System.NullReferenceException: MaterialLabel with TypeScale #67

PaulP92 opened this issue Feb 18, 2019 · 1 comment
Labels
bug Something isn't working valid This issue/bug/feature request is valid

Comments

@PaulP92
Copy link

PaulP92 commented Feb 18, 2019

Describe the bug
If you use the default Material.Configuration and add a MaterialLabel with TypeScale to a Page a System.NullReferenceException is thrown.

To Reproduce
Steps to reproduce the behavior:

  1. Call XF.Material.Forms.Material.Init(this); (without MaterialConfiguration)
  2. Add a MaterialLabel to MainPage
  3. Set TypeScale to H5
  4. See error

Expected behavior
Use MaterialLabel with default system Fonts

Smartphone:

  • Device: iPhone XS Max Simulator
  • OS: 12.1

Additional context
Stacktrace:
" at XF.Material.Forms.UI.MaterialLabel.OnTypeScaleChanged (XF.Material.Forms.Resources.Typography.MaterialTypeScale materialTypeScale) [0x0005f] in /Users/vsts/agent/2.146.0/work/1/s/XF.Material/XF.Material.Forms/UI/MaterialLabel.cs:94 \n at XF.Material.Forms.UI.MaterialLabel.OnPropertyChanged (System.String propertyName) [0x00014] in /Users/vsts/agent/2.146.0/work/1/s/XF.Material/XF.Material.Forms/UI/MaterialLabel.cs:56 \n at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00114] in D:\\a\\1\\s\\Xamarin.Forms.Core\\BindableObject.cs:622 \n at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\\a\\1\\s\\Xamarin.Forms.Core\\BindableObject.cs:422 \n at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0003d] in D:\\a\\1\\s\\Xamarin.Forms.Core\\BindableObject.cs:572 \n at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\\a\\1\\s\\Xamarin.Forms.Core\\BindableObject.cs:122 \n at MaterialUX.MainPage.InitializeComponent () [0x00012]..."

@songurov
Copy link
Contributor

songurov commented Feb 18, 2019

xmlns:mtrl="clr-namespace:XF.Material.Forms.Resources;assembly=XF.Material.Forms"
xmlns:mtrltypo="clr-namespace:XF.Material.Forms.Resources.Typography;assembly=XF.Material.Forms"










<mtrltypo:MaterialFontConfiguration
x:Key="Material.Font"
Body1="{StaticResource FontFamily.RobotoRegular}"
Body2="{StaticResource FontFamily.RobotoRegular}"
Button="{StaticResource FontFamily.RobotoMedium}"
Caption="{StaticResource FontFamily.RobotoRegular}"
H1="{StaticResource FontFamily.RobotoRegular}"
H2="{StaticResource FontFamily.RobotoRegular}"
H3="{StaticResource FontFamily.RobotoRegular}"
H4="{StaticResource FontFamily.RobotoRegular}"
H5="{StaticResource FontFamily.RobotoRegular}"
H6="{StaticResource FontFamily.RobotoMedium}"
Overline="{StaticResource FontFamily.RobotoRegular}"
Subtitle1="{StaticResource FontFamily.RobotoRegular}"
Subtitle2="{StaticResource FontFamily.RobotoMedium}" />
<mtrl:MaterialColorConfiguration
x:Key="Material.Color"
Background="#EAEAEA"
Error="#B00020"
OnBackground="#000000"
OnError="#FFFFFF"
OnPrimary="#FFFFFF"
OnSecondary="#FFFFFF"
OnSurface="#000000"
Primary="#6200EE"
PrimaryVariant="#6200EE"
Secondary="#00377b"
Surface="#FFFFFF" />
<mtrl:MaterialConfiguration
x:Key="Material.Style"
ColorConfiguration="{StaticResource Material.Color}"
FontConfiguration="{StaticResource Material.Font}" />

<x:Double
x:Key="Material.FontSize.H1">96</x:Double>
<x:Double
x:Key="Material.FontSize.H2">60</x:Double>
<x:Double
x:Key="Material.FontSize.H3">48</x:Double>
<x:Double
x:Key="Material.FontSize.H4">34</x:Double>
<x:Double
x:Key="Material.FontSize.H5">24</x:Double>
<x:Double
x:Key="Material.FontSize.H6">20</x:Double>
<x:Double
x:Key="Material.FontSize.Subtitle1">16</x:Double>
<x:Double
x:Key="Material.FontSize.Subtitle2">14</x:Double>
<x:Double
x:Key="Material.FontSize.Body1">16</x:Double>
<x:Double
x:Key="Material.FontSize.Body2">14</x:Double>
<x:Double
x:Key="Material.FontSize.Button">14</x:Double>
<x:Double
x:Key="Material.FontSize.Caption">12</x:Double>
<x:Double
x:Key="Material.FontSize.Overline">10</x:Double>


<x:Double
x:Key="Material.LetterSpacing.H1">-1.5</x:Double>
<x:Double
x:Key="Material.LetterSpacing.H2">-0.5</x:Double>
<x:Double
x:Key="Material.LetterSpacing.H3">0</x:Double>
<x:Double
x:Key="Material.LetterSpacing.H4">0.25</x:Double>
<x:Double
x:Key="Material.LetterSpacing.H5">0</x:Double>
<x:Double
x:Key="Material.LetterSpacing.H6">0.15</x:Double>
<x:Double
x:Key="Material.LetterSpacing.Subtitle1">0.15</x:Double>
<x:Double
x:Key="Material.LetterSpacing.Subtitle2">0.1</x:Double>
<x:Double
x:Key="Material.LetterSpacing.Body1">0.5</x:Double>
<x:Double
x:Key="Material.LetterSpacing.Body2">0.25</x:Double>
<x:Double
x:Key="Material.LetterSpacing.Button">1.25</x:Double>
<x:Double
x:Key="Material.LetterSpacing.Caption">0.4</x:Double>
<x:Double
x:Key="Material.LetterSpacing.Overline">1.5</x:Double>
<x:Double
x:Key="Material.LetterSpacing.None">0</x:Double>


<OnIdiom.Tablet>560</OnIdiom.Tablet>
<OnIdiom.Phone>280</OnIdiom.Phone>

insert in App.xaml Resource and add fonts per/Platform

@contrix09 contrix09 self-assigned this Feb 18, 2019
@contrix09 contrix09 added bug Something isn't working valid This issue/bug/feature request is valid labels Feb 18, 2019
@contrix09 contrix09 removed their assignment Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working valid This issue/bug/feature request is valid
Projects
None yet
Development

No branches or pull requests

2 participants