Giter VIP home page Giter VIP logo

infinitered / redpotion Goto Github PK

View Code? Open in Web Editor NEW
235.0 34.0 41.0 768 KB

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

License: MIT License

Ruby 100.00%
rubymotion boilerplate

redpotion's Introduction

logo


Gem Version Build Status

RedPotion

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

RedPotion combines RMQ, ProMotion, CDQ, AFMotion, MotionPrint and MORE!. 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.

The makers of RMQ and ProMotion at InfiniteRed (web and mobile developers based in Portland, OR and San Francisco, CA) have teamed up with David Larrabee to create the ultimate RubyMotion library.

image

ProMotion for screens and RMQ for styles, animations, traversing, events, etc.




image

Read the RedPotion Documentation.

Read the RedPotion Quick Start Documentation.

Premium Support

RedPotion, as an open source project, is free to use and always will be. Infinite Red offers premium RedPotion support and general mobile app design/development services. Email us at [email protected] to get in touch with us for more details.

redpotion's People

Contributors

andrewhavens avatar austinseraphin avatar bmichotte avatar buffpojken avatar carlinisaacson avatar chrislerum avatar chunlea avatar derekgreenberg avatar dmarkow avatar gantman avatar giedriusr avatar hyr avatar iamjohnford avatar jamonholmgren avatar kevinvangelder avatar markrickert avatar radamanthus avatar shreeve avatar twerth avatar willem-h avatar willrax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redpotion's Issues

Test for content in a custom table cell view

I am using a custom cell class in a table cell and passing it state.

Here is my table cell view:

class CustomCell < PM::TableViewCell
  def state=(state)
    build_initial_view unless view_built? # Lay out view unless already laid out
    find(contentView).tap do |c|
      c.find(:label).data(state[:key]) if state[:key] # Pass state to views
    end
  end

  def view_built?
    @view_built
  end

  def build_initial_view
    find(contentView).tap do |c|
      c.append(UILabel, :label)
    end
    @view_built = true
  end
end

In my spec I can then set my view's state by doing something like this:

describe CustomCell do
  def cell
    @cell ||= CustomCell.new
  end

  def default_state
    {  key: "value"  }
  end

  before do
    cell.state = default_state # Setting state
  end

  after do
    @cell = nil
  end
end

What I am trying to do is then test for content like this:

it "has content" do
  cell.find(:label).data.should == "value"
end

When I run my spec I get this error:

  CustomCell has content: FAILED - [].==("value") failed

Any other ways of trying to find the view have failed as well. I either get nil or an empty array as in the above error.

My question is, how can I check that my views have the correct data in my view spec?

undefined method `production?' for #<UIApplication:0x10d15b7f0>

According to the docs, there is an app.production? method which is an alias of release?. I added some code to my App Delegate which runs some code that is intended for production/app store release, however I am seeing this error:

2015-06-02 15:49:22.878 app[98811:33490681] app_delegate.rb:7:in `on_load:': undefined method `production?' for #<UIApplication:0x10d15b7f0> (NoMethodError)
    from delegate_module.rb:16:in `application:didFinishLaunchingWithOptions:'
2015-06-02 15:49:22.890 app[98811:33490681] *** Terminating app due to uncaught exception 'NoMethodError', reason: 'app_delegate.rb:7:in `on_load:': undefined method `production?' for #<UIApplication:0x10d15b7f0> (NoMethodError)
    from delegate_module.rb:16:in `application:didFinishLaunchingWithOptions:'
'

Here is my code:

class AppDelegate < PM::Delegate
  status_bar true, animation: :fade

  def on_load(app, options)
    if app.production?
      $API_ROOT = 'https://production.example.com/api'
    elsif app.staging? # TODO: make this work since there is no iOS staging environment
      $API_ROOT = 'https://staging.example.com/api'
    elsif app.development?
      $API_ROOT = 'http://localhost:3000/api
    end
# ...

Am I doing something wrong?

Idea: Swipeable table cells

So I get requests from clients on almost EVERY project that they want to be able to have multiple buttons on either side of a tableview cell to do different things. I'm standardized on using MGSwipeTableCell as the tool of choice because it works well and is easy to understand.

Wondering if anyone else ever sees a need for this and if a DSL would be useful and maybe integrate into redpotion?

Here's a typical cell class:

class ChatCell < MGSwipeTableCell
  def on_load
    delete = MGSwipeButton.buttonWithTitle(
      "Delete",
      backgroundColor: color.grass,
      padding: 20,
      callback: -> sender { delete_action }
    )

    block = MGSwipeButton.buttonWithTitle(
      "Block User",
      backgroundColor: color.red,
      padding: 20,
      callback: -> sender { block_action }
    )

    self.rightButtons = [delete, block]
    self.rightSwipeSettings.transition = MGSwipeTransitionDrag
    self.rightExpansion.buttonIndex = 0
    self.rightExpansion.fillOnTrigger = true
  end

  def will_display
  end

  def delete_action
    mp "deleted!"
  end

  def block_action
    mp "blocked!"
  end
end

I'm thinking that this could be shortened to something like we do in ProMotion for the left and right titlebar buttons:

class ChatCell < PM::SwipeTableCell
  def on_load
    set_right_buttons([{
      title: "Delete",
      background_color: color.grass,
      padding: 20,
      action: :delete_action,
    }, {
      title: "Block User",
      background_color: color.red,
      padding: 20,
      action: :block_action,
    }], {
     # Options
     transition: MGSwipeTransitionDrag,
     expansion_index: 0,
     fill_on_trigger: true
    })
  end

  # ...
end

Screen vs. Controller in Stylesheet Naming

Moving projects over to redpotion, BlahController needs to be renamed to BlahScreen. But then there's the additional headache of BlahControllerStylesheet needing to be renamed to BlahScreenStylesheet. Plus... sometimes you don't have everything moved over.

Thoughts on the Stylesheet name being shortened and agnostic? BlahStylesheet?

Stylesheet drops WeakRef

When returning to a view controller (for example - after having logged in using Facebook SDK or similar), the WeakRef the stylesheet holds for the controller is dropped, resulting in a:
old_home_screen_stylesheet.rb:1:in stylesheet': Invalid Reference - probably recycled (WeakRef::RefError)`

when trying to apply any style after returning.

Building vendor project `vendor/Pods' failed to create at least one `.a' library

Hiya!

