ProMotion-XLForm 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05c859ed838fdd140e797b1dcbe49c572398a592
4
- data.tar.gz: 6c48299595d9d3324c4495169245c6339cb5adbb
3
+ metadata.gz: 9890e1816bb0725731ac8e10e8413c4d22063a0a
4
+ data.tar.gz: fd5779aab6a93194f091e0e323f7ba0c4ca88890
5
5
  SHA512:
6
- metadata.gz: '0885792527bcbd81684b5bc5f9505c447a011fd3e27c9f14700c9d83cfd11522709a54b25a975bc71cc645f253baa71c6363d1f7df0e4a37350bb3d089933811'
7
- data.tar.gz: 897df3976ae5e677566390e7370602eebf954bdd37769f54bfc21816c0640d2e532b0d9cd89a966169a589af18e5c5873fa6c2203fce256941e926674ce65d21
6
+ metadata.gz: 807971c87855a87079cca5b9ca9b8548fdfebce2fe89d66373e54121131fddf1cceb8e35b34256e73b15ff3528b7a0481e9b1c4b5c352075e1ed640c4f304ccb
7
+ data.tar.gz: '0727936efd3e9068df4d98341eb71467d00b8f81d3986bd02b6538951be00eb78ecdeffebe99063ed622c29c5514337a79eca3aa8e313216dea88a0d2db19849'
data/README.md CHANGED
@@ -19,9 +19,9 @@ $ rake pod:install
19
19
 
20
20
  ## Usage
21
21
 
22
- `PM::XLFormScreen` include `PM::ScreenModule` so you'll have all ProMotion methods available.
22
+ `PM::XLFormScreen` includes `PM::ScreenModule` so you'll have all the same ProMotion screen methods available.
23
23
 
24
- To create a form, create a new `PM::XLFormScreen` and implement `form_data`.
24
+ To create a form screen, subclass `PM::XLFormScreen` and define a `form_data` method.
25
25
 
26
26
  ```ruby
27
27
  class TestFormScreen < PM::XLFormScreen
@@ -107,30 +107,53 @@ end
107
107
  * :image (ProMotion-XLForm specific)
108
108
  * :color (ProMotion-XLForm specific using [RSColorPicker](https://github.com/RSully/RSColorPicker))
109
109
 
110
- ### Class options
110
+ ### Form Options
111
+
112
+ The `form_options` class method allows you to customize the default behavior of the form.
111
113
 
112
114
  ```ruby
113
115
  class TestFormScreen < PM::XLFormScreen
114
116
 
115
- form_options required: :asterisks, # add an asterisk to required fields
116
- on_save: :'save_form:', # will be called when you touch save
117
- on_cancel: :cancel_form, # will be called when you touch cancel
118
- auto_focus: true # the form will focus on the first focusable field
117
+ form_options on_save: :save_form, # adds a "Save" button in the nav bar and calls this method
118
+ on_cancel: :cancel_form, # adds a "Cancel" button in the nav bar and calls this method
119
+ required: :asterisks, # display an asterisk next to required fields
120
+ auto_focus: true # the form will focus on the first focusable field
119
121
 
120
- def save_form(values)
121
- dismiss_keyboard
122
- mp values
123
- end
122
+ def save_form(values)
123
+ dismiss_keyboard
124
+ mp values
125
+ end
124
126
 
125
- def cancel_form
126
- end
127
+ def cancel_form
128
+ end
127
129
  end
128
130
  ```
129
131
 
130
- If you don't want the default navigation controller buttons, you could add something like
132
+ #### Save & Cancel Buttons
133
+
134
+ By default, no buttons are displayed in the nav bar unless you configure the `on_save` or `on_cancel` options.
135
+
136
+ 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.
137
+
138
+ **Hash Options:**
139
+ - `title` or `system_item` - The button text or system item that will be displayed.
140
+ - `action` - The method that will be called when the button is tapped.
131
141
 
132
142
  ```ruby
143
+ form_options on_cancel: { system_item: :trash, action: :cancel_form },
144
+ on_save: { title: 'Continue', action: :continue }
145
+ ```
133
146
 
147
+ `system_item` can be any `UIBarButtonSystemItem` constant or one of the following symbols:
148
+ ```ruby
149
+ :done, :cancel, :edit, :save, :add, :flexible_space, :fixed_space, :compose,
150
+ :reply, :action, :organize, :bookmarks, :search, :refresh, :stop, :camera,
151
+ :trash, :play, :pause, :rewind, :fast_forward, :undo, :redo
152
+ ```
153
+
154
+ If you would like to display a button as part of your form, you could do something like this:
155
+
156
+ ```ruby
134
157
  form_options on_save: :my_save_method
135
158
 
136
159
  def form_data
@@ -253,7 +276,48 @@ class MyValueTransformer < PM::ValueTransformer
253
276
  end
254
277
  ```
255
278
 
256
- For a more advanced custom selector, you can set `view_controller_class:`. See [XLForm documentation](https://github.com/xmartlabs/XLForm/#custom-selectors---selector-row-with-a-custom-selector-view-controller) for more informations.
279
+ #### Custom Selector View Controller
280
+
281
+ For a more advanced custom selector, you can set `view_controller_class:`.
282
+
283
+ ```ruby
284
+ {
285
+ title: 'Person',
286
+ name: 'person',
287
+ type: :selector_push,
288
+ view_controller_class: PeopleListScreen
289
+ }
290
+ ```
291
+
292
+ 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.
293
+
294
+ ```ruby
295
+ class PeopleListScreen < PM::TableScreen
296
+ attr_accessor :rowDescriptor
297
+
298
+ def table_data
299
+ [{
300
+ title: @rowDescriptor.title,
301
+ cells: People.all.map do |person|
302
+ {
303
+ title: person.name,
304
+ action: -> {
305
+ rowDescriptor.value = person.id
306
+ close # go back to the previous screen
307
+ }
308
+ }
309
+ end
310
+ }]
311
+ end
312
+ end
313
+ ```
314
+
315
+ ![Screenshot of Map Custom Selector](https://github.com/xmartlabs/XLForm/raw/master/Examples/Objective-C/Examples/Selectors/CustomSelectors/XLFormRowViewController/XLForm-map-custom-selector.gif)
316
+
317
+ ![Screenshot of Dynamic Custom Selector](https://github.com/xmartlabs/XLForm/raw/master/Examples/Objective-C/Examples/Selectors/DynamicSelector/XLForm-dynamic-custom-selector.gif)
318
+
319
+ See [XLForm documentation](https://github.com/xmartlabs/XLForm/#custom-selectors---selector-row-with-a-custom-selector-view-controller) for more information.
320
+
257
321
 
258
322
  ### Cell
259
323
 
@@ -11,6 +11,12 @@ module ProMotion
11
11
  s
12
12
  end
13
13
 
14
+ def init
15
+ super.tap do
16
+ screen_init if respond_to?(:screen_init)
17
+ end
18
+ end
19
+
14
20
  def loadView
15
21
  self.respond_to?(:load_view) ? self.load_view : super
16
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ProMotion-XLForm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Michotte
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-30 00:00:00.000000000 Z
11
+ date: 2018-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ProMotion