mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-06-04 19:45:35 +08:00
Merge pull request #83 from sxross/master
Here's the pull request against version-0.7
This commit is contained in:
31
README.md
31
README.md
@@ -115,6 +115,11 @@ class AppDelegate < PM::Delegate
|
||||
end
|
||||
```
|
||||
|
||||
Note: You can use other keys in `on_load` when you open a new screen:
|
||||
|
||||
* `modal: ` [`true` | `false`]
|
||||
* `toolbar:` [`true` | `false`]
|
||||
|
||||
Make sure you remove the `didFinishLoadingWithOptions` method or call `super` in it. Otherwise
|
||||
ProMotion won't get set up and `on_load` won't be called.
|
||||
|
||||
@@ -462,6 +467,27 @@ your Rakefile and doing this:
|
||||
]
|
||||
```
|
||||
|
||||
A note about table screens. You may not want a sectioned table. In that case,
|
||||
use only one section and set its value to `nil`. For example:
|
||||
|
||||
```ruby
|
||||
[{
|
||||
title: nil,
|
||||
cells: [
|
||||
{title: "37th Annual Grammy Awards", subtitle: "Nokia Theater"}
|
||||
]
|
||||
}, {
|
||||
title: nil,
|
||||
cells: [
|
||||
{title: "87th Academy Awards", subtitle: "Nokia Theater"}
|
||||
]}, {
|
||||
title: nil,
|
||||
cells: [
|
||||
{title: "Golden Globe Awards", subtitle: "Beverly Hilton"}
|
||||
]
|
||||
}]
|
||||
```
|
||||
|
||||
## Using your own UIViewController
|
||||
|
||||
[Using your own UIViewController with ProMotion](https://github.com/clearsightstudio/ProMotion/blob/master/CUSTOM_VIEW_CONTROLLERS.md)
|
||||
@@ -718,6 +744,11 @@ end</code></pre>
|
||||
and store it in something like <code>@table_data</code>. Then your <code>table_data</code>
|
||||
method just returns that.
|
||||
|
||||
It's common to add labels to a subclassed tableview cell, so ProMotion finds any attributes
|
||||
that end in `_label` in your input hash and tries to assign to them without going through the
|
||||
hoop-jumping of using `:cell_class_attributes`. This only applies to tables cells where you have
|
||||
declared a `:cell_class`.
|
||||
|
||||
<pre><code>
|
||||
def table_data
|
||||
[{
|
||||
|
||||
@@ -68,4 +68,4 @@ module ProMotion
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
module ProMotion::MotionTable
|
||||
module SectionedTable
|
||||
include ProMotion::ViewHelper
|
||||
|
||||
|
||||
def table_setup
|
||||
PM.logger.error "Missing #table_data method in TableScreen #{self.class.to_s}." unless self.respond_to?(:table_data)
|
||||
|
||||
self.view = self.create_table_view_from_data(self.table_data)
|
||||
|
||||
|
||||
if self.class.respond_to?(:get_searchable) && self.class.get_searchable
|
||||
self.make_searchable(content_controller: self, search_bar: self.class.get_searchable_params)
|
||||
end
|
||||
@@ -158,6 +158,15 @@ module ProMotion::MotionTable
|
||||
table_cell.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin
|
||||
end
|
||||
|
||||
### Catch any custom class labels ###
|
||||
if data_cell[:cell_class]
|
||||
data_cell.select{|k| k =~ /_label$/}.each_pair do |k, v|
|
||||
cell = table_cell.send(k)
|
||||
cell.setText v
|
||||
cell.autoresizingMask = UIViewAutoresizingFlexibleWidth
|
||||
end
|
||||
end
|
||||
|
||||
if data_cell[:cell_class_attributes]
|
||||
set_attributes table_cell, data_cell[:cell_class_attributes]
|
||||
end
|
||||
@@ -267,4 +276,4 @@ module ProMotion::MotionTable
|
||||
trigger_action(cell[:action], cell[:arguments]) if cell[:action]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,6 +21,7 @@ module ProMotion
|
||||
end
|
||||
|
||||
self.add_nav_bar if args[:nav_bar]
|
||||
self.navigationController.toolbarHidden = !args[:toolbar] unless args[:toolbar].nil?
|
||||
self.on_init if self.respond_to?(:on_init)
|
||||
self.table_setup if self.respond_to?(:table_setup)
|
||||
self
|
||||
|
||||
@@ -168,3 +168,21 @@ describe "screen properties" do
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "screen with toolbar" do
|
||||
|
||||
it "showing" do
|
||||
# Simulate AppDelegate setup of main screen
|
||||
screen = HomeScreen.new modal: true, nav_bar: true, toolbar: true
|
||||
screen.on_load
|
||||
screen.navigationController.toolbarHidden?.should == false
|
||||
end
|
||||
|
||||
it "hidden" do
|
||||
# Simulate AppDelegate setup of main screen
|
||||
screen = HomeScreen.new modal: true, nav_bar: true, toolbar: false
|
||||
screen.on_load
|
||||
screen.navigationController.toolbarHidden?.should == true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user