teacup 2.1.12 → 2.1.13

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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- teacup (2.1.12)
4
+ teacup (2.1.13)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -2,9 +2,8 @@
2
2
  module Teacup
3
3
  # The Style class is where the precedence rules are applied. A Style can
4
4
  # query the Stylesheet that created it to look up other styles (for
5
- # `extends:`) and to import other Stylesheets. If it is handed a target (e.g.
6
- # a `UIView` instance) and orientation, it will merge those in appropriately
7
- # as well.
5
+ # `extends:`) and to import other Stylesheets. If it is handed a class (e.g.
6
+ # `UIView`) and orientation, it will merge those in appropriately as well.
8
7
  class Style < Hash
9
8
  attr_accessor :stylename
10
9
  attr_accessor :stylesheet
@@ -29,7 +28,7 @@ module Teacup
29
28
  supports[orientation_key]
30
29
  end
31
30
 
32
- def build(target=nil, rotation_orientation=nil, seen={})
31
+ def build(target_class=nil, rotation_orientation=nil, seen={})
33
32
  properties = Style.new
34
33
  properties.stylename = self.stylename
35
34
  properties.stylesheet = self.stylesheet
@@ -72,7 +71,7 @@ module Teacup
72
71
  # local style
73
72
  if stylesheet && stylesheet.is_a?(Teacup::Stylesheet)
74
73
  stylesheet.imported_stylesheets.reverse.each do |stylesheet|
75
- imported_properties = stylesheet.query(self.stylename, target, rotation_orientation, seen)
74
+ imported_properties = stylesheet.query(self.stylename, target_class, rotation_orientation, seen)
76
75
  delete_keys.each do |key|
77
76
  imported_properties.delete(key)
78
77
  end
@@ -85,7 +84,7 @@ module Teacup
85
84
  # turn style names into Hashes by querying them on the stylesheet
86
85
  # (this does not pass `seen`, because this is a new query)
87
86
  also_includes.each do |also_include|
88
- extended_properties = stylesheet.query(also_include, target, rotation_orientation)
87
+ extended_properties = stylesheet.query(also_include, target_class, rotation_orientation)
89
88
  delete_keys.each do |key|
90
89
  extended_properties.delete(key)
91
90
  end
@@ -95,9 +94,9 @@ module Teacup
95
94
  properties.delete(:extends)
96
95
 
97
96
  # if we know the class of the target, we can apply styles via class
98
- # inheritance. We do not pass `target` in this case.
99
- if target
100
- target.class.ancestors.each do |ancestor|
97
+ # inheritance.
98
+ if target_class
99
+ target_class.class.ancestors.each do |ancestor|
101
100
  extended_properties = stylesheet.query(ancestor, nil, rotation_orientation)
102
101
  Teacup::merge_defaults!(properties, extended_properties)
103
102
  end
@@ -125,23 +125,20 @@ module Teacup
125
125
  # @stylesheet_cache object is manipulated directly (to invalidate entries,
126
126
  # or the entire cache)
127
127
  def stylesheet_cache
128
- return nil
129
- # @stylesheet_cache ||= Hash.new do |by_stylename,_stylename|
130
- # by_stylename[_stylename] = Hash.new do |by_target,_target|
131
- # by_orientation = {}
132
- # by_target[_target] = by_orientation
133
- # end
134
- # end
128
+ @stylesheet_cache ||= Hash.new do |by_stylename,_stylename|
129
+ by_stylename[_stylename] = Hash.new do |by_target_class,_target_class|
130
+ by_orientation = {}
131
+ by_target_class[_target_class] = by_orientation
132
+ end
133
+ end
135
134
  end
136
135
 
137
- def get_stylesheet_cache(stylename, target, orientation)
138
- return nil
139
- # self.stylesheet_cache[stylename][target][orientation]
136
+ def get_stylesheet_cache(stylename, target_class, orientation)
137
+ self.stylesheet_cache[stylename][target_class][orientation]
140
138
  end
141
139
 
142
- def set_stylesheet_cache(stylename, target, orientation, value)
143
- return
144
- # self.stylesheet_cache[stylename][target][orientation] = value
140
+ def set_stylesheet_cache(stylename, target_class, orientation, value)
141
+ self.stylesheet_cache[stylename][target_class][orientation] = value
145
142
  end
146
143
 
147
144
  # Include another Stylesheet into this one, the rules defined
@@ -211,19 +208,20 @@ module Teacup
211
208
  # @example
212
209
  # Teacup::Stylesheet[:ipadbase].query(:continue_button)
213
210
  # # => {backgroundImage: UIImage.imageNamed("big_red_shiny_button"), title: "Continue!", top: 50}
214
- def query(stylename, target=nil, orientation=nil, seen={})
211
+ def query(stylename, target_class=nil, orientation=nil, seen={})
215
212
  return {} if seen[self]
216
213
  return {} unless stylename
217
214
 
218
- p stylename: stylename, target: target, orientation: orientation
219
- if cached = get_stylesheet_cache(stylename, target, orientation)
215
+ cached = get_stylesheet_cache(stylename, target_class, orientation)
216
+ if cached
217
+ # mutable hashes could mess with our cache, so return a duplicate
220
218
  return cached.dup
221
219
  else
222
220
  run_block
223
221
  seen[self] = true
224
222
 
225
- built = styles[stylename].build(target, orientation, seen)
226
- set_stylesheet_cache(stylename, target, orientation, built)
223
+ built = styles[stylename].build(target_class, orientation, seen)
224
+ set_stylesheet_cache(stylename, target_class, orientation, built)
227
225
  return built.dup
228
226
  end
229
227
  end
@@ -1,5 +1,5 @@
1
1
  module Teacup
2
2
 
3
- VERSION = '2.1.12'
3
+ VERSION = '2.1.13'
4
4
 
5
5
  end
@@ -5,7 +5,7 @@ describe "TableViewCells" do
5
5
  before do
6
6
  path = NSIndexPath.indexPathWithIndex(0).indexPathByAddingIndex(0)
7
7
  @cell = controller.view.cellForRowAtIndexPath(path)
8
- @padding = @cell.contentView.subviews[0]
8
+ @padding = @cell.padding
9
9
  end
10
10
 
11
11
  it "should have styled padding (backgroundColor.should)" do
@@ -82,7 +82,7 @@ describe "TableViewCells" do
82
82
  path = NSIndexPath.indexPathWithIndex(0).indexPathByAddingIndex(9)
83
83
  controller.view.scrollToRowAtIndexPath(path, atScrollPosition:UITableViewScrollPositionBottom, animated:false)
84
84
  @cell = controller.view.cellForRowAtIndexPath(path)
85
- @padding = @cell.contentView.subviews[0]
85
+ @padding = @cell.padding
86
86
  end
87
87
 
88
88
  it "should be a reused cell" do
@@ -19,7 +19,7 @@ DESC
19
19
  gem.summary = 'A community-driven DSL for creating user interfaces on iOS.'
20
20
  gem.homepage = 'https://github.com/rubymotion/teacup'
21
21
 
22
- gem.files = `git ls-files`.split($\)
22
+ gem.files = `git ls-files`.split($\).reject { |file| file =~ /^app\// }
23
23
  gem.require_paths = ['lib']
24
24
  gem.test_files = gem.files.grep(%r{^spec/})
25
25
  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.12
4
+ version: 2.1.13
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-10-10 00:00:00.000000000 Z
12
+ date: 2013-10-30 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
@@ -35,22 +35,6 @@ files:
35
35
  - LICENSE
36
36
  - README.md
37
37
  - Rakefile
38
- - app/app_delegate.rb
39
- - app/controllers/appearance_controller.rb
40
- - app/controllers/constraints_controller.rb
41
- - app/controllers/dependency_controller.rb
42
- - app/controllers/gradient_controller.rb
43
- - app/controllers/landscape_only_controller.rb
44
- - app/controllers/main_controller.rb
45
- - app/controllers/memory_leak_controller.rb
46
- - app/controllers/motion_layout_controller.rb
47
- - app/controllers/present_modal_controller.rb
48
- - app/controllers/table_view_controller.rb
49
- - app/controllers/tableview_controller.rb
50
- - app/custom_class.rb
51
- - app/styles/appearance.rb
52
- - app/styles/main_styles.rb
53
- - app/views/custom_view.rb
54
38
  - lib/teacup-ios/appearance.rb
55
39
  - lib/teacup-ios/core_extensions/teacup_handlers.rb
56
40
  - lib/teacup-ios/core_extensions/ui_view.rb
@@ -1,19 +0,0 @@
1
- class AppDelegate
2
-
3
- def application(application, didFinishLaunchingWithOptions:launchOptions)
4
- return true if RUBYMOTION_ENV == 'test'
5
-
6
- application.setStatusBarHidden(true, withAnimation:UIStatusBarAnimationSlide)
7
-
8
- @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
9
- # change this controller to whatever controller you want to test, or are
10
- # writing tests for.
11
- ctlr = TableViewController.new
12
- @window.rootViewController = ctlr
13
- @window.rootViewController.wantsFullScreenLayout = true
14
- @window.makeKeyAndVisible
15
-
16
- true
17
- end
18
-
19
- end
@@ -1,13 +0,0 @@
1
- class CustomAppearanceController < UIViewController
2
- attr :label_1
3
- attr :container
4
- attr :label_2
5
-
6
- layout do
7
- @label_1 = subview(CustomAppearanceLabel)
8
- @container = subview(CustomAppearanceContainer) do
9
- @label_2 = subview(CustomAppearanceLabel)
10
- end
11
- end
12
-
13
- end
@@ -1,92 +0,0 @@
1
- class ConstraintsController < UIViewController
2
- attr :container,
3
- :header_view,
4
- :footer_view,
5
- :center_view,
6
- :left_view,
7
- :top_right_view,
8
- :btm_right_view
9
-
10
- stylesheet :constraints
11
-
12
- layout :root do
13
- @container = subview(UIView, :container) do
14
- @header_view = subview(UIView, :header)
15
- @footer_view = subview(UIView, :footer)
16
- @center_view = subview(UIView, :center) do
17
- @left_view = subview(UIView, :left)
18
- @top_right_view = subview(UIView, :top_right)
19
- @btm_right_view = subview(UIView, :btm_right)
20
- end
21
- end
22
- end
23
-
24
- def supportedInterfaceOrientations
25
- UIInterfaceOrientationMaskAllButUpsideDown
26
- end
27
-
28
- end
29
-
30
-
31
- Teacup::Stylesheet.new :constraints do
32
-
33
- style :root,
34
- accessibilityLabel: 'root view'
35
-
36
- style :container,
37
- constraints: [:full],
38
- backgroundColor: UIColor.blackColor
39
-
40
- style :header,
41
- backgroundColor: UIColor.blueColor,
42
- constraints: [
43
- :full_width,
44
- :top,
45
- constrain_height(52),
46
- ]
47
-
48
- style :footer,
49
- backgroundColor: UIColor.magentaColor,
50
- constraints: [
51
- :full_width,
52
- :bottom,
53
- constrain(:height).equals(:header, :height),
54
- ]
55
-
56
- style :center,
57
- backgroundColor: UIColor.lightGrayColor,
58
- constraints: [
59
- constrain_below(:header).plus(8),
60
- constrain_above(:footer).minus(8),
61
- constrain_left(8),
62
- constrain_right(-8),
63
- ]
64
-
65
- style :left,
66
- backgroundColor: UIColor.redColor,
67
- constraints: [
68
- constrain_left(8),
69
- constrain_top(8),
70
- constrain(:right).plus(8).equals(:top_right, :left),
71
- constrain(:right).plus(8).equals(:btm_right, :left),
72
- constrain_bottom(-8),
73
- constrain(:width).equals(:top_right, :width),
74
- constrain(:width).equals(:btm_right, :width),
75
- ]
76
-
77
- style :top_right,
78
- backgroundColor: UIColor.greenColor,
79
- constraints: [
80
- constrain(:top).equals(:left, :top),
81
- constrain_right(-8),
82
- constrain(:height).equals(:btm_right, :height),
83
- constrain(:bottom).plus(8).equals(:btm_right, :top),
84
- ]
85
-
86
- style :btm_right,
87
- backgroundColor: UIColor.yellowColor,
88
- constraints: [
89
- constrain(:bottom).equals(:left, :bottom),
90
- ]
91
-
92
- end
@@ -1,24 +0,0 @@
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
@@ -1,3 +0,0 @@
1
-
2
- class GradientController < UIViewController
3
- end
@@ -1,16 +0,0 @@
1
-
2
- class LandscapeOnlyController < UIViewController
3
-
4
- def viewDidLoad
5
- UIApplication.sharedApplication.windows[0].rootViewController = MainController.alloc.init
6
- end
7
-
8
- def shouldAutorotateToInterfaceOrientation(orientation)
9
- if orientation == UIInterfaceOrientationLandscapeLeft or orientation == UIInterfaceOrientationLandscapeRight
10
- true
11
- else
12
- false
13
- end
14
- end
15
-
16
- end
@@ -1,66 +0,0 @@
1
- class MainController < UIViewController
2
- attr :welcome
3
- attr :button
4
-
5
- stylesheet :main
6
-
7
- layout :root do
8
- subview(CustomView, :background) do
9
- @welcome = subview(UILabel, :welcome)
10
- subview(UILabel, :footer)
11
- @button = subview(UIButton.buttonWithType(UIButtonTypeRoundedRect), :next_message)
12
- end
13
-
14
- @button.addTarget(self, action: :next_message, forControlEvents:UIControlEventTouchUpInside)
15
- end
16
-
17
- def next_view
18
- end
19
-
20
- def next_message
21
- msg = messages.shift
22
- if msg
23
- @welcome.text = msg
24
- else
25
- @welcome.text = 'Next example...'
26
-
27
- @button.removeTarget(self, action: :next_view, forControlEvents:UIControlEventTouchUpInside)
28
- @button.addTarget(self, action: :next_view, forControlEvents:UIControlEventTouchUpInside)
29
- end
30
- end
31
-
32
- def messages
33
- @messages ||= [
34
- 'This is teacup',
35
- 'Welcome',
36
- 'This is teacup',
37
- 'Welcome to teacup',
38
- 'You can do anything at teacup',
39
- 'Anything at all',
40
- 'The only limit is yourself ',
41
- 'Welcome to teacup',
42
- 'Welcome to teacup',
43
- 'This is teacup',
44
- 'Welcome to teacup',
45
- 'This is teacup, Welcome',
46
- 'Yes, this is teacup',
47
- 'This is teacup and welcome to you who have come to teacup',
48
- 'Anything is possible at teacup',
49
- 'You can to anything teacup',
50
- 'The infinite is possible at teacup',
51
- 'The unattainable is unknown at teacup',
52
- 'Welcome to teacup',
53
- 'This is teacup',
54
- 'Welcome to teacup',
55
- 'Welcome',
56
- 'This is teacup',
57
- 'Welcome to teacup',
58
- 'Welcome to teacup',
59
- ]
60
- end
61
-
62
- def shouldAutorotateToInterfaceOrientation(orientation)
63
- autorotateToOrientation(orientation)
64
- end
65
-
66
- end
@@ -1,26 +0,0 @@
1
- class MemoryLeakController < UIViewController
2
- DidDeallocNotification = 'DidDeallocNotification'
3
-
4
- stylesheet :memory_leak
5
-
6
- layout do
7
- subview(UIView, :view) do
8
- subview(UIView)
9
- end
10
- end
11
-
12
- def dealloc
13
- NSNotificationCenter.defaultCenter.postNotificationName(DidDeallocNotification, object:self)
14
- super
15
- end
16
-
17
- end
18
-
19
-
20
- Teacup::Stylesheet.new :memory_leak do
21
-
22
- style :view,
23
- frame: [[10, 10], [100, 100]],
24
- backgroundColor: UIColor.whiteColor
25
-
26
- end
@@ -1,36 +0,0 @@
1
- class MotionLayoutController < UIViewController
2
- attr :label1
3
- attr :label2
4
- attr :label3
5
- attr :container
6
-
7
- layout :root do
8
- @label1 = subview(UILabel, :label1, text: 'label1')
9
- @label2 = subview(UILabel, :label2, text: 'label2')
10
- @label3 = subview(UILabel, :label3, text: 'label3')
11
- @container = subview(CustomContainer, :container)
12
- end
13
-
14
- def layoutDidLoad
15
- auto do
16
- metrics "margin" => 20, "top" => 100
17
- horizontal '|-margin-[label1]-margin-[label2(==label1)]-margin-|'
18
- horizontal '|-margin-[label3]-margin-|'
19
- horizontal '|-margin-[container]-margin-|'
20
- vertical '|-top-[label1]'
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
33
- end
34
- end
35
-
36
- end
@@ -1,30 +0,0 @@
1
- class PresentModalController < UIViewController
2
- attr :modal
3
-
4
- stylesheet :present_modal
5
-
6
- layout :root do
7
- @button = subview(UIButton.buttonWithType(UIButtonTypeRoundedRect), :open_modal_button)
8
- @button.addTarget(self, action: :open_modal_button, forControlEvents:UIControlEventTouchUpInside)
9
- end
10
-
11
- def open_modal_button
12
- @modal = ConstraintsController.new
13
- self.presentViewController(@modal, animated:true, completion:nil)
14
- end
15
-
16
- end
17
-
18
-
19
- Teacup::Stylesheet.new :present_modal do
20
-
21
- style :root,
22
- backgroundColor: UIColor.blackColor
23
-
24
- style :open_modal_button,
25
- title: 'Open Modal',
26
- constraints: [
27
- :centered
28
- ]
29
-
30
- end
@@ -1,106 +0,0 @@
1
- class TableViewController < UITableViewController
2
- include Teacup::TableViewDelegate
3
-
4
- stylesheet :table
5
-
6
- def viewDidLoad
7
- self.view.registerClass(CustomCell, forCellReuseIdentifier:'cell id')
8
- end
9
-
10
- def numberOfSectionsInTableView(table_view)
11
- 1
12
- end
13
-
14
- def tableView(table_view, numberOfRowsInSection:section)
15
- 10
16
- end
17
-
18
- def tableView(tableView, heightForRowAtIndexPath:index_path)
19
- 100
20
- end
21
-
22
- def tableView(table_view, cellForRowAtIndexPath:index_path)
23
- cell = table_view.dequeueReusableCellWithIdentifier('cell id')
24
-
25
- # for testing cell reuse
26
- if cell.is_reused.nil?
27
- cell.is_reused = false
28
- else
29
- cell.is_reused ||= true
30
- end
31
-
32
- cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton
33
-
34
- cell.backgroundView = layout(UIView, :bg)
35
-
36
- layout(cell.contentView, :root) do
37
- subview(UIView, :padding) do
38
- cell.title_label = subview(UILabel, :cell_title_label, :text => "title #{index_path.row}")
39
- cell.details_label = subview(UILabel, :cell_details_label, :text => "details #{index_path.row}")
40
- cell.other_label = subview(UILabel, :cell_other_label, :text => "other #{index_path.row}")
41
- end
42
- end
43
-
44
- return cell
45
- end
46
-
47
- def tableView(table_view, didSelectRowAtIndexPath:index_path)
48
- table_view.deselectRowAtIndexPath(index_path, animated:true)
49
- end
50
-
51
- def tableView(tableView, willDisplayCell:cell, forRowAtIndexPath:indexPath)
52
- super
53
- # one more change, to prove that this method can be overridden
54
- cell.title_label.textColor = UIColor.blueColor
55
- end
56
-
57
- end
58
-
59
-
60
- class CustomCell < UITableViewCell
61
- attr_accessor :title_label, :details_label, :other_label, :is_reused
62
- end
63
-
64
-
65
- Teacup::Stylesheet.new :table do
66
- style :bg,
67
- backgroundColor: UIColor.colorWithRed(247.0 / 256.0, green:221.0 / 256.0, blue:186.0 / 256.0, alpha:1)
68
-
69
- style :padding,
70
- backgroundColor: UIColor.greenColor,
71
- constraints: [
72
- constrain(:width).equals(:superview, :width).times(0.96),
73
- constrain(:height).equals(:superview, :height).times(0.96),
74
- constrain(:center_x).equals(:superview, :center_x),
75
- constrain(:center_y).equals(:superview, :center_y)
76
- ]
77
-
78
- style :cell_title_label,
79
- font: UIFont.boldSystemFontOfSize(17),
80
- constraints: [
81
- constrain_height(20),
82
- constrain(:top).equals(:superview, :top),
83
- constrain(:width).equals(:superview, :width),
84
- constrain(:center_x).equals(:superview, :center_x)
85
- ]
86
-
87
- style :cell_details_label,
88
- font: UIFont.systemFontOfSize(14),
89
- color: UIColor.grayColor,
90
- constraints: [
91
- constrain_height(17),
92
- constrain_below(:cell_title_label, 5),
93
- constrain(:width).equals(:superview, :width),
94
- constrain(:center_x).equals(:superview, :center_x)
95
- ]
96
-
97
- style :cell_other_label,
98
- font: UIFont.systemFontOfSize(14),
99
- color: UIColor.grayColor,
100
- constraints: [
101
- constrain_height(17),
102
- constrain_below(:cell_details_label, 5),
103
- constrain(:width).equals(:superview, :width),
104
- constrain(:center_x).equals(:superview, :center_x)
105
- ]
106
- end
File without changes
@@ -1,22 +0,0 @@
1
- Teacup::Stylesheet.new :custom do
2
- style :container,
3
- frame: [[0, 0], [100, 20]]
4
-
5
- style :label,
6
- text: 'custom label',
7
- frame: [[0, 0], [100, 20]]
8
- end
9
-
10
- class CustomTeacupClass
11
- include Teacup::Layout
12
-
13
- def initialize
14
- self.stylesheet = :custom
15
- end
16
-
17
- def create_container
18
- layout(UIView, :container) do
19
- subview(UILabel, :label)
20
- end
21
- end
22
- end
@@ -1,24 +0,0 @@
1
- class CustomAppearanceLabel < UILabel
2
- end
3
-
4
- class CustomAppearanceContainer < UIView
5
- end
6
-
7
- Teacup.handler UIView, :redHerring do |view, alpha|
8
- view.alpha = alpha
9
- end
10
-
11
- Teacup::Appearance.new do
12
-
13
- style CustomAppearanceLabel,
14
- redHerring: 0.75,
15
- numberOfLines: 3
16
-
17
- style CustomAppearanceContainer,
18
- backgroundColor: UIColor.whiteColor
19
-
20
- style CustomAppearanceLabel, when_contained_in: CustomAppearanceContainer,
21
- redHerring: 0.5,
22
- numberOfLines: 2
23
-
24
- end
@@ -1,113 +0,0 @@
1
-
2
- Teacup::Stylesheet.new(:main) do
3
-
4
- # enable orientations on the root view
5
- style :root,
6
- left: 0,
7
- top: 0,
8
- width: 320,
9
- height: 480,
10
- backgroundColor: UIColor.yellowColor,
11
- portrait: true,
12
- upside_down: false,
13
-
14
- layer: {
15
- cornerRadius: 10.0,
16
- },
17
-
18
- landscape: {
19
- backgroundColor: UIColor.redColor,
20
- },
21
-
22
- landscape_left: {
23
- layer: {
24
- transform: transform_layer.spin(-pi / 2),
25
- },
26
- },
27
-
28
- landscape_right: {
29
- layer: {
30
- transform: transform_layer.spin(pi / 2),
31
- },
32
- }
33
-
34
- style(UILabel, {
35
- textColor: UIColor.blueColor,
36
- })
37
-
38
- style CustomView,
39
- # for testing how styles override (this gets overridden by any property in
40
- # a style block, regardless of whether it is in an orientation style)
41
- portrait: {
42
- alpha: 0.75
43
- },
44
- landscape: {
45
- alpha: 0.75
46
- }
47
-
48
- style(:background, {
49
- alpha: 0.5,
50
- left: 10,
51
- top: 30,
52
- backgroundColor: UIColor.blackColor,
53
- custom_attr: :custom_value,
54
-
55
- portrait: {
56
- width: 300,
57
- height: 440,
58
- backgroundColor: UIColor.darkGrayColor,
59
- },
60
-
61
- landscape: {
62
- width: 460,
63
- height: 280,
64
- alpha: 0.8,
65
- backgroundColor: UIColor.lightGrayColor,
66
- },
67
- })
68
-
69
- style(:welcome, {
70
- left: 10,
71
- top: 40,
72
- width: 280,
73
- height: 20,
74
- text: "Welcome to teacup",
75
- landscape: {
76
- left: 90,
77
- },
78
- })
79
-
80
- style(:footer, {
81
- left: 10,
82
- top: 410,
83
- width: 280,
84
- height: 20,
85
- text: "This is a teacup example",
86
- landscape: {
87
- top: 250,
88
- left: 90,
89
- },
90
- })
91
-
92
-
93
- style :next_message,
94
- height: 20,
95
- portrait: nil,
96
- title: "Next Message..."
97
-
98
- # deliberately declaring this twice for testing purposes
99
- # (declaring twice extends it)
100
- style :next_message,
101
- portrait: {
102
- left: 150,
103
- top: 370,
104
- width: 140, # this should get overridden
105
- },
106
-
107
- landscape: {
108
- left: 20,
109
- top: 200,
110
- width: 140, # this should get overridden
111
- }
112
-
113
- end
@@ -1,5 +0,0 @@
1
-
2
- class CustomView < UIView
3
- # not very custom, is it!?
4
- attr_accessor :custom_attr
5
- end