Sha256: 890dde0b3f95794e76baf5cad59fe406d0b2d2d9bc468d0d8ae56adff89428d4

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

#################
#
# Formotion::RowCellBuilder
# RowCellBuilder handles taking Formotion::Rows
# and configuring UITableViewCells based on their properties.
#
#################
module Formotion
  class RowCellBuilder
    extend BW::KVO

    # PARAMS row.is_a? Formotion::Row
    # RETURNS [cell configured to that row, a UITextField for that row if applicable or nil]
    def self.make_cell(row)
      cell, text_field = nil

      cell = UITableViewCell.alloc.initWithStyle(row.object.cell_style, reuseIdentifier:row.reuse_identifier)

      cell.accessoryType = cell.editingAccessoryType = UITableViewCellAccessoryNone

      cell.textLabel.text = row.title
      observe(row, "title") do |old_value, new_value|
        cell.textLabel.text = new_value
      end

      cell.detailTextLabel.text = row.subtitle
      observe(row, "subtitle") do |old_value, new_value|
        cell.detailTextLabel.text = new_value
      end

      edit_field = row.object.build_cell(cell)
      
      if edit_field and edit_field.respond_to?("accessibilityLabel=")
        label = row.accessibility
        label = row.title unless label
        edit_field.accessibilityLabel = label if label
      end

      [cell, edit_field]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
formotion-1.6 lib/formotion/row/row_cell_builder.rb