Giter VIP home page Giter VIP logo

promotion-xlform's Introduction

ProMotion-XLForm

ProMotion-XLForm provides a PM::XLFormScreen for ProMotion powered by the CocoaPod XLForm.

Build Status Gem Version

Installation

gem 'ProMotion-XLForm'

Then:

$ bundle
$ rake pod:install

Usage

PM::XLFormScreen includes PM::ScreenModule so you'll have all the same ProMotion screen methods available.

To create a form screen, subclass PM::XLFormScreen and define a form_data method.

class TestFormScreen < PM::XLFormScreen
  def form_data
    genders = [
      { id: :male, name: 'Male' },
      { id: :female, name: 'Female' },
      { id: :other,  name: 'Other' },
    ]

    [
      {
        title:  'Account information',
        cells: [
          {
            title:       'Email',
            name:        :email,
            type:        :email,
            placeholder: 'Enter your email',
            required:    true
          },
          {
            title: 'Name',
            name:  :name,
            type:  :text,
            value: 'Default value'
          },
          {
            title: 'Gender',
            name: :gender,
            type: :selector_push,
            options: Hash[genders.map do |gender|
              [gender[:id], gender[:name]]
            end]
          }
        ]
      }
    ]
  end
end

Available types

  • :text
  • :name
  • :url
  • :email
  • :password
  • :number
  • :phone
  • :twitter
  • :account
  • :integer
  • :decimal
  • :textview
  • :zip_code
  • :selector_push
  • :selector_popover
  • :selector_action_sheet
  • :selector_alert_view
  • :selector_picker_view
  • :selector_picker_view_inline
  • :multiple_selector
  • :multiple_selector_popover
  • :selector_left_right
  • :selector_segmented_control
  • :date_inline
  • :datetime_inline
  • :time_inline
  • :countdown_timer_inline
  • :date
  • :datetime
  • :time
  • :countdown_timer
  • :datepicker
  • :picker
  • :slider
  • :check
  • :switch
  • :button
  • :info
  • :step_counter
  • :image (ProMotion-XLForm specific)
  • :color (ProMotion-XLForm specific using RSColorPicker)

Form Options

The form_options class method allows you to customize the default behavior of the form.

class TestFormScreen < PM::XLFormScreen

  form_options on_save:   :save_form,   # adds a "Save" button in the nav bar and calls this method
               on_cancel: :cancel_form, # adds a "Cancel" button in the nav bar and calls this method
               required:  :asterisks,   # display an asterisk next to required fields
               auto_focus: true         # the form will focus on the first focusable field

  def save_form(values)
    dismiss_keyboard
    mp values
  end

  def cancel_form
  end
end

Save & Cancel Buttons

By default, no buttons are displayed in the nav bar unless you configure the on_save or on_cancel options.

You can either pass the name of the method that you want to call when that button is tapped, or you can pass a hash of options, allowing you to configure the title of the button.

Hash Options:

  • title or system_item - The button text or system item that will be displayed.
  • action - The method that will be called when the button is tapped.
form_options on_cancel: { system_item: :trash, action: :cancel_form },
             on_save: { title: 'Continue', action: :continue }

system_item can be any UIBarButtonSystemItem constant or one of the following symbols:

:done, :cancel, :edit, :save, :add, :flexible_space, :fixed_space, :compose,
:reply, :action, :organize, :bookmarks, :search, :refresh, :stop, :camera,
:trash, :play, :pause, :rewind, :fast_forward, :undo, :redo

If you would like to display a button as part of your form, you could do something like this:

form_options on_save: :my_save_method

def form_data
  [
    {
      title: 'Save',
      name: :save,
      type: :button,
      on_click: -> (cell) {
        on_save(nil)
      }
    }
  ]
end

def my_save_method(values)
  mp values
end

Getting values

You can get the values of your form with values. You can call dismiss_keyboard before before calling values to ensure you capture the input from the currently focused form element. You can also get validation errors with validation_errors and check if the form is valid with valid?. You can also get a specific value with value_for_cell(:my_cell).

Events

on_change, on_add and on_remove are available for cells, on_add and on_remove are available for sections.

{
  title: 'Sex',
  name: :sex,
  type: :selector_push,
  options: {
    male: 'Male',
    female: 'Female',
    other: 'Other'
  },
  # An optional row paramater may be passed |old_value, new_value|
  on_change: lambda do |old_value, new_value|
    puts "Changed from #{old_value} to #{new_value}"
  end
}
# An optional row paramater may be passed to on_change:
#  on_change: lambda do |old_value, new_value, row|
#    puts "Changed from #{old_value} to #{new_value}"
#    row.setTitle(new_value)
#    self.reloadFormRow(row) if old_value != new_value
#  end

Multivalued Sections (Insert, Delete, Reorder rows)

{
  title:  'Multiple value',
  name:   :multi_values,
  options: [:insert, :delete, :reorder],
  cells: [
    {
      title: 'Add a new tag',
      name:  :tag,
      type:  :text
    }
  ]
}

Custom Selectors

You can create a custom subform with a few options

{
  title:  'Custom section',
  cells: [
    {
      title: 'Custom',
      name:  :custom,
      cells: [
        {
            title: 'Some text',
            name:  :some_text,
            type:  :text
        },
        {
            title: 'Other text',
            name:  :some_other_text,
            type:  :text
        }
      ]
    }
  ]
}

By default, the cell will print a Hash.inspect of your subcells. You can change this by creating a valueTransformer and set value_transformer:.

{
  title: 'Custom',
  name:  :custom,
  value_transformer: MyValueTransformer
  cells: []
}

class MyValueTransformer < PM::ValueTransformer
  def transformedValue(value)
    return nil if value.nil?

    str = []
    str << value['some_text'] if value['some_text']
    str << value['some_other_text'] if value['some_other_text']

    str.join(',')
  end
end

Custom Selector View Controller

For a more advanced custom selector, you can set view_controller_class:.

{
  title: 'Person',
  name: 'person',
  type: :selector_push,
  view_controller_class: PeopleListScreen
}

Here is an example of a table screen. Note that the rowDescriptor setter must be implemented. In order to pass the value back to the previous form screen, update the value of the rowDescriptor. Note that XLForm will set the rowDescriptor later in your view controller's initialization process than you might expect.

class PeopleListScreen < PM::TableScreen
  attr_accessor :rowDescriptor

  def table_data
    [{
      title: @rowDescriptor.title,
      cells: People.all.map do |person|
        {
          title: person.name,
          action: -> {
            rowDescriptor.value = person.id
            close # go back to the previous screen
          }
        }
      end
    }]
  end
end

Screenshot of Map Custom Selector

Screenshot of Dynamic Custom Selector

See XLForm documentation for more information.

Cell

You can use your own cell by providing cell_class

{
  title: 'MyCustomCell',
  name: :custom_cell,
  cell_class: MyCustomCell
}

class MyCustomCell < PM::XLFormCell
  def initWithStyle(style, reuseIdentifier: reuse_identifier)
    super.tap do
      @label = UILabel.new
      self.contentView.addSubview(@label)
    end
  end

  def update
    super

    @label.text = value
    @label.sizeToFit
  end
end

In your cell, you can set the value with self.value= and get the value with self.value

Validators

You can add validators to cells.

{
  title:       'Email',
  name:        :email,
  type:        :email,
  required:    true,
  validators: {
    email: true
  }
}

:email and :url are available out of the box, as well as :regex. You will have to provide a valid regex and a message.

{
  title:       'Only letters',
  name:        :letters,
  type:        :text,
  required:    true,
  validators: {
    regex: { regex: /^[a-zA-Z]+$/, message: "Only letters please !" }
  }
}

Finally, you can provide a PM::Validator with a valid?(cell) method.

Make a row or section invisible depending on other rows values

You can show/hide cells depending on a cell value with a predicate

{
  title: 'Hide and seek',
  cells: [
    {
      title: 'Switch me',
      type: :switch,
      name: :hide_and_seek,
      value: true
    },
    {
      title: 'Appear when switch is on',
      name: :show_me,
      type: :info,
      hidden: {
        # the cell name wich will "trigger" the visibility
        name: :hide_and_seek,

        # the operand. Valid operands are :equal, :not_equal, :contains, :not_contains
        is: :equal,

        # the value which trigger the visibility
        value: true }
    },
    {
      title: 'Appear when switch is off',
      name: :hide_me,
      type: :info,

      # you can also write it this way
      hidden: ':hide_and_seek == false'
      # also valid ':some_text contains "a text"'
      #            ':some_text not contains "a text"'
    }
  ]
}

Buttons and click

You can add :on_click on :button which accepts 0 or 1 argument (the cell).

{
  title: 'Click me',
  name: :click_me,
  type: :button,
  on_click: -> (cell) {
    mp "You clicked me"
  }
}

Appearance

You can change the appearance of the cell using the appearance hash

{
  title:   'Options',
  name:    'options',
  type:    :selector_push,
  appearance: {
    font: UIFont.fontWithName('Helvetica Neue', size: 15.0),
    detail_font: UIFont.fontWithName('Helvetica Neue', size: 12.0),
    color: UIColor.greenColor,
    detail_color: UIColor.blueColor,
    background_color: UIColor.grayColor
  },
  options: {
    "value_1" => "Value 1",
    "value_2" => "Value 2",
    "value_3" => "Value 3",
    "value_4" => "Value 4",
  }
},
{
  title: 'Alignment',
  name: :align,
  type: :text,
  appearance: {
    alignment: :right # or NSTextAlignmentRight
  }
}

You can also pass any key-value to configure your cell. Take a look at this for more information

{
  appearance: {
    "slider.tintColor" => UIColor.grayColor
  }
}

Keyboard

For the text based cells (like :text, :password, :number, :integer, :decimal), you can specify a keyboard_type. The following keyboard types are available :

  • :default
  • :ascii
  • :numbers_punctuation
  • :url
  • :number_pad
  • :phone_pad
  • :name_phone_pad
  • :email
  • :decimal_pad
  • :twitter
  • :web_search
  • :alphabet

RMQ / RedPotion

If you use RMQ or RedPotion, you can style the screen with

def form_view(st)

end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Make some specs pass
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

License

Released under the MIT license.

promotion-xlform's People

Contributors

andrewhavens avatar bmichotte avatar dam13n avatar jbender avatar jeffcarbs avatar markrickert avatar michaeljkchoi avatar mileszim avatar nathanbrakken avatar serialbandicoot avatar spencerfdavis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

promotion-xlform's Issues

Submitting a form the old fashion way...

