motion-kit 0.9.2 → 0.9.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 462ad96599e3e4f19a827b86bdb8cf45e5dbe8d1
|
4
|
+
data.tar.gz: 7475ddcdd1b7827558b340287a06df1da1fa7208
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe0754471c569422d35378c26efd2b7c74e41fecf75d95f6c747af6ddc24105d8285b2b8eb11bcf554fcee76f5556bf97f387a6bafd2b66e20a75c70110894be
|
7
|
+
data.tar.gz: fa2b166f5e8b7e471000038831cda72f6f002b67b5bbdd1b7fd8bec56e39d77036557141d08191a98cf4a0417a233ea41f1acde4b29e0683bd1cd2d4bd416d5c
|
data/README.md
CHANGED
@@ -675,32 +675,6 @@ relative_to foo, down: 5, right: 5
|
|
675
675
|
from_bottom_left foo, up: 5, left: 5
|
676
676
|
```
|
677
677
|
|
678
|
-
### Constraints / AutoLayout
|
679
|
-
|
680
|
-
Inside a `constraints` block you can use the same helpers as above, but you'll
|
681
|
-
be using AutoLayout instead!
|
682
|
-
|
683
|
-
```ruby
|
684
|
-
constraints do
|
685
|
-
from_top_left x: 5, y: 5
|
686
|
-
end
|
687
|
-
```
|
688
|
-
|
689
|
-
But of course with constraints you can setup *relationships* between views.
|
690
|
-
|
691
|
-
```ruby
|
692
|
-
foo = self.get(:foo)
|
693
|
-
constraints do
|
694
|
-
from_top_left x: 5, y:5
|
695
|
-
from_top_left down: 5, right:5
|
696
|
-
width.equals(foo).minus(10)
|
697
|
-
height.equals(foo).minus(10)
|
698
|
-
# that's repetitive, so just set 'size'
|
699
|
-
size.equals(foo).minus(10)
|
700
|
-
size.equals(foo).minus([10, 15]) # 10pt thinner, 15pt shorter
|
701
|
-
end
|
702
|
-
```
|
703
|
-
|
704
678
|
|
705
679
|
### Some handy tricks
|
706
680
|
|
@@ -1,38 +1,18 @@
|
|
1
|
+
# These methods are defined in SugarCube's REPL helpers, but we want them to be
|
2
|
+
# delegated to either `UIViewLayout#frame` or `CALayer#setFrame`
|
3
|
+
#
|
1
4
|
# @requires MotionKit::BaseLayout
|
2
5
|
module MotionKit
|
3
6
|
class BaseLayout
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def right(*values)
|
14
|
-
apply(:right, *values)
|
15
|
-
end
|
16
|
-
|
17
|
-
def up(*values)
|
18
|
-
apply(:up, *values)
|
19
|
-
end
|
20
|
-
|
21
|
-
def down(*values)
|
22
|
-
apply(:down, *values)
|
23
|
-
end
|
24
|
-
|
25
|
-
def origin(*values)
|
26
|
-
apply(:origin, *values)
|
27
|
-
end
|
28
|
-
|
29
|
-
def size(*values)
|
30
|
-
apply(:size, *values)
|
31
|
-
end
|
32
|
-
|
33
|
-
def center(*values)
|
34
|
-
apply(:center, *values)
|
35
|
-
end
|
8
|
+
delegate_method_fix :frame
|
9
|
+
delegate_method_fix :left
|
10
|
+
delegate_method_fix :right
|
11
|
+
delegate_method_fix :up
|
12
|
+
delegate_method_fix :down
|
13
|
+
delegate_method_fix :origin
|
14
|
+
delegate_method_fix :size
|
15
|
+
delegate_method_fix :center
|
36
16
|
|
37
17
|
end
|
38
18
|
end
|
@@ -4,13 +4,15 @@ module MotionKit
|
|
4
4
|
|
5
5
|
# gradient colors:
|
6
6
|
def gradient(&block)
|
7
|
-
gradient_layer = target.motion_kit_meta
|
7
|
+
gradient_layer = target.motion_kit_meta[:motionkit_gradient_layer] || begin
|
8
8
|
gradient_layer = CAGradientLayer.layer
|
9
9
|
gradient_layer.frame = CGRect.new([0, 0], target.frame.size)
|
10
10
|
target.layer.insertSublayer(gradient_layer, atIndex:0)
|
11
|
+
target.motion_kit_meta[:motionkit_gradient_layer] = gradient_layer
|
11
12
|
|
12
13
|
gradient_layer
|
13
14
|
end
|
15
|
+
|
14
16
|
context(gradient_layer, &block)
|
15
17
|
|
16
18
|
gradient_layer
|
@@ -276,6 +276,26 @@ module MotionKit
|
|
276
276
|
@overridden_methods ||= []
|
277
277
|
end
|
278
278
|
|
279
|
+
# Prevents infinite loops when methods that are defined on Object/Kernel
|
280
|
+
# are not properly delegated to the target.
|
281
|
+
def delegate_method_fix(method_name)
|
282
|
+
running_name = "motion_kit_is_calling_#{method_name}"
|
283
|
+
define_method(method_name) do |*args, &block|
|
284
|
+
if target.motion_kit_meta[running_name]
|
285
|
+
if block
|
286
|
+
apply_with_context(method_name, *args, &block)
|
287
|
+
else
|
288
|
+
apply_with_target(method_name, *args)
|
289
|
+
end
|
290
|
+
else
|
291
|
+
target.motion_kit_meta[running_name] = true
|
292
|
+
retval = apply(method_name, *args)
|
293
|
+
target.motion_kit_meta[running_name] = false
|
294
|
+
return retval
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
279
299
|
# this last little "catch-all" method is helpful to warn against methods
|
280
300
|
# that are defined already. Since magic methods are so important, this
|
281
301
|
# warning can come in handy.
|
data/lib/motion-kit/version.rb
CHANGED