mercredi 2 avril 2014

Device Profiles and Views

There were some discussions on this topic, but I didn't find any suggestions that made me happy:



For example, we defined two profiles 'Tablet' and 'Phone'.

Then, we want to have different views for them (not a base view, but some other view).

We want ONE controller because making two controllers should not be a solution if we could make all the code works in one controller.



So, we have a function in the controller where we want to create a view depending on device. How to do that ?



We can ask for the active profile and then creates a right view for that profile. This is bad because code would be complicated (too many if's) if we have several profiles.



What should be solution ?



I suggest to implement some kind of resolver function which will resolve which view should be created depending on profile. So, it could look like this:




Code:



Ext.create(Ext.profileResolve('myListView'));


Ext.profileResolve(xtype) could be easily implemented if suggested naming conventions for naming profile based classes was used.



What do you think about the problem and suggested solution ?




Aucun commentaire:

Enregistrer un commentaire