teacup 0.3.12 → 1.0.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.
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +40 -0
- data/Rakefile +1 -0
- data/app/app_delegate.rb +3 -1
- data/app/controllers/first_controller.rb +0 -6
- data/lib/dummy.rb +13 -0
- data/lib/teacup/constraint.rb +258 -0
- data/lib/teacup/handler.rb +6 -3
- data/lib/teacup/layout.rb +52 -9
- data/lib/teacup/restyle.rb +12 -5
- data/lib/teacup/style.rb +1 -1
- data/lib/teacup/stylesheet.rb +45 -11
- data/lib/teacup/stylesheet_extensions/autoresize.rb +39 -0
- data/lib/teacup/stylesheet_extensions/constraints.rb +69 -0
- data/lib/teacup/stylesheet_extensions/geometry.rb +75 -0
- data/lib/teacup/stylesheet_extensions/rotation.rb +1 -2
- data/lib/teacup/version.rb +1 -1
- data/lib/teacup/z_core_extensions/ui_view.rb +115 -16
- data/lib/teacup/z_core_extensions/ui_view_controller.rb +54 -26
- data/lib/teacup/z_core_extensions/ui_view_getters.rb +8 -6
- data/lib/teacup/z_core_extensions/z_handlers.rb +45 -11
- data/lib/teacup.rb +2 -0
- data/spec/main_spec.rb +139 -191
- data/teacup.gemspec +1 -0
- data/vendor/TeacupDummy/TeacupDummy.h +11 -0
- data/vendor/TeacupDummy/TeacupDummy.m +8 -0
- metadata +9 -3
data/spec/main_spec.rb
CHANGED
@@ -1,205 +1,153 @@
|
|
1
1
|
describe "Application 'Teacup'" do
|
2
|
+
tests FirstController
|
3
|
+
|
2
4
|
before do
|
3
|
-
|
4
|
-
@
|
5
|
-
@
|
5
|
+
@root_view = window.subviews[0]
|
6
|
+
@background = @root_view.subviews[0]
|
7
|
+
@welcome = @background.subviews[0]
|
8
|
+
@footer = @background.subviews[1]
|
9
|
+
@button = @background.subviews[2]
|
6
10
|
end
|
7
11
|
|
8
|
-
|
9
|
-
|
12
|
+
it "should have a root view" do
|
13
|
+
view_ctrlr_view = controller.view
|
14
|
+
view_ctrlr_view.subviews.length.should == 1
|
15
|
+
view_ctrlr_view.subviews[0].class.should == CustomView
|
10
16
|
end
|
11
17
|
|
12
|
-
it "
|
13
|
-
|
18
|
+
it "should be able to rotate" do
|
19
|
+
controller.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationPortrait).should == true
|
20
|
+
controller.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationLandscapeRight).should == true
|
21
|
+
controller.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationLandscapeLeft).should == true
|
22
|
+
controller.shouldAutorotateToInterfaceOrientation(UIInterfaceOrientationPortraitUpsideDown).should == nil
|
14
23
|
end
|
15
24
|
|
16
|
-
it "should
|
17
|
-
|
18
|
-
|
19
|
-
|
25
|
+
it "root view should be styled as :root" do
|
26
|
+
@root_view.stylename.should == :root
|
27
|
+
@root_view.frame.origin.x.should == 0
|
28
|
+
@root_view.frame.origin.y.should == 0
|
29
|
+
@root_view.frame.size.width.should == 320
|
30
|
+
@root_view.frame.size.height.should == 480
|
31
|
+
@root_view.backgroundColor.should == UIColor.yellowColor
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be styled as :background" do
|
35
|
+
@background.stylename.should == :background
|
36
|
+
@background.frame.origin.x.should == 10
|
37
|
+
@background.frame.origin.y.should == 30
|
38
|
+
@background.frame.size.width.should == 300
|
39
|
+
@background.frame.size.height.should == 440
|
40
|
+
@background.backgroundColor.should == UIColor.darkGrayColor
|
41
|
+
end
|
42
|
+
|
43
|
+
it "background view should have subviews" do
|
44
|
+
@background.subviews.length.should == 3
|
45
|
+
@background.subviews[0].class.should == UILabel
|
46
|
+
@background.subviews[1].class.should == UILabel
|
47
|
+
@background.subviews[2].class.ancestors.include?(UIButton).should == true
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should not have styles overridden by base classes" do
|
51
|
+
@background.alpha.should == 0.5
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should have styles overridden orientation styles" do
|
55
|
+
@background.backgroundColor.should == UIColor.darkGrayColor
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should have all UILabels with color blue" do
|
59
|
+
@welcome.textColor.should == UIColor.blueColor
|
60
|
+
@footer.textColor.should == UIColor.blueColor
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should be styled as :welcome" do
|
64
|
+
@welcome.stylename.should == :welcome
|
65
|
+
@welcome.frame.origin.x.should == 10
|
66
|
+
@welcome.frame.origin.y.should == 40
|
67
|
+
@welcome.frame.size.width.should == 280
|
68
|
+
@welcome.frame.size.height.should == 20
|
69
|
+
@welcome.text.should == "Welcome to teacup"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should be styled as :footer" do
|
73
|
+
@footer.stylename.should == :footer
|
74
|
+
@footer.frame.origin.x.should == 10
|
75
|
+
@footer.frame.origin.y.should == 410
|
76
|
+
@footer.frame.size.width.should == 280
|
77
|
+
@footer.frame.size.height.should == 20
|
78
|
+
@footer.text.should == "This is a teacup example"
|
20
79
|
end
|
21
80
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
@button = @background.subviews[2]
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should have all UILabels with color blue" do
|
88
|
-
@welcome.textColor.should == UIColor.blueColor
|
89
|
-
@footer.textColor.should == UIColor.blueColor
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "welcome" do
|
93
|
-
it "should be styled as :welcome" do
|
94
|
-
@welcome.stylename.should == :welcome
|
95
|
-
@welcome.frame.origin.x.should == 10
|
96
|
-
@welcome.frame.origin.y.should == 40
|
97
|
-
@welcome.frame.size.width.should == 280
|
98
|
-
@welcome.frame.size.height.should == 20
|
99
|
-
@welcome.text.should == "Welcome to teacup"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe "footer" do
|
104
|
-
it "should be styled as :footer" do
|
105
|
-
@footer.stylename.should == :footer
|
106
|
-
@footer.frame.origin.x.should == 10
|
107
|
-
@footer.frame.origin.y.should == 410
|
108
|
-
@footer.frame.size.width.should == 280
|
109
|
-
@footer.frame.size.height.should == 20
|
110
|
-
@footer.text.should == "This is a teacup example"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "button" do
|
115
|
-
it "should be styled as :next_message" do
|
116
|
-
@button.stylename.should == :next_message
|
117
|
-
@button.frame.origin.x.should == 150
|
118
|
-
@button.frame.origin.y.should == 370
|
119
|
-
@button.frame.size.width.should == 130
|
120
|
-
@button.frame.size.height.should == 20
|
121
|
-
@button.titleForState(UIControlStateNormal).should == "Next Message..."
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|
128
|
-
|
129
|
-
describe "background view in landscape" do
|
130
|
-
|
131
|
-
before do
|
132
|
-
@background = @app.windows[0].subviews[0].subviews[0]
|
133
|
-
@view_ctrlr.landscape_only
|
134
|
-
UIApplication.sharedApplication.setStatusBarOrientation(UIInterfaceOrientationLandscapeLeft, animated:false)
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should be in landscape" do
|
138
|
-
# the rest of these tests *pass*, but the device orientation isn't actually
|
139
|
-
# updated to be landscape yet... :-/
|
140
|
-
UIDevice.currentDevice.orientation.should > 0
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should be styled as :background - landscape" do
|
144
|
-
@background.stylename.should == :background
|
145
|
-
@background.frame.origin.x.should == 10
|
146
|
-
@background.frame.origin.y.should == 30
|
147
|
-
@background.frame.size.width.should == 460
|
148
|
-
@background.frame.size.height.should == 280
|
149
|
-
@background.backgroundColor.should == UIColor.lightGrayColor
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should not have styles overridden by base classes" do
|
153
|
-
@background.alpha.should == 0.8
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should have styles overridden orientation styles" do
|
157
|
-
@background.backgroundColor.should == UIColor.lightGrayColor
|
158
|
-
end
|
159
|
-
|
160
|
-
describe "background subviews in landscape" do
|
161
|
-
|
162
|
-
before do
|
163
|
-
@welcome = @background.subviews[0]
|
164
|
-
@footer = @background.subviews[1]
|
165
|
-
@button = @background.subviews[2]
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "welcome" do
|
169
|
-
it "should be styled as :welcome - landscape" do
|
170
|
-
@welcome.stylename.should == :welcome
|
171
|
-
@welcome.frame.origin.x.should == 90
|
172
|
-
@welcome.frame.origin.y.should == 40
|
173
|
-
@welcome.frame.size.width.should == 280
|
174
|
-
@welcome.frame.size.height.should == 20
|
175
|
-
@welcome.text.should == "Welcome to teacup"
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe "footer" do
|
180
|
-
it "should be styled as :footer - landscape" do
|
181
|
-
@footer.stylename.should == :footer
|
182
|
-
@footer.frame.origin.x.should == 90
|
183
|
-
@footer.frame.origin.y.should == 250
|
184
|
-
@footer.frame.size.width.should == 280
|
185
|
-
@footer.frame.size.height.should == 20
|
186
|
-
@footer.text.should == "This is a teacup example"
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
describe "button" do
|
191
|
-
it "should be styled as :next_message - landscape" do
|
192
|
-
@button.stylename.should == :next_message
|
193
|
-
@button.frame.origin.x.should == 20
|
194
|
-
@button.frame.origin.y.should == 200
|
195
|
-
@button.frame.size.width.should == 130
|
196
|
-
@button.frame.size.height.should == 20
|
197
|
-
@button.titleForState(UIControlStateNormal).should == "Next Message..."
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
end
|
81
|
+
it "should be styled as :next_message" do
|
82
|
+
@button.stylename.should == :next_message
|
83
|
+
@button.frame.origin.x.should == 150
|
84
|
+
@button.frame.origin.y.should == 370
|
85
|
+
@button.frame.size.width.should == 130
|
86
|
+
@button.frame.size.height.should == 20
|
87
|
+
@button.titleForState(UIControlStateNormal).should == "Next Message..."
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
describe "background view in landscape" do
|
94
|
+
tests FirstController
|
95
|
+
|
96
|
+
before do
|
97
|
+
@root_view = window.subviews[0]
|
98
|
+
@background = @root_view.subviews[0]
|
99
|
+
@welcome = @background.subviews[0]
|
100
|
+
@footer = @background.subviews[1]
|
101
|
+
@button = @background.subviews[2]
|
102
|
+
rotate_device :to => :landscape
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should be in landscape" do
|
106
|
+
UIApplication.sharedApplication.statusBarOrientation.should == UIInterfaceOrientationLandscapeLeft
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should be styled as :background - landscape" do
|
110
|
+
@background.stylename.should == :background
|
111
|
+
@background.frame.origin.x.should == 10
|
112
|
+
@background.frame.origin.y.should == 30
|
113
|
+
@background.frame.size.width.should == 460
|
114
|
+
@background.frame.size.height.should == 280
|
115
|
+
@background.backgroundColor.should == UIColor.lightGrayColor
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should not have styles overridden by base classes" do
|
119
|
+
@background.alpha.should == 0.8
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should have styles overridden orientation styles" do
|
123
|
+
@background.backgroundColor.should == UIColor.lightGrayColor
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should be styled as :welcome - landscape" do
|
127
|
+
@welcome.stylename.should == :welcome
|
128
|
+
@welcome.frame.origin.x.should == 90
|
129
|
+
@welcome.frame.origin.y.should == 40
|
130
|
+
@welcome.frame.size.width.should == 280
|
131
|
+
@welcome.frame.size.height.should == 20
|
132
|
+
@welcome.text.should == "Welcome to teacup"
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should be styled as :footer - landscape" do
|
136
|
+
@footer.stylename.should == :footer
|
137
|
+
@footer.frame.origin.x.should == 90
|
138
|
+
@footer.frame.origin.y.should == 250
|
139
|
+
@footer.frame.size.width.should == 280
|
140
|
+
@footer.frame.size.height.should == 20
|
141
|
+
@footer.text.should == "This is a teacup example"
|
142
|
+
end
|
202
143
|
|
144
|
+
it "should be styled as :next_message - landscape" do
|
145
|
+
@button.stylename.should == :next_message
|
146
|
+
@button.frame.origin.x.should == 20
|
147
|
+
@button.frame.origin.y.should == 200
|
148
|
+
@button.frame.size.width.should == 130
|
149
|
+
@button.frame.size.height.should == 20
|
150
|
+
@button.titleForState(UIControlStateNormal).should == "Next Message..."
|
203
151
|
end
|
204
152
|
|
205
153
|
end
|
data/teacup.gemspec
CHANGED
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: 0.
|
4
|
+
version: 1.0.0
|
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: 2012-
|
12
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -74,12 +74,16 @@ files:
|
|
74
74
|
- app/views/custom_view.rb
|
75
75
|
- lib/dummy.rb
|
76
76
|
- lib/teacup.rb
|
77
|
+
- lib/teacup/constraint.rb
|
77
78
|
- lib/teacup/handler.rb
|
78
79
|
- lib/teacup/layout.rb
|
79
80
|
- lib/teacup/merge_defaults.rb
|
80
81
|
- lib/teacup/restyle.rb
|
81
82
|
- lib/teacup/style.rb
|
82
83
|
- lib/teacup/stylesheet.rb
|
84
|
+
- lib/teacup/stylesheet_extensions/autoresize.rb
|
85
|
+
- lib/teacup/stylesheet_extensions/constraints.rb
|
86
|
+
- lib/teacup/stylesheet_extensions/geometry.rb
|
83
87
|
- lib/teacup/stylesheet_extensions/rotation.rb
|
84
88
|
- lib/teacup/version.rb
|
85
89
|
- lib/teacup/z_core_extensions/ca_layer.rb
|
@@ -101,6 +105,8 @@ files:
|
|
101
105
|
- spec/stylesheet_spec.rb
|
102
106
|
- spec/view_spec.rb
|
103
107
|
- teacup.gemspec
|
108
|
+
- vendor/TeacupDummy/TeacupDummy.h
|
109
|
+
- vendor/TeacupDummy/TeacupDummy.m
|
104
110
|
homepage: https://github.com/rubymotion/teacup
|
105
111
|
licenses: []
|
106
112
|
post_install_message:
|
@@ -121,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
127
|
version: '0'
|
122
128
|
requirements: []
|
123
129
|
rubyforge_project:
|
124
|
-
rubygems_version: 1.8.
|
130
|
+
rubygems_version: 1.8.24
|
125
131
|
signing_key:
|
126
132
|
specification_version: 3
|
127
133
|
summary: A community-driven DSL for creating user interfaces on iOS.
|