I am currently upgrading from Promotion-Form to XLForm and it's taking me a minute to wrap my brain around all the amazing, new, powerful options involved. Very excited about what is to come, but I can't seem to figure out how to simply just submit a form. It seems way more complicated than it needs to be.

It used to be that the submit button on the form would call the necessary action. Done and done. But now I have to have an on_click attribute in the cell that references a form_options :on_save callback thing that then calls the action that I want. I can certainly accept a bit of verbosity for better functionality, but now that adds a "Save" button in the nav_bar that I don't want.

Maybe this is all possible and I'm just not reading the docs right, but why can't I just do something like this...

def form_data
  [{
    title: "Support Request",
    cells: [{
      name: :body,
      title: nil,
      placeholder: "What can we help you with?",
      type: :textview,
    },{
      name: :send,
      title: "Send",
      type: :button,
      on_click: :send_message
    }]
  }]
end

def send_message(values)
  { do fancy api stuff with values }
end

Undefined symbols for architecture i386

The gem compiles fine on my machine running xcode 7.1.1 but when attempting to use travis CI I get Undefined symbols for architecture i386 errors. In my .travis.yml I specify osx_image: xcode7.1. Anyone having a similar issue and find a solution?

xcode build info from travis :

MacOSX10.11.sdk - OS X 10.11 (macosx10.11)
SDKVersion: 10.11
Path: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
PlatformVersion: 1.1
PlatformPath: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform
ProductBuildVersion: 15A278
ProductCopyright: 1983-2015 Apple Inc.
ProductName: Mac OS X
ProductUserVisibleVersion: 10.11
ProductVersion: 10.11

Dynamic options for :selector_push type

Sorry if this is a noob question but I'm trying to load async some categories into the options key of a :selector_push type... ex:

{ name: "category", title: "Category", type: :selector_push, options: @categories }

Where @categories is initially an empty hash but fetches and populates the @categories on success and then re-renders the options. I can't seem to get it to re-render on success. It always shows the initial state. Thanks in advance.

Custom cell

What's the correct way of creating a custom cell? I've made one that lays out and styles properly in red potion but when it scrolls out of and returns into view the layout is all messed up.

`set_remote_image': undefined method `to_url' for nil:NilClass (NoMethodError)

I started getting this error when I upgraded to iOS 9. It might not be related, but I will continue to look into it.