I'm trying to get started with redpotion, but can't get past the initial setup. I'm on Yosemite, xcode 6.3 and everything else is set up fine (rake'ing a normal ruby-motion project works fine) but as soon as I've created the redpotion project (by the way, the documentation still has 'redpotion create ' instead of the rails-like 'redpotion new ') and I try to rake it, it fails creating .a libraries (or finding them?) for the vendor/Pods

I've tried to rake clean and rake newclear hoping it'd be that easy, but with no luck. Opening the .xcodeproj for Pods in Xcode and building it works fine as well. I thought, at first, that it might be that I'm on a case-sensitive HFS partition which has caused me trouble before (coming from Linux, when I installed I thought 'why wouldnt it be case sensitive?' and thats where that mistake is from) but the issue remains the same even after doing it all in a case sensitive sparsebundle.

Here's my stacktrace:

Scarlet:Selavi amnesthesia$ rake --trace
** Invoke default (first_time)
** Invoke simulator (first_time)
** Execute simulator
Name: Selavi
Using profile: /Volumes/Disk Image/Selavi/signing/selavi.mobileprovision
Using certificate: iPhone Developer: YOURNAME
** Invoke build:simulator (first_time)
** Invoke schema:build (first_time)
** Invoke schema:clean (first_time)
** Execute schema:clean
rm -rf ./resources/Selavi.xcdatamodeld
** Execute schema:build
** Execute build:simulator
rm -f ./build/iPhoneSimulator-7.1-Development/Selavi.app/Info.plist
/usr/bin/ar -rc "libext.a" CoreDataQueryManagedObjectBase.m.o
/usr/bin/ranlib "libext.a"
    ERROR! Building vendor project `vendor/Pods' failed to create at least one `.a' library.
/Library/RubyMotion/lib/motion/project/vendor.rb:220:in `build_xcode'
/Library/RubyMotion/lib/motion/project/vendor.rb:48:in `block in build'
/Library/RubyMotion/lib/motion/project/vendor.rb:47:in `chdir'
/Library/RubyMotion/lib/motion/project/vendor.rb:47:in `build'
/Library/RubyMotion/lib/motion/project/builder.rb:69:in `block in build'
/Library/RubyMotion/lib/motion/project/builder.rb:68:in `each'
/Library/RubyMotion/lib/motion/project/builder.rb:68:in `build'
/Library/RubyMotion/lib/motion/project/app.rb:78:in `build'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/motion-cocoapods-1.7.1/lib/motion/project/cocoapods.rb:53:in `build_with_cocoapods'
/Library/RubyMotion/lib/motion/project/template/ios.rb:68:in `block (2 levels) in <top (required)>'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/amnesthesia/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/Library/RubyMotion/lib/motion/project/template/ios.rb:187:in `block in <top (required)>'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/amnesthesia/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:199:in `each'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:199:in `invoke_prerequisites'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/Users/amnesthesia/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/bin/rake:23:in `load'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/bin/rake:23:in `<main>'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/bin/ruby_executable_hooks:15:in `eval'
/Users/amnesthesia/.rvm/gems/ruby-2.1.0@selavi-potion/bin/ruby_executable_hooks:15:in `<main>'

Any idea of what may be causing this? I've also tried downgrading the cocoapods gem, building in Xcode first, and so on - no luck.

What to set for codesign_certificate?

Sorry, I'm new to building RubyMotion apps. I see in the generated Rakefile that RedPotion sets some sample values for codesign_certificate and provisioning_profile:

  app.release do
    app.entitlements['get-task-allow'] = false
    app.codesign_certificate = 'iPhone Distribution: YOURNAME'
    app.provisioning_profile = "signing/myapp.mobileprovision"
    app.entitlements['beta-reports-active'] = true # For TestFlight

    app.seed_id = "YOUR_SEED_ID"
    app.entitlements['application-identifier'] = app.seed_id + '.' + app.identifier
    app.entitlements['keychain-access-groups'] = [ app.seed_id + '.' + app.identifier ]
  end

I didn't find any documentation on this in the RedPotion docs but it would be really helpful for newcomers like me. I managed to work my way through the Apple Dev Center and iTunes Connect to generate a .certSigningRequest, .cer, and .mobileprovision files. Now I'm trying to build and push to iTunes Connect for Test Flight distribution.

It looks like RedPotion is looking for my provisioning profile in a signing directory which was not generated, so I created one and moved the file there. Seems like maybe this directory should be automatically created and added to the .gitignore file, but maybe there's a reason that it is not. So now what do I set for codesign_certificate? Am I supposed to put my name/email in the YOURNAME placeholder? Or am I supposed to point to the .cer file?

Also I'm not sure what the seed_id option is for. I might run into that issue next. Some comments in the Rakefile would be helpful, or a page on the documentation site (which has been super helpful by the way!).

Any help you can provide would be greatly appreciated. Thanks!

Live reloading doesn't work for modules included in stylesheets

In the example below, when live is invoked in the REPL, updates to style1 are applied, but not when you update style2.

class MyStylesheet < ApplicationStylesheet
  include MyStylesheetAdditions

  def style1(st)
    # whatever
  end
end

module MyStylesheetAdditions
  def style2(st)
    # whatever
  end
end

UINavigationBar appearance not being applied

Hi there, first of all, really great work!

Issue

I'm having issues updating the UINavigationBar appearance from StandardAppearance. Uncommenting this block:

UINavigationBar.appearance.tap do |o|
  o.barTintColor = rmq.color.black
  o.setTintColor rmq.color.black

  o.setTitleTextAttributes( {
    UITextAttributeFont => rmq.font.medium,
    UITextAttributeTextColor => rmq.color.white
    #UITextAttributeTextShadowColor => color.clear
  })
end

Yields no change to the styles.

Env

  • iOS Simulator - iPhone 6 / iOS 8.4
  • redpotion (1.4.0)
  • Rubymotion 4.0 AND 3.14

Please let me know if you need any other info and any advice would be greatly appreciated!

Idea: React-style state model view rendering

Per my article posted this morning, I'd like to discuss bringing in a React-style set_state method on PM::Screen and providing a render (or layout) method in the RMQ stylesheet.

Other things to discuss:

  • View hierarchy diffing -- is it worthwhile from a performance standpoint? Updating UI elements in RMQ is super fast, so it might not make sense.
  • Components -- should we have some analog to React.js components?
  • Table screens / collection screens -- this should be easy(ish) with update_table_data and the like, but we should discuss.
  • Animations -- animating between state changes

Lastly, I have to thanks @twerth for building RMQ -- makes this sort of thing so easy. :-)

Generic screen template

