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

Setting badge for given tab when tab is not currently selected #596

Open
3 tasks done
bstillitano opened this issue Apr 19, 2022 · 1 comment
Open
3 tasks done

Setting badge for given tab when tab is not currently selected #596

bstillitano opened this issue Apr 19, 2022 · 1 comment

Comments

@bstillitano
Copy link

New Issue Checklist

Issue Description

I am attempting to set the badge value of a tab, while that tab is not the one currently visible. For example, I want tab 3 to update its badge value, while tab 5 is the currently selected one. I know my functions and notification methods are working fine, because I am able to console log a test string to ensure that it is being hit. It appears that the only time a badge can be updated, is when the tab the badge belongs to, is the currently selected tab.

Other useful things

N/A

@bstillitano
Copy link
Author

For anyone else with this issue, i've managed to work around this by doing the following in my TabmanViewController instance. All subclasses of ViewController, in my project, have a property called badgeValue which contains a didSet listener which posts a notification and subsequently triggers the update in my parent TabmanViewController:

Task { @MainActor [weak self] in
            for (index, viewController) in viewControllers.enumerated() {
                guard self?.bars.first?.items?.indices.contains(index) ?? false else { return }
                self?.bars.first?.items?[index].badgeValue = (viewController as? ViewController)?.badgeValue
            }
        }

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