motion-kit 0.11.2 → 0.12.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 +15 -12
- data/lib/motion-kit-cocoa/constraints/{constraints_layout.rb → constraints_helpers.rb} +2 -2
- data/lib/motion-kit-cocoa/layouts/{cagradientlayer_layout.rb → cagradientlayer_helpers.rb} +3 -3
- data/lib/motion-kit-cocoa/layouts/{calayer_layout.rb → calayer_helpers.rb} +2 -2
- data/lib/motion-kit-cocoa/layouts/sugarcube_compat.rb +1 -1
- data/lib/motion-kit-ios/deprecated.rb +31 -0
- data/lib/motion-kit-ios/layouts/{constraints_layout.rb → constraints_helpers.rb} +2 -2
- data/lib/motion-kit-ios/layouts/{uibutton_layout.rb → uibutton_helpers.rb} +3 -3
- data/lib/motion-kit-ios/layouts/{uiview_layout.rb → uiview_helpers.rb} +2 -2
- data/lib/motion-kit-ios/layouts/uiview_layout_autoresizing.rb +2 -2
- data/lib/motion-kit-ios/layouts/uiview_layout_constraints.rb +2 -2
- data/lib/motion-kit-ios/layouts/uiview_layout_frame.rb +2 -2
- data/lib/motion-kit-ios/layouts/uiview_layout_gradient.rb +2 -2
- data/lib/motion-kit-osx/deprecated.rb +52 -0
- data/lib/motion-kit-osx/layouts/{constraints_layout.rb → constraints_helpers.rb} +2 -2
- data/lib/motion-kit-osx/layouts/nsmenu_extensions.rb +2 -2
- data/lib/motion-kit-osx/layouts/{nsmenu_layout.rb → nsmenu_helpers.rb} +2 -2
- data/lib/motion-kit-osx/layouts/nsmenuitem_extensions.rb +2 -2
- data/lib/motion-kit-osx/layouts/{nstablecolumn_layout.rb → nstablecolumn_helpers.rb} +2 -2
- data/lib/motion-kit-osx/layouts/{nstableview_layout.rb → nstableview_helpers.rb} +3 -3
- data/lib/motion-kit-osx/layouts/{nsview_layout.rb → nsview_helpers.rb} +2 -2
- data/lib/motion-kit-osx/layouts/nsview_layout_autoresizing.rb +2 -2
- data/lib/motion-kit-osx/layouts/nsview_layout_constraints.rb +2 -2
- data/lib/motion-kit-osx/layouts/nsview_layout_frame.rb +2 -2
- data/lib/motion-kit-osx/layouts/nswindow_frame.rb +2 -2
- data/lib/motion-kit-osx/layouts/{nswindow_layout.rb → nswindow_helpers.rb} +2 -2
- data/lib/motion-kit/layouts/base_layout.rb +1 -1
- data/lib/motion-kit/version.rb +1 -1
- data/spec/ios/layer_layout_spec.rb +3 -3
- data/spec/ios/layout_extensions_spec.rb +1 -1
- data/spec/osx/constraints_helpers/simple_constraints_spec.rb +166 -159
- data/spec/osx/menu_extensions_spec.rb +2 -2
- data/spec/osx/{constraints_helpers/table_view_spec.rb → table_view_spec.rb} +1 -1
- metadata +17 -17
- data/spec/osx/constraints_helper_spec.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1027d089bb3ce6aafe9f4f55d152a6e3c22a4511
|
4
|
+
data.tar.gz: 7e6b2b1bca51e2d3e0aae3d71a2adb76cf31c768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f45d382fbffb1edea0cf1f4f53ca14344d997de32441319a4978d428fecf5721fe32f51e67c37437e28f335b932ab3ee3747059e6c269ec1f96df15f5bf032c2
|
7
|
+
data.tar.gz: 02332a86a6625fa6175423524e4bc94865a34c2d7da9a39318699edd144dea3e54893276c38331680e736ba64c67280a68284aa4852fdb31baaf99f2f8edf3b5
|
data/README.md
CHANGED
@@ -354,7 +354,7 @@ that take multiple arguments. Those can get "helper" methods.
|
|
354
354
|
# title on a UIButton
|
355
355
|
def login_button_style
|
356
356
|
title 'Press me'
|
357
|
-
# this gets delegated to
|
357
|
+
# this gets delegated to UIButtonHelpers#title(title), which in turn calls
|
358
358
|
# button.setTitle(title, forState: UIControlStateNormal)
|
359
359
|
end
|
360
360
|
```
|
@@ -383,15 +383,18 @@ Introspection and method_missing add a little overhead to your code, but in our
|
|
383
383
|
benchmarking it is insignificant and undetectable. Let us know if you find any
|
384
384
|
performance issues.
|
385
385
|
|
386
|
-
You can easily add your own helpers to MotionKit
|
387
|
-
are all named consistenly, e.g. `MotionKit::
|
388
|
-
`MotionKit::
|
386
|
+
You can easily add your own helpers to MotionKit. They
|
387
|
+
are all named consistenly, e.g. `MotionKit::UIViewHelpers`, e.g.
|
388
|
+
`MotionKit::UILabelHelpers`. You just need to specify the "target class" that
|
389
|
+
your helper class is meant to work with. Each class can only have *one helper
|
390
|
+
class*.
|
389
391
|
|
390
392
|
```ruby
|
391
393
|
module MotionKit
|
392
394
|
# these helpers will only be applied to instances of UILabel and UILabel
|
393
395
|
# subclasses
|
394
|
-
class
|
396
|
+
class UILabelHelpers < UIViewHelpers
|
397
|
+
targets UILabel
|
395
398
|
|
396
399
|
# style methods can accept any number of arguments, and a block. The current
|
397
400
|
# view should be referred to via the method `target`
|
@@ -426,19 +429,19 @@ end
|
|
426
429
|
|
427
430
|
For your own custom classes, or when you want to write
|
428
431
|
helper methods for a built-in class, you will need to write a class that
|
429
|
-
"`targets`" that class. This will be a subclass of `MK::
|
432
|
+
"`targets`" that class. This will be a subclass of `MK::UIViewHelpers`; it looks
|
430
433
|
and *feels* like a `MK::Layout` subclass, but these classes are used to extend
|
431
434
|
the MotionKit DSL, and should not be instantiated or used to build layouts.
|
432
435
|
|
433
436
|
Again, to be clear: you should be subclassing `MK::Layout` when you build your
|
434
|
-
controller layouts, and you should write a subclass of `MK::
|
437
|
+
controller layouts, and you should write a subclass of `MK::UIViewHelpers` *only*
|
435
438
|
when you are adding extensions to the MotionKit DSL.
|
436
439
|
|
437
440
|
```ruby
|
438
|
-
# Be sure to extend an existing
|
439
|
-
# functionality. Often this will be `MK::
|
440
|
-
# `MK::
|
441
|
-
class
|
441
|
+
# Be sure to extend an existing Helpers class, otherwise you'll lose a lot of
|
442
|
+
# functionality. Often this will be `MK::UIViewHelpers` on iOS and
|
443
|
+
# `MK::NSViewHelpers` on OS X.
|
444
|
+
class CustomViewHelpers < MK::UIViewHelpers
|
442
445
|
targets CustomView
|
443
446
|
|
444
447
|
def fore_color(value)
|
@@ -707,7 +710,7 @@ view, you need to use a separate method that is called after the view hierarchy
|
|
707
710
|
is created.
|
708
711
|
|
709
712
|
```ruby
|
710
|
-
class MainLayout <
|
713
|
+
class MainLayout < MK::Layout
|
711
714
|
|
712
715
|
def layout
|
713
716
|
add UILabel, :label do
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# @provides MotionKit::
|
1
|
+
# @provides MotionKit::ConstraintsHelpers
|
2
2
|
# @requires MotionKit::BaseLayout
|
3
3
|
# @requires MotionKit::ConstraintsTarget
|
4
4
|
module MotionKit
|
5
|
-
class
|
5
|
+
class ConstraintsHelpers < BaseLayout
|
6
6
|
targets ConstraintsTarget
|
7
7
|
|
8
8
|
# A more sensible name for the constraint that is created.
|
@@ -1,8 +1,8 @@
|
|
1
|
-
# @provides MotionKit::
|
2
|
-
# @requires MotionKit::
|
1
|
+
# @provides MotionKit::CAGradientLayerHelpers
|
2
|
+
# @requires MotionKit::CALayerHelpers
|
3
3
|
# @requires MotionKit::TreeLayout
|
4
4
|
module MotionKit
|
5
|
-
class
|
5
|
+
class CAGradientLayerHelpers < CALayerHelpers
|
6
6
|
targets CAGradientLayer
|
7
7
|
|
8
8
|
def colors(values)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# These methods are defined in SugarCube's REPL helpers, but we want them to be
|
2
|
-
# delegated to either `
|
2
|
+
# delegated to either `UIViewHelpers#frame` or `CALayer#setFrame`
|
3
3
|
#
|
4
4
|
# @requires MotionKit::BaseLayout
|
5
5
|
module MotionKit
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# @requires MotionKit::UIViewHelpers
|
2
|
+
# @requires MotionKit::UIButtonHelpers
|
3
|
+
# @requires MotionKit::CALayerHelpers
|
4
|
+
# @requires MotionKit::CAGradientLayerHelpers
|
5
|
+
module MotionKit
|
6
|
+
|
7
|
+
class UIViewLayout < UIViewHelpers
|
8
|
+
def self.inherited(subclass)
|
9
|
+
NSLog("Sorry! MotionKit changed. UIViewLayout is now UIViewHelpers. Update #{subclass} to extend from UIViewHelpers.")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class UIButtonLayout < UIButtonHelpers
|
14
|
+
def self.inherited(subclass)
|
15
|
+
NSLog("Sorry! MotionKit changed. UIButtonLayout is now UIButtonHelpers. Update #{subclass} to extend from UIButtonHelpers.")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class CALayerLayout < CALayerHelpers
|
20
|
+
def self.inherited(subclass)
|
21
|
+
NSLog("Sorry! MotionKit changed. CALayerLayout is now CALayerHelpers. Update #{subclass} to extend from CALayerHelpers.")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class CAGradientLayerLayout < CAGradientLayerHelpers
|
26
|
+
def self.inherited(subclass)
|
27
|
+
NSLog("Sorry! MotionKit changed. CAGradientLayerLayout is now CAGradientLayerHelpers. Update #{subclass} to extend from CAGradientLayerHelpers.")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# @provides MotionKit::
|
2
|
-
# @requires MotionKit::
|
1
|
+
# @provides MotionKit::UIButtonHelpers
|
2
|
+
# @requires MotionKit::UIViewHelpers
|
3
3
|
module MotionKit
|
4
|
-
class
|
4
|
+
class UIButtonHelpers < UIViewHelpers
|
5
5
|
targets UIButton
|
6
6
|
|
7
7
|
def title(value)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# @provides MotionKit::Layout
|
2
|
-
# @provides MotionKit::
|
2
|
+
# @provides MotionKit::UIViewHelpers
|
3
3
|
# @requires MotionKit::TreeLayout
|
4
4
|
module MotionKit
|
5
5
|
class Layout < TreeLayout
|
@@ -21,7 +21,7 @@ module MotionKit
|
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
-
class
|
24
|
+
class UIViewHelpers < Layout
|
25
25
|
targets UIView
|
26
26
|
end
|
27
27
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# @requires MotionKit::NSWindowHelpers
|
2
|
+
# @requires MotionKit::NSViewHelpers
|
3
|
+
# @requires MotionKit::NSTableViewHelpers
|
4
|
+
# @requires MotionKit::NSTableColumnHelpers
|
5
|
+
# @requires MotionKit::NSMenuHelpers
|
6
|
+
# @requires MotionKit::CALayerHelpers
|
7
|
+
# @requires MotionKit::CAGradientLayerHelpers
|
8
|
+
module MotionKit
|
9
|
+
|
10
|
+
class NSWindowLayout < NSWindowHelpers
|
11
|
+
def self.inherited(subclass)
|
12
|
+
NSLog("Sorry! MotionKit changed. NSWindowLayout is now NSWindowHelpers. Update #{subclass} to extend from NSWindowHelpers.")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class NSViewLayout < NSViewHelpers
|
17
|
+
def self.inherited(subclass)
|
18
|
+
NSLog("Sorry! MotionKit changed. NSViewLayout is now NSViewHelpers. Update #{subclass} to extend from NSViewHelpers.")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class NSTableViewLayout < NSTableViewHelpers
|
23
|
+
def self.inherited(subclass)
|
24
|
+
NSLog("Sorry! MotionKit changed. NSTableViewLayout is now NSTableViewHelpers. Update #{subclass} to extend from NSTableViewHelpers.")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class NSTableColumnLayout < NSTableColumnHelpers
|
29
|
+
def self.inherited(subclass)
|
30
|
+
NSLog("Sorry! MotionKit changed. NSTableColumnLayout is now NSTableColumnHelpers. Update #{subclass} to extend from NSTableColumnHelpers.")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class NSMenuLayout < NSMenuHelpers
|
35
|
+
def self.inherited(subclass)
|
36
|
+
NSLog("Sorry! MotionKit changed. NSMenuLayout is now NSMenuHelpers. Update #{subclass} to extend from NSMenuHelpers.")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class CALayerLayout < CALayerHelpers
|
41
|
+
def self.inherited(subclass)
|
42
|
+
NSLog("Sorry! MotionKit changed. CALayerLayout is now CALayerHelpers. Update #{subclass} to extend from CALayerHelpers.")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class CAGradientLayerLayout < CAGradientLayerHelpers
|
47
|
+
def self.inherited(subclass)
|
48
|
+
NSLog("Sorry! MotionKit changed. CAGradientLayerLayout is now CAGradientLayerHelpers. Update #{subclass} to extend from CAGradientLayerHelpers.")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# @requires MotionKit::
|
1
|
+
# @requires MotionKit::NSViewHelpers
|
2
2
|
module MotionKit
|
3
|
-
class
|
3
|
+
class NSViewHelpers
|
4
4
|
|
5
5
|
def content_compression_resistance_priority(value, for_orientation: orientation)
|
6
6
|
orientation = Constraint.orientation_lookup(orientation)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# @provides MotionKit::MenuLayout
|
2
|
-
# @provides MotionKit::
|
2
|
+
# @provides MotionKit::NSMenuHelpers
|
3
3
|
# @requires MotionKit::TreeLayout
|
4
4
|
module MotionKit
|
5
5
|
class MenuLayout < TreeLayout
|
@@ -103,7 +103,7 @@ module MotionKit
|
|
103
103
|
|
104
104
|
end
|
105
105
|
|
106
|
-
class
|
106
|
+
class NSMenuHelpers < MenuLayout
|
107
107
|
targets NSMenu
|
108
108
|
end
|
109
109
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# @provides MotionKit::
|
1
|
+
# @provides MotionKit::NSTableColumnHelpers
|
2
2
|
# @requires MotionKit::BaseLayout
|
3
3
|
module MotionKit
|
4
|
-
class
|
4
|
+
class NSTableColumnHelpers < BaseLayout
|
5
5
|
targets NSTableColumn
|
6
6
|
|
7
7
|
def title(value)
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# @provides MotionKit::
|
2
|
-
# @requires MotionKit::
|
1
|
+
# @provides MotionKit::NSTableViewHelpers
|
2
|
+
# @requires MotionKit::NSViewHelpers
|
3
3
|
module MotionKit
|
4
|
-
class
|
4
|
+
class NSTableViewHelpers < NSViewHelpers
|
5
5
|
targets NSTableView
|
6
6
|
|
7
7
|
def add_column(column_or_identifier, &block)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# @provides MotionKit::Layout
|
2
|
-
# @provides MotionKit::
|
2
|
+
# @provides MotionKit::NSViewHelpers
|
3
3
|
# @requires MotionKit::TreeLayout
|
4
4
|
module MotionKit
|
5
5
|
class Layout < TreeLayout
|
@@ -21,7 +21,7 @@ module MotionKit
|
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
-
class
|
24
|
+
class NSViewHelpers < Layout
|
25
25
|
targets NSView
|
26
26
|
end
|
27
27
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# @provides MotionKit::WindowLayout
|
2
|
-
# @provides MotionKit::
|
2
|
+
# @provides MotionKit::NSWindowHelpers
|
3
3
|
# @requires MotionKit::TreeLayout
|
4
4
|
module MotionKit
|
5
5
|
class WindowLayout < TreeLayout
|
@@ -29,7 +29,7 @@ module MotionKit
|
|
29
29
|
|
30
30
|
end
|
31
31
|
|
32
|
-
class
|
32
|
+
class NSWindowHelpers < WindowLayout
|
33
33
|
targets NSWindow
|
34
34
|
end
|
35
35
|
|
@@ -84,7 +84,7 @@ module MotionKit
|
|
84
84
|
# # passing a block to a method that returns an object. That object becomes
|
85
85
|
# # the new context.
|
86
86
|
# layer do
|
87
|
-
# #
|
87
|
+
# # target is now a CALayer, and methods are delegated to CALayerHelpers
|
88
88
|
# corner_radius 5
|
89
89
|
# end
|
90
90
|
# end
|