Skip to content

Instantly share code, notes, and snippets.

@doublerebel
Created October 11, 2012 21:27
Show Gist options
  • Save doublerebel/3875586 to your computer and use it in GitHub Desktop.
Save doublerebel/3875586 to your computer and use it in GitHub Desktop.
Example of a Tiger View Widget: Checkbox with Label
dip = (val) -> "#{val} dip"
class Settings.CheckBox extends Tiger.View
defaults:
width: '92%'
height: dip 48
# style: Ti.UI.Android.SWITCH_STYLE_CHECKBOX
constructor: (props) ->
@label = new Tiger.Label
left: dip 8
top: dip 12
text: props.title
font: props.font or {fontSize: dip(16), fontFamily: 'Roboto'}
textAlign: props.textAlign or Ti.UI.TEXT_ALIGNMENT_LEFT
@checkbox = new Tiger.Switch
height: dip 32
width: dip 32
right: dip 8
top: dip 8
value: props.value or false
color: 'transparent'
super
@label.click => @checkbox.set value: not @checkbox.get 'value'
@add(@label)
.add(@checkbox)
setValue: (value) ->
@checkbox.set value: value
getValue: (value) ->
@checkbox.get value
setTitle: (title) ->
@label.set title
getTitle: (title) ->
@label.get title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment