rmx 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/Gemfile +7 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +40 -0
  6. data/Rakefile +18 -0
  7. data/app/app_delegate.rb +5 -0
  8. data/lib/motion/RMXActionSheet.rb +14 -0
  9. data/lib/motion/RMXAutoLayoutLabel.rb +19 -0
  10. data/lib/motion/RMXAutoLayoutScrollView.rb +53 -0
  11. data/lib/motion/RMXCommonMethods.rb +27 -0
  12. data/lib/motion/RMXEventsFromProxy.rb +103 -0
  13. data/lib/motion/RMXExecutionBlock.rb +51 -0
  14. data/lib/motion/RMXKeyboardHelpers.rb +54 -0
  15. data/lib/motion/RMXLongTask.rb +133 -0
  16. data/lib/motion/RMXNavigationController.rb +133 -0
  17. data/lib/motion/RMXObjectExtensions.rb +10 -0
  18. data/lib/motion/RMXSegmentedController.rb +71 -0
  19. data/lib/motion/RMXSetAttributes.rb +34 -0
  20. data/lib/motion/RMXStrongToWeakHash.rb +46 -0
  21. data/lib/motion/RMXSynchronizedStrongToWeakHash.rb +40 -0
  22. data/lib/motion/RMXTableHandler.rb +212 -0
  23. data/lib/motion/RMXTableViewCell.rb +85 -0
  24. data/lib/motion/RMXTableViewCellInnerContentView.rb +16 -0
  25. data/lib/motion/RMXTableViewController.rb +65 -0
  26. data/lib/motion/RMXUnsafeUnretainedHolder.rb +30 -0
  27. data/lib/motion/RMXView.rb +84 -0
  28. data/lib/motion/RMXViewController.rb +65 -0
  29. data/lib/motion/RMXViewControllerPresentation.rb +127 -0
  30. data/lib/motion/RMXWeakHolder.rb +36 -0
  31. data/lib/motion/RMXWeakToStrongHash.rb +39 -0
  32. data/lib/motion/accessors.rb +29 -0
  33. data/lib/motion/base.rb +12 -0
  34. data/lib/motion/env.rb +9 -0
  35. data/lib/motion/events.rb +61 -0
  36. data/lib/motion/layout.rb +357 -0
  37. data/lib/motion/ui.rb +55 -0
  38. data/lib/motion/util.rb +155 -0
  39. data/lib/rmx/version.rb +3 -0
  40. data/lib/rmx.rb +50 -0
  41. data/resources/Default-568h@2x.png +0 -0
  42. data/rmx.gemspec +19 -0
  43. data/spec/main_spec.rb +240 -0
  44. metadata +86 -0
