Hello, I am developing an application. And I wanted the user to be able to choose between the light and dark theme. I know I need to use a database to make the theme permanent, even if the user closes the application. Has tinydb and sqlite, which would be better?
But my question is how I would make the chosen theme stay on all screens, especially when they have different components
Example I put all the texts in a color, how do I get that color on a different screen than the one I created the database?
Alexandre, welcome to the community!
In this case, you can store values in tinydb. Add the component in each screen using the same namespace. Than get the values using the same tag created in first screen.
Use this method, when screen initialize store a variable value to get tinydb tag value, and set component background color and if text is required then text color to according to theme…
You could put the new dictionaries blocks to good use.
ThemesSample.aia (4.4 KB)
You can also write as json text and use this extension to convert to dictionary.
"CardView01": 1 //(kodular colour code)
Then do the same as the previous post.
thanks, i’m doing some tests here, i believe i did something similar to what you said. If it works I will put my solution here.
I used a logic similar to this, I didn’t know how I would store the correct value, but now I will get it, thanks
Thanks. I understood, I had thought of something like that, but I was not managing to develop a logic
hello guys, sorry for not answering, I was very busy with college tasks.
I tried a lot but I’m not able to do the themes.
This is the dictionary
the dictionary is only on that screen
tema_claro = light theme
tema_escuro = dark theme
In my application the first screen is the menu and I put this dictionary on that screen
This variable is the theme and is on all screens
tema = theme
this block it gets the data from the color dictionary so that each element has its respective color
this block is on all screens
this is the block to change the colors of the menu screen, the other screens are different because they contain different elements
The “configs” screen is responsible for choosing between themes
this block is on all screens, but it is part of “value if label does not exist”
and there is no “if” block
the first procedure it is a navigation button menu
This block checks, changes and saves the theme that the user chooses
when I start the “menu” screen which is the second screen (the first is a splash screen) this error occurs.
Property setter was expecting a com.google.appinventor.components.runtime.TextBox component but got a Label instead.
when I start a screen that has some text boxes (I don’t know if this has anything to do with it, but I imported this screen from another application) these themes don’t change the colors of the screen, the rest works, and if I go back to the screen " menu "the application exits alone.
why is this error happening?
And when changing screens in the navigation menu, the theme doesn’t get the color as soon as it changes screens, there is a short space that shows the colors with the default theme and then changing to the chosen theme, does that really happen?