01-08-2018 15:39 - edited 01-08-2018 16:05
01-08-2018 15:39 - edited 01-08-2018 16:05
If you wanted to have the multi-screen application boilerplate having SVG split to several .gui files, you now have it. Updated Ionic Views UI micro-framework.
Same for jQuery-style $( '#id1 #id2' ) selectors.
Same for hierarchical subviews. View now comes with an energy-saving bonus: render is automatically suppressed when the screen is off (and app render is forced when the screen goes on). So, don't bother with that optimization. It just works.
Special thanks to @kmpm who helped to test and debug the thingy. Btw its size is about 100 lines of code, don't be afraid to look inside.
Don't forget to put a star if you like it.
10-14-2018 04:09 - edited 10-14-2018 04:11
10-14-2018 04:09 - edited 10-14-2018 04:11
@gaperton I've now implemented Ionic Views into my WIP app - thanks a lot for your effort and for sharing!
Took a little bit of head-scratching over how to link up the screen to buttons in the .gui, and then a whole bunch more to get button taps to work via onclick (onactivate doesn't seem to work at all?), but I got there in the end.
I would recommend extending screen2 in your demo to show how to use a button, if you would be so kind.
@Tjeerd As for your "back button in views" question, if you're asking how to use the physical back button on the watch, I've just a few minutes ago added this using a bit of help from https://community.fitbit.com/t5/SDK-Development/Physical-Button-Exit-App/m-p/2385358/highlight/false...
Not sure if this is the correct/ideal way, but I edited view.js to change the current ({ key }) setup for onkeypress to a regular function(e), so it all looks like this:
document.onkeypress = function(e) {
e.preventDefault(); // We don't want the OS to do the normal actions when we press the physical buttons, as this would close the app when pressing "back", etc.
if( e.key === 'down' ) app.onKeyDown();
else if( e.key === 'up' ) app.onKeyUp();
else if( e.key === 'back' ) app.onKeyBack();
}
}
onKeyDown(){
this.screen.onKeyDown();
}
onKeyUp(){
this.screen.onKeyUp();
}
onKeyBack(){
this.screen.onKeyBack();
}
Then, in my screen's .js I simply have
this.onKeyBack = () => { console.log( 'planWorkout -> Home'); Application.switchTo('Home'); }
in my onMount().
10-14-2018 16:03
10-14-2018 16:03
@Tjeerd As for your "back button in views" question, if you're asking how to use the physical back button on the watch, I've just a few minutes ago added this using a bit of help from https://community.fitbit.com/t5/SDK-Development/Physical-Button-Exit-App/m-p/2385358/highlight/false...
Not sure if this is the correct/ideal way, but I edited view.js to change the current ({ key }) setup for onkeypress to a regular function(e), so it all looks like this:
I did figure that out too, so my view.js looks the same 🙂
10-14-2018 16:09
10-14-2018 16:09
Another change I made is to disable the 'display.on' check in render as this was causing a small delay in updating the ui after re-enabling the screen. 'clock.ontick' already seem to take into account if the screen is on or off, so I guess the advantage of this check is not that big anyway.
Any thoughts on this?
10-14-2018 22:41
10-14-2018 22:41
10-14-2018 22:44
10-14-2018 22:44
> Another change I made is to disable the 'display.on' check in render as this was causing a small delay in updating the ui after re-enabling the screen.
Yep, this is the problem. It can be solved with hiding the view when the screen goes off and showing it when it goes on _after_ update. It will introduce the small subsecond delay but will be less confusing.
Suppressing the render when the screen is off should improve the battery life, although I never checked the real difference.