[ALOY-630] Use base xml files for views
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | Alloy, xml |
Reporter | Daniel Sefton |
Assignee | Unknown |
Created | 2013-04-19T17:27:22.000+0000 |
Updated | 2018-03-07T22:26:01.000+0000 |
Description
Views should be able to include other views as a template and override. In the example below I use the id tag to identify which section to override.
a simple example is as follows.
base.xml
<Alloy>
<Window id='win' class="container" onClose='onClose'>
<View id="menu" onClick="showhidemenu">
<Require src="menu_top" id="menucnt"/>
</View>
<View id="main">
<View id="iconBar" width="100%">
<ImageView id="menubtn" onClick="showhidemenu"></ImageView>
<Label class="title" id="title">Some title</Label>
</View>
<View id="grayLine"></View>
<View id="mainList">
some custom content
</View>
</View>
</Window>
</Alloy>
mywin.xml
<Extends src='base.xml'/>
<View id="menu" onClick="closeWindow">
<Require src="menu_new" id="menucnt"/>
</View>
<View id="mainList">
some new content
</View>
+1 for the concept. Open to the implementation.
Would the views added to the
I think a layout system would be better. Extending a view seems it can get a bit confusing. Without layouts, you could easily do something like:
John, I'm not sure I'm following. Also, we couldn't use
layout
since that is already in use by the Titanium API.No worries on 'layout'. Consider all of that pseudo. One of the best templating engines I've seen is Rails and that's what that comment was loosely based on: http://guides.rubyonrails.org/layouts_and_rendering.html. Basically a way to fill out a custom layout/template then fill it in with views that implement it. It is basically a preference from having dealt with this many days doing interactive and backend work. Extending can get hairy (hence the love of composition of inheritance now-a-days; another story though). :-D Here is another, fuller, example of implementing a template/layout. mytemplate.xml
someview.xml
Can the
Yep.