teacup 2.1.1 → 2.1.2

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- teacup (2.1.1)
4
+ teacup (2.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,11 +2,13 @@ class MotionLayoutController < UIViewController
2
2
  attr :label1
3
3
  attr :label2
4
4
  attr :label3
5
+ attr :container
5
6
 
6
7
  layout :root do
7
8
  @label1 = subview(UILabel, :label1, text: 'label1')
8
9
  @label2 = subview(UILabel, :label2, text: 'label2')
9
10
  @label3 = subview(UILabel, :label3, text: 'label3')
11
+ @container = subview(CustomContainer, :container)
10
12
  end
11
13
 
12
14
  def layoutDidLoad
@@ -14,8 +16,20 @@ class MotionLayoutController < UIViewController
14
16
  metrics "margin" => 20, "top" => 100
15
17
  horizontal '|-margin-[label1]-margin-[label2(==label1)]-margin-|'
16
18
  horizontal '|-margin-[label3]-margin-|'
19
+ horizontal '|-margin-[container]-margin-|'
17
20
  vertical '|-top-[label1]'
18
21
  vertical '|-220-[label3(==label1)]'
22
+ vertical '|-320-[container(==label1)]'
23
+ end
24
+ end
25
+
26
+ class CustomContainer < UIView
27
+ attr :label4
28
+
29
+ def init
30
+ super.tap do
31
+ @label4 = subview(UILabel, :label4, text: 'label4')
32
+ end
19
33
  end
20
34
  end
21
35
 
@@ -44,69 +44,69 @@ module Teacup
44
44
  case sym
45
45
  when :full
46
46
  [
47
- Teacup::Constraint.new(:self, :left).equals(relative_to, :left),
48
- Teacup::Constraint.new(:self, :top).equals(relative_to, :top),
49
- Teacup::Constraint.new(:self, :width).equals(relative_to, :width),
50
- Teacup::Constraint.new(:self, :height).equals(relative_to, :height),
47
+ self.new(:self, :left).equals(relative_to, :left),
48
+ self.new(:self, :top).equals(relative_to, :top),
49
+ self.new(:self, :width).equals(relative_to, :width),
50
+ self.new(:self, :height).equals(relative_to, :height),
51
51
  ]
52
52
  when :full_width
53
53
  [
54
- Teacup::Constraint.new(:self, :center_x).equals(relative_to, :center_x),
55
- Teacup::Constraint.new(:self, :width).equals(relative_to, :width),
54
+ self.new(:self, :center_x).equals(relative_to, :center_x),
55
+ self.new(:self, :width).equals(relative_to, :width),
56
56
  ]
57
57
  when :full_height
58
58
  [
59
- Teacup::Constraint.new(:self, :center_y).equals(relative_to, :center_y),
60
- Teacup::Constraint.new(:self, :height).equals(relative_to, :height),
59
+ self.new(:self, :center_y).equals(relative_to, :center_y),
60
+ self.new(:self, :height).equals(relative_to, :height),
61
61
  ]
62
62
  when :center_x
63
63
  [
64
- Teacup::Constraint.new(:self, :center_x).equals(:superview, :center_x),
64
+ self.new(:self, :center_x).equals(:superview, :center_x),
65
65
  ]
66
66
  when :center_y
67
67
  [
68
- Teacup::Constraint.new(:self, :center_y).equals(:superview, :center_y),
68
+ self.new(:self, :center_y).equals(:superview, :center_y),
69
69
  ]
70
70
  when :centered
71
71
  [
72
- Teacup::Constraint.new(:self, :center_x).equals(:superview, :center_x),
73
- Teacup::Constraint.new(:self, :center_y).equals(:superview, :center_y),
72
+ self.new(:self, :center_x).equals(:superview, :center_x),
73
+ self.new(:self, :center_y).equals(:superview, :center_y),
74
74
  ]
75
75
  when :top
76
76
  [
77
- Teacup::Constraint.new(:self, :top).equals(relative_to, :top),
77
+ self.new(:self, :top).equals(relative_to, :top),
78
78
  ]
79
79
  when :right
80
80
  [
81
- Teacup::Constraint.new(:self, :right).equals(relative_to, :right),
81
+ self.new(:self, :right).equals(relative_to, :right),
82
82
  ]
83
83
  when :bottom
84
84
  [
85
- Teacup::Constraint.new(:self, :bottom).equals(relative_to, :bottom),
85
+ self.new(:self, :bottom).equals(relative_to, :bottom),
86
86
  ]
87
87
  when :left
88
88
  [
89
- Teacup::Constraint.new(:self, :left).equals(relative_to, :left),
89
+ self.new(:self, :left).equals(relative_to, :left),
90
90
  ]
91
91
  when :top_left, :topleft
92
92
  [
93
- Teacup::Constraint.new(:self, :left).equals(relative_to, :left),
94
- Teacup::Constraint.new(:self, :top).equals(relative_to, :top),
93
+ self.new(:self, :left).equals(relative_to, :left),
94
+ self.new(:self, :top).equals(relative_to, :top),
95
95
  ]
96
96
  when :top_right, :topright
97
97
  [
98
- Teacup::Constraint.new(:self, :right).equals(relative_to, :right),
99
- Teacup::Constraint.new(:self, :top).equals(relative_to, :top),
98
+ self.new(:self, :right).equals(relative_to, :right),
99
+ self.new(:self, :top).equals(relative_to, :top),
100
100
  ]
101
101
  when :bottom_right, :bottomright
102
102
  [
103
- Teacup::Constraint.new(:self, :right).equals(relative_to, :right),
104
- Teacup::Constraint.new(:self, :bottom).equals(relative_to, :bottom),
103
+ self.new(:self, :right).equals(relative_to, :right),
104
+ self.new(:self, :bottom).equals(relative_to, :bottom),
105
105
  ]
106
106
  when :bottom_left, :bottomleft
107
107
  [
108
- Teacup::Constraint.new(:self, :left).equals(relative_to, :left),
109
- Teacup::Constraint.new(:self, :bottom).equals(relative_to, :bottom),
108
+ self.new(:self, :left).equals(relative_to, :left),
109
+ self.new(:self, :bottom).equals(relative_to, :bottom),
110
110
  ]
111
111
  else
112
112
  raise "Unknown symbol #{sym.inspect}"
@@ -118,7 +118,7 @@ module Teacup
118
118
  self.attribute = attribute
119
119
  self.constant = 0
120
120
  self.multiplier = 1
121
- self.priority = :high
121
+ self.priority = :high # this is the xcode default
122
122
  end
123
123
 
124
124
  def equals(relative_to, attribute2=nil)
@@ -188,7 +188,7 @@ module Teacup
188
188
  end
189
189
 
190
190
  def copy
191
- copy = Teacup::Constraint.new(self.target, self.attribute)
191
+ copy = self.class.new(self.target, self.attribute)
192
192
  copy.relationship = self.relationship
193
193
  copy.relative_to = self.relative_to
194
194
  copy.attribute2 = self.attribute2
@@ -211,16 +211,16 @@ module Teacup
211
211
  end
212
212
 
213
213
  def nslayoutconstraint
214
- NSLayoutConstraint.constraintWithItem( self.target,
214
+ nsconstraint = NSLayoutConstraint.constraintWithItem( self.target,
215
215
  attribute: self.attribute,
216
216
  relatedBy: self.relationship,
217
217
  toItem: self.relative_to,
218
218
  attribute: self.attribute2,
219
219
  multiplier: self.multiplier,
220
220
  constant: self.constant
221
- ) .tap do |nsconstraint|
222
- nsconstraint.priority = priority_lookup self.priority
223
- end
221
+ )
222
+ nsconstraint.priority = priority_lookup(self.priority)
223
+ return nsconstraint
224
224
  end
225
225
 
226
226
  private
@@ -4,11 +4,7 @@ module Teacup
4
4
  # Returns all the subviews of `target` that have a stylename. `target` is not
5
5
  # included in the list. Used by the motion-layout integration in layout.rb.
6
6
  def get_styled_subviews(target)
7
- retval = target.subviews.select { |v| v.stylename }
8
- retval.concat(target.subviews.map do |subview|
9
- get_styled_subviews(subview)
10
- end)
11
- retval.flatten
7
+ target.subviews.select { |v| v.stylename }
12
8
  end
13
9
 
14
10
  def to_instance(class_or_instance)
@@ -1,5 +1,5 @@
1
1
  module Teacup
2
2
 
3
- VERSION = '2.1.1'
3
+ VERSION = '2.1.2'
4
4
 
5
5
  end
@@ -39,6 +39,14 @@ describe "MotionLayout" do
39
39
  label3_top.should == 220
40
40
  end
41
41
 
42
+ it 'should have label4 at 320' do
43
+ frame = controller.container.label4.frame
44
+ frame = controller.container.convertRect(frame, toView: controller.view)
45
+ label4_top = CGRectGetMinY(frame)
46
+ label4_top.should == 320
47
+ end
48
+
49
+
42
50
  end
43
51
 
44
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teacup
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-12 00:00:00.000000000 Z
12
+ date: 2013-07-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! 'Teacup is a community-driven DSL for making CSS-like styling, and
15
15
  layouts for