-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add better support for dynamic view groups #20
Comments
Hi and welcome! I think, because I don't think an alloc/ I haven't touched this code seriously for the last 2 years so I'd need some time to actually re-learn it, and my focus is elsewhere, so apologies if a solution will take some time. |
Awesome, let me give it a try and see if I can't come up with something generic so that it can be included in the repo for other users. I just wanted to make sure I wasn't missing anything since I am still a bit new to Rust. Let me do some experimenting and I will submit a PR once I have a solution that I am happy with. Thanks again! |
Currently works for both Named and Unamed structures. Right now all fields have to implement View + Drawable. In addition they have to implement Clone + Copy otherwise Transform impl will fail since translate will attempt to move out a value behind a shared reference. This makes it currently incompatible with LinerarLayout. Fixes bugadani#20
Hello,
I am writing a layout that will be populated with data from quering a backend service. Depending on the response we will populate the layout in different manners. However I am having a bit of trouble doing this with the current implementation of embedded-layout. Currently the ways of holding views are
Views
,Chain
and thederive
macro.Views
allows for holding of the same type whileChain
allows holding of differentDrawable
s and also takes over ownership of the Views/Drawables. However sinceChain
/Views
are using trait bounds, the type will vary depending on the current contents.Below are two examples of an upcoming arrivals view for a train, one attemping to use
Chain
and the other attempting to useViews
. Both fail since the type information will differ depending on if the list of arrivals is empty or not.Attempt using Chain
Problem is that
northbound_layouts
does not have a single type since the Chain type will differ if the list is empty or the list have items.Attempt using Views
Problem is that
layout_holder
does not have a single type since the Array type will differ if the list is empty or the list have items.Ideally there would a datastructure that would be able to hold a list of
dyn Drawable<Color = ..., Output = ()>
but since thedraw
function has a generic it violates object safety and can't be done. I was wondering if you had any ideas on how to dynamically create layouts with the givenViews
/Chain
structures or if you would be open to creating a new structure that woudl be more suited this use case. Thanks and awesome crate.The text was updated successfully, but these errors were encountered: