Himalayan-Academy / Siva-Siva-App

Code Repository for the Siva Siva Mobile App
11 stars 3 forks source link

Make a proposal for refactoring the overall architecture #245

Open Brahmanathaswami opened 4 years ago

Brahmanathaswami commented 4 years ago

This is a vague request, but I want to make it official. Time you spend on this can put on your invoice. Perhaps before you do any more responsive work, I suspect you may want to see some refactoring first, then we are not having refactor more code... later?

Brahmanathaswami commented 4 years ago

@bwmilby assigned to you...

bwmilby commented 4 years ago

One pattern that would be good for the whole app is to have base groups exist on every card. One example would be:

Then there could be a behavior to the stack that would position those 4 groups. The height for the header/footer would remain constant (or could be adjusted by the header/footer group script) and the body group would take the remaining space. If a particular card did not need either the header or footer area, then the group could be set to a height of 0 or 1 pixel (or the behavior script could check for existence of the header/footer group). The background group could have a custom property to indicate if it should be full bleed or within the safe rect. The grc/img could be directly on the card, it would just add a few conditionals (tests for object existence) in the script.

This would allow: after preOpenCard, before resizeStack, and before closeCard to be included in the one behavior to handle the main responsive calls. Then each group would have either a script or behavior that only handled positioning of elements within itself. This pattern was employed in the unified footerNavigation group. I would change it slightly in this implementation. (Instead of having all objects included in all stacks, I would only include the necessary buttons and delete any extra ones. This would allow positioning to be done by layer order instead of by an ordered list as done currently.)

Brahmanathaswami commented 4 years ago

Go for it!

bwmilby commented 4 years ago

Here's a demo stack that shows the idea of the groups and how a group script can handle the resize of the objects. Have the SivaSiva app open first though since it relies on the UI behavior stack being in memory.

template.livecode.zip

It isn't locked like the app, so you can grab the corner and resize it to see things move. Probably would be more interesting with some object inside the groups and I can do that if desired.