[TouchGFX] Reusable Modal window on every screen?
Hi everyone,
I'm currently working on a project where the device has to continuously read files from USB but where a user can also plug the device into a computer and mount it as a USB device to transfer and delete files and what-not.
Now, I can detect when external power is plugged-in and want to show the user a modal dialog where they can choose what should happen next - "USB device mode" or "Standalone mode + charging".
This modal dialog, however, should be shown on (or be reachable from) each and every screen within the application.
Now, I came across two different solutions, both of which I do not particularly like:
- create a container for the modal, add some selection logic and put this container onto each screen. Now, I have two, first mind that I add this modal to every newly created screen, and second, I have to copy code to show and hide the modal to every view and presenter within the project (which doesn't feel all that portable).
- create a dedicated "USB mode selection" screen that is only in the application once and on detected USB connection, somehow store the screen that was active before I switched there. This would also lead to code duplication since every screen would need to remember to register as the previous screen so that it can be restored afterwards. This approach is also not maintainable since the base `Presenter` class does not know about the concept of a view at all - which means I cannot use the "central" `deactivate` method of the `Presenter`s' base class to store the last active screen. Furthermore, the Presenter Facet of a derived presenter doesn't know about the concept of a model, hence I could not call the model to store the last active screen
Is there any better way I am currently unaware of? What am I missing here?
Thanks in advance.