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

Added setSelectedItem & setBadge method #84

Merged
merged 11 commits into from
Oct 28, 2022

Conversation

milon27
Copy link
Contributor

@milon27 milon27 commented Jun 23, 2021

//overload setupWithNavController
fun setupWithNavController(menu:Menu,navController: NavController) {
        NavigationComponentHelper.setupWithNavController(menu, this, navController)
    }

+fun setupWithNavController(navController: NavController) {
+   NavigationComponentHelper.setupWithNavController(this.menu, this, navController)
+    Navigation.setViewNavController(this,navController)
+}

//select an item 
+fun setSelectedItem(pos:Int){
+     try{
+         this.itemActiveIndex=pos
+          NavigationUI.onNavDestinationSelected(this.menu.getItem(pos), this.findNavController())
+      }catch (e:Exception){
+          throw Exception("set menu using PopupMenu")
+      }
+  }

//set badge indicator
+ if(badge_arr.contains(index)){
+     canvas.drawCircle(
+        item.rect.centerX()
+            .toInt() - itemIconSize.toInt() / 2f - ((textLength / 2) * (1 - (OPAQUE - item.alpha) / OPAQUE)),
+       height / 2f - itemIconSize.toInt() / 2f,
+        10f,
+        badgePaint
+      )
+ }

This was referenced Jun 23, 2021
@brookmg
Copy link
Contributor

brookmg commented Jun 23, 2021

#29 (comment)

@milon27
Copy link
Contributor Author

milon27 commented Jun 23, 2021

ok, so we can't have the badge in this library?

@brookmg
Copy link
Contributor

brookmg commented Jun 24, 2021

At this time yes. Unless @ibrahimsn98 has a new pointer on it as he is the owner and lead of this lib

@ibrahimsn98 ibrahimsn98 merged commit 9e17306 into ibrahimsn98:master Oct 28, 2022
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

Successfully merging this pull request may close these issues.

None yet

3 participants