**NOTE: MotionTable is deprecated and has been merged into the ProMotion project.
MotionTable is a RubyMotion gem for easily building table views in iOS.
Feedback welcome: jamon@clearsightstudio.com(@jamonholmgren) or silas@clearsightstudio.com(@silasjmatson)
Installation
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install motion-table
Alternatively, get the edge version:
gem 'motion-table', :git => 'git@github.com:clearsightstudio/motion-table.git'
Usage
Include MotionTable in your controller and handle UITableViews Easily
class MyController < UITableViewController include MotionTable::GroupedTable def viewDidLoad super self.title = "Settings" @grouped_table_view_data ||= [{ title: "Your Account", cells: [ { title: "Edit Profile", action: :edit_profile}, { title: "Log Out", action: :log_out }, ] }, { title: "My App Settings", cells: [{ title: "Be Awesome", subtitle: "Do so. Please." image: { image: UIImage.imageNamed("image"), radius: 12 } }, { title: "Mute", accessory: :switch, accessoryDefault: false, accessoryAction: :save_mute }, ] }] self.view = self.createTableViewFromData(@grouped_table_view_data) end def log_out # This will be called when the Log Out table cell is pressed end def edit_profile # Implement your edit_profile view here end def save_mute(args) # Depending on whether the switch is on or off, # args => { value: true } or # args => { value: false } end end
class MyController < UITableViewController include MotionTable::PlainTable def viewDidLoad super self.title = "Settings" @plain_table_view_data ||= [ { title: "Friends", cells: [ { title: "Friend 1", action: :view_friend, arguments: 1}, ] }, { title: "Contacts", cells: [ { title: "Foo", action: :something_here, arguments: { bar: "baz", this: "that"} }, ] } ] self.makeSearchable # Will add search capability, nothing more needed :) self.view = self.createTableViewFromData(@plain_table_view_data) end def view_friend(id) # load this friend based on id end def something_here(args={}) # You can pass any data structure into :arguments, it is just passed as an argument to your implementation # You have to handle it. Like so: args.each do |k, v| puts "Argument passed: #{v}" end end end
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
