Created
May 5, 2018 05:22
-
-
Save vlkam/4b1ae7b5036174ab117ff35ac64cde94 to your computer and use it in GitHub Desktop.
Font markup extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ContentProperty("FontSize")] | |
public class FontSizeExtension : IMarkupExtension | |
{ | |
public double FontSize { get; set; } | |
//public double Factor { get; set; } = 0; | |
public double Mini { get; set; } = -1; | |
public double SizeiOS { get; set; } = -1; | |
public double iOSmini { get; set; } = -1; | |
//public double FactoriOS { get; set; } = -1; | |
public double Android { get; set; } = -1; | |
public double AndroidMini { get; set; } = -1; | |
//public double FactorAndroid { get; set; } = -1; | |
public object ProvideValue(IServiceProvider serviceProvider) | |
{ | |
switch (Device.RuntimePlatform) | |
{ | |
case Device.iOS: | |
if (Device.Info.PixelScreenSize.Width > 640) | |
{ | |
return // by priority | |
SizeiOS > -1 ? SizeiOS : | |
FontSize; | |
} | |
else | |
{ | |
return // by priority | |
iOSmini > -1 ? iOSmini : | |
Mini > -1 ? Mini : | |
SizeiOS > -1 ? SizeiOS : | |
FontSize; | |
} | |
case Device.Android: | |
if (Device.Info.PixelScreenSize.Width > 500) | |
{ | |
return // by priority | |
Android > -1 ? Android : | |
FontSize; | |
} | |
else | |
{ | |
return // by priority | |
AndroidMini > -1 ? AndroidMini : | |
Mini > -1 ? Mini : | |
Android > -1 ? Android : | |
FontSize; | |
} | |
default: | |
return FontSize; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment