simple-view 0.0.5

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.
Files changed (59) hide show
  1. data/.gitignore +5 -0
  2. data/.rvmrc +2 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +14 -0
  5. data/LICENSE +22 -0
  6. data/README.md +148 -0
  7. data/Rakefile +16 -0
  8. data/app/app_delegate.rb +9 -0
  9. data/app/simple_view_controller.rb +27 -0
  10. data/lib/simple-view.rb +16 -0
  11. data/lib/simple_view/builders/helpers/has_background_color.rb +10 -0
  12. data/lib/simple_view/builders/helpers/has_color.rb +9 -0
  13. data/lib/simple_view/builders/helpers/has_font.rb +9 -0
  14. data/lib/simple_view/builders/helpers/has_text_color.rb +11 -0
  15. data/lib/simple_view/builders/helpers/has_tint_color.rb +10 -0
  16. data/lib/simple_view/builders/ui_activity_indicator_view_builder.rb +12 -0
  17. data/lib/simple_view/builders/ui_button_builder.rb +32 -0
  18. data/lib/simple_view/builders/ui_control_builder.rb +9 -0
  19. data/lib/simple_view/builders/ui_image_view_builder.rb +38 -0
  20. data/lib/simple_view/builders/ui_label_builder.rb +18 -0
  21. data/lib/simple_view/builders/ui_progress_view_builder.rb +28 -0
  22. data/lib/simple_view/builders/ui_search_bar_builder.rb +31 -0
  23. data/lib/simple_view/builders/ui_segmented_control_builder.rb +28 -0
  24. data/lib/simple_view/builders/ui_slider_builder.rb +52 -0
  25. data/lib/simple_view/builders/ui_switch_builder.rb +10 -0
  26. data/lib/simple_view/builders/ui_tab_bar_builder.rb +20 -0
  27. data/lib/simple_view/builders/ui_table_view_builder.rb +15 -0
  28. data/lib/simple_view/builders/ui_table_view_cell_builder.rb +19 -0
  29. data/lib/simple_view/builders/ui_text_field_builder.rb +8 -0
  30. data/lib/simple_view/builders/ui_text_view_builder.rb +8 -0
  31. data/lib/simple_view/builders/ui_toolbar_builder.rb +11 -0
  32. data/lib/simple_view/builders/ui_view_builder.rb +58 -0
  33. data/lib/simple_view/extensions/string.rb +52 -0
  34. data/lib/simple_view/extensions/ui_color.rb +9 -0
  35. data/lib/simple_view/extensions/ui_font.rb +9 -0
  36. data/lib/simple_view/extensions/ui_image.rb +9 -0
  37. data/lib/simple_view/extensions/ui_view.rb +101 -0
  38. data/lib/simple_view/layout.rb +8 -0
  39. data/lib/simple_view/styles.rb +14 -0
  40. data/lib/simple_view/version.rb +3 -0
  41. data/lib/simple_view/view_proxy.rb +69 -0
  42. data/resources/test.jpg +0 -0
  43. data/simple_view.gemspec +16 -0
  44. data/spec/builders/ui_activity_indicator_view_builder_spec.rb +12 -0
  45. data/spec/builders/ui_button_builder_spec.rb +12 -0
  46. data/spec/builders/ui_control_builder_spec.rb +5 -0
  47. data/spec/builders/ui_image_view_builder_spec.rb +31 -0
  48. data/spec/builders/ui_progress_view_builder_spec.rb +12 -0
  49. data/spec/builders/ui_segmented_control_builder_spec.rb +13 -0
  50. data/spec/builders/ui_table_view_builder_spec.rb +12 -0
  51. data/spec/builders/ui_table_view_cell_builder_spec.rb +17 -0
  52. data/spec/builders/ui_view_builder_spec.rb +35 -0
  53. data/spec/extensions/string_spec.rb +38 -0
  54. data/spec/extensions/ui_color_spec.rb +8 -0
  55. data/spec/extensions/ui_font_spec.rb +8 -0
  56. data/spec/extensions/ui_image_spec.rb +8 -0
  57. data/spec/extensions/ui_view_spec.rb +111 -0
  58. data/spec/simple_view_spec.rb +193 -0
  59. metadata +118 -0
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .repl_history
2
+ build
3
+ *.tmproj
4
+ *.sublime-project
5
+ *.sublime-workspace
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ rvm_install_on_use_flag=1
2
+ rvm use --create 1.9.3@simpleview
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,14 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ simple-view (0.0.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ simple-view!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Sean Ho
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # SimpleView
2
+
3
+ A DSL for UIKit for RubyMotion.
4
+
5
+ Demo app: [Currency](https://github.com/seanho/CurrencyApp-RubyMotion)
6
+
7
+ ## Installation
8
+
9
+ Add the gem to your Gemfile
10
+
11
+ `gem 'simple-view', :git => 'https://github.com/seanho/SimpleView.git'`
12
+
13
+ Then `bundle install`
14
+
15
+ Require SimpleView in Rakefile
16
+
17
+ ```ruby
18
+ $:.unshift("/Library/RubyMotion/lib")
19
+ require 'motion/project'
20
+ require 'simple-view'
21
+
22
+ Motion::Project::App.setup do |app|
23
+ ...
24
+ end
25
+
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ````ruby
31
+ def viewDidLoad
32
+ SimpleView::Layouts.setup(view) do
33
+ label width: 200, height: 20, text: "Choose your lucky word", color: "#eee"
34
+ image_view top: 50, left: 50, right: 50, image: "sample.jpg"
35
+ toolbar anchors: [:bottom]
36
+ end
37
+ end
38
+ ````
39
+
40
+ Everything inside setup block will be added to the view automatically.
41
+
42
+ Hash parameters works only on KVC-compliant properties. To configure view object in more detail, use a block
43
+
44
+ ````ruby
45
+ def viewDidLoad
46
+ SimpleView::Layouts.setup(view) do
47
+ button do
48
+ @view.setTitle("Submit" forState: UIControlStateNormal)
49
+ end
50
+ end
51
+ end
52
+ ````
53
+
54
+ ### UIKit support
55
+ - UIActivityIndicatorView via `activity_indicator`
56
+ - UIButton via `button`
57
+ - UIDatePicker via `date_picker`
58
+ - UIImageView via `image_view`
59
+ - UILabel via `label`
60
+ - UIPageControl via `page_control`
61
+ - UIPickerView via `picker_view`
62
+ - UIProgressView via `progress_view`
63
+ - UIScrollView via `scroll_view`
64
+ - UISearchBar via `search_bar`
65
+ - UISegmentedControl via `segmented_control`
66
+ - UISlider via `slider`
67
+ - UIStepper via `stepper`
68
+ - UISwitch via `switch`
69
+ - UITabBar via `tab_bar`
70
+ - UITableView via `table_view`
71
+ - UITableViewCell via `table_view_cell`
72
+ - UITextField via `text_field`
73
+ - UITextView via `text_view`
74
+ - UIToolbar via `toolbar`
75
+ - UIView via `rect`
76
+ - UIWebView via `web_view`
77
+
78
+ ### Custom view support
79
+
80
+ SimpleView works not only with UIKit, custom or 3rd party created views and controls can also be used
81
+
82
+ ````ruby
83
+ SimpleView::Layouts.setup(view) do
84
+ add CustomViewClass, name: "custom_view"...
85
+ end
86
+ ````
87
+
88
+ ### Style Template
89
+
90
+ _Experimental. Might change in future._
91
+
92
+ Define a style and apply to multiple views with ease.
93
+
94
+ ````ruby
95
+ class AppDelegate
96
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
97
+ SimpleView::Styles.define :tag_label,
98
+ font: "italic 13",
99
+ text_color: "#999"
100
+ end
101
+ end
102
+
103
+ class ViewController
104
+ def viewDidLoad
105
+ SimpleView::Layouts.setup(view, controller: self) do
106
+ label styles: :tag_label, text: "Left", anchors: [:left]
107
+ label styles: :tag_label, text: "Right", anchors: [:right]
108
+ end
109
+ end
110
+ end
111
+ ````
112
+
113
+
114
+ ### View anchoring
115
+
116
+ ````ruby
117
+ SimpleView::Layouts.setup(view) do
118
+ toolbar bottom: 10, left: 10, right: 10, anchors: [:bottom]
119
+ end
120
+ ````
121
+
122
+ ### Passing in locals
123
+
124
+ Hash parameters will automatically turns into instance variable within the block
125
+
126
+ ````ruby
127
+ def viewDidLoad
128
+ SimpleView::Layouts.setup(view, controller: self) do
129
+ table_view delegate: @controller, dataSource: @controller
130
+ end
131
+ end
132
+ ````
133
+
134
+ ### View tagging with string
135
+
136
+ No need to declare ivar, no need to use integer tag, just name your view and access it by the name.
137
+
138
+ ````ruby
139
+ def viewDidLoad
140
+ SimpleView::Layouts.setup(view) do
141
+ label name: "price_label" # give a name to the label
142
+ end
143
+ end
144
+
145
+ def someOtherMethod
146
+ view.subview("price_label") # get the label
147
+ end
148
+ ````
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ $:.unshift("/Library/RubyMotion/lib")
5
+ require 'motion/project'
6
+
7
+ Motion::Project::App.setup do |app|
8
+ app.name = 'SimpleViewDemo'
9
+
10
+ app.files.unshift(Dir.glob(File.join(app.project_dir, 'lib/simple_view/*.rb')))
11
+ app.files.unshift(Dir.glob(File.join(app.project_dir, 'lib/simple_view/builders/*.rb')))
12
+ app.files.unshift(File.join(app.project_dir, 'lib/simple_view/builders/ui_control_builder.rb'))
13
+ app.files.unshift(File.join(app.project_dir, 'lib/simple_view/builders/ui_view_builder.rb'))
14
+ app.files.unshift(Dir.glob(File.join(app.project_dir, 'lib/simple_view/builders/helpers/*.rb')))
15
+ app.files.unshift(Dir.glob(File.join(app.project_dir, 'lib/simple_view/extensions/*.rb')))
16
+ end
@@ -0,0 +1,9 @@
1
+ class AppDelegate
2
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
3
+ @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
4
+ @window.rootViewController = UINavigationController.alloc.initWithRootViewController(SimpleViewController.alloc.init)
5
+ @window.rootViewController.wantsFullScreenLayout = true
6
+ @window.makeKeyAndVisible
7
+ true
8
+ end
9
+ end
@@ -0,0 +1,27 @@
1
+ class SimpleViewController < UIViewController
2
+ include SimpleView::Layout
3
+
4
+ def viewDidLoad
5
+ SimpleView::Styles.define :square,
6
+ width: 20,
7
+ height: 20
8
+
9
+ setup view, controller: self do
10
+ controller.title = "SimpleView Demo"
11
+
12
+ rect styles: :square, backgroundColor: "#000", anchors: [:top, :left, :bottom, :right]
13
+
14
+ rect styles: :square, backgroundColor: "#990000", anchors: [:top, :left]
15
+ rect styles: :square, backgroundColor: "#993300", anchors: [:top]
16
+ rect styles: :square, backgroundColor: "#CC9900", anchors: [:top, :right]
17
+
18
+ rect styles: :square, backgroundColor: "#006600", anchors: [:left]
19
+ rect styles: :square, backgroundColor: "#336666", anchors: []
20
+ rect styles: :square, backgroundColor: "#0033FF", anchors: [:right]
21
+
22
+ rect styles: :square, backgroundColor: "#000099", anchors: [:bottom, :left]
23
+ rect styles: :square, backgroundColor: "#660099", anchors: [:bottom]
24
+ rect styles: :square, backgroundColor: "#990066", anchors: [:bottom, :right]
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ require "simple_view/version"
2
+
3
+ unless defined?(Motion::Project::Config)
4
+ raise "This file must be required within a RubyMotion project Rakefile."
5
+ end
6
+
7
+ Motion::Project::App.setup do |app|
8
+ app.files += File.join(File.dirname(__FILE__), 'view_proxy.rb')
9
+ app.files.unshift(File.join(File.dirname(__FILE__), 'simple_view/layout.rb'))
10
+ app.files.unshift(File.join(File.dirname(__FILE__), 'simple_view/styles.rb'))
11
+ app.files.unshift(Dir.glob(File.join(File.dirname(__FILE__), 'simple_view/builders/*.rb')))
12
+ app.files.unshift(File.join(File.dirname(__FILE__), 'simple_view/builders/ui_control_builder.rb'))
13
+ app.files.unshift(File.join(File.dirname(__FILE__), 'simple_view/builders/ui_view_builder.rb'))
14
+ app.files.unshift(Dir.glob(File.join(File.dirname(__FILE__), 'simple_view/builders/helpers/*.rb')))
15
+ app.files.unshift(Dir.glob(File.join(File.dirname(__FILE__), 'simple_view/extensions/*.rb')))
16
+ end
@@ -0,0 +1,10 @@
1
+ module SimpleView
2
+ module Builders
3
+ module HasBackgroundColor
4
+ def setBackgroundColor(color)
5
+ @view.backgroundColor = color.to_color
6
+ end
7
+ alias_method :setBackground_color, :setBackgroundColor
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module SimpleView
2
+ module Builders
3
+ module HasColor
4
+ def setColor(color)
5
+ @view.color = color.to_color
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module SimpleView
2
+ module Builders
3
+ module HasFont
4
+ def setFont font
5
+ @view.font = font.to_font
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module SimpleView
2
+ module Builders
3
+ module HasTextColor
4
+ def setTextColor(color)
5
+ @view.textColor = color.to_color
6
+ end
7
+ alias_method :setText_color, :setTextColor
8
+ alias_method :setColor, :setTextColor
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ module SimpleView
2
+ module Builders
3
+ module HasTintColor
4
+ def setTintColor(color)
5
+ @view.tintColor = color.to_color
6
+ end
7
+ alias_method :setTint_color, :setTintColor
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UIActivityIndicatorViewBuilder < UIViewBuilder
4
+ include SimpleView::Builders::HasColor
5
+
6
+ def view_for_class(klass, options = {})
7
+ style = options.delete(:style) || UIActivityIndicatorViewStyleWhite
8
+ klass.alloc.initWithActivityIndicatorStyle(style)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,32 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UIButtonBuilder < UIControlBuilder
4
+ include SimpleView::Builders::HasTintColor
5
+
6
+ def view_for_class(klass, options = {})
7
+ button_type = options.delete(:buttonType) || options.delete(:button_type) || UIButtonTypeRoundedRect
8
+ klass.buttonWithType(button_type)
9
+ end
10
+
11
+ def setImage(image, forState: state)
12
+ @view.setImage(image.to_image, forState: state)
13
+ end
14
+
15
+ def setImage(image, forStates: states)
16
+ @view.setImage(image.to_image, forState, forStates: states)
17
+ end
18
+
19
+ def setBackgroundImage(image, forState: state)
20
+ @view.setBackgroundImage(image.to_image, forState, forState: state)
21
+ end
22
+
23
+ def setBackgroundImage(image, forStates: states)
24
+ @view.setBackgroundImage(image.to_image, forState, forStates: states)
25
+ end
26
+
27
+ def setDisabledDimsImage(image)
28
+ @view.setDisabledDimsImage(image.to_image, forState)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,9 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UIControlBuilder < UIViewBuilder
4
+ def view_for_class(klass, options = {})
5
+ klass.alloc.init
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,38 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UIImageViewBuilder < UIViewBuilder
4
+ def view_for_class(klass, options = {})
5
+ image = extract_image(options, :image)
6
+ highlighted_image = extract_image(options, [:highlightedImage, :highlighted_image])
7
+
8
+ if image && highlighted_image
9
+ klass.alloc.initWithImage(image, highlightedImage: highlighted_image)
10
+ elsif image
11
+ klass.alloc.initWithImage(image)
12
+ else
13
+ klass.alloc.initWithFrame(CGRectZero)
14
+ end
15
+ end
16
+
17
+ def extract_image(options, key)
18
+ if key.is_a?(Array)
19
+ key.each do |k|
20
+ image = options.delete(k)
21
+ break unless image.nil?
22
+ end
23
+ else
24
+ image = options.delete(key)
25
+ end
26
+ image.nil? ? nil : image.to_image
27
+ end
28
+
29
+ def setImage(image)
30
+ @view.image = image.to_image
31
+ end
32
+
33
+ def setHighlightedImage(image)
34
+ @view.highlightedImage = image.to_image
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,18 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UILabelBuilder < UIViewBuilder
4
+ include SimpleView::Builders::HasFont
5
+ include SimpleView::Builders::HasTextColor
6
+
7
+ def setHighlightedTextColor(color)
8
+ @view.highlightedTextColor = color.to_color
9
+ end
10
+ alias_method :setHighlighted_text_color, :setHighlightedTextColor
11
+
12
+ def setShadowColor(color)
13
+ @view.shadowColor = color.to_color
14
+ end
15
+ alias_method :setShadow_color, :setShadowColor
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,28 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UIProgressViewBuilder < UIViewBuilder
4
+ def view_for_class(klass, options = {})
5
+ style = options.delete(:style) || UIProgressViewStyleDefault
6
+ klass.alloc.initWithProgressViewStyle(style)
7
+ end
8
+
9
+ def setProgressImage(image)
10
+ @view.progressImage = image.to_image
11
+ end
12
+
13
+ def setTrackImage(image)
14
+ @view.trackImage = image.to_image
15
+ end
16
+
17
+ def setProgressTintColor(color)
18
+ @view.progressTintColor = color.to_color
19
+ end
20
+ alias_method :setProgress_tint_color, :setProgressTintColor
21
+
22
+ def setTrackTintColor(color)
23
+ @view.trackTintColor = color.to_color
24
+ end
25
+ alias_method :setTrack_tint_color, :setTrackTintColor
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,31 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UISearchBarBuilder < UIViewBuilder
4
+ include SimpleView::Builders::HasTintColor
5
+
6
+ def setBackgroundImage(image)
7
+ @view.backgroundImage = image.to_image
8
+ end
9
+
10
+ def setImage(image, forSearchBarIcon: icon, state: state)
11
+ @view.setImage(image.to_image, forSearchBarIcon: icon, state: state)
12
+ end
13
+
14
+ def setSearchFieldBackgroundImage(image, forState:state)
15
+ @view.setSearchFieldBackgroundImage(image.to_image, forState:state)
16
+ end
17
+
18
+ def setScopeBarBackgroundImage(image)
19
+ @view.scopeBarBackgroundImage = image.to_image
20
+ end
21
+
22
+ def setScopeBarButtonBackgroundImage(image, forState: state)
23
+ @view.setScopeBarButtonBackgroundImage(image.to_image, forState: state)
24
+ end
25
+
26
+ def setScopeBarButtonDividerImage(image, forLeftSegmentState: leftState, rightSegmentState: rightState)
27
+ @view.setScopeBarButtonDividerImage(image.to_image, forLeftSegmentState: leftState, rightSegmentState: rightState)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UISegmentedControlBuilder < UIControlBuilder
4
+ include SimpleView::Builders::HasTintColor
5
+
6
+ def view_for_class(klass, options = {})
7
+ items = options.delete(:items) || []
8
+ klass.alloc.initWithItems(items)
9
+ end
10
+
11
+ def setImage(image, forSegment: segment)
12
+ @view.setImage(image.to_image, forSegment: segment)
13
+ end
14
+
15
+ def setImage(image, forSegmentAtIndex: index)
16
+ @view.setImage(image.to_image, forSegmentAtIndex: index)
17
+ end
18
+
19
+ def setBackgroundImage(image, forState: state, barMetrics: metrics)
20
+ @view.setBackgroundImage(image.to_image, forState: state, barMetrics: metrics)
21
+ end
22
+
23
+ def setDividerImage(image, forLeftSegmentState: leftState, rightSegmentState: rightState, barMetrics: metrics)
24
+ @view.setDividerImage(image.to_image, forLeftSegmentState: leftState, rightSegmentState: rightState, barMetrics: metrics)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,52 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UISliderBuilder < UIControlBuilder
4
+ def setMinimumTrackImage(image, forStates: state)
5
+ @view.setMinimumTrackImage(image.to_image, forStates: state)
6
+ end
7
+
8
+ def setMaximumTrackImage(image, forStates: state)
9
+ @view.setMaximumTrackImage(image.to_image, forStates: state)
10
+ end
11
+
12
+ def setThumbImage(image, forStates: state)
13
+ @view.setThumbImage(image.to_image, forStates: state)
14
+ end
15
+
16
+ def setThumbImage(image, forState: state)
17
+ @view.setThumbImage(image.to_image, forState: state)
18
+ end
19
+
20
+ def setMinimumTrackImage(image, forState: state)
21
+ @view.setMinimumTrackImage(image.to_image, forState: state)
22
+ end
23
+
24
+ def setMaximumTrackImage(image, forState: state)
25
+ @view.setMaximumTrackImage(image.to_image, forState: state)
26
+ end
27
+
28
+ def setMinimumValueImage(image)
29
+ @view.setMinimumValueImage(image.to_image)
30
+ end
31
+
32
+ def setMaximumValueImage(image)
33
+ @view.setMaximumValueImage(image.to_image)
34
+ end
35
+
36
+ def setMinimumTrackTintColor(color)
37
+ @view.minimumTrackTintColor = color.to_color
38
+ end
39
+ alias_method :setMinimum_track_tint_color, :setMinimumTrackTintColor
40
+
41
+ def setMaximumTrackTintColor(color)
42
+ @view.maximumTrackTintColor = color.to_color
43
+ end
44
+ alias_method :setMaximum_track_tint_color, :setMaximumTrackTintColor
45
+
46
+ def setThumbTintColor(color)
47
+ @view.thumbTintColor = color.to_color
48
+ end
49
+ alias_method :setThumb_tint_color, :setThumbTintColor
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,10 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UISwitchBuilder < UIControlBuilder
4
+ def setOnTintColor(color)
5
+ @view.onTintColor = color.to_color
6
+ end
7
+ alias_method :setOn_tint_color, :setOnTintColor
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UITabBarBuilder < UIViewBuilder
4
+ include SimpleView::Builders::HasTintColor
5
+
6
+ def setBackgroundImage(image)
7
+ @view.backgroundImage = image.to_image
8
+ end
9
+
10
+ def setSelectedImage(image)
11
+ @view.selectedImage = image.to_image
12
+ end
13
+
14
+ def setSelectedImageTintColor(color)
15
+ @view.selectedImageTintColor = color.to_color
16
+ end
17
+ alias_method :setSelected_image_tint_color, :setSelectedImageTintColor
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UITableViewBuilder < UIViewBuilder
4
+ def view_for_class(klass, options = {})
5
+ style = options.delete(:style) || UITableViewStylePlain
6
+ klass.alloc.initWithFrame(CGRectZero, style: style)
7
+ end
8
+
9
+ def setSeparatorColor color
10
+ @view.separatorColor = color.to_color
11
+ end
12
+ alias_method :setSeparator_color, :setSeparatorColor
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UITableViewCellBuilder < UIViewBuilder
4
+ def view_for_class(klass, options = {})
5
+ style = options.delete(:style) || UITableViewCellStyleDefault
6
+ identifier = options.delete(:reuseIdentifier) || options.delete(:reuse_identifier)
7
+ klass.alloc.initWithStyle(style, reuseIdentifier: identifier)
8
+ end
9
+
10
+ def setImage image
11
+ @view.image = image.to_image
12
+ end
13
+
14
+ def setSelectedImage image
15
+ @view.selectedImage = image.to_image
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,8 @@
1
+ module SimpleView
2
+ module Builders
3
+ class UITextFieldBuilder < UIViewBuilder
4
+ include SimpleView::Builders::HasFont
5
+ include SimpleView::Builders::HasTextColor
6
+ end
7
+ end
8
+ end