Skip to content

Instantly share code, notes, and snippets.

@lbrenman
Created August 12, 2016 01:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lbrenman/f3695c638c97804b8eff11cfb7375aee to your computer and use it in GitHub Desktop.
Titanium Master Detail Basic Example
/*
This is your global styles file. Selectors and rules you define
here will be applied throughout your app. However, these rules
have the lowest priority of any style settings.
For more information, see the "Style Priorities" section of
http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Styles_and_Themes
For example, the following would apply to all labels, windows,
and text fields (depending on platform) in your app unless you
overrode the settings with other TSS, XML, or JS settings:
'Label[platform=android,windows]': {
color: '#000' // all platforms except Android and Windows default to black
}
'Window': {
backgroundColor: '#fff' // white background instead of default transparent or black
}
'TextField[platform=android]': {
height: Ti.UI.SIZE
}
*/
'Window': {
backgroundColor: '#fff' // white background instead of default transparent or black
}
'TableViewRow': {
hasChild: true,
height: 44,
color: 'black'
}
'Label': {
color: '#000'
}
function closeWindow(){
$.detailWin.close();
}
".container" : {
}
<Alloy>
<Window id="detailWin" title="Detail">
<!-- <Button onClick="closeWindow">Close Window</Button> -->
<Label>Detail Data</Label>
</Window>
</Alloy>
function openDetail(e) {
var detailWin = Alloy.createController('detail').getView();
if(OS_IOS) {
$.navWin.openWindow(detailWin);
} else if(OS_ANDROID) {
detailWin.open();
detailWin.addEventListener('open',function(evt){
var activity=detailWin.activity;
activity.actionBar.displayHomeAsUp=true;
activity.actionBar.setHomeButtonEnabled(false);
activity.actionBar.onHomeIconItemSelected=function(){
evt.source.close();
};
});
}
}
if(OS_IOS) {
$.navWin.open();
} else if(OS_ANDROID) {
$.win1.open();
}
".container": {
backgroundColor:"white"
}
"Label": {
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
color: "#000"
}
"#label": {
font: {
fontSize: 12
}
}
<Alloy>
<NavigationWindow id="navWin" platform="ios">
<Window id="win1" title="Master">
<!-- <Button id="button" onClick="openDetail">Open Detail</Button> -->
<TableView>
<TableViewRow title='Row 1' onClick="openDetail" />
<TableViewRow title='Row 2' onClick="openDetail" />
<TableViewRow title='Row 3' onClick="openDetail" />
<TableViewRow title='Row 4' onClick="openDetail" />
<TableViewRow title='Row 5' onClick="openDetail" />
</TableView>
</Window>
</NavigationWindow>
<Window id="win1" title="Master" platform="android">
<!-- <Button id="button" onClick="openDetail">Open Detail</Button> -->
<TableView>
<TableViewRow title='Row 1' onClick="openDetail" />
<TableViewRow title='Row 2' onClick="openDetail" />
<TableViewRow title='Row 3' onClick="openDetail" />
<TableViewRow title='Row 4' onClick="openDetail" />
<TableViewRow title='Row 5' onClick="openDetail" />
</TableView>
</Window>
</Alloy>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment