Sha256: 9d4367b84c1c00b800555a28927b6a602dd5720885a99d7b8c46b2893c976f3e

Contents?: true

Size: 810 Bytes

Versions: 4

Compression:

Stored size: 810 Bytes

Contents

module Formotion
  module RowType
    class SwitchRow < Base
      include BW::KVO

      def build_cell(cell)
        cell.selectionStyle = UITableViewCellSelectionStyleNone
        switchView = UISwitch.alloc.initWithFrame(CGRectZero)
        switchView.accessibilityLabel = row.title + " Switch"
        cell.accessoryView = cell.editingAccessoryView = switchView
        switchView.setOn(row.value || false, animated:false)
        switchView.when(UIControlEventValueChanged) do
          break_with_semaphore do
            row.value = switchView.isOn
          end
        end
        observe(self.row, "value") do |old_value, new_value|
          break_with_semaphore do
            switchView.setOn(row.value || false, animated: false)
          end
        end
        nil
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
formotion-1.1.2 lib/formotion/row_type/switch_row.rb
formotion-1.1.1 lib/formotion/row_type/switch_row.rb
formotion-1.1 lib/formotion/row_type/switch_row.rb
formotion-1.0 lib/formotion/row_type/switch_row.rb