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

The plugin does not work on the last xamarin.forms version #106

Open
jhovelnu opened this issue Jun 22, 2023 · 2 comments
Open

The plugin does not work on the last xamarin.forms version #106

jhovelnu opened this issue Jun 22, 2023 · 2 comments

Comments

@jhovelnu
Copy link

The plugin does not work on the last xamarin.forms version:

On Android app the badge can be showed

On IOS app the background color does not work

Can you please update this Plugin with the latest version for xamarin.forms?

@jhovelnu
Copy link
Author

@jhovelnu
Copy link
Author

The issue is on the BadgeView.cs

image

When the Position Center is set the badged is showed, but in other Position the badge is not showed because the margin position.

private void ApplyLayoutParams()
{
var layoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);

        if (!_hasWrappedLayout)
        {
            var targetParams = ((FrameLayout.LayoutParams)Target.LayoutParameters);
            var w = targetParams.Width / 2;
            var h = targetParams.Height / 2;

            layoutParameters.Gravity = GravityFlags.Center;
            switch (Postion)
            {
                case BadgePosition.PositionTopLeft:
                    layoutParameters.SetMargins(_badgeMarginL - w, _badgeMarginT - h, 0, 0);
                    break;
                case BadgePosition.PositionTopRight:
                    layoutParameters.SetMargins(0, _badgeMarginT - h, _badgeMarginR - w, 0);
                    break;
                case BadgePosition.PositionBottomLeft:
                    layoutParameters.SetMargins(_badgeMarginL - w, 0, 0, 0 + _badgeMarginB - h);
                    break;
                case BadgePosition.PositionBottomRight:
                    layoutParameters.SetMargins(0, 0, _badgeMarginR - w, 0 + _badgeMarginB - h);
                    break;
                case BadgePosition.PositionCenter:
                    layoutParameters.SetMargins(_badgeMarginL, _badgeMarginT, _badgeMarginR, _badgeMarginB);
                    break;
                case BadgePosition.PositionTopCenter:
                    layoutParameters.SetMargins(0, 0 + _badgeMarginT - h, 0, 0);
                    break;
                case BadgePosition.PositionBottomCenter:
                    layoutParameters.SetMargins(0, 0, 0, 0 + _badgeMarginB - h);
                    break;
                case BadgePosition.PositionLeftCenter:
                    layoutParameters.SetMargins(_badgeMarginL - w, 0, 0, 0);
                    break;
                case BadgePosition.PositionRightCenter:
                    layoutParameters.SetMargins(0, 0, _badgeMarginR - w, 0);
                    break;
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant