Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

TabBar #16

Open
maticzav opened this issue Jan 12, 2017 · 0 comments
Open

TabBar #16

maticzav opened this issue Jan 12, 2017 · 0 comments

Comments

@maticzav
Copy link

maticzav commented Jan 12, 2017

Hi!
I am a bit new to this Elm reusability ideology and I found myself cracking my head over a problem I have been working on, so could you please help?

My idea is to be able to have, like iPhone apps have this tab bar line at the bottom of the screen, a simple line used for in app navigation in Elm. Now, in my opinion the ideal outcome would be to be able to have two completely separate modules and batch them together into one with this module.

All in all, I basically have no complete idea about how to implement the model and configuration, but I came to some conclusions (which might be wrong):

  1. The view functions of tabs must be in configuration (this is taken directly from Evan's code which clearly states that no functionality should be in model) , but then how am I to define which view function is for which tab? I solved this by wrapping whole view into a tuple with first value of String (as id). <- This is 100% wrong, because then if we have a state which keeps an ID of a current tab, we can theoretically come out with impossible combination (like tab for which view doesn't exist) and compiler would not notice that.

  2. Because view functions would be passed in a list inside a configuration they would all have to have the same type. I thought of a solution where you put your tabs in a record and then say like:

[ Bar.view << .bar
, Foo.view << .foo 
] 
-- They all have the same type then.
  1. Then there's this idea of different messages type which I thought I could solve by creating "general" Msg type, but then there's nesting with Html.map around every view and I believe there's an easier way of achieving it.

In conclusion, I have very little idea about how to make this right, but I believe it's possible to make it.
My repo for this project is: Elm-TabBar

Here I have implemented some of the ideas from above, but this doesn't even display current tab, because I would have to filter our from views the correct view for current tab and I believed this is completely wrong.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant