Class: Motion::Xray::BooleanEditor

Inherits:
PropertyEditor show all
Defined in:
lib/motion-xray/z_editors/xray_boolean_editor.rb

Instance Attribute Summary

Attributes inherited from Editor

#property, #target

Instance Method Summary collapse

Methods inherited from PropertyEditor

#get_value, #initialize, #set_value

Methods inherited from Editor

#did_change?, #get_edit_view, #initialize, with_target

Constructor Details

This class inherits a constructor from Motion::Xray::PropertyEditor

Instance Method Details

#edit_view(container_width) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/motion-xray/z_editors/xray_boolean_editor.rb', line 5

def edit_view(container_width)
  return UIView.alloc.initWithFrame([[0, 0], [container_width, 27]]).tap do |view|
    view << UILabel.alloc.initWithFrame([[0, 4.5], view.bounds.size]).tap do |lbl|
      lbl.backgroundColor = :clear.uicolor
      lbl.text = "#{@property}?"
      lbl.font = :small.uifont
    end
    view << UISwitch.alloc.init.tap do |switch|
      switch.frame = switch.frame.x(view.bounds.max_x - switch.frame.width)
      switch.on = !!get_value
      switch.on(:change) {
        set_value(switch.on?)
      }
    end
  end
end