Skip to content

Instantly share code, notes, and snippets.

@tonylukasavage
Created July 16, 2013 14:49
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save tonylukasavage/6009423 to your computer and use it in GitHub Desktop.
Save tonylukasavage/6009423 to your computer and use it in GitHub Desktop.
TSS reset for Alloy/Titanium
'Label[platform=android]': {
color: '#000' // all platforms except Android default to black
}
'Window': {
backgroundColor: '#fff' // white background instead of default transparent
}
'Window[platform=android]': {
modal: false // make android windows all heavyweight
}
'TextField': {
borderStyle: Ti.UI.INPUT_BORDERSTYLE_ROUNDED // common default style
}
@skypanther
Copy link

I'd add:

'TextField[platform=android]': {
  height: Ti.UI.SIZE
},
'View': {
    backgroundColor: '#fff' // white background instead of default transparent
},
'TableView': {
    backgroundColor: '#fff' // white background instead of default transparent
},
'TableViewRow': {
    backgroundColor: '#fff' // white background instead of default transparent
}

@FokkeZB
Copy link

FokkeZB commented Jul 16, 2013

@skypanther, I don't think you should make all views have white backgrounds. This is going to ruin people's apps if they start using the reset TSS.

In development though, it would be a good practice to by default set them to green, so that you are forced to set appropriate backgroundColors or transparent if really needed ;)

@skypanther
Copy link

My reason is that you shouldn't use transparent backgrounds (default) unless you need to because of performance issues. UI composition takes longer if the OS needs to figure out which pixels are transparent and which values should "show through" from lower layers. This is especially a problem on Android which composites views more slowly than iOS already.

As I posted in the Google group, I think sensible defaults should be in the /styles/app.tss (including backgrounds being all white). Then, you'd override those for your particular app by setting your defaults in the /theme/styles/app.tss. If you need them to be transparent, you could set them there (or in your View's TSS files).

You could do a dev-time setting as you say to have green backgrounds with config.json settings as well.

@FokkeZB
Copy link

FokkeZB commented Jul 17, 2013

@skypanter, I created a JIRA ticket with an alternative solution for this: https://jira.appcelerator.org/browse/TC-2621. If this gets adopted, the TSS reset could set view backgroundColors to inherit by default.

I just think the reset TSS shouldn't break people's apps, but if the reset TSS would only be inserted into the app.tss of newly created Alloy projects that would be less of an issue of course.

@FokkeZB
Copy link

FokkeZB commented Jul 17, 2013

Another one I'd add:

'ImageView[platform=ios]': {
    preventDefaultImage: true // never show ugly image while loading remote
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment