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 +4 -4
- data/README.md +79 -15
- data/lib/ProMotion/XLForm/xl_form_view_controller.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9890e1816bb0725731ac8e10e8413c4d22063a0a
|
4
|
+
data.tar.gz: fd5779aab6a93194f091e0e323f7ba0c4ca88890
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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`
|
22
|
+
`PM::XLFormScreen` includes `PM::ScreenModule` so you'll have all the same ProMotion screen methods available.
|
23
23
|
|
24
|
-
To create a form,
|
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
|
-
###
|
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
|
116
|
-
|
117
|
-
|
118
|
-
auto_focus: true
|
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
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
122
|
+
def save_form(values)
|
123
|
+
dismiss_keyboard
|
124
|
+
mp values
|
125
|
+
end
|
124
126
|
|
125
|
-
|
126
|
-
|
127
|
+
def cancel_form
|
128
|
+
end
|
127
129
|
end
|
128
130
|
```
|
129
131
|
|
130
|
-
|
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
|
-
|
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
|
|
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.
|
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-
|
11
|
+
date: 2018-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ProMotion
|