A conditional side menu

On the first screen will have the login, the app makes a user verification in firebase.

I’m having difficulty creating a conditional side menu.
If you are a regular user, you must disable the admin item.
If you are an admin user, you must enable the admin item in the side menu.
How should I proceed?
image


I’m having the problem:
Select list item: Attempt to get item number 4 of a list of length 0: ()

tks

It simply means the list is empty, there aren’t any items to select from.

Is this your complete block?

When screen init you set to get tag list when you are getting the value in listview , you set the firebase get value into a variable but where is the firebase to get value block???

1 Like

No, I only showed part of my block.
The part where I’m struggling.
This screen is where the registered user with an administrator profile will see a complete list of all registered users.
Here, the ADMIN user will have the power to register new users and delete them.
This whole part is working perfectly.


My difficulty is no side menu.
I want one of the links in the side menu to appear whether for the admin user or not.

tks

And what would be the solution to reading a list correctly?
tks

Welcome. I suggest to split the app into 2 projects.
Separate the routines for each type of user that can access.
And create the 2 apps independent of each other.
Example: Look at this routine to enable the side menu, it won’t exist if you separate the routines into 2 apps.
In future updates in 1 app , will not interfere with the other app (in case of bugs)
:+1:

1 Like

Thanks Rogerio.
It’s a much simpler solution. Hadn’t really thought about it.
I will look forward to receiving other suggestions. In case I can’t solve it, I’ll accept your idea.
tks

1 Like

What I have suggested is what has been done for many many many years.:+1:

You have highlighted a block there instead of using another if condition in in the else block just use only the procedure.

I.e
If select list item list get global dados user index 4 = admin
Then menu admin procedure
Else menu user procedure

However you will be getting the value either as admin or user. So if the value is admin let it open admin menu if not let it to open user menu. Just try and let me know it

Here my simple suggestion.

When user register on your app then simply save a value in firebase that u later can use to differentiate the users as admin or normal users.
And then use a simple if else logic.

If fb admin tag value = true
Then side menu visible
Else side menu disable

I already have in the base the values of the common users or administrator.
In the first screen, the user logs in normally, after he is directed to another screen.
If the user logged in to “admin” then this item should appear:

However I don’t know how to make firebase return the value to me.
My last attempt was this:

tks @themaayur

My last attempt was this:

tks @Still-learning

1 Like

But after getting tag list , you need to get fb value then only this part will work. If possible show us the fb structure…

Also in oder to make more complex why don’t you make it simple one. . After registration just save the name in a tinydb as admin or user. And in this screen in the screen initial itself just check the tinydb value. If it is admin show admin if not show user

If not you can create another bucket as admin and user after successful login or registration.
Like
(Admin-bucket)
Tag(username) - value (yes)

In this screen just get tag list of the bucket admin and user. If the name existing in either one show the relevant sidemenu

Could you demonstrate this to me through the blocks?
tks @themaayur

This is my base:
image

Then after getting tag list get tag value … and after getting the tag value just apply what you did just before the post. It will work

But the problem is, you are not getting the particular user tag value, instead you are getting all the tag values so it won’t work

here i manually entered number in the place of tag; but you can use any tinydb or any other design to get exact users tag value… it will work…

This is just ref
image

1 Like

Thanks @Still-learning
I understood the logic.
But this example you present me search in just a specific tag.
How would I do this across the base?
tks

I don’t think that is good idea… you need to check the particular user is admin or user. Suppose if you set across the base mean, app will favour to what you using the search text. It means in the Is in the list if you User , then app will open User panel only because across the base mean user text is present That’s why I am telling this is not good.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.