joshka / tui-widgets

A collection of useful widgets for building terminal user interfaces using Ratatui
https://crates.io/crates/tui-widgets
Apache License 2.0
39 stars 5 forks source link

Possibility to render stateful widget inside popup #10

Open kxxt opened 6 months ago

kxxt commented 6 months ago

I want to render a stateful widget(The built-in widget list). But it appears that I can't pass the state through tui-popup.

Would it be possible to design an API to allow state to be passed through tui-popup to a inner stateful widget? Or should we change the API to make popup work more like a Block so that users could manually render whatever they want inside it?

joshka commented 6 months ago

I'm open to the idea. Do you any ideas about what the the API would look like if you implemented this?

kxxt commented 6 months ago

I'm open to the idea. Do you any ideas about what the the API would look like if you implemented this?

I think the most obvious way is to create another type StatefulPopup but that will introduce lots of duplicated code which is not ideal (though we could avoid probably most of the duplication by using macros).

joshka commented 6 months ago

A similar gap was mentioned in https://discord.com/channels/1070692720437383208/1072907135664529508/1237425024969871420

I think the most obvious way is to create another type StatefulPopup but that will introduce lots of duplicated code which is not ideal (though we could avoid probably most of the duplication by using macros).

I have a preference for this to be a single widget rather than two if it makes sense. The trait implementations are after all just traits Perhaps this is not possible however.

joshka commented 3 months ago

Moving this issue to tui-widgets repo