motion-layout 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4f42af24024b537423331b8b2285825e9d7857d5
4
+ data.tar.gz: 3b5390b2f8861cf387dc67cad41f0f9d93b62d6e
5
+ SHA512:
6
+ metadata.gz: ba2dde578ce4440ab16c19f7a0b0dcb02bd1ea869007f418d20c2c1e1b3e4a49a3556e848896cfc283ffd5011a28009d00819aa24f9bce6754df240aa6be98c1
7
+ data.tar.gz: 84fa6e2e52e1fce4c484ff093f803cb96bc5ca09ae99ff7da3b04c5e5255c088d66495feb84c9948375fe16f5b782dae3cd4b60492427f1c4bd4f4631e69be7d
data/README.md CHANGED
@@ -22,7 +22,7 @@ Then in your `Rakefile`:
22
22
 
23
23
  ## Usage
24
24
 
25
- Using AutoLayout is a way to put UI elements in your iPhone app without using Interface Builder, and without being very specific about pixel sizes, locations, etc. The layout strings are ASCII inspired, and Apple's documentation on the [Visual Format Language](http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/AutolayoutPG/Articles/formatLanguage.html#//apple_ref/doc/uid/TP40010853-CH3-SW1) is a necessary read and reference.
25
+ Using AutoLayout is a way to put UI elements in your iPhone app without using Interface Builder, and without being very specific about pixel sizes, locations, etc. The layout strings are ASCII inspired, and Apple's documentation on the [Visual Format Language](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage/VisualFormatLanguage.html) is a necessary read and reference.
26
26
 
27
27
  Here's an example of `Motion::Layout` usage from inside of [Basecamp for iPhone](https://itunes.apple.com/us/app/id599139477) on a `UITableView`'s `tableFooterView`:
28
28
 
@@ -45,7 +45,7 @@ And here's an example you can run right inside this repo, the Time app converted
45
45
  ``` ruby
46
46
  Motion::Layout.new do |layout|
47
47
  layout.view view
48
- layout.subviews "state" => @state, "action" => @action
48
+ layout.subviews state: @state, action: @action
49
49
  layout.metrics "top" => 200, "margin" => 20, "height" => 40
50
50
  layout.vertical "|-top-[state(==height)]-margin-[action(==height)]"
51
51
  layout.horizontal "|-margin-[state]-margin-|"
@@ -10,11 +10,11 @@ module Motion
10
10
  end
11
11
 
12
12
  def metrics(metrics)
13
- @metrics = metrics
13
+ @metrics = Hash[metrics.keys.map(&:to_s).zip(metrics.values)]
14
14
  end
15
15
 
16
16
  def subviews(subviews)
17
- @subviews = subviews
17
+ @subviews = Hash[subviews.keys.map(&:to_s).zip(subviews.values)]
18
18
  end
19
19
 
20
20
  def view(view)
@@ -34,15 +34,17 @@ module Motion
34
34
  def strain
35
35
  @subviews.values.each do |subview|
36
36
  subview.translatesAutoresizingMaskIntoConstraints = false
37
- @view.addSubview(subview)
37
+ @view.addSubview(subview) unless subview.superview
38
38
  end
39
39
 
40
+ views = @subviews.merge("superview" => @view)
41
+
40
42
  constraints = []
41
43
  constraints += @verticals.map do |vertical|
42
- NSLayoutConstraint.constraintsWithVisualFormat("V:#{vertical}", options:NSLayoutFormatAlignAllCenterX, metrics:@metrics, views:@subviews)
44
+ NSLayoutConstraint.constraintsWithVisualFormat("V:#{vertical}", options:NSLayoutFormatAlignAllCenterX, metrics:@metrics, views:views)
43
45
  end
44
46
  constraints += @horizontals.map do |horizontal|
45
- NSLayoutConstraint.constraintsWithVisualFormat("H:#{horizontal}", options:NSLayoutFormatAlignAllCenterY, metrics:@metrics, views:@subviews)
47
+ NSLayoutConstraint.constraintsWithVisualFormat("H:#{horizontal}", options:NSLayoutFormatAlignAllCenterY, metrics:@metrics, views:views)
46
48
  end
47
49
 
48
50
  @view.addConstraints(constraints.flatten)
@@ -1,5 +1,5 @@
1
1
  module Motion
2
2
  class Layout
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-layout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nick Quaranto
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-31 00:00:00.000000000 Z
11
+ date: 2014-01-27 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: A nice way to use iOS6+ autolayout in your RubyMotion app. Use ASCII-art
15
14
  inspired format strings to build your app's layout!
@@ -36,27 +35,26 @@ files:
36
35
  - screenshot2.png
37
36
  homepage: https://github.com/qrush/motion-layout
38
37
  licenses: []
38
+ metadata: {}
39
39
  post_install_message:
40
40
  rdoc_options: []
41
41
  require_paths:
42
42
  - lib
43
43
  required_ruby_version: !ruby/object:Gem::Requirement
44
- none: false
45
44
  requirements:
46
- - - ! '>='
45
+ - - '>='
47
46
  - !ruby/object:Gem::Version
48
47
  version: '0'
49
48
  required_rubygems_version: !ruby/object:Gem::Requirement
50
- none: false
51
49
  requirements:
52
- - - ! '>='
50
+ - - '>='
53
51
  - !ruby/object:Gem::Version
54
52
  version: '0'
55
53
  requirements: []
56
54
  rubyforge_project:
57
- rubygems_version: 1.8.23
55
+ rubygems_version: 2.2.1
58
56
  signing_key:
59
- specification_version: 3
57
+ specification_version: 4
60
58
  summary: A nice way to use iOS6+ autolayout in your RubyMotion app. Use ASCII-art
61
59
  inspired format strings to build your app's layout!
62
60
  test_files: []