2024-10-30 11:30 AM - edited 2024-10-30 11:37 AM
Hi there Touchgfx team!
I've this ui requirement: A header with battery, date/time, battery, and extra icon.
I also have 15 different screens. The model receives a signal from the backend and thats how it knows that it needs to show the USB icon.
I know how to do a notify from model -> view, and I know I could do this for the 15 different screens. The problem I'm facing is that the USB icon needs to appear in the other screens if the user goes to a different screen. I know I could also setup a flag in the model and get the vale in the setupScreen()
My question is: is there an easier way to do this? I would like to avoid creating 15 different propagation functions for the USB, and other 15 for the other icon. I was thinking about creating a custom container and updating it from the model just once, and somehow all the views with the container will update.
I have the same question for the "date/time" text. At this moment, each view has a function that calls the presenter, and then the model, to get the date value. But, if the data/time text is in all the screens, is there a better way?
Thanks a lot in advance
Solved! Go to Solution.
2024-11-01 02:55 AM
Hello @JPabl.1 ,
No, there is no other way of doing it as this is the role of the MVP.
I understand that created 2 functions for each screen is a bit annoying, but they are mostly copy paste.
Regards,
2024-11-01 02:55 AM
Hello @JPabl.1 ,
No, there is no other way of doing it as this is the role of the MVP.
I understand that created 2 functions for each screen is a bit annoying, but they are mostly copy paste.
Regards,
2024-11-01 03:09 AM - edited 2024-11-01 05:24 AM
How much code does it take?
Time can be pulled from the model every x ticks or pushed to the view when time changes.
My application has some display settings such as temperature unit (Celsius or Fahrenheit) and each screen pulls the unit from the model via the presenter (method defined in modellistener). Some screens do not pull the unit, but get values with units pushed to them.
2024-11-01 03:21 AM