ProMotion-form 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +96 -13
  3. data/lib/ProMotion/form/form.rb +4 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a5e782943d995a200866bab9067db1a937cbb69
4
- data.tar.gz: b9a0527f77ced2d3eb4a0072e27b5d83016c23fc
3
+ metadata.gz: d903204fe76ee994fc1344fef6cb072158f3b27d
4
+ data.tar.gz: a666e3693a1d65b4f0c29dbcc5a6fc68902895f4
5
5
  SHA512:
6
- metadata.gz: 9bf7baa4f40e171f977a97e7d65db23599ae94178ec8dfe939679d48f888de578d325200fefee00d46804ad66d56ccc8f8263582aacce1178b3db37b24a6d034
7
- data.tar.gz: 07ceb43547db03ba16c15231c404546de764458d7f687ee8fd5fa47145bd215ac9a9743a842917e48b322e71558d23a6b943f0290ddebbfd6d80512a13d46d2a
6
+ metadata.gz: b697146f4529a0c759c32c786bf870dfed63b3a5eaac6be25ebc929d8df5d39e8b2565dba2614a70c8b9460384ef72606d60b00de273ae22e3cda275e664ab0c
7
+ data.tar.gz: 7c7e0724be01b84ff8b3a6407c86d96c19bbb06150b41712bbb3165a0eb771292c2627771a6053292b32742c794b8db3b36d69e8b1aa3722c9bb6e3fc897a74f
data/README.md CHANGED
@@ -160,6 +160,7 @@ Here are sample form fields with some explanation
160
160
  class: NSArray, # explicitly set the class of the field value
161
161
  template: { type: :image }, # set the field types of a collection (`class` must be NSArray or NSOrderedSet)
162
162
  sortable: true, # make the field sortable (`class` must be NSArray or NSOrderedSet)
163
+ image: 'thumbnail', # the name of the image to display on the left side of the cell. You can also pass an instance of an image: UIImage.imageNamed('thumbnail')
163
164
  }
164
165
  ```
165
166
 
@@ -191,16 +192,41 @@ Here are sample form fields with some explanation
191
192
  * `:properties` - a flexible way to set cell properties (see Styling section below)
192
193
  * string keys - you can also define styling parameters as top-level strings
193
194
 
195
+ ##### Common Properties:
196
+
197
+ The properties hash provides access to all [`UITableViewCell`](https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableViewCell_Class/index.html) properties. Here are some examples of common properties:
198
+
199
+ * `textLabel` - The `UILabel` used for displaying the `:title` text.
200
+ * `detailTextLabel` - The `UILabel` used for displaying the `:value` text.
201
+ * `imageView` - The `UIImageView` that is displayed on the left side of the cell. ProMotion-form provides the `image:` helper on the cell hash for specifying this image.
202
+
203
+ * `contentView` - The default superview for content displayed by the cell.
204
+ * `backgroundColor` - The background color of the cell.
205
+ * `backgroundView` - The background view of the cell. The default is nil.
206
+
207
+ * `accessoryType` - The icon that appears on the right side of the cell. You may specify one of the following constants:
208
+ * `UITableViewCellAccessoryNone` (default)
209
+ * `UITableViewCellAccessoryDisclosureIndicator`
210
+ * `UITableViewCellAccessoryDetailDisclosureButton`
211
+ * `UITableViewCellAccessoryCheckmark`
212
+ * `UITableViewCellAccessoryDetailButton`
213
+ * `accessoryView` - An instance of your own custom accessory view.
214
+
215
+ * `selectionStyle` - The background view that applies when the cell is tapped (selected). You may specify one of the following constants:
216
+ * `UITableViewCellSelectionStyleNone`
217
+ * `UITableViewCellSelectionStyleBlue`
218
+ * `UITableViewCellSelectionStyleGray`
219
+ * `UITableViewCellSelectionStyleDefault` (default)
220
+
194
221
  ## Styling
195
222
 
196
223
  #### Method 1: Put them into a hash
197
224
 
198
225
  ```
199
- properties: {
200
- "accessoryView" => CustomAccessory.new,
201
- "backgroundColor" => UIColor.colorWhite,
202
- "detailTextLabel.font" => UIFont.fontWithName("MyFont", size:20),
203
- },
226
+ properties: {
227
+ "accessoryView" => CustomAccessory.new,
228
+ "backgroundColor" => UIColor.colorWhite,
229
+ "detailTextLabel.font" => UIFont.fontWithName("MyFont", size:20),
204
230
  }
205
231
  ```
206
232
 
@@ -246,10 +272,64 @@ end
246
272
  #### Method 4: Combine styles, with overrides (using '+')
247
273
 
248
274
  ```
249
- properties: style(:basic, :alert) + {
250
- "backgroundColor" => UIColor.yellowColor,
251
- },
275
+ properties: style(:basic, :alert) + {
276
+ "backgroundColor" => UIColor.yellowColor,
277
+ }
278
+ ```
279
+
280
+ Note that you can use symbols for keys instead of strings:
281
+
282
+ ```
283
+ properties: {
284
+ backgroundColor: UIColor.colorWhite,
285
+ textLabel: {
286
+ font: UIFont.fontWithName("MyFont", size:20)
287
+ }
288
+ }
289
+ ```
290
+
291
+ However, if you are combining styles, you may want to specify they keys as strings so that the rest of your styles are not overwritten:
292
+
293
+ ```
294
+ {
295
+ properties: style(:basic, :bold),
252
296
  }
297
+
298
+ # ...
299
+
300
+ def styles
301
+ {
302
+ basic: {
303
+ textLabel: {
304
+ color: UIColor.redColor
305
+ font: UIFont.fontWithName("MyFont", size:20)
306
+ }
307
+ },
308
+ bold: {
309
+ # This textLabel hash would overwrite the previous hash, so the red color would not be applied
310
+ textLabel: {
311
+ font: UIFont.fontWithName("MyBoldFont", size:20)
312
+ }
313
+ }
314
+ }
315
+ end
316
+ ```
317
+
318
+ Example of using strings with dot notation for combining styles:
319
+
320
+ ```
321
+ def styles
322
+ {
323
+ basic: {
324
+ 'textLabel.color' => UIColor.redColor
325
+ 'textLabel.font' => UIFont.fontWithName("MyFont", size:20)
326
+ },
327
+ bold: {
328
+ # This textLabel would include the red color because we only chose to overwrite the font property
329
+ 'textLabel.font' => UIFont.fontWithName("MyBoldFont", size:20)
330
+ }
331
+ }
332
+ end
253
333
  ```
254
334
 
255
335
  #### update_form_data
@@ -285,8 +365,11 @@ This is a Struct with a `#fields` method (which is used to build the form in FXF
285
365
  ## Contributing
286
366
 
287
367
  1. Fork it
288
- 2. Create your feature branch (`git checkout -b my-new-feature`)
289
- 3. Commit your changes (`git commit -am 'Add some feature'`)
290
- 4. Make some specs pass
291
- 5. Push to the branch (`git push origin my-new-feature`)
292
- 6. Create new Pull Request
368
+ 2. Install the gem dependencies: `bundle install`
369
+ 3. Install the CocoaPod dependencies: `bundle exec rake pod:install`
370
+ 4. Create your feature branch (`git checkout -b my-new-feature`)
371
+ 5. Run the test suite: `bundle exec rake spec`
372
+ 6. Make your changes. Add some specs.
373
+ 7. Commit your changes (`git commit -am 'Add some feature'`)
374
+ 8. Push to the branch (`git push -u origin my-new-feature`)
375
+ 9. Create new Pull Request
@@ -63,10 +63,13 @@ module ProMotion
63
63
  data.update(FormStyle.to_style(input[:style ])) if input[:style ]
64
64
 
65
65
  # pass non-helper keys to FXForms
66
- helpers = [ :cell_class, :name, :style, :properties ]
66
+ helpers = [ :cell_class, :name, :style, :properties, :label ]
67
67
  (input.keys - helpers).each {|key| data[key] = input[key] }
68
68
 
69
69
  # process "after" helper keys
70
+ if input[:title].nil? or input[:title].empty? # FXForms crashes on empty strings
71
+ input[:title] = ' '
72
+ end
70
73
  data[:key ] ||= input[:name ] || input[:title].downcase.gsub(/[^0-9a-z]/i, '_').to_sym
71
74
  data[:title] ||= input[:label] || input[:name ].to_s
72
75
  data[:cell ] ||= input[:cell_class] if input[:cell_class]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ProMotion-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamon Holmgren
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-02 00:00:00.000000000 Z
11
+ date: 2015-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ProMotion
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project:
117
- rubygems_version: 2.4.6
117
+ rubygems_version: 2.4.5
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Adds PM::FormScreen support to ProMotion, similar to Formotion but lighter.