Status bar efficiency help

I'm creating a status bar to show the level of the bin reading info from firebase and displaying its level and changing the status bars color depending on the percentage it is full..i will also have to do this fr a load cells weight just wondering is there a more time and space efficient way to do it than i have ... there has to be ...im currently using 100 if else statements and every time it changes a percent the status bar changes surely there is a better way to do this tia
Screenshot 2023-07-01 202630

Screenshot 2023-07-01 202551

Screenshot 2023-07-01 202703

Screenshot 2023-07-01 202905

Screenshot 2023-07-01 202932

(Canned Reply: ABG - Download those blocks and post them here)

Please download and post each of those event block(s)/procedures here ...
P.S. These blocks can be dragged directly into your Blocks Editor workspace.

See Download Block Images for a demo.

yeah i just took snippets to give the idea as its 100 if else statements ...ive tried upload the entire block but it wont let obviously too large

The images are too tiny for us to read them Darragh.

Edit: If the Image produced by App Inventor is too big, can you upload it to, say, your google drive or your own website?

To reduce the code, prepare a table with value in column 1 and the other four dependent values in columns 2-5.

Do a table lookup to get what you want to load.

You could do something like this (I used a clock to change the percentage values, and a csv file to contain the colour and percent data)

statusbarcolourchangeprogress2.aia (3.8 KB)

csv extract:

7,"4281597747,7%"
8,"4281597747,8%"
9,"4281597747,9%"
10,"4281597747,10%"
11,"4294967040,11%"
12,"4294967040,12%"
13,"4294967040,13%"
14,"4294967040,14%"

You can find the colour numbers here

I think that without csv, with these few blocks it should also work:

2 Likes

Thanks everyone il give theese options a try