data/spec/main_spec.rb ADDED
@@ -0,0 +1,240 @@
1
+ describe "Equation-style AutoLayout Constraints" do
2
+
3
+ def self.test_constraint_equation(c1_str, optional_desc=nil, &block)
4
+ it "#{optional_desc || c1_str}" do
5
+ c1 = @layout.eq c1_str
6
+ c2 = block.call
7
+ c1.priority.should == c2.priority
8
+ c1.firstItem.should == c2.firstItem
9
+ c1.firstAttribute.should == c2.firstAttribute
10
+ c1.relation.should == c2.relation
11
+ c1.secondItem.should == c2.secondItem
12
+ c1.secondAttribute.should == c2.secondAttribute
13
+ c1.multiplier.should == c2.multiplier
14
+ c1.constant.should == c2.constant
15
+ end
16
+ end
17
+
18
+ before do
19
+ @view = UIView.new
20
+ @label1 = UILabel.new
21
+ @label2 = UILabel.new
22
+ @layout = RMX::Layout.new
23
+ @layout.view @view
24
+ @layout.subviews({
25
+ "label1" => @label1,
26
+ "label2" => @label2
27
+ })
28
+ end
29
+
30
+ test_constraint_equation("label1.left == 0") do
31
+ NSLayoutConstraint.constraintWithItem(@label1,
32
+ attribute:NSLayoutAttributeLeft,
33
+ relatedBy:NSLayoutRelationEqual,
34
+ toItem:@view,
35
+ attribute:NSLayoutAttributeLeft,
36
+ multiplier:1.0,
37
+ constant:0)
38
+ end
39
+
40
+ test_constraint_equation("label1.left == 8") do
41
+ NSLayoutConstraint.constraintWithItem(@label1,
42
+ attribute:NSLayoutAttributeLeft,
43
+ relatedBy:NSLayoutRelationEqual,
44
+ toItem:@view,
45
+ attribute:NSLayoutAttributeLeft,
46
+ multiplier:1.0,
47
+ constant:8)
48
+ end
49
+
50
+ test_constraint_equation("label1.right == -20") do
51
+ NSLayoutConstraint.constraintWithItem(@label1,
52
+ attribute:NSLayoutAttributeRight,
53
+ relatedBy:NSLayoutRelationEqual,
54
+ toItem:@view,
55
+ attribute:NSLayoutAttributeRight,
56
+ multiplier:1.0,
57
+ constant:-20)
58
+ end
59
+
60
+ test_constraint_equation("label1.top == 0") do
61
+ NSLayoutConstraint.constraintWithItem(@label1,
62
+ attribute:NSLayoutAttributeTop,
63
+ relatedBy:NSLayoutRelationEqual,
64
+ toItem:@view,
65
+ attribute:NSLayoutAttributeTop,
66
+ multiplier:1.0,
67
+ constant:0)
68
+ end
69
+
70
+ test_constraint_equation("label1.bottom == -36") do
71
+ NSLayoutConstraint.constraintWithItem(@label1,
72
+ attribute:NSLayoutAttributeBottom,
73
+ relatedBy:NSLayoutRelationEqual,
74
+ toItem:@view,
75
+ attribute:NSLayoutAttributeBottom,
76
+ multiplier:1.0,
77
+ constant:-36)
78
+ end
79
+
80
+ test_constraint_equation("label1.height == 1") do
81
+ NSLayoutConstraint.constraintWithItem(@label1,
82
+ attribute:NSLayoutAttributeHeight,
83
+ relatedBy:NSLayoutRelationEqual,
84
+ toItem:nil,
85
+ attribute:NSLayoutAttributeNotAnAttribute,
86
+ multiplier:1.0,
87
+ constant:1)
88
+ end
89
+
90
+ test_constraint_equation("label1.centerX == 0") do
91
+ NSLayoutConstraint.constraintWithItem(@label1,
92
+ attribute:NSLayoutAttributeCenterX,
93
+ relatedBy:NSLayoutRelationEqual,
94
+ toItem:@view,
95
+ attribute:NSLayoutAttributeCenterX,
96
+ multiplier:1.0,
97
+ constant:0)
98
+ end
99
+
100
+ test_constraint_equation("label1.width == 1.5") do
101
+ NSLayoutConstraint.constraintWithItem(@label1,
102
+ attribute:NSLayoutAttributeWidth,
103
+ relatedBy:NSLayoutRelationEqual,
104
+ toItem:nil,
105
+ attribute:NSLayoutAttributeNotAnAttribute,
106
+ multiplier:1.0,
107
+ constant:1.5)
108
+ end
109
+
110
+ test_constraint_equation("label1.left >= 6") do
111
+ NSLayoutConstraint.constraintWithItem(@label1,
112
+ attribute:NSLayoutAttributeLeft,
113
+ relatedBy:NSLayoutRelationGreaterThanOrEqual,
114
+ toItem:@view,
115
+ attribute:NSLayoutAttributeLeft,
116
+ multiplier:1.0,
117
+ constant:6)
118
+ end
119
+
120
+ test_constraint_equation("label1.width == 0 @ low # prefer box hugs content") do
121
+ NSLayoutConstraint.constraintWithItem(@label1,
122
+ attribute:NSLayoutAttributeWidth,
123
+ relatedBy:NSLayoutRelationEqual,
124
+ toItem:nil,
125
+ attribute:NSLayoutAttributeNotAnAttribute,
126
+ multiplier:1.0,
127
+ constant:0).tap { |x| x.priority = UILayoutPriorityDefaultLow }
128
+ end
129
+
130
+ test_constraint_equation("label1.left == 24 @ low # this button prefers to hug the left") do
131
+ NSLayoutConstraint.constraintWithItem(@label1,
132
+ attribute:NSLayoutAttributeLeft,
133
+ relatedBy:NSLayoutRelationEqual,
134
+ toItem:@view,
135
+ attribute:NSLayoutAttributeLeft,
136
+ multiplier:1.0,
137
+ constant:24).tap { |x| x.priority = UILayoutPriorityDefaultLow }
138
+ end
139
+
140
+ test_constraint_equation("label1.top == view.top + 8") do
141
+ NSLayoutConstraint.constraintWithItem(@label1,
142
+ attribute:NSLayoutAttributeTop,
143
+ relatedBy:NSLayoutRelationEqual,
144
+ toItem:@view,
145
+ attribute:NSLayoutAttributeTop,
146
+ multiplier:1.0,
147
+ constant:8)
148
+ end
149
+
150
+ test_constraint_equation("label1.left == label2.left * 0.5 - 5") do
151
+ NSLayoutConstraint.constraintWithItem(@label1,
152
+ attribute:NSLayoutAttributeLeft,
153
+ relatedBy:NSLayoutRelationEqual,
154
+ toItem:@label2,
155
+ attribute:NSLayoutAttributeLeft,
156
+ multiplier:0.5,
157
+ constant:-5)
158
+ end
159
+
160
+ test_constraint_equation("label1.top == label2.top + 5") do
161
+ NSLayoutConstraint.constraintWithItem(@label1,
162
+ attribute:NSLayoutAttributeTop,
163
+ relatedBy:NSLayoutRelationEqual,
164
+ toItem:@label2,
165
+ attribute:NSLayoutAttributeTop,
166
+ multiplier:1.0,
167
+ constant:5)
168
+ end
169
+
170
+ test_constraint_equation("label1.top == label2.bottom") do
171
+ NSLayoutConstraint.constraintWithItem(@label1,
172
+ attribute:NSLayoutAttributeTop,
173
+ relatedBy:NSLayoutRelationEqual,
174
+ toItem:@label2,
175
+ attribute:NSLayoutAttributeBottom,
176
+ multiplier:1.0,
177
+ constant:0)
178
+ end
179
+
180
+ test_constraint_equation("label1.width == label2.width @ low # the widths of the labels prefer to be the same") do
181
+ NSLayoutConstraint.constraintWithItem(@label1,
182
+ attribute:NSLayoutAttributeWidth,
183
+ relatedBy:NSLayoutRelationEqual,
184
+ toItem:@label2,
185
+ attribute:NSLayoutAttributeWidth,
186
+ multiplier:1.0,
187
+ constant:0).tap { |x| x.priority = UILayoutPriorityDefaultLow }
188
+ end
189
+
190
+ test_constraint_equation("label1.left == label2.right + 20") do
191
+ NSLayoutConstraint.constraintWithItem(@label1,
192
+ attribute:NSLayoutAttributeLeft,
193
+ relatedBy:NSLayoutRelationEqual,
194
+ toItem:@label2,
195
+ attribute:NSLayoutAttributeRight,
196
+ multiplier:1.0,
197
+ constant:20)
198
+ end
199
+
200
+ test_constraint_equation("label1.centerY == label2.centerY") do
201
+ NSLayoutConstraint.constraintWithItem(@label1,
202
+ attribute:NSLayoutAttributeCenterY,
203
+ relatedBy:NSLayoutRelationEqual,
204
+ toItem:@label2,
205
+ attribute:NSLayoutAttributeCenterY,
206
+ multiplier:1.0,
207
+ constant:0)
208
+ end
209
+
210
+ test_constraint_equation("label1.left >= label2.right + 6") do
211
+ NSLayoutConstraint.constraintWithItem(@label1,
212
+ attribute:NSLayoutAttributeLeft,
213
+ relatedBy:NSLayoutRelationGreaterThanOrEqual,
214
+ toItem:@label2,
215
+ attribute:NSLayoutAttributeRight,
216
+ multiplier:1.0,
217
+ constant:6)
218
+ end
219
+
220
+ test_constraint_equation("label1.right <= view.right - 8") do
221
+ NSLayoutConstraint.constraintWithItem(@label1,
222
+ attribute:NSLayoutAttributeRight,
223
+ relatedBy:NSLayoutRelationLessThanOrEqual,
224
+ toItem:@view,
225
+ attribute:NSLayoutAttributeRight,
226
+ multiplier:1.0,
227
+ constant:-8)
228
+ end
229
+
230
+ test_constraint_equation("label1.right <= label2.left - 10") do
231
+ NSLayoutConstraint.constraintWithItem(@label1,
232
+ attribute:NSLayoutAttributeRight,
233
+ relatedBy:NSLayoutRelationLessThanOrEqual,
234
+ toItem:@label2,
235
+ attribute:NSLayoutAttributeLeft,
236
+ multiplier:1.0,
237
+ constant:-10)
238
+ end
239
+
240
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rmx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
+ platform: ruby
6
+ authors:
7
+ - Joe Noon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-23 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Extensions and helpers for dealing with various areas of rubymotion
14
+ email:
15
+ - joenoon@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - .gitignore
21
+ - Gemfile
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - app/app_delegate.rb
26
+ - lib/motion/RMXActionSheet.rb
27
+ - lib/motion/RMXAutoLayoutLabel.rb
28
+ - lib/motion/RMXAutoLayoutScrollView.rb
29
+ - lib/motion/RMXCommonMethods.rb
30
+ - lib/motion/RMXEventsFromProxy.rb
31
+ - lib/motion/RMXExecutionBlock.rb
32
+ - lib/motion/RMXKeyboardHelpers.rb
33
+ - lib/motion/RMXLongTask.rb
34
+ - lib/motion/RMXNavigationController.rb
35
+ - lib/motion/RMXObjectExtensions.rb
36
+ - lib/motion/RMXSegmentedController.rb
37
+ - lib/motion/RMXSetAttributes.rb
38
+ - lib/motion/RMXStrongToWeakHash.rb
39
+ - lib/motion/RMXSynchronizedStrongToWeakHash.rb
40
+ - lib/motion/RMXTableHandler.rb
41
+ - lib/motion/RMXTableViewCell.rb
42
+ - lib/motion/RMXTableViewCellInnerContentView.rb
43
+ - lib/motion/RMXTableViewController.rb
44
+ - lib/motion/RMXUnsafeUnretainedHolder.rb
45
+ - lib/motion/RMXView.rb
46
+ - lib/motion/RMXViewController.rb
47
+ - lib/motion/RMXViewControllerPresentation.rb
48
+ - lib/motion/RMXWeakHolder.rb
49
+ - lib/motion/RMXWeakToStrongHash.rb
50
+ - lib/motion/accessors.rb
51
+ - lib/motion/base.rb
52
+ - lib/motion/env.rb
53
+ - lib/motion/events.rb
54
+ - lib/motion/layout.rb
55
+ - lib/motion/ui.rb
56
+ - lib/motion/util.rb
57
+ - lib/rmx.rb
58
+ - lib/rmx/version.rb
59
+ - resources/Default-568h@2x.png
60
+ - rmx.gemspec
61
+ - spec/main_spec.rb
62
+ homepage: https://github.com/joenoon/rmx
63
+ licenses: []
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.0.14
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Extensions and helpers for dealing with various areas of rubymotion
85
+ test_files:
86
+ - spec/main_spec.rb