redpotion 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -3
  3. data/bin/potion +4 -0
  4. data/lib/project/ext/kernel.rb +2 -0
  5. data/lib/project/ext/object.rb +2 -0
  6. data/lib/project/ext/pm_delegate.rb +6 -0
  7. data/lib/project/ext/ui_collection_view_cell.rb +2 -0
  8. data/lib/project/ext/ui_color.rb +3 -1
  9. data/lib/project/ext/ui_image_view.rb +37 -9
  10. data/lib/project/ext/ui_table_view_cell.rb +2 -0
  11. data/lib/project/ext/ui_view.rb +2 -0
  12. data/lib/project/ext/ui_view_controller.rb +2 -0
  13. data/lib/project/pro_motion/data_table.rb +1 -0
  14. data/lib/project/pro_motion/data_table_screen.rb +1 -0
  15. data/lib/project/pro_motion/data_table_searchable.rb +1 -0
  16. data/lib/project/pro_motion/screen.rb +2 -0
  17. data/lib/project/pro_motion/support.rb +2 -0
  18. data/lib/project/pro_motion/table.rb +1 -0
  19. data/lib/project/ruby_motion_query/app.rb +9 -1
  20. data/lib/project/ruby_motion_query/stylers/ui_image_view.rb +1 -0
  21. data/lib/project/ruby_motion_query/traverse.rb +2 -0
  22. data/lib/project/version.rb +1 -1
  23. data/templates/collection_view_screen/app/screens/name_screen.rb +2 -0
  24. data/templates/collection_view_screen/app/stylesheets/name_cell_stylesheet.rb +1 -0
  25. data/templates/collection_view_screen/app/views/name_cell.rb +2 -0
  26. data/templates/metal_table_screen/app/screens/name_screen.rb +2 -0
  27. data/templates/metal_table_screen/app/stylesheets/name_screen_stylesheet.rb +1 -0
  28. data/templates/metal_table_screen/app/views/name_cell.rb +2 -0
  29. data/templates/metal_table_screen/spec/screens/name_screen_spec.rb +1 -0
  30. data/templates/screen/app/screens/name_screen.rb +2 -0
  31. data/templates/screen/app/stylesheets/name_screen_stylesheet.rb +2 -0
  32. data/templates/screen/spec/screens/name_screen_spec.rb +1 -0
  33. data/templates/table_screen_cell/app/views/name.rb +1 -2
  34. metadata +5 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c612a7c529685b2e3d9788f59c71f6326ed2e9c5
4
- data.tar.gz: 0868dfb194fad46b871c527a278ea85e356e39af
3
+ metadata.gz: 04e83a3c050909fd7827bc277ca1f71f1316e849
4
+ data.tar.gz: d1413854f702ecbf9d36d66a1d64f6bf5561650b
5
5
  SHA512:
6
- metadata.gz: db1174afce9b8419e240349f1dc88a43b06d6dcdb69ae2b2a95062825a4a0888061b30d38eb9a61054810ad25625e50e9be9a2b32fe3bcdabe4578fd42b472d5
7
- data.tar.gz: 2384817d833b77a6950aaf56ad8c60039bf6cbb99bbe623d97f2a26ef1da4020a4f3bf273464f449642bc0174e9603f5b7af73a7e8e70275f2e471288e56de7f
6
+ metadata.gz: da82e2a3404ad63a8e77b89f71d7353c5331132f66710af74ee918b2ab285b9a8280af968e1d545943fd5bfe288319a5eb1f0fed0b3083a2017c1943beb1a0a8
7
+ data.tar.gz: 4d9cb28f587bdb43c719710f4d6aa5128f9807888c29a4d2e8d16c62e7ab6ad631793514ca73840c717a8984dee8cd1e4a6727c71815d9e9ffe4c8e32b71e572
data/README.md CHANGED
@@ -10,12 +10,12 @@
10
10
 
11
11
  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**
12
12
 
13
- RedPotion combines [RMQ](http://rubymotionquery.com/), [ProMotion](https://github.com/clearsightstudio/ProMotion), [CDQ](https://github.com/infinitered/cdq), [AFMotion](https://github.com/clayallsopp/afmotion), [MotionPrint](https://github.com/OTGApps/motion_print) and [MORE!](#full-listing-of-gems-and-pods-for-redpotion). It also adds new features to better integrate RMQ with ProMotion. The goal is simply to choose standard libraries and promote best practices, allowing you to develop iOS apps in record time.
13
+ RedPotion combines [RMQ](http://rubymotionquery.com/), [ProMotion](https://github.com/infinitered/ProMotion), [CDQ](https://github.com/infinitered/cdq), [AFMotion](https://github.com/clayallsopp/afmotion), [MotionPrint](https://github.com/OTGApps/motion_print) and [MORE!](#full-listing-of-gems-and-pods-for-redpotion). It also adds new features to better integrate RMQ with ProMotion. The goal is simply to choose standard libraries and promote best practices, allowing you to develop iOS apps in record time.
14
14
 
15
15
 
16
- The **makers of RMQ** at [InfiniteRed](http://infinitered.com/) and the **creators of ProMotion** at [ClearSight](https://clearsightstudio.com/) as well as [David Larrabee](https://twitter.com/Squidpunch) have teamed up to create the ultimate RubyMotion library.
16
+ The **makers of RMQ and ProMotion** at [InfiniteRed](http://infinite.red) (web and mobile developers based in Portland, OR and San Francisco, CA) have teamed up with [David Larrabee](https://twitter.com/Squidpunch) to create the ultimate RubyMotion library.
17
17
 
18
- [![image](https://ir_wp.s3.amazonaws.com/wp-content/uploads/sites/11/2013/08/InfiniteRed_logo_100h.png)](http://infinitered.com/)               [![image](https://clearsightstudio.com/assets/images/clearsight-logos/color-logo@2x-458a9655.png)](https://clearsightstudio.com/)
18
+ [![image](http://infinite.red/images/ir-logo.svg)](http://infinite.red)
19
19
 
20
20
  ProMotion for screens and RMQ for styles, animations, traversing, events, etc.
21
21
 
data/bin/potion CHANGED
@@ -6,6 +6,7 @@ require 'open-uri'
6
6
  require_relative "../lib/project/version"
7
7
 
8
8
  class PotionCommandLine
9
+
9
10
  HELP_TEXT = %{ potion version #{RedPotion::VERSION}
10
11
 
11
12
  Some things you can do with the potion command:
@@ -43,6 +44,7 @@ class PotionCommandLine
43
44
  > rmq docs "background image" }
44
45
 
45
46
  class << self
47
+
46
48
  SKIP_FLAGS = [ "--skip-cdq", "--skip-afmotion" ]
47
49
 
48
50
  VALID_CREATE_TYPES = [
@@ -262,7 +264,9 @@ class PotionCommandLine
262
264
  data = IO.readlines("Gemfile.lock")
263
265
  data.any?{|l| l.match(/\s.cdq\s\(/) }
264
266
  end
267
+
265
268
  end
269
+
266
270
  end
267
271
 
268
272
  # Process input, execute actions
@@ -1,5 +1,6 @@
1
1
  if RUBYMOTION_ENV == "development"
2
2
  class TopLevel
3
+
3
4
  def live(interval = 1.0, debug=false)
4
5
  rmq_live_stylesheets interval, debug
5
6
  end
@@ -15,5 +16,6 @@ if RUBYMOTION_ENV == "development"
15
16
  def close(args={})
16
17
  find.screen.close(args)
17
18
  end
19
+
18
20
  end
19
21
  end
@@ -1,4 +1,5 @@
1
1
  class Object
2
+
2
3
  def app
3
4
  rmq.app
4
5
  end
@@ -22,4 +23,5 @@ class Object
22
23
  def screen
23
24
  rmq.screen
24
25
  end
26
+
25
27
  end
@@ -5,22 +5,28 @@ end
5
5
  # Defines which ProMotion classes handle delegates
6
6
  module ProMotion
7
7
  class ViewController < UIViewController
8
+
8
9
  def class_handles_delegates?
9
10
  true
10
11
  end
12
+
11
13
  end
12
14
 
13
15
  class TableViewController < UITableViewController
16
+
14
17
  def class_handles_delegates?
15
18
  true
16
19
  end
20
+
17
21
  end
18
22
 
19
23
  # Include the entire class declaration chain for people that may not have
20
24
  # the ProMotion-form gem installed.
21
25
  class FormViewController < FXFormViewController
26
+
22
27
  def class_handles_delegates?
23
28
  true
24
29
  end
30
+
25
31
  end
26
32
  end
@@ -1,4 +1,5 @@
1
1
  class UICollectionViewCell
2
+
2
3
  # You can use either rmq_build or on_load, not both. If you have both, on_load will be ignored,
3
4
  # you can however call it from rmq_build. They are the same, on_load follows the ProMotion style
4
5
  # and is recommended.
@@ -14,4 +15,5 @@ class UICollectionViewCell
14
15
  super
15
16
  @reused = true
16
17
  end
18
+
17
19
  end
@@ -1,9 +1,10 @@
1
1
  class UIColor
2
+
2
3
  def with(options)
3
4
  type = CGSize.type[/(f|d)/]
4
5
  r, g, b, a = Pointer.new(type), Pointer.new(type), Pointer.new(type), Pointer.new(type)
5
6
  self.getRed(r, green: g, blue: b, alpha: a)
6
-
7
+
7
8
  r = options[:r] || options[:red] || r.value
8
9
  g = options[:g] || options[:green] || g.value
9
10
  b = options[:b] || options[:blue] || b.value
@@ -11,4 +12,5 @@ class UIColor
11
12
 
12
13
  UIColor.colorWithRed(r, green: g, blue: b, alpha: a)
13
14
  end
15
+
14
16
  end
@@ -1,27 +1,55 @@
1
1
  class UIImageView
2
2
 
3
- def remote_image=(value)
4
- if !!defined?(SDWebImageManager)
5
- @remote_image_operations ||= {}
3
+ def remote_image=(args)
4
+ url = args.respond_to?(:fetch) ? args.fetch(:url) : args
5
+ callback = args.respond_to?(:fetch) ? args.fetch(:on_load, -> {}) : -> {}
6
+ load_remote_image(url, callback)
7
+ end
8
+
9
+ private
6
10
 
11
+ def load_remote_image(url, callback = nil)
12
+ if defined?(SDWebImageManager)
13
+ @remote_image_operations ||= {}
7
14
  # Cancel the previous remote operation if it exists
8
15
  operation = @remote_image_operations[("%p" % self)]
9
16
  if operation && operation.respond_to?(:cancel)
10
17
  operation.cancel
11
18
  @remote_image_operations[("%p" % self)] = nil
12
19
  end
20
+ url = NSURL.URLWithString(url) unless url.is_a?(NSURL)
21
+ @remote_image_operations[("%p" % self)] = load_remote_image_using_sdwebimage(url, callback)
22
+ else
23
+ puts "\n[RedPotion ERROR] tried to set remote_image without SDWebImage CocoaPod. Please add this to your Rakefile: \n\napp.pods do\n pod \"SDWebImage\"\nend\n"
24
+ end
25
+ end
13
26
 
14
- value = NSURL.URLWithString(value) unless value.is_a?(NSURL)
15
- @remote_image_operations[("%p" % self)] = SDWebImageManager.sharedManager.downloadWithURL(value,
16
- options:SDWebImageRefreshCached,
17
- progress:nil,
27
+ def load_remote_image_using_sdwebimage(url, callback = nil)
28
+ manager = SDWebImageManager.sharedManager
29
+ if manager.respond_to?('downloadWithURL:options:progress:completed')
30
+ # Support for SDWebImage v3.x
31
+ manager.downloadWithURL(url,
32
+ options: SDWebImageRefreshCached,
33
+ progress: nil,
18
34
  completed: -> image, error, cacheType, finished {
19
35
  Dispatch::Queue.main.async do
20
36
  self.image = image
37
+ callback.call if callback
21
38
  end unless image.nil?
22
- })
39
+ }
40
+ )
23
41
  else
24
- puts "\n[RedPotion ERROR] tried to set remote_image without SDWebImage cocoapod. Please add this to your Rakefile: \n\napp.pods do\n pod \"SDWebImage\"\nend\n"
42
+ # Support for SDWebImage v4.x
43
+ manager.loadImageWithURL(url,
44
+ options: SDWebImageRefreshCached,
45
+ progress: nil,
46
+ completed: -> image, imageData, error, cacheType, finished, imageURL {
47
+ Dispatch::Queue.main.async do
48
+ self.image = image
49
+ callback.call if callback
50
+ end unless image.nil?
51
+ }
52
+ )
25
53
  end
26
54
  end
27
55
 
@@ -1,8 +1,10 @@
1
1
  class UITableViewCell
2
+
2
3
  # You can use either rmq_build or on_load, not both. If you have both, on_load will be ignored,
3
4
  # you can however call it from rmq_build. They are the same, on_load follows the ProMotion style
4
5
  # and is recommended.
5
6
  def rmq_build
6
7
  self.on_load
7
8
  end
9
+
8
10
  end
@@ -1,4 +1,5 @@
1
1
  class UIView
2
+
2
3
  # You can use either rmq_build or on_load, not both. If you have both, on_load will be ignored,
3
4
  # you can however call it from rmq_build. They are the same, on_load follows the ProMotion style
4
5
  # and is recommended.
@@ -86,4 +87,5 @@ class UIView
86
87
  def stylesheet=(value)
87
88
  rmq.stylesheet = value
88
89
  end
90
+
89
91
  end
@@ -1,4 +1,5 @@
1
1
  class UIViewController
2
+
2
3
  def append(view_or_constant, style=nil, opts = {})
3
4
  self.rmq.append(view_or_constant, style, opts)
4
5
  end
@@ -164,4 +165,5 @@ class UIViewController
164
165
  def pm_handles_delegates?
165
166
  self.respond_to?(:class_handles_delegates?) && self.class_handles_delegates?
166
167
  end
168
+
167
169
  end
@@ -1,5 +1,6 @@
1
1
  module ProMotion
2
2
  module DataTable
3
+
3
4
  include TableClassMethods
4
5
  include ProMotion::Styling
5
6
  include ProMotion::Table
@@ -1,5 +1,6 @@
1
1
  module ProMotion
2
2
  class DataTableScreen < TableViewController
3
+
3
4
  include ProMotion::ScreenModule
4
5
  include ProMotion::DataTable
5
6
 
@@ -80,6 +80,7 @@ module ProMotion
80
80
  self.table_view.setScrollEnabled false
81
81
  @table_search_display_controller.delegate.will_begin_search if @table_search_display_controller.delegate.respond_to? "will_begin_search"
82
82
  end
83
+
83
84
  end
84
85
  end
85
86
  end
@@ -1,7 +1,9 @@
1
1
  module ProMotion
2
2
  class Screen < ViewController
3
+
3
4
  def app
4
5
  RubyMotionQuery::App
5
6
  end
7
+
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
1
  module ProMotion
2
2
  module Support
3
+
3
4
  def app
4
5
  RubyMotionQuery::App
5
6
  end
7
+
6
8
  end
7
9
  end
@@ -1,4 +1,5 @@
1
1
  module ProMotion
2
+
2
3
  class TableScreen < TableViewController
3
4
  # Don't call super -- would result in two on_load calls to the cell.
4
5
  def on_cell_created(cell, data)
@@ -1,6 +1,7 @@
1
1
  module RubyMotionQuery
2
2
  class App
3
3
  class << self
4
+
4
5
  def current_screen(root_view_controller = nil)
5
6
  current_view_controller root_view_controller
6
7
  end
@@ -13,11 +14,18 @@ module RubyMotionQuery
13
14
  if !!defined?(SDWebImageManager)
14
15
  image_cache = SDImageCache.sharedImageCache
15
16
  image_cache.clearMemory
16
- image_cache.clearDisk
17
+ if image_cache.respond_to?(:clearDisk)
18
+ # Support for SDWebImage v3.x
19
+ image_cache.clearDisk
20
+ else
21
+ # Support for SDWebImage v4.x
22
+ image_cache.deleteOldFilesWithCompletion(nil)
23
+ end
17
24
  else
18
25
  puts "\n[RedPotion ERROR] tried to reset image cache without SDWebImage cocoapod. Please add this to your Rakefile: \n\napp.pods do\n pod \"SDWebImage\"\nend\n"
19
26
  end
20
27
  end
28
+
21
29
  end
22
30
  end
23
31
  end
@@ -11,6 +11,7 @@ module RubyMotionQuery
11
11
  def placeholder_image=(value)
12
12
  @view.image = value
13
13
  end
14
+
14
15
  end
15
16
  end
16
17
  end
@@ -1,9 +1,11 @@
1
1
  module RubyMotionQuery
2
2
  class RMQ
3
+
3
4
  # TODO Why doesn't this work?
4
5
  #alias :screen :view_controller
5
6
  def screen
6
7
  view_controller
7
8
  end
9
+
8
10
  end
9
11
  end
@@ -1,3 +1,3 @@
1
1
  module RedPotion
2
- VERSION = "1.5.0"
2
+ VERSION = "1.6.0"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  class <%= @name_camel_case %>Screen < UICollectionViewController
2
+
2
3
  include ProMotion::ScreenModule
3
4
 
4
5
  title "Your title here"
@@ -50,4 +51,5 @@ class <%= @name_camel_case %>Screen < UICollectionViewController
50
51
  def will_animate_rotate(orientation, duration)
51
52
  reapply_styles
52
53
  end
54
+
53
55
  end
@@ -1,4 +1,5 @@
1
1
  module <%= @name_camel_case %>CellStylesheet
2
+
2
3
  def cell_size
3
4
  {w: 96, h: 96}
4
5
  end
@@ -1,4 +1,5 @@
1
1
  class <%= @name_camel_case %>Cell < UICollectionViewCell
2
+
2
3
  def on_load
3
4
  find(self).apply_style :<%= @name %>_cell
4
5
 
@@ -6,4 +7,5 @@ class <%= @name_camel_case %>Cell < UICollectionViewCell
6
7
  # Add your subviews, init stuff here
7
8
  # @foo = q.append!(UILabel, :foo)
8
9
  end
10
+
9
11
  end
@@ -1,4 +1,5 @@
1
1
  class <%= @name_camel_case %>Screen < UITableViewController
2
+
2
3
  include ProMotion::ScreenModule
3
4
 
4
5
  title "Your title here"
@@ -70,4 +71,5 @@ class <%= @name_camel_case %>Screen < UITableViewController
70
71
  def will_animate_rotate(orientation, duration)
71
72
  reapply_styles
72
73
  end
74
+
73
75
  end
@@ -22,4 +22,5 @@ class <%= @name_camel_case %>ScreenStylesheet < ApplicationStylesheet
22
22
  st.frame = {left: 5, top: 5, from_right: 10, from_bottom: 5}
23
23
  st.color = color.black
24
24
  end
25
+
25
26
  end
@@ -1,4 +1,5 @@
1
1
  class <%= @name_camel_case %>Cell < UITableViewCell
2
+
2
3
  def on_load
3
4
  find(self.contentView).tap do |q|
4
5
  @name = q.append!(UILabel, :cell_name)
@@ -8,4 +9,5 @@ class <%= @name_camel_case %>Cell < UITableViewCell
8
9
  def update(data)
9
10
  @name.text = "#{data[:name]} is #{data[:num]}"
10
11
  end
12
+
11
13
  end
@@ -5,4 +5,5 @@ describe '<%= @name_camel_case %>Screen' do
5
5
 
6
6
  after do
7
7
  end
8
+
8
9
  end
@@ -1,4 +1,5 @@
1
1
  class <%= @name_camel_case %>Screen < PM::<%= @screen_base %>
2
+
2
3
  title "Your title here"
3
4
  stylesheet <%= @name_camel_case %>ScreenStylesheet
4
5
 
@@ -26,4 +27,5 @@ class <%= @name_camel_case %>Screen < PM::<%= @screen_base %>
26
27
  def will_animate_rotate(orientation, duration)
27
28
  reapply_styles
28
29
  end
30
+
29
31
  end
@@ -1,4 +1,5 @@
1
1
  class <%= @name_camel_case %>ScreenStylesheet < ApplicationStylesheet
2
+
2
3
  # Add your view stylesheets here. You can then override styles if needed,
3
4
  # example: include FooStylesheet
4
5
 
@@ -10,4 +11,5 @@ class <%= @name_camel_case %>ScreenStylesheet < ApplicationStylesheet
10
11
  def root_view(st)
11
12
  st.background_color = color.white
12
13
  end
14
+
13
15
  end
@@ -5,4 +5,5 @@ describe '<%= @name_camel_case %>Screen' do
5
5
 
6
6
  after do
7
7
  end
8
+
8
9
  end
@@ -1,4 +1,5 @@
1
1
  class <%= @name_camel_case %> < PM::TableViewCell
2
+
2
3
  def on_load
3
4
  apply_style :<%= @name %>
4
5
 
@@ -22,8 +23,6 @@ class <%= @name_camel_case %> < PM::TableViewCell
22
23
 
23
24
  end
24
25
 
25
-
26
-
27
26
  __END__
28
27
 
29
28
  You can use this like so in your table_screen:
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redpotion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
- - InfiniteRed
8
- - ClearSight Studio
7
+ - Infinite Red
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-11-30 00:00:00.000000000 Z
11
+ date: 2017-06-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: ruby_motion_query
@@ -111,8 +110,7 @@ dependencies:
111
110
  version: '0'
112
111
  description: RedPotion - The best combination of RubyMotion tools and libraries
113
112
  email:
114
- - hello@infinitered.com
115
- - hello@clearsightstudio.com
113
+ - hello@infinite.red
116
114
  executables:
117
115
  - potion
118
116
  extensions: []
@@ -181,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
179
  version: '0'
182
180
  requirements: []
183
181
  rubyforge_project:
184
- rubygems_version: 2.4.5.1
182
+ rubygems_version: 2.5.2
185
183
  signing_key:
186
184
  specification_version: 4
187
185
  summary: RedPotion combines RMQ, ProMotion, CDQ, AFMotion, and more for the perfect