-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want return back to challenge list without app restart #2
Comments
I can try help with it but as i see it not obvious now. Choose returns play.New and i dont know how to return to the previous view |
I'll look and write you instructions later today |
I've found solution. Run play.New with function callback that returns choose.Update. |
@mortum5 best option is something like that in case key.Matches(msg, m.b.Back):
chooseModel := choose.New()
commands := tea.Sequence(chooseModel.Init(), func() tea.Msg {
return m.w // pass tea.WindowSizeMsg to sync window size
})
return chooseModel, commands Here is navigation idea sequenceDiagram
participant App as App event loop
App->>+Choose: Show Choose
Choose-->>Choose: Challenge selected
Choose-->>-App: Play model
App->>+Play: Show Play
Play-->>Play: Back pressed
Play-->>-App: Choose model
App->>+Choose: Show Choose
So, you need to define key bindings, add navigation as in code sample, and check it works (check window resize as well). Important: check if |
Your solution works as alternative. But there is no need for callbacks. You can pass Choose model instance in Play and return it in Play.Update. But you still need to sync window size. Downside is state coupling. So I think creating choose.New instance is better. |
Mmm. I forgot about import cycle. @mortum5 so, create PR, let's see your solution. |
Yes, I tried to use a new select instance first, but ran into a problem with the imports |
But you are right about window size. I will think how to sync them. P.S. Found, just override msg |
Create PR draft, I can help |
Add 'b/backspace' button handling to return to list
The text was updated successfully, but these errors were encountered: