motion-form 0.0.5 → 0.0.6

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: 4e3d23204e901a1c9c7613f06210b68d2cb4b522
4
- data.tar.gz: 768a418ce327e9ca5c4ea9395d0ad22c8339994c
3
+ metadata.gz: 66e50570ed58cf1ae93083737014c30a1a93fd52
4
+ data.tar.gz: 15622ad5748a3688273a4d15eea204dcb4e2384a
5
5
  SHA512:
6
- metadata.gz: 4ca6e278373778e03f495c05dcdd63a3cb78f0a0d59349c71735b83b5c5a37cf48d43984859d39acf417ec11be131933d1272e2997e63b548e9092c926539b46
7
- data.tar.gz: 71b1e387576ce464f2cc82af538783a333b36f1cb7a19f0cfe949d48b53fa04582fb18729df53125e9375765a3fd713a728e5ce0ddc5eb8b5ab0db1e36da12aa
6
+ metadata.gz: 9497e6398e3cb0fdc5d549752365fe3a0a89de191333d0e8ff16ac2072f33b35fc5812e28763a32ec6dab4f1404e35f96d261474edbe46aba888cfdee0bfa406
7
+ data.tar.gz: c63d225eab258ffaef7f06b3e6f9423eb87a8c12c8928d2f3c8355530bcb41c1c08cc64bd0438760c4780180725ed9db589d3ce4a8389b260ebae133a0fd1ec4
@@ -25,7 +25,15 @@ class BaseCell < UITableViewCell
25
25
  NSNotificationCenter.defaultCenter
26
26
  end
27
27
 
28
- def post(notification)
29
- notification_center.postNotificationName(notification, object: self, userInfo: notification_payload)
28
+ def post(notification, payload = nil)
29
+ notification_center.postNotificationName(notification, object: self, userInfo: payload)
30
+ end
31
+
32
+ def observe(notification_name, selector)
33
+ notification_center.addObserver(self, selector: selector, name: notification_name, object: nil)
34
+ end
35
+
36
+ def dealloc
37
+ notification_center.removeObserver(self)
30
38
  end
31
39
  end
@@ -28,7 +28,7 @@ class ButtonCell < TextFieldCell
28
28
  end
29
29
 
30
30
  def tapped(recognizer)
31
- post('FormCellWasTapped')
31
+ post('FormCellWasTapped', notification_payload)
32
32
  end
33
33
 
34
34
  def add_right_view
@@ -4,12 +4,22 @@ motion_require '../views/icon_view'
4
4
  class TextFieldCell < BaseCell
5
5
  IDENTIFIER = 'TextFieldCell'
6
6
 
7
+ def initWithStyle(style, reuseIdentifier: reuse_identifier)
8
+ super.tap do |cell|
9
+ cell.observe('ButtonCallbackWillFire', 'resign_textfield:')
10
+ end
11
+ end
12
+
7
13
  class << self
8
14
  def has_value?
9
15
  true
10
16
  end
11
17
  end
12
18
 
19
+ def resign_textfield(notification)
20
+ text_field.resignFirstResponder if text_field.isFirstResponder
21
+ end
22
+
13
23
  def label=(label)
14
24
  text_field.placeholder = label
15
25
  end
@@ -55,11 +65,11 @@ class TextFieldCell < BaseCell
55
65
  end
56
66
 
57
67
  def textFieldDidBeginEditing(text_field)
58
- post('FormCellDidBeginEditing')
68
+ post('FormCellDidBeginEditing', notification_payload)
59
69
  end
60
70
 
61
71
  def textFieldDidEndEditing(text_field)
62
- post('FormCellDidEndEditing')
72
+ post('FormCellDidEndEditing', notification_payload)
63
73
  end
64
74
 
65
75
  def textFieldShouldReturn(text_field)
@@ -8,6 +8,7 @@ module MotionForm
8
8
  initWithFrame(frame, style: UITableViewStylePlain).tap do |f|
9
9
  f.register_cells
10
10
  f.separatorStyle = UITableViewCellSeparatorStyleNone
11
+ f.translatesAutoresizingMaskIntoConstraints = false
11
12
 
12
13
  f.dataSource = self
13
14
  f.delegate = self
@@ -14,9 +14,17 @@ module MotionForm
14
14
 
15
15
  yield form if block_given?
16
16
 
17
- form.frame = view.bounds
18
-
19
17
  view.addSubview(form)
18
+
19
+ %w(H V).each do |direction|
20
+ constraints = NSLayoutConstraint.constraintsWithVisualFormat(
21
+ "#{direction}:|[form]|",
22
+ options: 0,
23
+ metrics: nil,
24
+ views: { 'form' => form } )
25
+
26
+ view.addConstraints(constraints)
27
+ end
20
28
  end
21
29
  end
22
30
 
@@ -37,11 +45,11 @@ module MotionForm
37
45
  end
38
46
 
39
47
  def section_header_color
40
- @section_header_color || UIColor.redColor
48
+ @section_header_color || '#bac3c7'.to_color
41
49
  end
42
50
 
43
51
  def section_header_text_color
44
- @section_header_text_color || UIColor.whiteColor
52
+ @section_header_text_color || '#eaf0f1'.to_color
45
53
  end
46
54
  end
47
55
  end
@@ -9,18 +9,20 @@ class BaseRow
9
9
  @value = options.fetch(:value, nil)
10
10
  end
11
11
 
12
- def observers
13
- @observers ||= []
12
+ def notification_center
13
+ NSNotificationCenter.defaultCenter
14
14
  end
15
15
 
16
- def remove_all_observers
17
- observers.each do |observer|
18
- notification_center.removeObserver(observer)
19
- end
16
+ def post(notification)
17
+ notification_center.postNotificationName(notification, object: self, userInfo: nil)
20
18
  end
21
19
 
22
- def notification_center
23
- NSNotificationCenter.defaultCenter
20
+ def observe(notification_name, selector)
21
+ notification_center.addObserver(self, selector: selector, name: notification_name, object: nil)
22
+ end
23
+
24
+ def dealloc
25
+ notification_center.removeObserver(self)
24
26
  end
25
27
 
26
28
  def cell_identifier
@@ -19,11 +19,13 @@ class ButtonRow < TextFieldRow
19
19
  end
20
20
 
21
21
  def listen
22
- observers << notification_center.addObserver(self, selector: 'tapped:', name: 'FormCellWasTapped', object: nil)
22
+ observe('FormCellWasTapped', 'tapped:')
23
23
  end
24
24
 
25
25
  def tapped(notification)
26
26
  if notification.userInfo[:key] == key
27
+ post('ButtonCallbackWillFire')
28
+
27
29
  on_tap_callback.call
28
30
  end
29
31
  end
@@ -11,7 +11,7 @@ class TextFieldRow < BaseRow
11
11
  end
12
12
 
13
13
  def listen
14
- observers << notification_center.addObserver(self, selector: 'did_end_editing:', name: 'FormCellDidEndEditing', object: nil)
14
+ observe('FormCellDidEndEditing', 'did_end_editing:')
15
15
  end
16
16
 
17
17
  def did_end_editing(notification)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Devon Blandin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-31 00:00:00.000000000 Z
11
+ date: 2013-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: motion-keyboard-avoiding