2015-09-23 08:16:59.790 MyApp[71158:3888111] xl_sub_form_screen.rb:40:in `set_remote_image': undefined method `to_url' for nil:NilClass (NoMethodError)
    from xl_sub_form_screen.rb:40:in `setup:'
    from xl_sub_form_screen.rb:40:in `create_table_cell:'
    from xl_sub_form_screen.rb:40:in `tableView:cellForRowAtIndexPath:'

Add ability to add multiple images

This one could be hard but I'm going to need it for an upcoming project :)

Perhaps something like this:

# Requires a minimum of 2 images, up to 12 total.
{
  title: 'Images',
  name:  :picture,
  type:  :image,
  max: 12,
  required: 2
}

PM::XLFormCell

Create a PM::XLFormCell which extends XLFormBaseCell for an easier use

problem installig gem

Hi,
maybe this is a newbie question, but everytime i try to run the app, i'm getting this error:

Undefined symbols for architecture i386:
  "_XLFormRowDescriptorTypeAccount", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeBooleanCheck", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeBooleanSwitch", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeButton", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeCountDownTimer", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeCountDownTimerInline", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeDate", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeDateInline", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeDatePicker", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeDateTime", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeDateTimeInline", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeDecimal", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeEmail", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeInfo", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeInteger", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeMultipleSelector", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeMultipleSelectorPopover", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeName", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeNumber", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypePassword", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypePhone", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypePicker", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorActionSheet", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorAlertView", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorLeftRight", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorPickerView", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorPickerViewInline", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorPopover", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorPush", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorSegmentedControl", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeSlider", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeStepCounter", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeText", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeTextView", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeTime", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeTimeInline", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeTwitter", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
  "_XLFormRowDescriptorTypeURL", referenced from:
      _MREP_67EC5726164D427F9471BF577747AFFC in xl_form.rb.o
ld: symbol(s) not found for architecture i386

I can use other gems without problem, even "ProMotion-Form"is working correctly

any idea how can i solve it?
Thank you!

Hide fields based on option doesnt work

Hi,
I was testing the "hide" functionality and it doesn't work for options. but it works when is a switch.

i tried the code from the test file:

{
  title: 'Options',
  name: 'options',
  type: :selector_push,
  appearance: {
    font: UIFont.fontWithName('Helvetica Neue', size: 15.0),
    detail_font: UIFont.fontWithName('Helvetica Neue', size: 12.0),
    color: UIColor.greenColor,
    detail_color: UIColor.blueColor,
    background_color: UIColor.grayColor
  },
  options: {
    "value_1" => "Value 1",
    "value_2" => "Value 2",
    "value_3" => "Value 3",
    "value_4" => "Value 4",
  },
  value: "value_1",
  on_change: -> (old_value, new_value) {
    mp old_value: old_value,
       new_value: new_value
  }
},
{
  title: 'Value 1 ?',
  name: :show_me_selector,
  type: :text,
  hidden: { name: :options, is: :equal, value: 'value_1', options: true },
  value: 'is selected !'
},

from https://github.com/bmichotte/ProMotion-XLForm/blob/master/app/screens/test_form_screen.rb#L71 and https://github.com/bmichotte/ProMotion-XLForm/blob/master/app/screens/test_form_screen.rb#L242

it should only display the "Value 1? is selected!" when is that one selected, instead is not changing anything.

is this a known issue or i'm doing something wrong??
thank you!!!

Undefined symbols for architecture i386:

I'm running into this error when trying to rake my project in RM 4.4 and sdk 9.1

I've done rake clean:all followed by rake pod:install and then rake

Here's the full error:

   Compile ./app/stylesheets/settings_screen_stylesheet.rb
    Create ./build/iPhoneSimulator-8.0-Development/Nurses.app
      Link ./build/iPhoneSimulator-8.0-Development/Nurses.app/Nurses
Undefined symbols for architecture i386:
  "_XLFormRowDescriptorTypeAccount", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeBooleanCheck", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeBooleanSwitch", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeButton", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeCountDownTimer", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeCountDownTimerInline", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeDate", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeDateInline", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeDatePicker", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeDateTime", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeDateTimeInline", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeDecimal", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeEmail", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeInfo", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeInteger", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeMultipleSelector", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeMultipleSelectorPopover", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeName", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeNumber", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypePassword", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypePhone", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypePicker", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorActionSheet", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorAlertView", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorLeftRight", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorPickerView", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorPickerViewInline", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorPopover", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorPush", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeSelectorSegmentedControl", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeSlider", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeStepCounter", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeText", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeTextView", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeTime", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeTimeInline", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeTwitter", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
  "_XLFormRowDescriptorTypeURL", referenced from:
      _MREP_DF6E0BB38F5A418C9583EAA08972F8C1 in xl_form.rb.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
rake aborted!

localizing buttons actions

Hi,
I'm translating my app into several languages, but i noticed that some "system" buttons generated by XLForm are not translated, is there a way to do this? (sorry if this is a silly question...)

i'd like to translate "done", "save", "choose from library" etc.. that seems to stay the same no matter which language the devices is.

Thank you!

XLFormScreen background_color

I can't seem to change the background color of a form screen with RMQ. I have tried setting this in the form screen stylesheet and in the application stylesheet. Nothing seems to work.

def root_view(st)
  st.background_color = color.white
end

It just does the sorta standard light gray background color instead. Is there some sort of hard-coded background color being set for a form screen?

Support regular old custom cells

I tried adding this to my cell array with no luck:

{
  name: :text_cell,
  height: 86, 
  cell_class: TextCell,
  title: I18n.t(:warmth_gague),
  selection_style: :none
}

TextCell is a PM::TableViewCell.

I get this error:

2015-08-03 19:02:50.998 App Dev[70514:5832043] -[TextCell setRowDescriptor:]: unrecognized selector sent to instance 0x113796e60
2015-08-03 19:02:51.024 App Dev[70514:5832043] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TextCell setRowDescriptor:]: unrecognized selector sent to instance 0x113796e60'

insert_mode :last_row or :button no longer works?

I may be misunderstanding this behavior in the first place, apologies if so, but I can't seem to get the example given for multivalued sections to work. I thought this produced something like this XLForm example?

The resulting field acts like a :selector_push with a single textfield. There's no errors or anything, am I just using the API wrong here? If so, is there a better way to achieve that ⬆️ XLForm example?

Thanks!

My Setup:

def form_data
  [
    {
    title: 'Custom Fields',
    cells: [
      {
        title: 'Multi-value with XLFormSectionInsertModeButton',
        name: 'multi',
        options: [:insert, :delete, :reorder],
        insert_mode: :last_row,
        cells: [
          {
            title: 'Some text',
            name: :some_text,
            type: :text
          }
        ]
      }
    ]
  ]
end

Env Details:

  • Ruby 2.3.0
  • Rubymotion 4.11
  • ProMotion-XLForm 0.0.15
  • XLForm 3.2.0

appearance is not working when adding on type text field

Hi,
Below is my code. It's not setting the detail_font to bold. i have tried in 3 different ways but not setting textfield detail_font to bold.

def form_data
  [{
      cells: [{
                title: '',
                name: :title,
                type: :text,
                value: task['title'],
                appearance: {
                    font: UIFont.fontWithName('HelveticaNeue-Bold', size: 16.0),
                    detail_font: UIFont.fontWithName('HelveticaNeue-Bold', size: 16.0),
                    #font: UIFont.fontWithName('Arial-BoldMT', size: 16.0),
                    #detail_font: UIFont.fontWithName('Arial-BoldMT', size: 16.0),
                   # font: UIFont.boldSystemFontOfSize(18),
                   # detail_font: UIFont.boldSystemFontOfSize(18)
              }
       }]
  }]
end

How can i do that?
Thanks

Question: Is it possible to set a default value for :multiple_selector row types?

I have a :multiple_selector up and running on a form but I would like to pre select a few values from the list. Is that possible?

I've tried adding a value: option but it doesn't seem to like any of the formats I've tried to pass to it. For instance, I've tried this:

value: Hash[ModelName.map do |ptag|
  [ptag.api_id, ptag.name]
end],

I would think this would've selected all the available options (since that's the same exact thing I pass into the options: line in the row.

Any assistance here is great appreciated!

Error when using use_frameworks!

 Terminating app due to uncaught exception 'NameError', reason: '/usr/local/lib/ruby/gems/2.5.0/gems/ProMotion-XLForm-0.0.18/lib/ProMotion/XLForm/cells/xl_form_cell.rb:2:in `<main>': uninitialized constant ProMotion::XLFormBaseCell (NameError)
        from /usr/local/lib/ruby/gems/2.5.0/gems/ProMotion-XLForm-0.0.18/lib/ProMotion/XLForm/cells/xl_form_cell.rb:164:in `<main>'

Ill look into more and see if i can make a PR. Just putting it here in case someone has already solved.

Setting 'value' for ':date' cell causes errors

When you set a default value of a date field, you get an
Error:

xl_sub_form_screen.rb:40:in `==:': undefined method `year' for true:TrueClass (NoMethodError)

