motion-form 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/project/cells/base_cell.rb +10 -2
- data/lib/project/cells/button_cell.rb +1 -1
- data/lib/project/cells/text_field_cell.rb +12 -2
- data/lib/project/form/base.rb +1 -0
- data/lib/project/motion-form.rb +12 -4
- data/lib/project/rows/base_row.rb +10 -8
- data/lib/project/rows/button_row.rb +3 -1
- data/lib/project/rows/text_field_row.rb +1 -1
- 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: 66e50570ed58cf1ae93083737014c30a1a93fd52
|
4
|
+
data.tar.gz: 15622ad5748a3688273a4d15eea204dcb4e2384a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
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
|
@@ -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)
|
data/lib/project/form/base.rb
CHANGED
data/lib/project/motion-form.rb
CHANGED
@@ -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 ||
|
48
|
+
@section_header_color || '#bac3c7'.to_color
|
41
49
|
end
|
42
50
|
|
43
51
|
def section_header_text_color
|
44
|
-
@section_header_text_color ||
|
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
|
13
|
-
|
12
|
+
def notification_center
|
13
|
+
NSNotificationCenter.defaultCenter
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
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
|
23
|
-
|
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
|
-
|
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
|
-
|
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.
|
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
|
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
|