Page MenuHomePhabricator

[MVVM] Multistyle Factory
Open, Incoming QueuePublic

Description

multi style support factory wil be new class.
Create() can return Future not a Real Instance.
Event will give style information as a parameter.

e.g.
Efl.Ui.ListItemMultiFactory liFac = new Efl.Ui.ListItemMultiFactory(parent = lView);
Efl.Ui.ImageFactory imgFac = new Efl.Ui.ImageFactory(parent = lView);
imgFac.Connect("filepath");
liFac.ClassAdd(Efl.Ui.ListDefaultItem.GetClass(), "item_class", "default");
liFac.ClassAdd(Efl.Ui.ListTitleItem.GetClass(), "item_class", "title");

when the view call the create, it is just future and when style property is ready,
actual efl_add and createEvent is called.
liFac.CreateEvent += (object, model, parent, style) {
To be discussed more

if (style == "default") {

var item = (Efl.Ui.ListDefaultItem) object;

item.icon = imgFac.Create(model, object);
item.label. ???? // how to connect asyncronous string to label part?

}
else if (style == "title") {

var item = (Efl.Ui.ListTitleItem) object;
item.icon = imgFac.Create(model, object);
item.label. ????

}}

This may possiblely named asynchronous factory , cause the other case of factory will be synchronous by giving create() with real instance.

We could connect item.label by passing a Observable_Value like defined in https://phab.enlightenment.org/T7441

What do you think?

can you add this idea to the pseudo code or samples of T7441?

One more thing, this task also include the way to get Efl.Class by some predefined class values as like liFac.ClassAdd(Efl.Ui.ListDefaultItem.GetClass(), "item_class", "default");
To make this task possible, it should be pre-implemented.

current if "Efl.Ui.ListTitleItem" is a Efl.Ui.Layout.Object all you need to do is connect the property with the edjepart
or implement something in "Efl.Ui.ListTitleItem" to connec in this property and update the values

see more in layout_model_connect.c in /* image widget */ section

SanghyeonLee added a comment.EditedNov 4 2018, 11:56 PM

We are discussing about new item based on Efl.Ui.List_Item which will have some Efl.Part informations.
I thought we've already had some agreements of using Efl.Part instead of string and connect(),
so I wonder why this subject is repeated again.

@felipealmeida sorry for bothering you, but I think we need your explain about this. could you?

Hello, you can ignore Larry's comment. He was not aware the discussion is about modifying the current code. I think we can keep ourselves to T441.

cedric added a subscriber: cedric.Nov 16 2018, 10:52 AM

I don't understand in the example why you would have to write any code in a multi style factory at all. The idea would be to connect a property on the factory that would be used to decide which subfactory is called to instantiate that item. For example :

liFac.connect("style");

It would define the default part which is the one used by the factory to define the property to get from the model. The factory would just have to fetch that property and request from the hash table the factory that was registered for that string and call that factory create function to create the item.

Additional connect on the multi factory would be redirected to all the factory registered on it. If some connect are unecessary on some of the registered factory, you can still do the connect on each factory independently.

If you want to customize the content of an item and swallow additional object, you would just inherit from the Efl.Ui.ListTitleItem.GetClass() and implement the create function that would call efl_super there. You would then be able to implement your specific object creation there. If you do not want to create a full scale Eo class, you can still use override.

Btw in the above example, I would do a ModelConnect on the multi factory for the property "icon" to be connected with the imgFac and due a simple connect("label", "another-property-in-the-model");

SanghyeonLee added a comment.EditedDec 26 2018, 3:56 AM

this task is discussed fragmentary in other tasks,
so I write some agreement of this multiple factory.

to support mulitple factory, user may need to make custom factory,
but they could make child factory for each styles as user convenient.

efl.ui.ItemFactory itemFac1 = new efl.ui.ItemFactory();
itemFac1.SetStyle(efl.ui.ListDefaultItem.GetClass());
itemFac1.label.BindProperty("first_name");

efl.ui.ItemFactory itemFac1 = new efl.ui.ItemFactory();
itemFac2.SetStyle(efl.ui.ListTitleItem.GetClass());
itemFac2.label.BindProperty("title");

efl.ui.CustomFactory custFac = new efl.ui.CustomFactory();
cusFac.item.BindFactory(itemFac1, "style");
cusFac.title.BindFactory(itemFac2, "style");

still dynamic part is not certain as I understanding but I guess it works like this.

@cedric could you confirm this?

I might name the factory StyleFactory instead of ItemFactory, but yes, that's the concept.

zmike moved this task from Backlog to Felipe on the efl: mvvm board.Jan 9 2019, 12:26 PM
cedric moved this task from Felipe to Cedric on the efl: mvvm board.Jan 9 2019, 7:27 PM
cedric claimed this task.
cedric added a subscriber: felipealmeida.