teacup 2.1.3 → 2.1.4

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.3)
4
+ teacup (2.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,24 @@
1
+ class DependencyController < UIViewController
2
+ attr :button
3
+
4
+ stylesheet :dependency
5
+
6
+ layout do
7
+ @button = subview(UIView, :my_button)
8
+ end
9
+
10
+ end
11
+
12
+
13
+ Teacup::Stylesheet.new :dependency do
14
+
15
+ style :button,
16
+ size: [90, 90],
17
+ backgroundColor: UIColor.redColor
18
+
19
+ style :my_button, extends: :button,
20
+ top: 0,
21
+ center_x: 80, # <-- This results in a frame of [[80, 0], [90, 90]] instead of [[35, 0], [90, 90]]
22
+ title: 'My Button'
23
+
24
+ end
@@ -25,13 +25,28 @@
25
25
  module Teacup
26
26
  module_function
27
27
 
28
+ # Some properties need to be assigned before others (size in particular, so
29
+ # that `:center_x` can work properly). This hash makes sure higher priority
30
+ # style names before lower-numbers.
31
+ Priorities = {
32
+ frame: 2,
33
+ size: 1,
34
+ width: 1,
35
+ height: 1,
36
+ }
37
+ Priorities.default = -1
38
+
28
39
  # applies a Hash of styles, and converts the frame styles (origin, size, top,
29
40
  # left, width, height) into one frame property.
30
41
  #
31
42
  # For UIAppearance support, the class of the UIView class that is being
32
43
  # modified can be passed in
33
44
  def apply_hash(target, properties, klass=nil)
34
- properties.each do |key, value|
45
+ properties.sort do |a, b|
46
+ priority_a = Priorities[a[0]]
47
+ priority_b = Priorities[b[0]]
48
+ priority_b <=> priority_a
49
+ end.each do |key, value|
35
50
  Teacup.apply target, key, value, klass
36
51
  end
37
52
  end
data/lib/teacup/layout.rb CHANGED
@@ -164,6 +164,7 @@ module Teacup
164
164
  # assign the 'teacup_next_responder', which is queried for a stylesheet if
165
165
  # one is not explicitly assigned to the view
166
166
  if view.is_a? Layout
167
+ puts("=============== layout.rb line #{__LINE__} ===============")
167
168
  view.teacup_next_responder = self
168
169
  end
169
170
 
@@ -1,5 +1,5 @@
1
1
  module Teacup
2
2
 
3
- VERSION = '2.1.3'
3
+ VERSION = '2.1.4'
4
4
 
5
5
  end
@@ -1,3 +1,4 @@
1
+ # Fixes here should be copied to teacup-osx/style.rb
1
2
  module Teacup
2
3
  # The Style class is where the precedence rules are applied. A Style can
3
4
  # query the Stylesheet that created it to look up other styles (for
@@ -1,3 +1,4 @@
1
+ # Fixes here should be copied to teacup-ios/style.rb
1
2
  module Teacup
2
3
  # The Style class is where the precedence rules are applied. A Style can
3
4
  # query the Stylesheet that created it to look up other styles (for
@@ -0,0 +1,11 @@
1
+ describe "Style Dependencies" do
2
+ tests DependencyController
3
+
4
+ it "should style size before styling center_x" do
5
+ @controller.button.frame.origin.x.should == 35
6
+ @controller.button.frame.origin.y.should == 0
7
+ @controller.button.frame.size.width.should == 90
8
+ @controller.button.frame.size.height.should == 90
9
+ end
10
+
11
+ 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.3
4
+ version: 2.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -38,6 +38,7 @@ files:
38
38
  - app/app_delegate.rb
39
39
  - app/controllers/appearance_controller.rb
40
40
  - app/controllers/constraints_controller.rb
41
+ - app/controllers/dependency_controller.rb
41
42
  - app/controllers/gradient_controller.rb
42
43
  - app/controllers/landscape_only_controller.rb
43
44
  - app/controllers/main_controller.rb
@@ -134,6 +135,7 @@ files:
134
135
  - spec/ios/calculations_spec.rb
135
136
  - spec/ios/constraints_spec.rb
136
137
  - spec/ios/custom_class_spec.rb
138
+ - spec/ios/dependencies.rb
137
139
  - spec/ios/gradient_spec.rb
138
140
  - spec/ios/layout_module_spec.rb
139
141
  - spec/ios/layout_spec.rb
@@ -179,6 +181,7 @@ test_files:
179
181
  - spec/ios/calculations_spec.rb
180
182
  - spec/ios/constraints_spec.rb
181
183
  - spec/ios/custom_class_spec.rb
184
+ - spec/ios/dependencies.rb
182
185
  - spec/ios/gradient_spec.rb
183
186
  - spec/ios/layout_module_spec.rb
184
187
  - spec/ios/layout_spec.rb