tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/7089-mobile-application-screen-flow-with-transitionsRobotlegs: Discussion 2013-11-15T11:44:50Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/293121732013-10-11T08:01:12Z2013-10-11T08:01:12ZMobile Application Screen Flow with Transitions<div><p>Hey tangent,</p>
<blockquote>
<p>I also read a bit on Finite State Machine by Joel Hooks, but I
lack some samples to dive deeper to understand it.</p>
</blockquote>
<p>The FSM is meant to manage application's states. Transitions
/effects are view's states and thus the logic to handle them
belongs to the views.</p>
<p>The Home view could enable or disable the transitions depending
on some conditions.</p>
<blockquote>
<p>When service has finished performing the update, the "Edit"
screen would animate back to "Home" screen, and the home screen
will show a jazzy animation on the edited item with the new
values.</p>
</blockquote>
<p>I guess that you're dispatching an event (from a model or from
view's mediator) when the update has finished.<br>
If the Home view holding the navigator would be mediated,
HomeMediator could listen for that event and pass the event payload
to view's API, which will perform the transition with or without
effects.<br>
Where you store that information (transitionsEnabled true or false)
depends on your setup. It could be a Model or it could be each
individual view (through their mediators) dispatching an event with
the flag set to true or false.</p>
<p>Does that make sense to you?</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/293121732013-10-20T18:25:56Z2013-10-20T18:25:56ZMobile Application Screen Flow with Transitions<div><p>Thanks for your advice, I am just having trouble to decide where
the "transition" logic resides, as well as animation orchestration
(let's say it is a sequence of animation that starts from
DetailView, then ViewNavigator, then HomeView).</p>
<p>On one hand that can be put in model, but the model would then
have certain logic to decide under what circumstance animation
should happen; another place to put it would be Mediator, but it is
against the simplicity nature of Mediator where "if"/"switch"
should stay away from.</p>
<p>I wonder if there would be a good practice to have this kind of
conditional view-transition workflow implemented as the moving
parts are quite loosely coupled.</p></div>tangenttag:robotlegs.tenderapp.com,2009-10-18:Comment/293121732013-10-21T15:48:18Z2013-10-21T15:48:18ZMobile Application Screen Flow with Transitions<div><p>There are 2 aspects to your problem. One is the navigation, and
the other is the animation.</p>
<p>How are you managing the navigation? Do you have some buttons in
a navigationContent?<br>
Or a list with the views' names? Or should the navigation be
triggered by some other action, like you said in your first post,
after the 'service has finished performing the update'?</p>
<p>In my previous post, I said that the Home View would contain the
navigation, but if I understand correctly, you have a view that you
call ViewNavigator that's responsible for navigating between
different Views: HomeView, DetailsView, OtherView...<br>
So, this ViewNavigator will have to decide which view to push next.
But, I don't know exactly how you want the navigation to happen,
i.e. based on user interaction or depending on the state of some
data. Would it be always the same flow, from Details to Home, from
Home to OtherView, or you could go from Details to any other view?
You mentioned the FSM. Maybe it would make sense to use it, if
navigating between different views would somehow reflect the
application's states.<br>
There is also Neil's state machine:<br>
<a href=
"https://github.com/AS3StateMachine/StateMachine">https://github.com/AS3StateMachine/StateMachine</a></p>
<p>Now, the animation/transition effects. It is not clear to me who
is performing the animation. I thought you'd let the ViewNavigator
apply some effects when pushing a new view, but it seems that each
view has its own animations?</p>
<blockquote>
<p>On one hand that can be put in model, but the model would then
have certain logic to decide under what circumstance animation
should happen;</p>
</blockquote>
<p>A NavigationModel could contain a mapping of view classes to
animations/effects - a collection of VOs or simply:<br></p>
<pre>
[{"index":0, "view":SomeView, "withEffects ":true},
{"index":1, "view":AnotherView, "withEffects ":false},
{"index":2, "view":OtherView, "withEffects ":true}]
</pre>
<p>Or a mapping of "fromView", "toView", "withEffects". As I said
in my first post, when the service is done, it could dispatch an
event with "fromView" as a payload , a command would access the
model and another event (from model or command) would let
ViewNavigatorMediator know which data to pass on to its view.<br>
I'm imagining this flow:<br>
user is editing EditView->update button clicked->event with
the view name as payload->mediator re-dispatches
event->command->service performs update, then dispatches
event->command accesses NavigationModel ->event with VO
containing "toView", "withEffects"->ViewNavigatorMediator passes
the VO on to ViewNavigator's API -> navigation w/o effects.</p>
<p>The Model doesn't have to decide anything and for sure it
shouldn't be in charge of the animation. How you use the Model
depends on your use case.</p>
<p>Maybe it would suffice to pass the array collection on to the
view in charge of the navigation, say as a data provider for a
list. The user would select an item from the list and in the
handler you'd know if there is a need for effects or not.</p>
<blockquote>
<p>another place to put it would be Mediator, but it is against the
simplicity nature of Mediator where "if"/"switch" should stay away
from.</p>
</blockquote>
<p>Exactly! A Mediator shouldn't have to do such work :)</p>
<p>There is also a utility for robotlegs 1: <a href=
"https://github.com/epologee/navigator-as3/tree/master/source/com/epologee/navigator">
https://github.com/epologee/navigator-as3/tree/master/source/com/ep...</a><br>
No idea if it's what you need, because I've never used it.</p></div>Ondina D.F.