redpotion 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d21e4e6f969c24f37a4353f71e9eee37ec2eb46f
4
- data.tar.gz: 7e13e159041370cb4356f2d8d6b1f005e340fbf5
3
+ metadata.gz: dc77574563b630914de6587aacae72b20f999385
4
+ data.tar.gz: 4b8900f7a93ec82b96c875c034423aa38081b4e9
5
5
  SHA512:
6
- metadata.gz: ab585f17e01afda7512152fc28e73c9390e1994291c9d6af386c69e9543179f7a36a160e71924d8fdb95dc43b67ad3ff85918d967ec55698a7ecf10c8f515710
7
- data.tar.gz: 4ad4a47811f1c80f25db4bac1da5d6faf25b944ec3ebfa739a8d8dff2bb3d0a5ca3f8096ffe8796f21f1bfe3ede8bb7dbfbc53599bd57b413de1120e2e343680
6
+ metadata.gz: 7ea81b4f72947a4d27bd87cb138b711056ce0f2b4fd2a718f8f0617b6272f50b489e2d29ac03c972a078b00df60d9e0a74e51a2306c2805673acbe9b00f90c56
7
+ data.tar.gz: ba39d2a5f701f04350e92ecdcdde2408fa709084438709dc849310dffe683d74d708c5a559637a4dc7e11704335bbe6bd86a06da069acdcdc5308b7bb145cc87
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
- ![image](http://ir_wp.s3.amazonaws.com/wp-content/uploads/sites/11/2015/01/RedPotion_logo_1000w_padding.png)
1
+ ![image](http://ir_public.s3.amazonaws.com/projects/redpotion/RedPotion_logo_transparent.png)
2
2
 
3
3
  # RedPotion
4
+ [![Build Status](https://travis-ci.org/infinitered/redpotion.svg?branch=master)](https://travis-ci.org/infinitered/redpotion)
4
5
 
5
6
  We believe iPhone development should be clean, scalable, and fast with a language that developers not only enjoy, but actively choose. With the advent of Ruby for iPhone development the RubyMotion community has combined and tested the most active and powerful gems into a single package called **RedPotion**
6
7
 
@@ -70,7 +71,7 @@ Open the `home_screen.rb` file, then add this
70
71
 
71
72
  append UIButton, :go_button
72
73
 
73
- @sample_image = append UIImageView, :sample_image
74
+ @sample_image = append!(UIImageView, :sample_image)
74
75
  ```
75
76
 
76
77
  Delete this line:
@@ -99,6 +100,9 @@ end
99
100
  def sample_image(st)
100
101
  st.frame = {left: 20, below_prev: 10, from_right: 20, from_bottom: 20}
101
102
  st.background_color = color.gray
103
+
104
+ # an example of using the view directly
105
+ st.view.contentMode = UIViewContentModeScaleAspectFit
102
106
  end
103
107
  ```
104
108
 
@@ -113,8 +117,9 @@ append UIButton, :go_button
113
117
 
114
118
  With this:
115
119
  ```ruby
116
- append(UIButton, :go_button).on(:touch) do
120
+ append(UIButton, :go_button).on(:touch) do |sender|
117
121
  @sample_image.remote_image = @image_url.text
122
+ @image_url.resignFirstResponder # Closes keyboard
118
123
  end
119
124
  ```
120
125
 
@@ -127,16 +132,21 @@ def on_load
127
132
 
128
133
  @image_url = append!(UITextField, :image_url)
129
134
 
130
- append(UIButton, :go_button).on(:touch) do
135
+ append(UIButton, :go_button).on(:touch) do |sender|
131
136
  @sample_image.remote_image = @image_url.text
137
+ @image_url.resignFirstResponder # Closes keyboard
132
138
  end
133
139
 
134
- @sample_image = append UIImageView, :sample_image
140
+ @sample_image = append!(UIImageView, :sample_image)
135
141
  end
136
142
  ```
137
143
 
138
144
  Now paste this URL in and hit **Go**
139
- `http://bit.ly/1M3UEZL`
145
+ `http://bit.ly/18iMhwc`
146
+
147
+ You should have this:
148
+
149
+ ![image](http://ir_wp.s3.amazonaws.com/wp-content/uploads/sites/11/2015/03/myapp_screenshot.jpg)
140
150
 
141
151
 
142
152
  ## New generators to integrate RMQ & ProMotion nicely ##
@@ -274,6 +284,42 @@ UIColor has a `with` method. Allowing you to build a color from an existing col
274
284
  color.my_custom_color.with(a: 0.5)
275
285
  ```
276
286
 
287
+ PM::DataTableScreen - added a clean way to integrate a table screen with a custom cell, and data backed model
288
+
289
+ ```ruby
290
+ class ContributerScreen < PM::DataTableScreen
291
+ title "RedPotion Contributers"
292
+ refreshable
293
+ stylesheet ContributerScreenStylesheet
294
+ model Contributer
295
+ end
296
+
297
+ class Contributer < CDQManagedObject
298
+ def cell
299
+ {
300
+ cell_class: ContributerCell,
301
+ properties: {
302
+ name: name
303
+ }
304
+ }
305
+ end
306
+ end
307
+
308
+ class ContributerCell < ProMotion::TableViewCell
309
+ def on_load
310
+ apply_style :cell
311
+
312
+ find(self.contentView).tap do |q|
313
+ @title = q.append!(UILabel, :cell_title)
314
+ end
315
+ end
316
+
317
+ def name=(value)
318
+ @title.text = value
319
+ end
320
+ end
321
+ ```
322
+
277
323
  ## Full listing of Gems and Pods for RedPotion
278
324
  **Gems**
279
325
  * [RMQ](http://rubymotionquery.com/)
data/bin/potion CHANGED
@@ -35,7 +35,7 @@ class PotionCommandLine
35
35
  Misc
36
36
  > potion -h, --help
37
37
  > potion -v, --version
38
-
38
+
39
39
  Documentation
40
40
  > rmq docs
41
41
  > rmq docs query
@@ -57,6 +57,11 @@ class PotionCommandLine
57
57
 
58
58
 
59
59
  def create(template_or_app_name, *options)
60
+ if template_or_app_name.nil?
61
+ puts "potion - Invalid command, try adding an application name or template name."
62
+ return
63
+ end
64
+
60
65
  options.compact!
61
66
  # Dry Run option - TODO - change this to --dry_run to streamline
62
67
  if options.first == 'dry_run'
@@ -0,0 +1,11 @@
1
+ if RUBYMOTION_ENV == "development"
2
+ module Kernel
3
+ def live_stylesheets(interval = 0.5, debug=false)
4
+ rmq_live_stylesheets interval, debug
5
+ end
6
+
7
+ def enable_live_stylesheets(interval)
8
+ enable_rmq_live_stylesheets interval
9
+ end
10
+ end
11
+ end
@@ -8,6 +8,6 @@ class Object
8
8
  end
9
9
 
10
10
  def find(*args) # Do not alias this, strange bugs happen where classes don't have methods
11
- rmq(args)
11
+ rmq(*args)
12
12
  end
13
13
  end
@@ -1,7 +1,12 @@
1
1
  class UIColor
2
2
  def with(options)
3
- r, g, b, a = Pointer.new('d'), Pointer.new('d'), Pointer.new('d'), Pointer.new('d')
4
- self.getRed(r, green: g, blue: b, alpha: a)
3
+ begin
4
+ r, g, b, a = Pointer.new('d'), Pointer.new('d'), Pointer.new('d'), Pointer.new('d')
5
+ self.getRed(r, green: g, blue: b, alpha: a)
6
+ rescue
7
+ r, g, b, a = Pointer.new('f'), Pointer.new('f'), Pointer.new('f'), Pointer.new('f')
8
+ self.getRed(r, green: g, blue: b, alpha: a)
9
+ end
5
10
 
6
11
  r = options[:r] || options[:red] || r.value
7
12
  g = options[:g] || options[:green] || g.value
@@ -82,7 +82,12 @@ class UIView
82
82
  def stylesheet
83
83
  rmq.stylesheet
84
84
  end
85
+
85
86
  def stylesheet=(value)
86
87
  rmq.stylesheet = value
87
88
  end
89
+
90
+ def find(*args)
91
+ rmq(self).find(*args)
92
+ end
88
93
  end
@@ -46,12 +46,19 @@ class UIViewController
46
46
  def stylesheet
47
47
  rmq.stylesheet
48
48
  end
49
+
49
50
  def stylesheet=(value)
50
51
  rmq.stylesheet = value
51
52
  end
53
+
54
+ def find(*args)
55
+ rmq(self.view).find(*args)
56
+ end
57
+
52
58
  def self.stylesheet(style_sheet_class)
53
59
  @rmq_style_sheet_class = style_sheet_class
54
60
  end
61
+
55
62
  def self.rmq_style_sheet_class
56
63
  @rmq_style_sheet_class
57
64
  end
@@ -81,6 +88,7 @@ class UIViewController
81
88
 
82
89
  def view_will_appear(animated)
83
90
  end
91
+
84
92
  def viewWillAppear(animated)
85
93
  unless pm_handles_delegates?
86
94
  self.view_will_appear(animated)
@@ -89,6 +97,7 @@ class UIViewController
89
97
 
90
98
  def view_did_appear(animated)
91
99
  end
100
+
92
101
  def viewDidAppear(animated)
93
102
  unless pm_handles_delegates?
94
103
  self.view_did_appear(animated)
@@ -97,6 +106,7 @@ class UIViewController
97
106
 
98
107
  def view_will_disappear(animated)
99
108
  end
109
+
100
110
  def viewWillDisappear(animated)
101
111
  unless pm_handles_delegates?
102
112
  self.view_will_disappear(animated)
@@ -105,6 +115,7 @@ class UIViewController
105
115
 
106
116
  def view_did_disappear(animated)
107
117
  end
118
+
108
119
  def viewDidDisappear(animated)
109
120
  unless pm_handles_delegates?
110
121
  self.view_did_disappear(animated)
@@ -113,6 +124,7 @@ class UIViewController
113
124
 
114
125
  def should_rotate(orientation)
115
126
  end
127
+
116
128
  def shouldAutorotateToInterfaceOrientation(orientation)
117
129
  self.should_rotate(orientation)
118
130
  end
@@ -120,24 +132,28 @@ class UIViewController
120
132
  def should_autorotate
121
133
  true
122
134
  end
135
+
123
136
  def shouldAutorotate
124
137
  self.should_autorotate
125
138
  end
126
139
 
127
140
  def will_rotate(orientation, duration)
128
141
  end
142
+
129
143
  def willRotateToInterfaceOrientation(orientation, duration:duration)
130
144
  self.will_rotate(orientation, duration)
131
145
  end
132
146
 
133
147
  def on_rotate(orientation)
134
148
  end
149
+
135
150
  def didRotateFromInterfaceOrientation(orientation)
136
151
  self.on_rotate orientation
137
152
  end
138
153
 
139
154
  def will_animate_rotate(orientation, duration)
140
155
  end
156
+
141
157
  def willAnimateRotationToInterfaceOrientation(orientation, duration: duration)
142
158
  self.will_animate_rotate(orientation, duration)
143
159
  end
@@ -1,21 +1,17 @@
1
1
  module ProMotion
2
- #TODO ? - set_attributes is called twice - seems like this is in PM core
3
- # this is because we call setup when we build the cell and setup when its
4
- # about to display - this is because PM wants styling to fire in each case -
5
- # and properties was where the styling is done in PM
6
- #
7
- # if we are going to wire an event when a value is set on a cell, this could
8
- # be problematic, especially likely since cells are reused, etc
9
- # see my new cell for example, where I have to remove and then add events
10
- # because of the double call
11
-
12
2
  class DataTableScreen < TableScreen
13
- def self.cell(cell)
14
- @cell = cell
15
- end
3
+ class << self
4
+ def model(value, scope=nil)
5
+ if value.method_defined?(:cell)
6
+ @data_model = value
7
+ @data_scope = scope || :all
8
+ else
9
+ raise "#{value} must define the cell method"
10
+ end
11
+ end
16
12
 
17
- def self.cell_properties
18
- @cell
13
+ def data_model; @data_model; end
14
+ def data_scope; @data_scope; end
19
15
  end
20
16
 
21
17
  def table_data
@@ -24,43 +20,20 @@ module ProMotion
24
20
  }]
25
21
  end
26
22
 
27
- def cell_properties
28
- self.class.cell_properties
29
- end
30
-
31
23
  def cell_data
32
- return [] if cell_properties.nil?
33
24
  return [] if data_model.nil?
34
25
 
35
- data_model.send(data_scope).collect do |c|
36
- {
37
- cell_class: cell_class,
38
- properties: properties.inject({}) do |hash, element|
39
- hash[element.first] = c.send(element.last)
40
- hash
41
- end
42
- }
43
- end
26
+ data_model.send(data_scope).collect(&:cell)
44
27
  end
45
28
 
46
29
  private
47
30
 
48
- def properties
49
- @properties ||= cell_properties[:template].reject do |k,v|
50
- k == :cell_class
51
- end
52
- end
53
-
54
- def cell_class
55
- @cell_class ||= cell_properties[:template][:cell_class]
56
- end
57
-
58
31
  def data_model
59
- @data_model ||= cell_properties[:model]
32
+ self.class.data_model
60
33
  end
61
34
 
62
35
  def data_scope
63
- @data_scope ||= cell_properties[:scope] || :all
36
+ self.class.data_scope
64
37
  end
65
38
  end
66
39
  end
@@ -1,20 +1,7 @@
1
1
  module ProMotion
2
2
  class TableScreen < TableViewController
3
-
4
- # Temporarily here until this is added to ProMotion
5
- def create_table_cell(data_cell)
6
- new_cell = nil
7
- table_cell = table_view.dequeueReusableCellWithIdentifier(data_cell[:cell_identifier]) || begin
8
- new_cell = data_cell[:cell_class].alloc.initWithStyle(data_cell[:cell_style], reuseIdentifier:data_cell[:cell_identifier])
9
- new_cell.extend(PM::TableViewCellModule) unless new_cell.is_a?(PM::TableViewCellModule)
10
- new_cell.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin
11
- new_cell.clipsToBounds = true # fix for changed default in 7.1
12
- new_cell.send(:on_load) if new_cell.respond_to?(:on_load)
13
- new_cell.setup(data_cell, self)
14
- new_cell
15
- end
16
- table_cell.send(:on_reuse) if !new_cell && table_cell.respond_to?(:on_reuse)
17
- table_cell
18
- end
3
+ # For some reason, this empty class definition is required
4
+ # or we get a NoMethodError with the `searchable`
5
+ # class method call. O_o
19
6
  end
20
7
  end
@@ -1,3 +1,3 @@
1
1
  module RedPotion
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -54,8 +54,6 @@ class <%= @name_camel_case %>Screen < UITableViewController
54
54
  cell
55
55
  end
56
56
 
57
- # Remove the following if you're only using portrait
58
-
59
57
  # You don't have to reapply styles to all UIViews, if you want to optimize, another way to do it
60
58
  # is tag the views you need to restyle in your stylesheet, then only reapply the tagged views, like so:
61
59
  # def logo(st)
@@ -67,6 +65,8 @@ class <%= @name_camel_case %>Screen < UITableViewController
67
65
  #
68
66
  # Then in will_animate_rotate
69
67
  # find(:reapply_style).reapply_styles#
68
+
69
+ # Remove the following if you're only using portrait
70
70
  def will_animate_rotate(orientation, duration)
71
71
  reapply_styles
72
72
  end
@@ -10,8 +10,6 @@ class <%= @name_camel_case %>Screen < PM::<%= @screen_base %>
10
10
  end
11
11
  <% end %>
12
12
 
13
- # Remove the following if you're only using portrait
14
-
15
13
  # You don't have to reapply styles to all UIViews, if you want to optimize, another way to do it
16
14
  # is tag the views you need to restyle in your stylesheet, then only reapply the tagged views, like so:
17
15
  # def logo(st)
@@ -23,6 +21,8 @@ class <%= @name_camel_case %>Screen < PM::<%= @screen_base %>
23
21
  #
24
22
  # Then in will_animate_rotate
25
23
  # find(:reapply_style).reapply_styles#
24
+
25
+ # Remove the following if you're only using portrait
26
26
  def will_animate_rotate(orientation, duration)
27
27
  reapply_styles
28
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redpotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfiniteRed
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-03 00:00:00.000000000 Z
12
+ date: 2015-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_motion_query
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.1'
20
+ version: 1.3.1
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.1'
27
+ version: 1.3.1
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: ProMotion
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 2.2.1
34
+ version: '2.3'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 2.2.1
41
+ version: '2.3'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: motion_print
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -106,6 +106,7 @@ extra_rdoc_files: []
106
106
  files:
107
107
  - README.md
108
108
  - bin/potion
109
+ - lib/project/ext/kernel.rb
109
110
  - lib/project/ext/object.rb
110
111
  - lib/project/ext/ui_color.rb
111
112
  - lib/project/ext/ui_image_view.rb