Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multi-screen App Template - Ionic Views v1.1

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.

Best Answer
24 REPLIES 24

@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().

Best Answer

 

@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 🙂

Best Answer
0 Votes

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?

Best Answer
0 Votes
The code is what I would've rather called "guidelines" than actual rules. 🙂

https://www.youtube.com/watch?v=jl0hMfqNQ-g

You're encouraged to make all the changes to view.js you need. Whatever
works for you is right.

Thing with
e.preventDefault();
is smart idea.

Thanks for the feedback. I will probably release an updated version soon
which will use less memory (substitute subview arrays with linked lists). I
will take the feedback into account. And you can always make the pull
request.
Best Answer
0 Votes

> 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.

Best Answer
0 Votes