My code:

def form_data
  ...
  {
    name: :the_future,
    title: "The Future",
    type: :date,
    value: NSDate.new.delta(days: 1),
    properties: {
      min: NSDate.new.delta(days: 1),
      max: NSDate.new.delta(days: 31)
    }
  }
  ...
end

Crash when setting :insert_mode to :button

I'm trying to set the insert mode to button instead of last_row via https://github.com/bmichotte/ProMotion-XLForm/blob/master/lib/ProMotion/XLForm/xl_form_patch.rb#L117

However, when I set insert_mode to :button I get the following crash:

ProMotion-XLForm[2468:8710476] *** Terminating app due to uncaught exception 'TypeError', reason: 'xl_form_patch.rb:82:in `section:': can't convert nil into Integer (TypeError)
    from xl_form_section_builder.rb:5:in `create_section:'
    from xl_form.rb:21:in `block in build'
    from xl_form.rb:20:in `build'
    from xl_form_screen.rb:64:in `update_form_data'
    from xl_form_screen.rb:10:in `viewDidLoad'
'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000102f7ef45 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010050adeb objc_exception_throw + 48
    2   ProMotion-XLForm                    0x000000010025e320 _ZL10__vm_raisev + 400
    3   ProMotion-XLForm                    0x000000010025e450 rb_vm_raise + 208
    4   ProMotion-XLForm                    0x0000000100159f89 rb_exc_raise + 9
    5   ProMotion-XLForm                    0x0000000100153e15 rb_raise + 245
    6   ProMotion-XLForm                    0x000000010018ef47 rb_convert_to_integer + 775
    7   ProMotion-XLForm                    0x000000010003cb0b vm_rval_to_ulong_long + 475
    8   ProMotion-XLForm                    0x00000001000be3e9 __unnamed_100 + 25
    9   ProMotion-XLForm                    0x000000010001f6e6 -[XLFormSectionDescriptor canInsertUsingButton] + 44
    10  ProMotion-XLForm                    0x000000010001de53 -[XLFormSectionDescriptor initWithTitle:sectionOptions:sectionInsertMode:] + 131
    11  ProMotion-XLForm                    0x000000010001e166 +[XLFormSectionDescriptor formSectionWithTitle:sectionOptions:sectionInsertMode:] + 90
    12  ProMotion-XLForm                    0x00000001000bff92 __unnamed_253 + 162
    13  ProMotion-XLForm                    0x000000010022f424 rb_vm_dispatch + 6196
    14  ProMotion-XLForm                    0x000000010003326c vm_dispatch + 1436
    15  ProMotion-XLForm                    0x00000001000be037 rb_scope__section:__ + 647
    16  ProMotion-XLForm                    0x000000010022f8bc rb_vm_dispatch + 7372
    17  ProMotion-XLForm                    0x000000010003326c vm_dispatch + 1436
    18  ProMotion-XLForm                    0x00000001000c8c6a rb_scope__create_section:__ + 202
    19  ProMotion-XLForm                    0x000000010022f8bc rb_vm_dispatch + 7372
    20  ProMotion-XLForm                    0x000000010003326c vm_dispatch + 1436
    21  ProMotion-XLForm                    0x00000001000cb039 rb_scope__build__block__ + 121
    22  ProMotion-XLForm                    0x0000000100230c8f _ZL13vm_block_evalP7RoxorVMP11rb_vm_blockP13objc_selectormiPKm + 1439
    23  ProMotion-XLForm                    0x0000000100230e90 rb_vm_yield_args + 64
    24  ProMotion-XLForm                    0x00000001002248cb rb_yield + 59
    25  ProMotion-XLForm                    0x000000010011c73d rary_each + 77
    26  ProMotion-XLForm                    0x000000010022f8bc rb_vm_dispatch + 7372
    27  ProMotion-XLForm                    0x000000010003326c vm_dispatch + 1436
    28  ProMotion-XLForm                    0x00000001000caf7d rb_scope__build__ + 637
    29  ProMotion-XLForm                    0x000000010022f8bc rb_vm_dispatch + 7372
    30  ProMotion-XLForm                    0x000000010003326c vm_dispatch + 1436
    31  ProMotion-XLForm                    0x00000001000d3afc rb_scope__update_form_data__ + 812
    32  ProMotion-XLForm                    0x000000010022f8bc rb_vm_dispatch + 7372
    33  ProMotion-XLForm                    0x000000010003326c vm_dispatch + 1436
    34  ProMotion-XLForm                    0x00000001000d2d4e rb_scope__viewDidLoad__ + 238
    35  ProMotion-XLForm                    0x00000001000d35ad __unnamed_18 + 13
    36  UIKit                               0x0000000100dc4cc4 -[UIViewController loadViewIfRequired] + 1198
    37  UIKit                               0x0000000100e090ee -[UINavigationController _layoutViewController:] + 54
    38  UIKit                               0x0000000100e099c2 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 462
    39  UIKit                               0x0000000100e09b34 -[UINavigationController _startTransition:fromViewController:toViewController:] + 126
    40  UIKit                               0x0000000100e0ad8d -[UINavigationController _startDeferredTransitionIfNeeded:] + 890
    41  UIKit                               0x0000000100e0bcea -[UINavigationController __viewWillLayoutSubviews] + 57
    42  UIKit                               0x0000000100fb1c85 -[UILayoutContainerView layoutSubviews] + 248
    43  UIKit                               0x00000001139c9c30 -[UILayoutContainerViewAccessibility layoutSubviews] + 43
    44  UIKit                               0x0000000100ce6e40 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 710
    45  QuartzCore                          0x00000001028e859a -[CALayer layoutSublayers] + 146
    46  QuartzCore                          0x00000001028dce70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
    47  QuartzCore                          0x00000001028dccee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    48  QuartzCore                          0x00000001028d1475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
    49  QuartzCore                          0x00000001028fec0a _ZN2CA11Transaction6commitEv + 486
    50  QuartzCore                          0x00000001028ff37c _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    51  CoreFoundation                      0x0000000102eaa947 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    52  CoreFoundation                      0x0000000102eaa8b7 __CFRunLoopDoObservers + 391
    53  CoreFoundation                      0x0000000102e9fe2c CFRunLoopRunSpecific + 524
    54  UIKit                               0x0000000100c2d4f5 -[UIApplication _run] + 402
    55  UIKit                               0x0000000100c3230d UIApplicationMain + 171
    56  ProMotion-XLForm                    0x000000010003de5f main + 111
    57  libdyld.dylib                       0x000000010427192d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type TypeError

jeffcarbs@5de974b (just adding the :insert_mode option) causes a crash.

Some other notes:

  • Setting insert_mode to :last_row works as expected.
  • Setting insert_mode to XLFormSectionInsertModeButton causes the same crash.

is possible to style table section?

Hi, I want to give style to the sections on the table, is that possible??
i've tried applying "appearance" just to the section doest work, or using the method

def will_display_header

that works on ProMotion, but here is just ignored, I want to do it because the text is displaying really big on my tables, not like on the demos :/

thank you!

form_options question

How does one set different titles utilzing your form_options? In your code you have this:

   if form_options[:on_cancel]
        on_cancel = form_options[:on_cancel]
        title = NSLocalizedString('Cancel', nil)
        item = :cancel
        if on_cancel.is_a? Hash
          title = on_cancel[:title] if on_cancel[:title]
          item = on_cancel[:item] if on_cancel[:item]
        end

        set_nav_bar_button :left, {
          system_item: item,
          title: title,
          action: 'on_cancel:'
        }
      end

But even trying such things as

form_options   on_cancel: {on_cancel: :cancel_form, title: "Test"}

And even though I was printing out from your gem:


      if form_options[:on_cancel]
        on_cancel = form_options[:on_cancel]
        title = NSLocalizedString('Cancel', nil)
        item = :cancel
        puts on_cancel
        if on_cancel.is_a? Hash
          puts "is a hash #{on_cancel[:title]}"
          title = on_cancel[:title] if on_cancel[:title]
          item = on_cancel[:item] if on_cancel[:item]
        end
puts "title is: #{title}"
        set_nav_bar_button :left, {
          system_item: item,
          title: title,
          action: 'on_cancel:'
        }
      end

And though I was seeing the printout - nothing ever changed in the screen. I even tried rake newclear but nothing.

However I'm also confused as it's checking if it's a hash but then the ACTION is still on_cancel: -- which would fail as it would be hash at that point and not a pointer to a method, correct?

How to create a multi-check list?

I want to create a section of options that allow multiple rows to be checked. For the resulting value, I would like an array of values:

{
  "people" => [
    "john",
    "sue"
  ]
}

However, the only way I can figure out how to get this to work looks like this:

{
  title: "Select some people",
  cells: [
    { type: :check, name: "people_john", title: 'John', },
    { type: :check, name: "people_sue", title: 'Sue', },
  ]
}

...and returns the following hash:

{
  "people_john" => true,
  "people_sue" => true
}

Is there a way that I can display this list so that the selected values are returned as an array?

Backtrace always shows xl_sub_form_screen.rb:40

Just upgraded to 0.0.10 and I am still having this issue. Not sure how this is happening, but every time I have an error in my app, and I expect to see the backtrace be related to the code that was executed, instead it shows xl_sub_form_screen.rb:40 on every line:

2015-09-25 08:02:10.993 MyApp[41828:7545129] xl_sub_form_screen.rb:40:in `block in parse_relationships_for_instance:': can't convert String into Integer (TypeError)
    from xl_sub_form_screen.rb:40:in `parse_relationships_for_instance:'
    from xl_sub_form_screen.rb:40:in `parse_included:'
    from xl_sub_form_screen.rb:40:in `parse_collection:'
    from xl_sub_form_screen.rb:40:in `block in all'
    from xl_sub_form_screen.rb:40:in `block in request:'

None of this code has anything to do with PM-XLForm except that it is showing up in the backtrace.

Button Doesn't Appear

Hoping this is something silly on my part.

I'm setting up a login form with a button at the bottom of the form. The button does not appear.

 class LoginScreen < PM::XLFormScreen
   title "Login Screen"

   form_options required:  :asterisks, # add an asterisk to required fields
                # on_save:   :save_the_form, # will be called when you touch save
                on_cancel: :cancel_form, # will be called when you touch cancel
                auto_focus: true # the form will focus on the first focusable field

   def form_data
     [
       {title: 'Login',
        cells: [
          { title: "Username",
            name: :username,
            type: :text,
            placeholder: "Username",
            required: true },
         { title: "Password",
           name: :password,
           type: :password,
           placeholder: "Password",
           required: true },
         { title: "Login Here",
           name: :login,
           type: :button,
           on_click: -> (cell){ save_the_form(values) } 
         }
        ]
      }
     ]
   end

   def save_the_form(values)
     mp values
   end
 end

Any help is appreciated. Thanks!

Table cell constraints working at first then failing.

I'm using MotionKit to style some of my form cells for constraints, it appears to work on load, the cell grows and shrinks with the text.

Once I scroll, however, I get a warning:

 Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.

I know that PM::TableScreen has the ability to set the estimated row height with:

  row_height :auto, estimated: 100

but I get this error when I add the code:

 undefined method `row_height:estimated:' for FormScreen::Class (NoMethodError)