@jamonholmgren and I talked about some new templates in RedPotion, one is a generic screen:

Basically we need a way to make any ol' controller a screen. API would be like this:

potion create generic_screen UICollectionViewController foos

That would create that controller as a screen and include the include ProMotion::ScreenModule as well as some other included commented out. This way you can turn any controller type into a screen.

It should name this a screen and place it in the screens folder.

potion create model foo hangs

This is majorly harmless bug but I thought I'd report it anyway just so it's known.

For some reason the potion create model model_name hangs when I try it. If I go for rmq create model model_name instead, it works without issue.

I'm have redpotion v 0.7.1, rmq 1.1.0, promotion 2.2.1(only redpotion is in the gemfile though)

It seems to hang forever before anything is outputted to the terminal until I control+c

Failing tests removed - needs TLC

I'm going to comment these tests out in my local branch to avoid false positives with my PR, but I'm documenting them here.

@markrickert here's the info

data_table_screen_spec.rb has 1 failing test and 2 errors on lines:

  • 201-206
  • 243-251
  • 253-265

What's the recommended approach for catching a touch event on a cell in a DataTableScreen?

I've got a simple ::PM::DataTableScreen that looks like this:

class TagsPopularScreen < ::PM::DataTableScreen
  title 'Popular'
  stylesheet TagsPopularScreenStylesheet
  model Tag, scope: :where_is_popular
  searchable placeholder: "Search", fields: [:tag], hide_initially: true
end

What's the recommended approach for catching a touch event on one of the cells? This is trivial in a normal ProMotion table screen because you're providing the actions with the cell data. But I'm not sure what the right way to do that would be for a table where the data is coming from a CDQ data source.

Do I need to get in underneath and catch the raw iOS touch event for the table and work out manually what cell was tapped? Or is there a shorthand?

Thanks,
M@

Having trouble changing color of title in nav bar in tab bar screen

I have been able to change the color of the title within a regular screen. However, now I am using a tab bar and it is not applying the color to the title.

class ListScreenStylesheet < ApplicationStylesheet
  def nav_bar
    controller.navigationController.navigationBar
  end

  def setup
    nav_bar.translucent = false
    nav_bar.barTintColor = color.dark_gray
    nav_bar.tintColor = color.white
  end
end

It is correctly changing the background color, but not changing the text of the title to white. However, it is changing the color of the right/left nav bar items to white text. From what I understand, tintColor controls the color of the title too. Am I doing something wrong?

Cell height

Hi, following example code:

module MyCellStylesheet
  def my_cell_height
    300
  end

  def my_cell(st)
    st.frame = { l: 5, t: 100, w: screen_width, h: my_cell_height }
  end
end

No matter what I enter as my_cell_height (e.g. 300 or 10), the actual height of the cell doesn't change. I've tried with different cells and different heights but nothing happens. As the redpotion generator generates the code regarding the height, I assume this is the correct (and only) place to change the height.

This is what the log tells me:

(#<UITableViewCellContentView:0...)> find(self).log

 object_id   | class                 | style_name              | frame                           |
 sv id       | superview             | subviews count          | tags                            |
 - - - - - - | - - - - - - - - - - - | - - - - - - - - - - - - | - - - - - - - - - - - - - - - - |
 4635218720  | UITableViewCellContent| content_view            | {l: 0, t: 0, w: 375, h: 43.5}   |
 4635216768  | MyCell            | 2                       |                                 |
 - - - - - - | - - - - - - - - - - - | - - - - - - - - - - - - | - - - - - - - - - - - - - - - - |
RMQ 4674630768. 1 selected. selectors: [#<UITableViewCellContentView:0x11447d320>]
=> nil

(#<UITableViewCellContentView:0...)> find(self).closest(MyCell).log

 object_id   | class                 | style_name              | frame                           |
 sv id       | superview             | subviews count          | tags                            |
 - - - - - - | - - - - - - - - - - - | - - - - - - - - - - - - | - - - - - - - - - - - - - - - - |
 4635216768  | MyCell            | my_cell             | {l: 0, t: 155, w: 375, h: 44}   |
 4519189584  | UITableViewWrapperView| 3                       |                                 |
 - - - - - - | - - - - - - - - - - - | - - - - - - - - - - - - | - - - - - - - - - - - - - - - - |

What am I missing? Thanks!

Require the cell template included in the model - DataTableScreen

Per a discussion we had on #64, I would like to propose that we enforce that the model is where the cell structure is defined. It's cleaner, and more intention leading.

@markrickert and I both agree that we prefer forcing the dev specify the cell be in the model. We should probably include that the cell method is implemented on the model and raise an error if not if we are going to be forcing that the cell is defined in the model used for the screen.

I am interested in others thoughts, agree? disagree? Dont care? Chime in now!

Automatic resizing for smaller devices

Hi again guys.

I am having a problem making my app layout look good on some screens I made by hand on smaller devices. The app is designed for iPhone 6 and I am testing on iPod Touch 5g. Is there a recommended way of doing this? I'm not sure how to set up RMQ so that the views auto resize but it looked like this was supposed to happen by default. I would provide screen shots but they kind of give our app away. The basic problem is that stuff is too big and it is leaking off the edge. Do I have to detect each screen size and provide sizes for each? That seems... tedious.

Anyway thanks again for a great library and I hope I'm not taking up too much of your guys time. Lol

Add on_load to UIView

The next version of ProMotion will work with .on_load on a view, this will get called if ProMotion creates a view, such as in a table. IMO RedPotion should also call on_load anytime it currently calls rmq_build. And we should prefer on_load over rmq_build for RedPotion projects.

Frame isn't properly calculated

When appending views inside other views:

class SignupStartView < UIView
    attr_reader :sign_up, :sign_in
    def initWithFrame(rect)
        if super
            append!(UIImageView, :logo)
        end
        self
    end
    def drawRect(rect)
        super
    end
end

and then setting the frame of UIImageView with:

  def logo(st)
    st.image = UIImage.imageNamed('signup/logo_title.png')
        st.frame = {l: 5, t: 5, fr: 5, fb: 5}
  end

frame isn't properly calculated. Even though the SignupStartView receives a frame of

<CGRect origin=#<CGPoint x=0.0 y=0.0> size=#<CGSize width=375.0 height=274.0>>

the frame of the UIImageView is set to:

<CGRect origin=#<CGPoint x=-5.0 y=-5.0> size=#<CGSize width=10.0 height=10.0>>

When setting widht/height manually in the stylesheet, it works as expected?

Loosen RMQ and ProMotion dependencies

Interested in others thoughts on if there is a reason we should not do this?

I think that we should change our dependencies on RMQ and ProMotion to be less restrictive and only bump the requirement when we know there is new functionality in the dependent gem that we require.

Currently we have:

spec.add_runtime_dependency "ruby_motion_query", "~> 1.4.0"
spec.add_runtime_dependency "ProMotion", "~> 2.3.1"

but is there any reason we should not do:

spec.add_runtime_dependency "ruby_motion_query", ">= 1.4.0"
spec.add_runtime_dependency "ProMotion", ">= 2.3.1"

I have thought about this a few times, but if I read #106 correctly, I think the problem is there was a bug fixed in 1.4.1 of ProMotion - but as a user of RedPotion you are restricted to our next release - if we loosened the restriction like above - I as a user could bump ProMotion without any new redpotion release, and fix the underlying bug that was fixed in that product.

title_view in PM::TableScreen doesn't work

Hi!

I am trying to style a PM::TableScreen according to my client design specs.

The title_view command isn't working, I generated a new view using potion create view.

LineListScreen.rb

class LineListScreen < PM::TableScreen
  title_view Title.new
  refreshable
  searchable placeholder: "Search"
  stylesheet LineListScreenStylesheet
  include API

  def on_load
    @table_data = []
    load_async
  end

  def load_async
    get_lines do
      @lines = Line.all.to_a
      @table_data = [{
        cells: @lines.map do |line|
          {
            title: line.name,
            subtitle: "phone number"
          }
        end
      }]
      stop_refreshing
      update_table_data
    end
  end

  def on_refresh
    load_async
  end

  def table_data
    @table_data
  end

end

Title.rb

class Title < UIView

  def on_load
    apply_style :title

    append UILabel, :virtualq
  end

end

LineListScreenStylesheet.rb

class LineListScreenStylesheet < ApplicationStylesheet

  include TitleStylesheet

  def setup

  end

  def root_view(st)
    # st.superview.superview.frame = {l: 0, t: 0, w: 375, h: 648}
    # st.superview.superview.background_color = color.virtualq
    st.background_color = color.vq_gray
    # mp st
  end
end

TitleStylesheet.rb

module TitleStylesheet

  def title(st)
    st.frame = {l: 0, t: 0, w: 375, h: 64}
    st.background_color = color.virtualq
    # Style overall view here
    mp st 
  end

  def virtualq(st)
    st.frame = {l: 0, t: 0, w: 375, h: 64}
    st.text_alignment = :center
    st.text = "virtualQ"
    st.background_color = color.virtualq
    st.font = font.medium_small
    mp st
  end

end

As far as I can tell, Title.rb's on_load never gets called. The TitleStylesheet also never gets called.

Am I doing it wrong?

Undefined method make_button

Hi, In a PM::TableScreen I'm trying to use the app.make_button method to create some buttons for an ActionSheet. Unfortunately I get an undefined method error.

I copied the button code from an example of the docs, my code looks basically like this (the error happens using this code):

class HomeTableScreen < PM::TableScreen
  title "Test"
  stylesheet HomeTableScreenStylesheet

  def on_load
    some_action
  end

  def table_data
    [{ cells: some_data }]
  end

  def some_action
    taco = app.make_button("Taco") {
            puts "Taco pressed"
          }
  end
end

Here is the stack trace (I can provide the generated crashlog if needed):

undefined method `make_button' for RubyMotionQuery::App:Class (NoMethodError)
2015-05-10 12:42:15.041 testapp[7212:7434475] *** Terminating app due to uncaught exception 'NoMethodError', reason: 'home_table_screen.rb:29:in `gram_button': undefined method `make_button' for RubyMotionQuery::App:Class (NoMethodError)
'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010343ec65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010077ebb7 objc_exception_throw + 45
    2   testapp                            0x000000010036a91f _ZL10__vm_raisev + 399
    3   testapp                            0x000000010036aa4d rb_vm_raise + 205
    4   testapp                            0x0000000100268b59 rb_exc_raise + 9
    5   testapp                            0x0000000100368cc2 rb_vm_method_missing + 786
    6   testapp                            0x000000010033bbf5 rb_vm_dispatch + 5925
    7   testapp                            0x000000010033a38d rb_vm_trigger_method_missing + 1053
    8   testapp                            0x000000010033b5ef rb_vm_dispatch + 4383
    9   testapp                            0x00000001000415bc vm_dispatch + 1436
    10  testapp                            0x0000000100226a43 rb_scope__gram_button__ + 355
    11  testapp                            0x0000000100226fcd __unnamed_29 + 13
    12  UIKit                               0x0000000100ca2da2 -[UIApplication sendAction:to:from:forEvent:] + 75
    13  UIKit                               0x0000000100ca2da2 -[UIApplication sendAction:to:from:forEvent:] + 75
    14  UIKit                               0x0000000100db454a -[UIControl _sendActionsForEvents:withEvent:] + 467
    15  UIKit                               0x0000000100db3919 -[UIControl touchesEnded:withEvent:] + 522
    16  UIKit                               0x0000000100cef998 -[UIWindow _sendTouchesForEvent:] + 735
    17  UIKit                               0x0000000100cf02c2 -[UIWindow sendEvent:] + 682
    18  UIKit                               0x0000000100cb6581 -[UIApplication sendEvent:] + 246
    19  UIKit                               0x0000000100cc3d1c _UIApplicationHandleEventFromQueueEvent + 18265
    20  UIKit                               0x0000000100c9e5dc _UIApplicationHandleEventQueue + 2066
    21  CoreFoundation                      0x0000000103372431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    22  CoreFoundation                      0x00000001033682fd __CFRunLoopDoSources0 + 269
    23  CoreFoundation                      0x0000000103367934 __CFRunLoopRun + 868
    24  CoreFoundation                      0x0000000103367366 CFRunLoopRunSpecific + 470
    25  GraphicsServices                    0x0000000105067a3e GSEventRunModal + 161
    26  UIKit                               0x0000000100ca1900 UIApplicationMain + 1282
    27  testapp                            0x000000010004964f main + 111
    28  libdyld.dylib                       0x00000001047ef145 start + 1
    29  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NoMethodError

================================================================================
The application terminated. A crash report file may have been generated by the
system, use `rake crashlog' to open it. Use `rake debug=1' to restart the app
in the debugger.
================================================================================

I've triple checked everything so I hope it's not a typo from my side. Thanks a lot for your help and your work on this brilliant gem.

Remove exception when stylesheet is not defined

@twerth had mentioned removing the exception for when a stylesheet is not defined. Let's remove that as RedPotion, RMQ, and ProMotion will continue to work without it, it simply wont have a nice place to put all the styles.

Should we warn, or just let it be when one is not provided?

`potion create` is generating a Rails app?

Okay, this is bizarre. I just installed and generated a new RedPotion app and it generated what looks like a Rails app instead of a RubyMotion app:

$ rbenv install 2.2.2 && rbenv global 2.2.2
$ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]

$ gem install potion # oops

$ gem install redpotion
redpotion's executable "potion" conflicts with potion
Overwrite the executable? [yN]  y
Successfully installed redpotion-1.2.0

$ potion -v
1.2.0

$ potion create myapp
     Creating app
  Template Cloning redpotion-template template
  Template redpotion-template already exists, performing a pull
remote: Counting objects: 62, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 62 (delta 5), reused 4 (delta 4), pack-reused 50
Unpacking objects: 100% (62/62), done.
From github.com:infinitered/redpotion-template
 * branch            master     -> FETCH_HEAD
   06c24a4..b865a5f  master     -> origin/master
Running bundle...
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 10.4.2
Using i18n 0.7.0
Installing json 1.8.2
Installing minitest 5.6.1
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 4.2.1
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.6
Using loofah 2.0.2
Using rails-html-sanitizer 1.0.2
Using actionview 4.2.1
Using rack 1.6.1
Using rack-test 0.6.3
Using actionpack 4.2.1
Using globalid 0.3.5
Using activejob 4.2.1
Using mime-types 2.6.1
Using mail 2.6.3
Using actionmailer 4.2.1
Using activemodel 4.2.1
Using arel 6.0.0
Using activerecord 4.2.1
Installing debug_inspector 0.0.2
Installing binding_of_caller 0.7.2
Installing columnize 0.9.0
Installing byebug 5.0.0
Using coffee-script-source 1.9.1.1
Using execjs 2.5.2
Using coffee-script 2.4.1
Using thor 0.19.1
Using railties 4.2.1
Installing coffee-rails 4.1.0
Installing multi_json 1.11.0
Installing jbuilder 2.2.16
Installing jquery-rails 4.0.3
Using bundler 1.9.9
Using sprockets 3.1.0
Using sprockets-rails 2.3.1
Using rails 4.2.1
Using rdoc 4.2.0
Using sass 3.4.14
Installing tilt 1.4.1
Installing sass-rails 5.0.3
Installing sdoc 0.4.1
Installing spring 1.3.6
Installing sqlite3 1.3.10
Installing turbolinks 2.5.3
Installing uglifier 2.7.1
Installing web-console 2.1.2
Bundle complete! 12 Gemfile dependencies, 54 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Running rake pod:install...
rake aborted!
Don't know how to build task 'pod:install'

(See full trace by running task with --trace)

      Complete. Things you can do:
      > rake spec
      > rake
      (main)> exit

      Then try these:
      > rake device_name='iPhone 4s'
      > rake device_name='iPhone 5s'
      > rake device_name='iPhone 5s' target=7.1
      > rake device_name='iPhone 6 Plus'
      > rake device_name='iPad Retina'
      > rake device

      Or for XCode 5.1
      > rake retina=3.5
      > rake retina=4
      > rake device_family=ipad

$ cd myapp/
$ rake pod:install
rake aborted!
Don't know how to build task 'pod:install'

(See full trace by running task with --trace)

$ ls -la
total 48
drwxr-xr-x+ 18 andrew  staff   612 May 27 10:13 .
drwxr-xr-x+  4 andrew  staff   136 May 27 11:03 ..
-rw-r--r--+  1 andrew  staff   474 May 27 10:13 .gitignore
-rw-r--r--+  1 andrew  staff  1476 May 27 10:13 Gemfile
-rw-r--r--+  1 andrew  staff  3828 May 27 10:13 Gemfile.lock
-rw-r--r--+  1 andrew  staff   478 May 27 10:13 README.rdoc
-rw-r--r--+  1 andrew  staff   249 May 27 10:13 Rakefile
drwxr-xr-x+  8 andrew  staff   272 May 27 10:13 app
drwxr-xr-x+  7 andrew  staff   238 May 27 10:13 bin
drwxr-xr-x+ 11 andrew  staff   374 May 27 10:13 config
-rw-r--r--+  1 andrew  staff   153 May 27 10:13 config.ru
drwxr-xr-x+  3 andrew  staff   102 May 27 10:13 db
drwxr-xr-x+  4 andrew  staff   136 May 27 10:13 lib
drwxr-xr-x+  3 andrew  staff   102 May 27 10:13 log
drwxr-xr-x+  7 andrew  staff   238 May 27 10:13 public
drwxr-xr-x+  9 andrew  staff   306 May 27 10:13 test
drwxr-xr-x+  3 andrew  staff   102 May 27 10:13 tmp
drwxr-xr-x+  3 andrew  staff   102 May 27 10:13 vendor
$ cat Rakefile
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)

Rails.application.load_tasks

Documentation

Be nice to have repo based documentation, but not in the ReadMe. In markdown. Something people can do a PR for. Perhaps a script to push it to wherever it lives. Like ProMotion does.

Idea: DataTableScreen refreshes row automatically when the model file is saved to core data

So I think this might be a really killer feature to have:

I have my managed object:

class Whatever < CDQManagedObject
end

and a PM::DataTableScreen that displays its contents.

Core data ManagedObjects give us a didSave method that's called when core data saves the file to the store. I've verified that it's called when you do a cdq.save.

Now we need to figure a way to remember what position its in in the table and then just call

update_table_data(NSIndexPath.indexPathForRow(x, inSection:y))

Thoughts on how we might achieve this?

Live reloading for PM Screens

I'm working on it. Should hook into live.

Also, would like to output an info debug when loading the simulator up:

[RedPotion] Type in `live` to enable live reloading of screens and stylesheets
> 

UITableViewCell centre

Hi, I have this code:

# app/views/my_cell.rb
class MyCell < PM::TableViewCell
  def on_load
    apply_style :my_cell

    content = find(self.contentView)
    @title = content.append! UILabel, :my_cell_title
    @segmented = content.append! UISegmentedControl, :segmented_control

    @segmented.segmentedControlStyle = UISegmentedControlStyleBar
    @segmented.insertSegmentWithTitle('One', atIndex: 0, animated: false)
    @segmented.insertSegmentWithTitle('Two', atIndex: 1, animated: false)
  end

  def title=(value)
    @title.text = value
  end
  def title
    @title
  end
end
# app/stylesheets/my_cell_stylesheet.rb
module MyCellStylesheet
  def my_cell_height
    40
  end

  def my_cell(st)
    st.frame = {l: 5, t: 100, w: 80, h: my_cell_height}
    # Style overall view here
  end

  def my_cell_title(st)
    st.frame = { l: 10, fr: 10, centered: :vertical, h: 20 }
    st.font = font.medium
    st.color = color.black
  end

  def segmented_control(st)
    st.frame = { left: 20, fr: 20, centered: :both, h: 30 }
  end
end

Which results in this:
picture

I have two questions, first: shouldn't the segmented_control be horizontally centered?

And second question: if I use this code instead (in the stylesheet):

def segmented_control(st)
    st.frame = { left: 20, fr: 20, centered: :vertically, h: 30 }
end

How is this vertically centered?
vertically cented

What am I doing wrong? If I had to guess, I would say that the view of the cell itself is not filling the whole available space and therefore the segmented_control is misplaced whilst despite centered. Thanks a lot!

Idea: progress spinner

We should decided on a progress gem, like JGProgressHUD or whatever, and make a nice wrapper around it in RedPotion. Especially the common stuff.

Review Travis

I'm seeing Travis build failures more regularly, creating an iissue as a reminder to review and fix what I think is an intermittent test. Or at least review and fix the failures

Getting: uninitialized constant CDQ::CDQConfig::YAML error after bundle update

I just ran a bundle update on my RedPotion project and got the following CDQ error:

*** Starting simulator
(main)> 2015-08-01 12:00:02.422 Pendulum[57525:536800] config.rb:38:in `block in initialize:': uninitialized constant CDQ::CDQConfig::YAML (NameError)
    from config.rb:38:in `initialize:'
    from config.rb:94:in `default'
    from model.rb:9:in `initialize:'
    from object.rb:17:in `models'
    from object.rb:13:in `stores'
    from object.rb:9:in `contexts'
    from object.rb:55:in `setup:'
    from app_delegate.rb:8:in `on_load:'
    from delegate_module.rb:16:in `application:didFinishLaunchingWithOptions:'
2015-08-01 12:00:02.434 Pendulum[57525:536800] *** Terminating app due to uncaught exception 'NameError', reason: 'config.rb:38:in `block in initialize:': uninitialized constant CDQ::CDQConfig::YAML (NameError)
    from config.rb:38:in `initialize:'
    from config.rb:94:in `default'
    from model.rb:9:in `initialize:'
    from object.rb:17:in `models'
    from object.rb:13:in `stores'
    from object.rb:9:in `contexts'
    from object.rb:55:in `setup:'
    from app_delegate.rb:8:in `on_load:'
    from delegate_module.rb:16:in `application:didFinishLaunchingWithOptions:'
'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010473fc65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000100b62bb7 objc_exception_throw + 45
    2   Pendulum                            0x000000010053647f _ZL10__vm_raisev + 399
    3   Pendulum                            0x00000001005365ad rb_vm_raise + 205
    4   Pendulum                            0x00000001004334a9 rb_exc_raise + 9
    5   Pendulum                            0x000000010042d754 rb_name_error + 228
    6   Pendulum                            0x00000001004e55e9 rb_mod_const_missing + 121
    7   Pendulum                            0x0000000100507d39 rb_vm_dispatch + 7401
    8   Pendulum                            0x00000001004e64fd rb_const_get_0 + 1165
    9   Pendulum                            0x000000010005be4e vm_get_const + 302
    10  Pendulum                            0x00000001001573dc rb_scope__initialize:__block__ + 92
    11  Pendulum                            0x0000000100508fef _ZL13vm_block_evalP7RoxorVMP11rb_vm_blockP13objc_selectormiPKm + 1119
    12  Pendulum                            0x0000000100509310 rb_vm_yield_args + 64
    13  Pendulum                            0x00000001004fcdcb rb_yield + 59
    14  Pendulum                            0x0000000100536789 rb_ensure + 25
    15  Pendulum                            0x0000000100507775 rb_vm_dispatch + 5925
    16  Pendulum                            0x000000010005c4ac vm_dispatch + 1436
    17  Pendulum                            0x000000010015679e rb_scope__initialize:__ + 686
    18  Pendulum                            0x0000000100507d39 rb_vm_dispatch + 7401
    19  Pendulum                            0x00000001004670e4 rb_class_new_instance0 + 884
    20  Pendulum                            0x0000000100507775 rb_vm_dispatch + 5925
    21  Pendulum                            0x000000010005c4ac vm_dispatch + 1436
    22  Pendulum                            0x0000000100158493 rb_scope__default__ + 387
    23  Pendulum                            0x0000000100507d39 rb_vm_dispatch + 7401
    24  Pendulum                            0x000000010005c4ac vm_dispatch + 1436
    25  Pendulum                            0x00000001001666ea rb_scope__initialize:__ + 186
    26  Pendulum                            0x0000000100507d39 rb_vm_dispatch + 7401
    27  Pendulum                            0x00000001004670e4 rb_class_new_instance0 + 884
    28  Pendulum                            0x0000000100507775 rb_vm_dispatch + 5925
    29  Pendulum                            0x000000010005c4ac vm_dispatch + 1436
    30  Pendulum                            0x0000000100171be9 rb_scope__models__ + 153
    31  Pendulum                            0x0000000100507d39 rb_vm_dispatch + 7401
    32  Pendulum                            0x000000010005c4ac vm_dispatch + 1436
    33  Pendulum                            0x0000000100171a8b rb_scope__stores__ + 187
    34  Pendulum                            0x0000000100507d39 rb_vm_dispatch + 7401
    35  Pendulum                            0x000000010005c4ac vm_dispatch + 1436
    36  Pendulum                            0x000000010017190b rb_scope__contexts__ + 187
    37  Pendulum                            0x0000000100507d39 rb_vm_dispatch + 7401
    38  Pendulum                            0x000000010005c4ac vm_dispatch + 1436
    39  Pendulum                            0x0000000100172346 rb_scope__setup:__ + 614
    40  Pendulum                            0x0000000100507d39 rb_vm_dispatch + 7401
    41  Pendulum                            0x000000010005c4ac vm_dispatch + 1436
    42  Pendulum                            0x00000001003bd673 rb_scope__on_load:__ + 163
    43  Pendulum                            0x0000000100507d39 rb_vm_dispatch + 7401
    44  Pendulum                            0x000000010005c4ac vm_dispatch + 1436
    45  Pendulum                            0x000000010030c8da rb_scope__application:didFinishLaunchingWithOptions:__ + 202
    46  Pendulum                            0x000000010030cadd __unnamed_46 + 61
    47  UIKit                               0x0000000102536748 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 240
    48  UIKit                               0x0000000102537357 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2540
    49  UIKit                               0x000000010253a19e -[UIApplication _runWithMainScene:transitionContext:completion:] + 1349
    50  UIKit                               0x0000000102539095 -[UIApplication workspaceDidEndTransaction:] + 179
    51  FrontBoardServices                  0x0000000108e0f5e5 __31-[FBSSerialQueue performAsync:]_block_invoke_2 + 21
    52  CoreFoundation                      0x000000010467341c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    53  CoreFoundation                      0x0000000104669165 __CFRunLoopDoBlocks + 341
    54  CoreFoundation                      0x0000000104668f25 __CFRunLoopRun + 2389
    55  CoreFoundation                      0x0000000104668366 CFRunLoopRunSpecific + 470
    56  UIKit                               0x0000000102538b02 -[UIApplication _run] + 413
    57  UIKit                               0x000000010253b8c0 UIApplicationMain + 1282
    58  Pendulum                            0x00000001000648cf main + 111
    59  libdyld.dylib                       0x0000000107201145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NameError

The project is pretty standard. Here's the gemfile:

source "https://rubygems.org"
gem "rake"
gem "motion-cocoapods"
gem "redpotion"
gem "cdq"
gem "afmotion"
gem "newclear" 
gem "ProMotion-form"
gem "ProMotion-push", "~> 0.2"
gem "ProMotion-map", "~> 0.3"
gem "ProMotion-iap"
gem "ProMotion-menu"
gem "bubble-wrap"
gem 'motion-blitz'

Any ideas?

Issue with `on_load` firing more than once

I was working with my existing app and making headway towards using RedPotion and noticed an interesting issue. I had a controller that I converted to a screen and it seemed to be appending my views more than once (3 times to be exact).

I thought that this was totally due to my migration path, but I was able to recreate pretty simply on the sample app of redpotion. If you simply open the home screen and add mp 'on_load HomeScreen' you will see the following result by simply running the app.

Simulate ./build/iPhoneSimulator-8.1-Development/RedPotion.app
(main)> "on_load HomeScreen"
"on_load HomeScreen"
"on_load HomeScreen"

Pretty sure I tracked down the issue - PR coming for this later today.

Idea: "headless" tables

@twerth and I discussed several scenarios related to #63 and infinitered/rmq#232. One of the sticking points is collections or sets of data and how to represent those on a screen. Todd and I agree that tables are underutilized as child views, and I'd like to make that easier.

I have this concept of a "headless" table view. ProMotion makes it easy to make a PM::TableScreen subclass, but what if we could do this in a normal screen:

class ContactScreen < PM::Screen
  def on_load
    append email_view, :emails
  end

  def email_view
    @email_view ||= build_table_view([{
      title: "Email addresses",
      cells: @emails.map do |email|
        {
          cell_class: SomeCustomClass,
          title: email,
          action: :tapped_email,
          arguments: { email: email } 
        }
      end
    }])
  end

  def tapped_email(args={})
    args[:email] # => some email
  end
end

No explicit PM::TableScreen subclass would be necessary. All events would be passed through to the parent screen, and the UITableViewController instance would be automatically built, added as a childViewController, and managed from your current screen instance. These things are usually pretty boilerplate anyway, so it makes sense to have a helper for this.

Thoughts?

Remove default Pods/Gems as needed

A beginner to RubyMotion won't know anything about AFnetworking or CDQ. We'd love the gem to still be fore them. So lets add a few potion tasks to remove CDQ after the fact.

potion remove cdq
postion remove afmotion

Idea: scaffolding generators

Hello! This is a continuation of a conversation that started on Twitter. Just creating this issue to start the conversation around this feature.

It would be really useful to have a scaffolding generator, much like Rails, which would provide the basic CRUD operations. This would also serve as an example of how to wire up views, create forms, and work with CDQ. A simple ToDo list example app would go a long way in helping beginners to learn iOS/ProMotion/RedPotion. I don't know of anything like that.

Another common task is working with an API. Another potential scaffolding generator could be the same CRUD operations using AFMotion instead of CDQ.

Let me know what the next steps would be in implementing this. I'm happy to help. Though I must admit that I'm still relatively new to iOS/RubyMotion development.

Documentation for using CDQ not working

I'm not sure if this is an issue with RedPotion, CDQ or myself being a noob but after running through the CDQ tutorial here http://docs.redpotion.org/en/latest/cookbook/core_data/ I'm getting an error when trying to run the iOS simulator. So far I've uncommented the schema and generated the model files.

*** Starting simulator 2015-07-11 14:56:30.203 todo2[73446:1865241] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

I've tried this with the iOS 7.0 and the 8.4 simulator. I've even tried recreating a blank project to make sure it wasn't my own code causing it. The app works fine until I make the schema and model files.

I'm using the following gem versions:

RedPotion 1.3.0
ProMotion 2.4.2
CDQ 1.0.3

StackTrace:

*** First throw call stack:
(
    0   CoreFoundation                      0x0000000103283c65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010093fbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x00000001031508ca -[__NSArrayM insertObject:atIndex:] + 954
    3   todo2                               0x000000010000229e -[YKParser parseWithError:] + 708
    4   todo2                               0x000000010000151f +[YAMLKit loadFromString:] + 95
    5   todo2                               0x0000000100054e92 __unnamed_353 + 98
    6   todo2                               0x0000000100439abe rb_vm_dispatch + 6270
    7   todo2                               0x0000000100040f6c vm_dispatch + 1436
    8   todo2                               0x0000000100057753 rb_scope__load:__ + 211
    9   todo2                               0x0000000100439f29 rb_vm_dispatch + 7401
    10  todo2                               0x0000000100040f6c vm_dispatch + 1436
    11  todo2                               0x000000010005a0b0 rb_scope__initialize:__block__ + 208
    12  todo2                               0x000000010043b1df _ZL13vm_block_evalP7RoxorVMP11rb_vm_blockP13objc_selectormiPKm + 1119
    13  todo2                               0x000000010043b500 rb_vm_yield_args + 64
    14  todo2                               0x000000010042efbb rb_yield + 59
    15  todo2                               0x0000000100468979 rb_ensure + 25
    16  todo2                               0x0000000100439965 rb_vm_dispatch + 5925
    17  todo2                               0x0000000100040f6c vm_dispatch + 1436
    18  todo2                               0x00000001000593fe rb_scope__initialize:__ + 686
    19  todo2                               0x0000000100439f29 rb_vm_dispatch + 7401
    20  todo2                               0x00000001003992d4 rb_class_new_instance0 + 884
    21  todo2                               0x0000000100439965 rb_vm_dispatch + 5925
    22  todo2                               0x0000000100040f6c vm_dispatch + 1436
    23  todo2                               0x000000010005b0f3 rb_scope__default__ + 387
    24  todo2                               0x0000000100439f29 rb_vm_dispatch + 7401
    25  todo2                               0x0000000100040f6c vm_dispatch + 1436
    26  todo2                               0x000000010005cb7a rb_scope__initialize:__ + 186
    27  todo2                               0x0000000100439f29 rb_vm_dispatch + 7401
    28  todo2                               0x00000001003992d4 rb_class_new_instance0 + 884
    29  todo2                               0x0000000100439965 rb_vm_dispatch + 5925
    30  todo2                               0x0000000100040f6c vm_dispatch + 1436
    31  todo2                               0x00000001000ab319 rb_scope__models__ + 153
    32  todo2                               0x0000000100439f29 rb_vm_dispatch + 7401
    33  todo2                               0x0000000100040f6c vm_dispatch + 1436
    34  todo2                               0x00000001000ca38e rb_scope__cdq:__ + 990
    35  todo2                               0x0000000100439f29 rb_vm_dispatch + 7401
    36  todo2                               0x0000000100040f6c vm_dispatch + 1436
    37  todo2                               0x00000001000ce5d3 rb_scope__cdq:__ + 163
    38  todo2                               0x0000000100439f29 rb_vm_dispatch + 7401
    39  todo2                               0x0000000100040f6c vm_dispatch + 1436
    40  todo2                               0x00000001000cd437 rb_scope__inherited:__ + 135
    41  todo2                               0x0000000100439f29 rb_vm_dispatch + 7401
    42  todo2                               0x000000010033c683 rb_class_inherited + 275
    43  todo2                               0x0000000100460778 rb_vm_define_class + 1016
    44  todo2                               0x00000001003216f0 rb_scope1 + 112
    45  todo2                               0x0000000100321a55 MREP_D03103273A2A47B99E820C70C5455622 + 677
    46  todo2                               0x0000000100048fb1 RubyMotionInit + 2113
    47  todo2                               0x0000000100049045 main + 85
    48  libdyld.dylib                       0x0000000104615145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Any ideas if I'm doing something wrong?

Refreshable TableView Crash On Example App

(main)> 2015-04-18 20:29:19.546 RedPotion[53366:624352] refreshable.rb:41:in `refreshView:': undefined local variable or method `refreshable_callback' for #<ContributerScreen:0x1
0b4b7a60> (NameError)
2015-04-18 20:29:19.551 RedPotion[53366:624352] *** Terminating app due to uncaught exception 'NameError', reason: 'refreshable.rb:41:in `refreshView:': undefined local variable
or method `refreshable_callback' for #<ContributerScreen:0x10b4b7a60> (NameError)
'
*** First throw call stack:
(
        0   CoreFoundation                      0x00000001031e9c65 __exceptionPreprocess + 165
        1   libobjc.A.dylib                     0x0000000100714bb7 objc_exception_throw + 45
        2   RedPotion                           0x0000000100348caf _ZL10__vm_raisev + 399
        3   RedPotion                           0x0000000100348ddd rb_vm_raise + 205
        4   RedPotion                           0x0000000100246ee9 rb_exc_raise + 9
        5   RedPotion                           0x0000000100347052 rb_vm_method_missing + 786
        6   RedPotion                           0x0000000100319f85 rb_vm_dispatch + 5925
        7   RedPotion                           0x000000010031871d rb_vm_trigger_method_missing + 1053
        8   RedPotion                           0x000000010031997f rb_vm_dispatch + 4383
        9   RedPotion                           0x000000010001ed7c vm_dispatch + 1436
        10  RedPotion                           0x00000001001c530d rb_scope__refreshView:__ + 381
        11  RedPotion                           0x00000001001c5608 __unnamed_25 + 40
        12  UIKit                               0x0000000100c38da2 -[UIApplication sendAction:to:from:forEvent:] + 75
        13  UIKit                               0x0000000100d4a54a -[UIControl _sendActionsForEvents:withEvent:] + 467
        14  UIKit                               0x000000010131aaf5 -[UIRefreshControl _setRefreshControlState:notify:] + 318
        15  libdispatch.dylib                   0x000000010473af16 _dispatch_call_block_and_release + 12
        16  libdispatch.dylib                   0x0000000104755964 _dispatch_client_callout + 8
        17  libdispatch.dylib                   0x000000010473f50c _dispatch_after_timer_callback + 89
        18  libdispatch.dylib                   0x0000000104755964 _dispatch_client_callout + 8
        19  libdispatch.dylib                   0x000000010474c1e2 _dispatch_source_latch_and_call + 786
        20  libdispatch.dylib                   0x00000001047454a0 _dispatch_source_invoke + 404
        21  libdispatch.dylib                   0x0000000104740927 _dispatch_main_queue_callback_4CF + 398
        22  CoreFoundation                      0x00000001031511f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
        23  CoreFoundation                      0x0000000103112dcb __CFRunLoopRun + 2043
        24  CoreFoundation                      0x0000000103112366 CFRunLoopRunSpecific + 470
        25  GraphicsServices                    0x0000000104ffda3e GSEventRunModal + 161
        26  UIKit                               0x0000000100c37900 UIApplicationMain + 1282
        27  RedPotion                           0x0000000100026e5f main + 111
        28  libdyld.dylib                       0x0000000104785145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NameError

================================================================================
The application terminated. A crash report file may have been generated by the
system, use `rake crashlog' to open it. Use `rake debug=1' to restart the app
in the debugger.
================================================================================

Steps to reproduce:

  1. Open Example App.
  2. Click Data Table Screen.
  3. Pull To Refresh.
  4. App Crashes.

potion remove cdq - should remove spec helper as well

currently running potion remove cdq leaves the spec helper cdq adds - making specs crash until you manually remove the file.

Documenting this now - will probably get a PR out for it out in the next day or so (unless someone beats me to it!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.