This file contains hidden or 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
void UpdateToolbarTextFont(Android.Widget.TextView textView, Font customFont, Typeface originalFont) | |
{ | |
if (customFont != null) | |
{ | |
textView.Typeface =customFont.ToTypeface(); | |
float tValue = customFont.ToScaledPixel(); | |
textView.SetTextSize(ComplexUnitType.Sp, tValue); | |
} | |
else | |
{ |
This file contains hidden or 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
void UpdateTitleViewLayoutPadding(LinearLayout titleViewLayout, Thickness padding) | |
{ | |
titleViewLayout?.SetPadding((int)padding.Left, (int)padding.Top, (int)padding.Right, (int)padding.Bottom); | |
} | |
void UpdateTitleViewLayoutMargin(LinearLayout titleViewLayout, Thickness margin) | |
{ | |
var titleViewParams = titleViewLayout.LayoutParameters as Android.Widget.FrameLayout.LayoutParams; | |
titleViewParams?.SetMargins((int)margin.Left, (int)margin.Top, (int)margin.Right, (int)margin.Bottom); | |
titleViewLayout.LayoutParameters = titleViewParams; |
This file contains hidden or 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
Drawable CreateShape(ShapeType type,int strokeWidth,int cornerRadius,Xamarin.Forms.Color? fillColor,Xamarin.Forms.Color? strokeColor) | |
{ | |
GradientDrawable shape = new GradientDrawable(); | |
shape.SetShape(type); | |
if(fillColor !=null) | |
{ | |
shape.SetColor(fillColor?.ToAndroid() ?? Xamarin.Forms.Color.Transparent.ToAndroid()); | |
} | |
if (strokeColor != null) |
This file contains hidden or 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
void UpdateToolbarBackground(Android.Support.V7.Widget.Toolbar toolbar, Page lastPage, Activity activity, Android.Graphics.Drawables.Drawable defaultBackground) | |
{ | |
if (string.IsNullOrEmpty(CustomNavigationPage.GetBarBackground(lastPage)) && CustomNavigationPage.GetGradientColors(lastPage) == null) | |
{ | |
toolbar.SetBackground(defaultBackground); | |
} | |
else | |
{ |
This file contains hidden or 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
void UpdateToolbarShadow(Android.Support.V7.Widget.Toolbar toolbar, bool hasShadow, Activity activity, Android.Graphics.Drawables.Drawable windowContent) | |
{ | |
var androidContent = activity?.Window?.DecorView?.FindViewById<FrameLayout>(Window.IdAndroidContent); | |
if (androidContent != null) | |
{ | |
if (hasShadow && activity != null) | |
{ | |
GradientDrawable shadowGradient = new GradientDrawable(GradientDrawable.Orientation.RightLeft, new int[] { Android.Graphics.Color.Transparent.ToArgb(), Android.Graphics.Color.Gray.ToArgb() }); | |
shadowGradient.SetCornerRadius(0f); |
This file contains hidden or 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
void SetTitlePosition( CustomNavigationPage.TitleAlignment alignment,Thickness padding, Thickness margin, CGRect vFrame) | |
{ | |
var marginX = margin.Top; | |
var marginY = margin.Left; | |
var marginWidth = margin.Left + margin.Right; | |
var marginHeight = margin.Top + margin.Bottom; | |
var paddingWidth = padding.Left + padding.Right; | |
var paddingHeight = padding.Top + padding.Bottom; | |
var paddingX = padding.Left; |
This file contains hidden or 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
void SetupBackground(UIImage image,float alpha) | |
{ | |
NavigationController.NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default); | |
NavigationController.NavigationBar.Alpha = alpha; | |
} | |
void SetupBackground() | |
{ | |
if (string.IsNullOrEmpty(CustomNavigationPage.GetBarBackground(Element)) && CustomNavigationPage.GetGradientColors(Element) == null) | |
{ |
This file contains hidden or 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
void SetupShadow(bool hasShadow) | |
{ | |
if(hasShadow) | |
{ | |
NavigationController.NavigationBar.Layer.ShadowColor = UIColor.Gray.CGColor; | |
NavigationController.NavigationBar.Layer.ShadowOffset = new CGSize(0, 0); | |
NavigationController.NavigationBar.Layer.ShadowOpacity = 1; | |
} | |
else | |
{ |
This file contains hidden or 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
void SetupTextFont(UILabel label,Font font,Color? titleColor) | |
{ | |
var cPage = Element as CustomPage; | |
if (cPage!=null && cPage.FormattedTitle != null && cPage.FormattedTitle.Spans.Count > 0) | |
{ | |
SetupFormattedText(titleLabel, cPage.FormattedTitle, cPage.Title); | |
} | |
else | |
{ |
This file contains hidden or 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
public class CustomPage : ContentPage | |
{ | |
public static readonly BindableProperty FormattedTitleProperty = BindableProperty.Create(nameof(FormattedTitle),typeof(FormattedString),typeof(CustomPage),null); | |
public FormattedString FormattedTitle | |
{ | |
get { return (FormattedString)GetValue(FormattedTitleProperty); } | |
set | |
{ | |
SetValue(FormattedTitleProperty, value); |