simple-view 0.6.3 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_view/version.rb +1 -1
- data/lib/simple_view/view_builder.rb +29 -23
- metadata +2 -2
data/lib/simple_view/version.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module SimpleView
|
2
2
|
class ViewBuilder
|
3
3
|
attr_reader :view
|
4
|
-
attr_accessor :top, :left, :bottom, :right, :width, :height
|
5
4
|
|
6
5
|
# first args (optional): bounds
|
7
6
|
# second args (optional): options
|
@@ -17,13 +16,13 @@ module SimpleView
|
|
17
16
|
options = args.size > 1 ? args[1] : {}
|
18
17
|
end
|
19
18
|
|
20
|
-
builder = ViewBuilder.new klass, options
|
21
|
-
builder.size_within bounds
|
19
|
+
builder = ViewBuilder.new klass, bounds, options
|
22
20
|
builder.view
|
23
21
|
end
|
24
22
|
|
25
|
-
def initialize klass, options = {}
|
23
|
+
def initialize klass, bounds = CGRectZero, options = {}
|
26
24
|
options = extended_options_with_style klass, options
|
25
|
+
calculate_frame_for bounds, options
|
27
26
|
convert_primitives_to_objects_in_hash options
|
28
27
|
|
29
28
|
@view = view_for_class klass, klass, options
|
@@ -62,44 +61,50 @@ module SimpleView
|
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
65
|
-
def
|
66
|
-
|
64
|
+
def calculate_frame_for bounds, options = {}
|
65
|
+
width = options.delete(:width)
|
66
|
+
height = options.delete(:height)
|
67
|
+
top = options.delete(:top)
|
68
|
+
right = options.delete(:right)
|
69
|
+
bottom = options.delete(:bottom)
|
70
|
+
left = options.delete(:left)
|
67
71
|
|
68
72
|
if width.nil? && height.nil? && right.nil? && bottom.nil?
|
69
|
-
|
73
|
+
options[:frame] = CGRectZero
|
70
74
|
else
|
75
|
+
frame = CGRectZero
|
71
76
|
max_width = bounds.size.width
|
72
77
|
max_height = bounds.size.height
|
73
78
|
|
74
79
|
if width.nil?
|
75
|
-
|
80
|
+
width = 0.0
|
76
81
|
elsif width > 0 && width <= 1
|
77
82
|
if right.nil?
|
78
|
-
|
79
|
-
|
83
|
+
left ||= 0
|
84
|
+
right = max_width - max_width * width
|
80
85
|
else
|
81
|
-
|
86
|
+
left = max_width - max_width * width
|
82
87
|
end
|
83
88
|
end
|
84
89
|
|
85
90
|
if height.nil?
|
86
|
-
|
91
|
+
height = 0.0
|
87
92
|
elsif height > 0 && height <= 1
|
88
93
|
if bottom.nil?
|
89
|
-
|
90
|
-
|
94
|
+
top ||= 0
|
95
|
+
bottom = max_height - max_height * height
|
91
96
|
else
|
92
|
-
|
97
|
+
top = max_height - max_height * height
|
93
98
|
end
|
94
99
|
end
|
95
100
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
101
|
+
mask = UIViewAutoresizingNone
|
102
|
+
mask |= UIViewAutoresizingFlexibleTopMargin if top.nil?
|
103
|
+
mask |= UIViewAutoresizingFlexibleLeftMargin if left.nil?
|
104
|
+
mask |= UIViewAutoresizingFlexibleBottomMargin if bottom.nil?
|
105
|
+
mask |= UIViewAutoresizingFlexibleRightMargin if right.nil?
|
106
|
+
mask |= UIViewAutoresizingFlexibleWidth if !left.nil? && !right.nil?
|
107
|
+
mask |= UIViewAutoresizingFlexibleHeight if !top.nil? && !bottom.nil?
|
103
108
|
|
104
109
|
if !left.nil? && !right.nil?
|
105
110
|
frame.origin.x = left
|
@@ -129,7 +134,8 @@ module SimpleView
|
|
129
134
|
frame.size.height = height
|
130
135
|
end
|
131
136
|
|
132
|
-
|
137
|
+
options[:frame] = frame
|
138
|
+
options[:autoresizingMask] = mask
|
133
139
|
end
|
134
140
|
end
|
135
141
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
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-02-
|
12
|
+
date: 2013-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: RubyMotion DSL for UIKit
|
15
15
|
email:
|