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

[iOS Bug] IndexOutOfRange when setting the Text property #62

Closed
Phenek opened this issue Jan 9, 2019 · 3 comments
Closed

[iOS Bug] IndexOutOfRange when setting the Text property #62

Phenek opened this issue Jan 9, 2019 · 3 comments
Labels

Comments

@Phenek
Copy link

Phenek commented Jan 9, 2019

My implementation is like so:

            var tab = new AccountPage();
            var navigation = new NavigationPage(tab)
            {
                Title = "Profil",
                Icon = "Profile",
            };

            tab.SetBinding(TabBadge.BadgeTextProperty, nameof(BottomMenuViewModel.Count));
            tab.SetBinding(TabBadge.BadgeColorProperty, nameof(BottomMenuViewModel.Color));
            tab.SetBinding(TabBadge.BadgeTextColorProperty, nameof(BottomMenuViewModel.TextColor));
            tab.BindingContext = viewModel;
            Children.Add(navigation);

When changing the BadgeTextProperty I got an IndexOutOfRange on iOS Only.
Message: Index was outside the bounds of the array.

The StackTrace take me to the Plugin.Badge.iOS.BadgedTabbedPageRenderer.OnTabbedPagePropertyChanged

@Phenek
Copy link
Author

Phenek commented Jan 9, 2019

I think is about the CheckValidTabIndex function in the iOS Renderer

The function is searching for the IndexOf(tab) and need to be the IndexOf(navigation)
regarding my implementation. #58

@xabre xabre added the bug label Jan 10, 2019
@Phenek
Copy link
Author

Phenek commented Jan 10, 2019

For a workaround we could do :

        public bool CheckValidTabIndex(Page page, out int tabIndex)
        {
            tabIndex = Tabbed.Children.IndexOf(page);
            if(tabIndex == -1 && page.Parent != null)
            {
                 tabIndex = Tabbed.Children.IndexOf(page.Parent);
            }
            return tabIndex < TabBar.Items.Length && tabIndex >= 0;;
        }

Regards,

foxanna added a commit to foxanna/xamarin-forms-tab-badge that referenced this issue Feb 1, 2019
foxanna added a commit to foxanna/xamarin-forms-tab-badge that referenced this issue Feb 1, 2019
@foxanna foxanna mentioned this issue Feb 1, 2019
xabre pushed a commit that referenced this issue Feb 1, 2019
* Issue #62: Avoid IndexOutOfRange exception

* Issue #62: Properly detect tab index when it is wrapped into parent
@xabre
Copy link
Owner

xabre commented Feb 3, 2019

PR #63 was merged and released with v2.1.1

@xabre xabre closed this as completed Feb 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants