Ace Ventura
Ace Ventura

Reputation: 86

How to dynamically (at a runtime) add menu items to NavigationDrawer in Jetpack Compose

I am building a Jetpack Compose 3 application. I have local database which holds information about "sensors". There could be no sensors defined in the database or n number of sensors. The user is able to create new sensors.

The SensorPage.kt displays details of each sensor. I would like the UI to display each sensor as a menu item (NavigationDrawerItem) in a ModalNavigationDrawer.

The problem is each NavigationDrawerItem has to be hard coded and passed to ModalNavigationDrawer at the time of coding. Since these are dynamically loaded from database I have not been able to find a way how to accomplish this.

Any ideas and pointers into the right direction are appreciated.

enter image description here

Upvotes: 1

Views: 182

Answers (0)

Related Questions