Пример #1
0
 public static void UpdateFromPropertyChangedEvent(this BadgeView badgeView, Element element, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == TabBadge.BadgeTextProperty.PropertyName)
     {
         badgeView.Text = TabBadge.GetBadgeText(element);
     }
     else if (e.PropertyName == TabBadge.BadgeColorProperty.PropertyName)
     {
         badgeView.BadgeColor = TabBadge.GetBadgeColor(element).ToAndroid();
     }
     else if (e.PropertyName == TabBadge.BadgeTextColorProperty.PropertyName)
     {
         badgeView.TextColor = TabBadge.GetBadgeTextColor(element).ToAndroid();
     }
     else if (e.PropertyName == TabBadge.BadgeFontProperty.PropertyName)
     {
         badgeView.Typeface = TabBadge.GetBadgeFont(element).ToTypeface();
     }
     else if (e.PropertyName == TabBadge.BadgePositionProperty.PropertyName)
     {
         badgeView.Postion = TabBadge.GetBadgePosition(element);
     }
     else if (e.PropertyName == TabBadge.BadgeMarginProperty.PropertyName)
     {
         var margin = TabBadge.GetBadgeMargin(element);
         badgeView.SetMargins((float)margin.Left, (float)margin.Top, (float)margin.Right, (float)margin.Bottom);
     }
 }
Пример #2
0
        public static void UpdateFromElement(this BadgeView badgeView, Page element)
        {
            var badgeText = TabBadge.GetBadgeText(element);

            badgeView.Text = badgeText;

            var tabColor = TabBadge.GetBadgeColor(element);

            if (tabColor != Color.Default)
            {
                badgeView.BadgeColor = tabColor.ToAndroid();
            }

            var tabTextColor = TabBadge.GetBadgeTextColor(element);

            if (tabTextColor != Color.Default)
            {
                badgeView.TextColor = tabTextColor.ToAndroid();
            }

            // set font if not default
            var font = TabBadge.GetBadgeFont(element);

            if (font != Font.Default)
            {
                badgeView.Typeface = font.ToTypeface();
            }

            var margin = TabBadge.GetBadgeMargin(element);

            badgeView.SetMargins((float)margin.Left, (float)margin.Top, (float)margin.Right, (float)margin.Bottom);
            badgeView.Postion = TabBadge.GetBadgePosition(element);
        }