Any ideas on how to get this to work with my form?

can't convert Class into String after newclear

After rake newclear, I get this error

Terminating app due to uncaught exception 'TypeError', reason: 'xl_form_screen.rb:97:in `valid?': can't convert Class into String

It appears that the pod is updated and no longer returns an array?

Question: How to display data from CDQ model in selector

I'm sure there's a way to do this but I can't seem to figure it out...

I have a model with certain city/state names like this: "Dallas, TX", "San Diego, CA", etc

And in a form selector (any type of selector will do) I'm trying something like this:

{
name: "region",
title: "Location",
type: :selector_push,
options: {
          AreaPlace.map do |place|
            "#{place.id}" => "#{place.name}"
          end
  }
}

But I get this syntax error:

syntax error, unexpected tASSOC, expecting keyword_end
            "#{place.id}" => "#{place.name}"
                           ^
/Users/sethsiegler/Dropbox/motion_stuff/fuse-ios/app/screens/registration_screen.rb:54: syntax error, unexpected '\n', expecting tASSOC
/Users/sethsiegler/Dropbox/motion_stuff/fuse-ios/app/screens/registration_screen.rb:73: syntax error, unexpected ']', expecting keyword_end
/Users/sethsiegler/Dropbox/motion_stuff/fuse-ios/app/screens/registration_screen.rb:142: syntax error, unexpected $end, expecting keyword_end

Create custom cell

Hi!
i'm trying to create a custom cell, where i want to display a image previously selected from the "image" cell provided by this gem.
the trick is that the image is remote, so i just want to put a cell before the image selector to display it.

i'm following the instructions from the readme, but i'm facing a problem:

xl_form_patch.rb:59:in `cellForFormController:': allocator undefined for :CurrentBannerFormCell (TypeError)

I just did a copy&paste form the code and change the name of the new cell, but this is failing, can anyone help me here?

thank you!

Textarea vs textview - no error messaging.

I recently spent a chunk of time troubleshooting a crash with no error messaging. I was attempting to use textarea instead of textview when defining a form_data's cell type. Upon trying to render the screen, the whole app would crash with no error message. Some kind of messaging might be helpful here. Maybe I'll submit a PR.

Add support for selecting a keyboard type

Perhaps I'm going about my particular problem the wrong way, but it seems to me that one should be able to, for example, specify a field be of type :password and, when clicked, pop up the :integer type keyboard. Is keyboard type selection on a per-screen basis part of RedPotion?

Is there an option I'm missing for each item in my cells array that achieves this?

Question: Any way to handle nested/related fields?

I'm building a form and I'm running into some issues with nested resources. Here's a simplified version of my data model:

{
  "id": 123,
  "name": "Bob Smith",
  "email_addresses": [
    {
      "id": 456,
      "label": "home",
      "address": "[email protected]"
    },
    {
      "id": 789,
      "label": "work",
      "address": "[email protected]"
    }
  ]
}

Here's my current form (note that it's only capturing the address field). This form will eventually need to support more complex inputs like mailing address.

[
  {
    title: 'Account information',
    cells: [
      {
        title: 'Name',
        name: :name,
        type: :name,
        placeholder: 'Name'
      }
    ]
  },
  {
    title: 'Email addresses',
    name: :email_addresses,
    options: [:insert, :delete, :reorder],
    cells: [
      {
        title: '',
        name: :address,
        type: :email,
        placeholder: 'Email address'
        # Needs to (but doesn't) capture the id/label
      }
    ]
  }
]

I think the underlying question is: is there a way for one "form row" to support multiple fields/inputs without needing to use a separate screen.

I'd really like it to work similar to the Apple contacts works where all multiple inputs for the same field appear inline/adjacent to one another. Is there any way to do that with this gem currently?

Problem adding .on(:touch) event to form footer

On my LoginScreen I have a footer on the form that says "Forgot your username or password?" and I would like that to be tappable. I tried finding the last UITableViewHeaderFooterView and putting a .on(:touch) right on it.

find(UITableViewHeaderFooterView).last.on(:touch) do
  mp "forgot something?"
end

But, I keep getting this error:

events.rb:92:in `block in on:': [RMQ Error]  Event already exists on this object: touch. Remove first, using .off (RuntimeError)

I was not expecting an event to be on that footer, so first I checked to make sure that I was grabbing the right view by doing this:

find(UITableViewHeaderFooterView).last.get.contentView.backgroundColor = color.red

That correctly turns the whole footer view red. So, I've got the right view. So, next I tried turning the mystery event off first like this:

find(UITableViewHeaderFooterView).last.off
find(UITableViewHeaderFooterView).last.on(:touch) do
  mp "forgot something?"
end

But I get this error:

event.rb:124:in `remove': undefined method `removeTarget:action:forControlEvents:' for #<UITableViewHeaderFooterView:0x11466f8a0> (NoMethodError)

The weird thing is that if I remove the setting of the event and just do this:

find(UITableViewHeaderFooterView).last.off

I do NOT get an error. Weird stuff happening. Any thoughts?

Styling the form with rmq

I've attempted to style the form using req, however I can't seem to figure out how to do it.

class MyScreen < PM::XLFormScreen

  def on_load
    rmq.stylesheet = MyStylesheet
  end

StyleSheet

  def form_view(st)
    st.background_color = UIColor.greenColor
  end

However no styling is applied, looking at the code, I need to get if self.class.respond_to?(:rmq_style_sheet_class) && self.class.rmq_style_sheet_class to be true, however I can't figure out how to achieve this. Please help :)

ProMotion-Form's 'dismiss_keyboard' method

Is dismiss_keyboard necessary in ProMotion-XLForm?

As per PM-Form's README

dismiss_keyboard

Dismisses the keyboard. Note that you may need to call this before render_form to ensure that you capture the input from the currently focused form element.

I have the code on a fork, if you feel this is necessary/provides a cleaner convenience method.

# lib/ProMotion/XLForm/xl_form_screen.rb

def dismiss_keyboard
  self.view.endEditing true
end

multiple_selector and multiple_selector_popover don't seem to be working now.

I've updated Rubymotion, and am using Redpotion. Tried using the example in the read me / docts, but nothing happens upon click:

   ```

{
title: 'Feedback:',
name: :treatment_feedback,
type: :multiple_selector,
options: {
:lights => "lights",
:vibration => "vibration"
}
},
{
title: 'Multiple',
name: :multiple_selector_popover,
type: :multiple_selector,
options: {
:roses => 'Roses are #FF0000',
:violets => 'Violets are #0000FF',
:base => 'All my base',
:belong => 'are belong to you.'
}
},

Possible to make link clickable inside textview?

I tried using rmq by setting data_detector_type = :all but didn't work

def will_appear
    rmq(UITextView).style{|st| st.editable = false, st.data_detector_types = :all }
end

Is there a way to get this done.

Thanks

Problem shoveling a new section into form_data

This one is a bit of a doozy. I'm not sure if this is a problem on my end or simply a limitation of XLForm, but hopefully you can shed some light on this for me. I'll try to break it down as best I can.

I have a collection of settings with the following json structure:

"key": "hide_connections_on_profile",
"name": "Users – Hide User’s Connections list",
"description": "Profile",
"setting": true,
"category": "Privacy",
"label": "Hide my Connections list from my profile"

I go through the list and grab all the uniq categories, then map through those as the the different sections of the form. That is all working flawlessly right now.

def settings
  @categories = @settings.map{ |setting| setting.category}.uniq.sort
  @categories.map do |category|
    @category_of_settings = @settings.select{ |user| user.category == category }
    {
      title: category.upcase,
      cells:
      @category_of_settings.map do |setting|
        {
          name: setting.key,
          title: setting.label,
          type: :check,
          value: setting.setting
        }
      end
    }
  end
end

The problem is that I don't have a save button. Since I am dealing exclusively with loops here, I need to inject the save button at the end. And that's where things are not going well. First, I tried switching the first block to an each, wrapping the whole thing in [ ], with the possibility of conditionally adding a save button.

def settings
  @categories = @settings.map{ |setting| setting.category}.uniq.sort
  [
  @categories.each do |category|
    @category_of_settings = @settings.select{ |user| user.category == category }
    {
      title: category.upcase,
      cells:
      @category_of_settings.map do |setting|
        {
          name: setting.key,
          title: setting.label,
          type: :check,
          value: setting.setting
        }
      end
    }
  end
  ]
end

It compiles just fine, but when I load that screen, I get the following error:

xl_form_patch.rb:76:in `section:': can't convert Symbol into Integer (TypeError)

I tried going back to map and then creating 2 separate methods, settings and save_button and then shoveling them together in a form_data method:

def form_data
  settings << save_button
end  

def settings
  @categories = @settings.map{ |setting| setting.category}.uniq.sort
  @categories.map do |category|
    @category_of_settings = @settings.select{ |user| user.category == category }
    {
      title: category.upcase,
      cells:
      @category_of_settings.map do |setting|
        {
          name: setting.key,
          title: setting.label,
          type: :check,
          value: setting.setting
        }
      end
    }
  end
end

def save_button
  [{
    title: nil,
    cells: [{
      name: :save,
      title: "Save",
      type: :button,
      on_click: -> { save_settings }
    }]
  }]
end

Again, it compiles just fine, but then I get the same error:

xl_form_patch.rb:76:in `section:': can't convert Symbol into Integer (TypeError)

And at this point, I'm at a loss. Not sure if what I'm after is just not possible or if I'm missing some subtly in there somewhere.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.