weltan / navigation

based off re-navigator example
MIT License
2 stars 1 forks source link

Switching scenes prior to animation #1

Open coyotespike opened 7 years ago

coyotespike commented 7 years ago

Thanks for making this more substantive example of re-navigation, I'm finding it very helpful to learn and to teach.

I confirmed your result that ':nav/current' switches scenes before the animation happens.

I defined a new sub:

(register-sub
 :nav/current-key
 (fn [db _]
   (let [current (subscribe [:nav/current])]
    (reaction
     (:key @current)))))

And used it like

(defn scene [props]
  (let [
;       current-key (keyword (aget props "scene" "key"))
        current-key (subscribe [:nav/current-key])]]
        (case current-key
      :login-route [login-scene]
      :chat-table-route [chat-table-view]
      :chat-route [chat-view]
[login-scene])))

As a result, when I click on the buttons, the animation happens, but it pages to the home page, where we already were.

Like the reagent cookbook, we will probably end up collecting components for instruction, and it would be nice to update via subscriptions instead of javascripty props. How can we get the animation in sync? I don't fully understand the cause of this behavior.

If I think of something I will post here.

weltan commented 7 years ago

Hey, not sure how far you got here, or if you're even looking at this anymore, but I had some time to work on this...

I made a fork of re-navigate so I could use the updated react-native v0.31 stuff. Updated fork is here: https://github.com/weltan/re-navigate

Tried to see if that fixed the animation syncing things, but no luck.

I'm going to keep looking at this, slash may ask around on the #cljsrn Slack channel. I also don't understand why the re-navigate example doesn't show how to switch complete scenes, rather than update the component, seems like that's the more common use-case.

coyotespike commented 7 years ago

Yes, I agree about the re-navigate example! Of course it's possible to swap out components/attributes of the same scene, but completely different scenes makes more intuitive sense to me.

Hopefully this weekend I'll start a sort of cookbook, just to collect demos of as many components as possible, and I'd like to include your navigation example or an adaptation of it. Whenever we figure out the animation syncing thing, that can go in too. :-)

weltan commented 7 years ago

That'd be sweet, let me know how it goes, and you can certainly use anything I've written!