motion-kit 0.10.11 → 0.11.0
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/README.md +92 -2
- data/lib/motion-kit/calculator/calculate.rb +1 -1
- data/lib/motion-kit/calculator/view_calculator.rb +5 -5
- data/lib/motion-kit/layouts/base_layout.rb +21 -15
- data/lib/motion-kit/layouts/base_layout_class_methods.rb +2 -7
- data/lib/motion-kit/layouts/tree_layout.rb +141 -106
- data/lib/motion-kit/object.rb +0 -9
- data/lib/motion-kit/version.rb +1 -1
- data/lib/motion-kit-cocoa/constraints/constraint.rb +11 -12
- data/lib/motion-kit-cocoa/constraints/constraint_placeholder.rb +3 -3
- data/lib/motion-kit-cocoa/constraints/constraints_layout.rb +103 -58
- data/lib/motion-kit-ios/layouts/constraints_layout.rb +4 -2
- data/lib/motion-kit-ios/layouts/uiview_layout.rb +0 -17
- data/lib/motion-kit-ios/layouts/uiview_layout_constraints.rb +10 -10
- data/lib/motion-kit-ios/layouts/uiview_layout_frame.rb +1 -1
- data/lib/motion-kit-osx/layouts/constraints_layout.rb +18 -16
- data/lib/motion-kit-osx/layouts/nstableview_layout.rb +13 -0
- data/lib/motion-kit-osx/layouts/nsview_layout.rb +0 -19
- data/lib/motion-kit-osx/layouts/nsview_layout_constraints.rb +10 -10
- data/lib/motion-kit-osx/layouts/nsview_layout_frame.rb +1 -1
- data/lib/motion-kit-osx/layouts/nswindow_layout.rb +0 -49
- data/spec/ios/apply_styles_spec.rb +27 -12
- data/spec/ios/calayer_spec.rb +9 -0
- data/spec/ios/child_layouts_spec.rb +53 -0
- data/spec/ios/constraints_helpers/scale_constraints_spec.rb +62 -0
- data/spec/ios/create_layout_spec.rb +1 -1
- data/spec/ios/custom_root_layout_spec.rb +1 -1
- data/spec/ios/frame_helper_spec.rb +2 -2
- data/spec/ios/layout_spec.rb +3 -20
- data/spec/ios/layout_state_spec.rb +1 -1
- data/spec/ios/motionkit_util_spec.rb +0 -87
- data/spec/ios/reapply_frame.rb +0 -2
- data/spec/ios/relative_layout.spec.rb +2 -2
- data/spec/ios/remove_layout_spec.rb +2 -3
- data/spec/ios/view_attr_spec.rb +7 -0
- data/spec/osx/constraints_helpers/table_view_spec.rb +34 -0
- data/spec/osx/custom_root_layout_spec.rb +1 -1
- data/spec/osx/frame_helper_spec.rb +2 -2
- metadata +10 -3
- data/lib/motion-kit-cocoa/cocoa_util.rb +0 -59
@@ -1,22 +1,37 @@
|
|
1
1
|
describe "Layouts automatically apply styles" do
|
2
2
|
|
3
3
|
before do
|
4
|
-
@subject = TestApplyStyles.new
|
4
|
+
@subject = TestApplyStyles.new.build
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@subject.did_call_label
|
7
|
+
describe "should call all style methods" do
|
8
|
+
{
|
9
|
+
logo: -> { @subject.did_call_logo },
|
10
|
+
h1_label: -> { @subject.did_call_h1_label },
|
11
|
+
label: -> { @subject.did_call_label },
|
12
|
+
}.each do |name, condition|
|
13
|
+
it "should call #{name} style method" do
|
14
|
+
condition.call.should == true
|
15
|
+
end
|
16
|
+
end
|
12
17
|
end
|
13
18
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
describe "should apply all styles" do
|
20
|
+
it 'should style :logo' do
|
21
|
+
@subject.get(:logo).text.should == 'MK'
|
22
|
+
end
|
23
|
+
it 'should style :label' do
|
24
|
+
@subject.get(:label).text.should == ':label'
|
25
|
+
end
|
26
|
+
it 'should style :label' do
|
27
|
+
@subject.get(:label).numberOfLines.should == 2
|
28
|
+
end
|
29
|
+
it 'should style :label' do
|
30
|
+
@subject.get(:label).font.pointSize.should == 16
|
31
|
+
end
|
32
|
+
it 'should style :label' do
|
33
|
+
@subject.get(:label).textColor.should == UIColor.blackColor
|
34
|
+
end
|
20
35
|
end
|
21
36
|
|
22
37
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
describe 'Child Layouts' do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@layout = TestChildrenLayout.new.build
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'should have 3 child layouts' do
|
8
|
+
@layout.child_layouts.length.should == 3
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should have a layout named :child_button' do
|
12
|
+
@layout.get(:child_button).should.be.kind_of(ChildButtonLayout)
|
13
|
+
end
|
14
|
+
|
15
|
+
it ':child_button layout should have a view named :button' do
|
16
|
+
@layout.get(:child_button).get(:button).should.be.kind_of(UIButton)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should have a layout named :child_image' do
|
20
|
+
@layout.get(:child_image).should.be.kind_of(ChildImageLayout)
|
21
|
+
end
|
22
|
+
|
23
|
+
it ':child_image layout should have a view named :image' do
|
24
|
+
@layout.get(:child_image).get(:image).should.be.kind_of(UIImageView)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'Calling reapply! on parent layout' do
|
28
|
+
|
29
|
+
before do
|
30
|
+
@layout.reapply!
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should reapply :label on root' do
|
34
|
+
@layout.get(:label).text.should == 'root reapplied'
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should reapply :label on child layout' do
|
38
|
+
@layout.child_layouts[0].get(:label).text.should == 'reapplied'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should reapply :button on child layout' do
|
42
|
+
@layout.get(:child_button).reapply!
|
43
|
+
@layout.get(:child_button).get(:button).currentTitle.should == 'reapplied'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should reapply :image on child layout' do
|
47
|
+
reapplied_image = @layout.get(:child_image).reapplied_image
|
48
|
+
@layout.get(:child_image).get(:image).image.should == reapplied_image
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class MagicSizeView < UIView
|
2
|
+
|
3
|
+
def intrinsicContentSize
|
4
|
+
CGSize.new(200, 100)
|
5
|
+
end
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
describe 'Constraints - Size helpers' do
|
11
|
+
|
12
|
+
before do
|
13
|
+
@layout = MK::Layout.new
|
14
|
+
@constraint = nil
|
15
|
+
@view = MagicSizeView.new
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should support `height :scale`' do
|
19
|
+
@layout.context(@view) do
|
20
|
+
@layout.constraints do
|
21
|
+
@constraint = @layout.height(:scale)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
@constraint.target.should == @view
|
26
|
+
@constraint.attribute.should == :height
|
27
|
+
@constraint.attribute2.should == :width
|
28
|
+
@constraint.relationship.should == :equal
|
29
|
+
@constraint.multiplier.should == 0.5
|
30
|
+
nsconstraint = @constraint.resolve_all(@layout, @view).first
|
31
|
+
nsconstraint.firstItem.should == @view
|
32
|
+
nsconstraint.firstAttribute.should == NSLayoutAttributeHeight
|
33
|
+
nsconstraint.secondItem.should == @view
|
34
|
+
nsconstraint.secondAttribute.should == NSLayoutAttributeWidth
|
35
|
+
nsconstraint.relation.should == NSLayoutRelationEqual
|
36
|
+
nsconstraint.multiplier.should == 0.5
|
37
|
+
nsconstraint.constant.should == 0
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should support `width :scale`' do
|
41
|
+
@layout.context(@view) do
|
42
|
+
@layout.constraints do
|
43
|
+
@constraint = @layout.width(:scale)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
@constraint.target.should == @view
|
48
|
+
@constraint.attribute.should == :width
|
49
|
+
@constraint.attribute2.should == :height
|
50
|
+
@constraint.relationship.should == :equal
|
51
|
+
@constraint.multiplier.should == 2.0
|
52
|
+
nsconstraint = @constraint.resolve_all(@layout, @view).first
|
53
|
+
nsconstraint.firstItem.should == @view
|
54
|
+
nsconstraint.firstAttribute.should == NSLayoutAttributeWidth
|
55
|
+
nsconstraint.secondItem.should == @view
|
56
|
+
nsconstraint.secondAttribute.should == NSLayoutAttributeHeight
|
57
|
+
nsconstraint.relation.should == NSLayoutRelationEqual
|
58
|
+
nsconstraint.multiplier.should == 2.0
|
59
|
+
nsconstraint.constant.should == 0
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -9,7 +9,7 @@ describe 'Frame helpers' do
|
|
9
9
|
@view_size = CGSize.new(8, 10)
|
10
10
|
@view = UIView.alloc.initWithFrame([[0, 0], @view_size])
|
11
11
|
@view.backgroundColor = UIColor.whiteColor
|
12
|
-
@view
|
12
|
+
@layout.name_element(@view, :view)
|
13
13
|
|
14
14
|
@superview_size = CGSize.new(60, 40)
|
15
15
|
@superview = UIView.alloc.initWithFrame([[0, 0], @superview_size])
|
@@ -18,7 +18,7 @@ describe 'Frame helpers' do
|
|
18
18
|
|
19
19
|
@another_view = UIView.alloc.initWithFrame([[10, 100], [120, 48]])
|
20
20
|
@another_view.backgroundColor = UIColor.redColor
|
21
|
-
@another_view
|
21
|
+
@layout.name_element(@another_view, :another_view)
|
22
22
|
|
23
23
|
top_view.addSubview(@another_view)
|
24
24
|
top_view.addSubview(@superview)
|
data/spec/ios/layout_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
describe
|
1
|
+
describe 'Simple Layout' do
|
2
2
|
before do
|
3
|
-
@subject = TestLayout.new
|
3
|
+
@subject = TestLayout.new.build
|
4
4
|
end
|
5
5
|
|
6
6
|
it "should be an instance of MotionKit::Layout" do
|
@@ -12,7 +12,7 @@ describe MotionKit::Layout do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should add a UIView subview with the name :basic_view" do
|
15
|
-
view = @subject.
|
15
|
+
view = @subject.get(:basic_view)
|
16
16
|
view.should.be.kind_of(UIView)
|
17
17
|
end
|
18
18
|
|
@@ -30,25 +30,14 @@ describe MotionKit::Layout do
|
|
30
30
|
|
31
31
|
it "should allow getting the subviews by their id" do
|
32
32
|
@subject.get(:basic_view).should.be.kind_of UIView
|
33
|
-
@subject.get(:basic_view, in: @subject.view).should.be.kind_of UIView
|
34
|
-
@subject.get(:basic_view, in: @subject.view).should == @subject.get(:basic_view)
|
35
|
-
|
36
33
|
@subject.get(:basic_button).should.be.kind_of UIButton
|
37
|
-
@subject.get(:basic_button, in: @subject.view).should.be.kind_of UIView
|
38
|
-
@subject.get(:basic_button, in: @subject.view).should == @subject.get(:basic_button)
|
39
|
-
|
40
34
|
@subject.get(:basic_label).should.be.kind_of UILabel
|
41
|
-
@subject.get(:basic_label, in: @subject.view).should.be.kind_of UIView
|
42
|
-
@subject.get(:basic_label, in: @subject.view).should == @subject.get(:basic_label)
|
43
35
|
end
|
44
36
|
|
45
37
|
it "should allow getting the subviews by first, last and nth child" do
|
46
38
|
@subject.first(:repeated_label_3).should.be.kind_of UIView
|
47
|
-
@subject.first(:repeated_label_3, in: @subject.other_view).should.be.kind_of UIView
|
48
39
|
@subject.nth(:repeated_label_3, 1).should.be.kind_of UIButton
|
49
|
-
@subject.nth(:repeated_label_3, at: 1, in: @subject.other_view).should.be.kind_of UIButton
|
50
40
|
@subject.last(:repeated_label_3).should.be.kind_of UILabel
|
51
|
-
@subject.last(:repeated_label_3, in: @subject.other_view).should.be.kind_of UILabel
|
52
41
|
end
|
53
42
|
|
54
43
|
it "should allow getting all the subviews by name" do
|
@@ -57,12 +46,6 @@ describe MotionKit::Layout do
|
|
57
46
|
views[0].should.be.kind_of UIView
|
58
47
|
views[1].should.be.kind_of UIButton
|
59
48
|
views[2].should.be.kind_of UILabel
|
60
|
-
|
61
|
-
views = @subject.all(:repeated_label_3, in: @subject.other_view)
|
62
|
-
views.length.should == 3
|
63
|
-
views[0].should.be.kind_of UIView
|
64
|
-
views[1].should.be.kind_of UIButton
|
65
|
-
views[2].should.be.kind_of UILabel
|
66
49
|
end
|
67
50
|
|
68
51
|
it "should support missing methods" do
|
@@ -12,91 +12,4 @@ describe 'MotionKit utility methods' do
|
|
12
12
|
MotionKit.appearance_class.should.be.kind_of(Class)
|
13
13
|
end
|
14
14
|
|
15
|
-
describe 'traversal methods' do
|
16
|
-
before do
|
17
|
-
view = UIView.new
|
18
|
-
view.tag = 1
|
19
|
-
subview1 = UIButton.new
|
20
|
-
subview1.tag = 2
|
21
|
-
subview2 = UILabel.new
|
22
|
-
subview2.tag = 3
|
23
|
-
subview3 = UILabel.new
|
24
|
-
subview3.tag = 4
|
25
|
-
subview4 = UIView.new
|
26
|
-
subview4.tag = 5
|
27
|
-
subview5 = UIButton.new
|
28
|
-
subview5.tag = 6
|
29
|
-
subview6 = UILabel.new
|
30
|
-
subview6.tag = 7
|
31
|
-
|
32
|
-
view.addSubview(subview1)
|
33
|
-
view.addSubview(subview2)
|
34
|
-
view.addSubview(subview3)
|
35
|
-
view.addSubview(subview4)
|
36
|
-
|
37
|
-
subview4.addSubview(subview5)
|
38
|
-
subview4.addSubview(subview6)
|
39
|
-
|
40
|
-
@subject = view
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should return the first UIButton that matches' do
|
44
|
-
found = MotionKit.find_first_view(@subject) { |view| view.is_a?(UIButton) }
|
45
|
-
found.should.be.kind_of(UIButton)
|
46
|
-
found.tag.should == 2
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'should return the first UILabel that matches' do
|
50
|
-
found = MotionKit.find_first_view(@subject) { |view| view.is_a?(UILabel) }
|
51
|
-
found.should.be.kind_of(UILabel)
|
52
|
-
found.tag.should == 3
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should return nil for first UIImage' do
|
56
|
-
found = MotionKit.find_first_view(@subject) { |view| view.is_a?(UIImage) }
|
57
|
-
found.should == nil
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'should return the last UIButton that matches' do
|
61
|
-
found = MotionKit.find_last_view(@subject) { |view| view.is_a?(UIButton) }
|
62
|
-
found.should.be.kind_of(UIButton)
|
63
|
-
found.tag.should == 6
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'should return the last UILabel that matches' do
|
67
|
-
found = MotionKit.find_last_view(@subject) { |view| view.is_a?(UILabel) }
|
68
|
-
found.should.be.kind_of(UILabel)
|
69
|
-
found.tag.should == 7
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'should return nil for last UIImage' do
|
73
|
-
found = MotionKit.find_last_view(@subject) { |view| view.is_a?(UIImage) }
|
74
|
-
found.should == nil
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'should return all the UIButton that match' do
|
78
|
-
found = MotionKit.find_all_views(@subject) { |view| view.is_a?(UIButton) }
|
79
|
-
found.length.should == 2
|
80
|
-
found.map { |view| view.tag }.should == [2, 6]
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should return all the UILabel that match' do
|
84
|
-
found = MotionKit.find_all_views(@subject) { |view| view.is_a?(UILabel) }
|
85
|
-
found.length.should == 3
|
86
|
-
found.map { |view| view.tag }.should == [3, 4, 7]
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'should return all the UIView that match' do
|
90
|
-
found = MotionKit.find_all_views(@subject) { |view| view.is_a?(UIView) }
|
91
|
-
found.length.should == 7
|
92
|
-
found.map { |view| view.tag }.should == [1, 2, 3, 4, 5, 6, 7]
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should return [] for all UIImages' do
|
96
|
-
found = MotionKit.find_all_views(@subject) { |view| view.is_a?(UIImage) }
|
97
|
-
found.should == []
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
15
|
end
|
data/spec/ios/reapply_frame.rb
CHANGED
@@ -13,10 +13,8 @@ describe 'Views frames should remain unchanged' do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "top should be in the right position before and after reapply" do
|
16
|
-
NSLog("top frame before reapply = #{@subject.get(:top).frame.inspect}")
|
17
16
|
@subject.get(:top).frame.should == CGRectMake(@cw/2 - 5, 0, 10, 10)
|
18
17
|
@subject.reapply!
|
19
|
-
NSLog("top frame after reapply = #{@subject.get(:top).frame.inspect}")
|
20
18
|
@subject.get(:top).frame.should == CGRectMake(@cw/2 - 5, 0, 10, 10)
|
21
19
|
end
|
22
20
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
describe
|
1
|
+
describe 'Remove views' do
|
2
2
|
before do
|
3
|
-
@subject = TestRemoveLayout.new
|
3
|
+
@subject = TestRemoveLayout.new.build
|
4
4
|
end
|
5
5
|
|
6
6
|
it 'should remove the #label view' do
|
@@ -19,7 +19,6 @@ describe MotionKit::Layout do
|
|
19
19
|
@subject.get(:view).should.be.kind_of(UIView)
|
20
20
|
@subject.remove_view
|
21
21
|
@subject.get(:view).should.be.nil
|
22
|
-
@subject.get(:image).should.be.nil
|
23
22
|
end
|
24
23
|
|
25
24
|
end
|
data/spec/ios/view_attr_spec.rb
CHANGED
@@ -22,4 +22,11 @@ describe 'View attr' do
|
|
22
22
|
label.should == @layout.label
|
23
23
|
end
|
24
24
|
|
25
|
+
it 'should handle multiple views' do
|
26
|
+
@layout.view
|
27
|
+
text_field = @layout.text_field
|
28
|
+
text_field.should.be.kind_of(UITextField)
|
29
|
+
text_view = @layout.text_view
|
30
|
+
text_view.should.be.kind_of(UITextView)
|
31
|
+
end
|
25
32
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
describe MotionKit::NSTableViewLayout do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@layout = TestTableColumnLayout.new.build
|
5
|
+
end
|
6
|
+
|
7
|
+
it 'should have a column called "foo"' do
|
8
|
+
column = @layout.table.tableColumnWithIdentifier('foo')
|
9
|
+
column.should.be.kind_of(NSTableColumn)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'column1 should say "Foo"' do
|
13
|
+
@layout.column1.headerCell.stringValue.should == 'Foo'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should have a column called "bar"' do
|
17
|
+
column = @layout.table.tableColumnWithIdentifier('bar')
|
18
|
+
column.should.be.kind_of(NSTableColumn)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'column2 should say "Bar"' do
|
22
|
+
@layout.column2.headerCell.stringValue.should == 'Bar'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have a column called "quux"' do
|
26
|
+
column = @layout.table.tableColumnWithIdentifier('quux')
|
27
|
+
column.should.be.kind_of(NSTableColumn)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'column3 should say "Quux"' do
|
31
|
+
@layout.column3.headerCell.stringValue.should == 'Quux'
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -17,7 +17,7 @@ describe 'Frame helpers' do
|
|
17
17
|
@view_size = CGSize.new(8, 10)
|
18
18
|
@view = NSView.alloc.initWithFrame([[0, 0], @view_size])
|
19
19
|
@view.backgroundColor = NSColor.whiteColor
|
20
|
-
@view
|
20
|
+
@layout.name_element(@view, :view)
|
21
21
|
|
22
22
|
@superview_size = CGSize.new(60, 40)
|
23
23
|
@superview = NSView.alloc.initWithFrame([[0, 0], @superview_size])
|
@@ -32,7 +32,7 @@ describe 'Frame helpers' do
|
|
32
32
|
|
33
33
|
@another_view = NSView.alloc.initWithFrame([[10, 100], [120, 48]])
|
34
34
|
@another_view.backgroundColor = NSColor.redColor
|
35
|
-
@another_view
|
35
|
+
@layout.name_element(@another_view, :another_view)
|
36
36
|
|
37
37
|
top_view.addSubview(@another_view)
|
38
38
|
top_view.addSubview(@superview)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motion-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin T.A. Gray
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dbt
|
@@ -48,7 +48,6 @@ files:
|
|
48
48
|
- lib/motion-kit/object.rb
|
49
49
|
- lib/motion-kit/util.rb
|
50
50
|
- lib/motion-kit/version.rb
|
51
|
-
- lib/motion-kit-cocoa/cocoa_util.rb
|
52
51
|
- lib/motion-kit-cocoa/constraints/constraint.rb
|
53
52
|
- lib/motion-kit-cocoa/constraints/constraint_placeholder.rb
|
54
53
|
- lib/motion-kit-cocoa/constraints/constraints_layout.rb
|
@@ -86,8 +85,10 @@ files:
|
|
86
85
|
- README.md
|
87
86
|
- spec/ios/apply_styles_spec.rb
|
88
87
|
- spec/ios/autoresizing_helper_spec.rb
|
88
|
+
- spec/ios/calayer_spec.rb
|
89
89
|
- spec/ios/calculate_spec.rb
|
90
90
|
- spec/ios/calculator_spec.rb
|
91
|
+
- spec/ios/child_layouts_spec.rb
|
91
92
|
- spec/ios/constraints_helpers/attribute_lookup_spec.rb
|
92
93
|
- spec/ios/constraints_helpers/axis_lookup_spec.rb
|
93
94
|
- spec/ios/constraints_helpers/center_constraints_spec.rb
|
@@ -96,6 +97,7 @@ files:
|
|
96
97
|
- spec/ios/constraints_helpers/relationship_lookup_spec.rb
|
97
98
|
- spec/ios/constraints_helpers/relative_corners_spec.rb
|
98
99
|
- spec/ios/constraints_helpers/relative_location_spec.rb
|
100
|
+
- spec/ios/constraints_helpers/scale_constraints_spec.rb
|
99
101
|
- spec/ios/constraints_helpers/simple_constraints_spec.rb
|
100
102
|
- spec/ios/constraints_helpers/size_constraints_spec.rb
|
101
103
|
- spec/ios/constraints_helpers/view_lookup_constraints_spec.rb
|
@@ -128,6 +130,7 @@ files:
|
|
128
130
|
- spec/osx/constraints_helpers/orientation_lookup_spec.rb
|
129
131
|
- spec/osx/constraints_helpers/simple_constraints_spec.rb
|
130
132
|
- spec/osx/constraints_helpers/size_constraints_spec.rb
|
133
|
+
- spec/osx/constraints_helpers/table_view_spec.rb
|
131
134
|
- spec/osx/create_menu_spec.rb
|
132
135
|
- spec/osx/create_via_extensions_spec.rb
|
133
136
|
- spec/osx/custom_root_layout_spec.rb
|
@@ -165,8 +168,10 @@ summary: The RubyMotion layout and styling gem.
|
|
165
168
|
test_files:
|
166
169
|
- spec/ios/apply_styles_spec.rb
|
167
170
|
- spec/ios/autoresizing_helper_spec.rb
|
171
|
+
- spec/ios/calayer_spec.rb
|
168
172
|
- spec/ios/calculate_spec.rb
|
169
173
|
- spec/ios/calculator_spec.rb
|
174
|
+
- spec/ios/child_layouts_spec.rb
|
170
175
|
- spec/ios/constraints_helpers/attribute_lookup_spec.rb
|
171
176
|
- spec/ios/constraints_helpers/axis_lookup_spec.rb
|
172
177
|
- spec/ios/constraints_helpers/center_constraints_spec.rb
|
@@ -175,6 +180,7 @@ test_files:
|
|
175
180
|
- spec/ios/constraints_helpers/relationship_lookup_spec.rb
|
176
181
|
- spec/ios/constraints_helpers/relative_corners_spec.rb
|
177
182
|
- spec/ios/constraints_helpers/relative_location_spec.rb
|
183
|
+
- spec/ios/constraints_helpers/scale_constraints_spec.rb
|
178
184
|
- spec/ios/constraints_helpers/simple_constraints_spec.rb
|
179
185
|
- spec/ios/constraints_helpers/size_constraints_spec.rb
|
180
186
|
- spec/ios/constraints_helpers/view_lookup_constraints_spec.rb
|
@@ -207,6 +213,7 @@ test_files:
|
|
207
213
|
- spec/osx/constraints_helpers/orientation_lookup_spec.rb
|
208
214
|
- spec/osx/constraints_helpers/simple_constraints_spec.rb
|
209
215
|
- spec/osx/constraints_helpers/size_constraints_spec.rb
|
216
|
+
- spec/osx/constraints_helpers/table_view_spec.rb
|
210
217
|
- spec/osx/create_menu_spec.rb
|
211
218
|
- spec/osx/create_via_extensions_spec.rb
|
212
219
|
- spec/osx/custom_root_layout_spec.rb
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module MotionKit
|
2
|
-
module_function
|
3
|
-
|
4
|
-
# performs a breadth-first search
|
5
|
-
def find_first_view(root, &condition)
|
6
|
-
if condition.call(root)
|
7
|
-
root
|
8
|
-
else
|
9
|
-
found = nil
|
10
|
-
root.subviews.find do |subview|
|
11
|
-
found = find_first_view(subview, &condition)
|
12
|
-
end
|
13
|
-
return found
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# performs a depth-first and reversed search
|
18
|
-
def find_last_view(root, &condition)
|
19
|
-
found = nil
|
20
|
-
root.subviews.reverse.find do |subview|
|
21
|
-
found = find_last_view(subview, &condition)
|
22
|
-
end
|
23
|
-
|
24
|
-
if ! found && condition.call(root)
|
25
|
-
found = root
|
26
|
-
end
|
27
|
-
|
28
|
-
return found
|
29
|
-
end
|
30
|
-
|
31
|
-
# performs a breadth-first search, but returns all matches
|
32
|
-
def find_all_views(root, &condition)
|
33
|
-
found = []
|
34
|
-
if condition.call(root)
|
35
|
-
found << root
|
36
|
-
end
|
37
|
-
|
38
|
-
(root.subviews || []).each do |subview|
|
39
|
-
found.concat(find_all_views(subview, &condition))
|
40
|
-
end
|
41
|
-
|
42
|
-
return found
|
43
|
-
end
|
44
|
-
|
45
|
-
# similar to find_all_views, but for CALayer
|
46
|
-
def find_all_layers(root, &condition)
|
47
|
-
found = []
|
48
|
-
if condition.call(root)
|
49
|
-
found << root
|
50
|
-
end
|
51
|
-
|
52
|
-
(root.sublayers || []).each do |sublayer|
|
53
|
-
found.concat(find_all_layers(sublayer, &condition))
|
54
|
-
end
|
55
|
-
|
56
|
-
return found
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|