teacup 2.1.3 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/app/controllers/dependency_controller.rb +24 -0
- data/lib/teacup/handler.rb +16 -1
- data/lib/teacup/layout.rb +1 -0
- data/lib/teacup/version.rb +1 -1
- data/lib/teacup-ios/style.rb +1 -0
- data/lib/teacup-osx/style.rb +1 -0
- data/spec/ios/dependencies.rb +11 -0
- metadata +4 -1
data/Gemfile.lock
CHANGED
@@ -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
|
data/lib/teacup/handler.rb
CHANGED
@@ -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.
|
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
|
|
data/lib/teacup/version.rb
CHANGED
data/lib/teacup-ios/style.rb
CHANGED
data/lib/teacup-osx/style.rb
CHANGED
@@ -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.
|
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
|