Added more deprecations (more)

- Removed DBT directives (not needed)
- Renamed a couple test files
- Cleaned up PM::Styling a bit
- Removed some unnecessary alias methods
This commit is contained in:
Jamon Holmgren
2014-06-05 21:26:29 -07:00
parent d9df9bb1b0
commit 027927132f
16 changed files with 31 additions and 55 deletions

View File

@@ -101,11 +101,11 @@ Overview: In ProMotion 2.0, we removed deprecated APIs, refactored and cleaned u
10. Removed cell hash `:subviews` attribute. Instead, subclass `PM::TableViewCell` and add your own subviews there.
11. Actually, there is one new feature. It's called `longpressable`. By adding `longpressable` at the top of your `PM::TableScreen` and then supplying a `long_press_action:` in your cell hash, you can implement a different action for long presses on table cells.
12. We no longer insert the cell hash into the arguments hash passed into your cell tap action. If you need that data, pass it in manually.
13.
13. Removed `add_element`, `add_view`, `remove_element`, `remove_view` aliases for `add` and `remove`.
**Internal changes:**
1. Removed `motion-require`. ProMotion now relies entirely on RubyMotion's built-in dependency detector. Most classes now have [DBT](https://github.com/colinta/dbt/) definitions so, if we need it in the future, ProMotion will be ready. But no DBT yet.
1. Removed `motion-require`. ProMotion now relies entirely on RubyMotion's built-in dependency detector.
2. Removed `rake spec:unit`, `rake spec:func`, `rake spec:single filename`. We don't really use these for development anymore.
3. Moved many files around into a more logical, simpler structure.
4. Removed `PM::Conversions`. The only helper we were using was the `objective_c_method_name` method, and that was only used in `PM::Styling`. So we moved it there.

View File

@@ -1,6 +1,5 @@
module ProMotion
class TableViewCell < UITableViewCell
# @requires module:TableViewCellModule
include TableViewCellModule
end
end

View File

@@ -1,7 +1,5 @@
module ProMotion
# @requires class:DelegateParent
class Delegate < DelegateParent
# @requires module:DelegateModule
include ProMotion::DelegateModule
end
end

View File

@@ -1,8 +1,6 @@
module ProMotion
module DelegateModule
# @requires module:Tabs
include ProMotion::Tabs
# @requires module:SplitScreen
include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad
attr_accessor :window, :home_screen

View File

@@ -1,5 +1,4 @@
module ProMotion
# @requires class:SplitViewController
module SplitScreen
def split_screen_controller(master, detail)
split = SplitViewController.alloc.init

View File

@@ -28,6 +28,12 @@ module ProMotion
button
end
# TODO: In PM 2.1+, entirely remove this deprecated method.
def set_nav_bar_left_button(title, args={})
PM.logger.deprecated "set_nav_bar_right_button and set_nav_bar_left_button have been removed. Use set_nav_bar_button :right/:left instead."
end
alias_method :set_nav_bar_right_button, :set_nav_bar_left_button
def set_toolbar_items(buttons = [], animated = true)
self.toolbarItems = Array(buttons).map{|b| b.is_a?(UIBarButtonItem) ? b : create_toolbar_button(b) }
navigationController.setToolbarHidden(false, animated:animated)

View File

@@ -1,9 +1,7 @@
module ProMotion
# @requires class:ViewController
class Screen < ViewController
# You can inherit a screen from any UIViewController if you include the ScreenModule
# Just make sure to implement the Obj-C methods in cocoatouch/view_controller.rb.
# @requires module:ScreenModule
include ProMotion::ScreenModule
end
end

View File

@@ -1,14 +1,9 @@
module ProMotion
module ScreenModule
# @require module:ScreenNavigation
include ProMotion::ScreenNavigation
# @require module:Styling
include ProMotion::Styling
# @require module:NavBarModule
include ProMotion::NavBarModule
# @require module:Tabs
include ProMotion::Tabs
# @require module:SplitScreen
include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad
attr_accessor :parent_screen, :first_screen, :modal, :split_screen
@@ -21,6 +16,7 @@ module ProMotion
add_nav_bar(args) if args[:nav_bar]
try :screen_setup
try :on_init
PM.logger.deprecated "In #{self.class.to_s}, #on_create has been deprecated and removed. Use #screen_init instead." if respond_to?(:on_create)
end
def modal?

View File

@@ -18,17 +18,13 @@ module ProMotion
element.send("#{k}", *v)
else
# Doesn't respond. Check if snake case.
if k.to_s.include?("_")
set_attribute(element, objective_c_method_name(k), v)
end
set_attribute(element, camelize(k), v) if k.to_s.include?("_")
end
element
end
def content_max(view, mode = :height)
return 0 if view.subviews.empty?
sizes = view.subviews.map do |sub_view|
view.subviews.map do |sub_view|
if sub_view.isHidden
0
elsif mode == :height
@@ -36,9 +32,7 @@ module ProMotion
else
sub_view.frame.origin.x + sub_view.frame.size.width
end
end
sizes.max
end.max.to_f
end
def content_height(view)
@@ -49,8 +43,9 @@ module ProMotion
content_max(view, :width)
end
# iterate up the view hierarchy to find the parent element
# of "type" containing this view
def closest_parent(type, this_view = nil)
# iterate up the view hierarchy to find the parent element of "type" containing this view
this_view ||= view_or_self.superview
while this_view != nil do
return this_view if this_view.is_a? type
@@ -62,14 +57,10 @@ module ProMotion
def add(element, attrs = {})
add_to view_or_self, element, attrs
end
alias :add_element :add
alias :add_view :add
def remove(elements)
Array(elements).each(&:removeFromSuperview)
end
alias :remove_element :remove
alias :remove_view :remove
def add_to(parent_element, elements, attrs = {})
attrs = get_attributes_from_symbol(attrs)
@@ -105,14 +96,16 @@ module ProMotion
raise ArgumentError
end
if colors.size == 3
rgb_color(colors[0], colors[1], colors[2])
else
raise ArgumentError
end
raise ArgumentError unless colors.size == 3
rgb_color(colors[0], colors[1], colors[2])
end
protected
# Turns a snake_case string into a camelCase string.
def camelize(str)
str.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
end
protected
def get_attributes_from_symbol(attrs)
return attrs if attrs.is_a?(Hash)
@@ -122,10 +115,6 @@ module ProMotion
new_attrs
end
def objective_c_method_name(str)
str.split('_').inject([]){ |buffer,e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
end
def map_resize_symbol(symbol)
@_resize_symbols ||= {
left: UIViewAutoresizingFlexibleLeftMargin,

View File

@@ -1,6 +1,5 @@
module ProMotion
module TableViewCellModule
# @requires module:Styling
include Styling
attr_accessor :data_cell, :table_screen
@@ -9,6 +8,7 @@ module ProMotion
self.table_screen = WeakRef.new(screen)
self.data_cell = data_cell
check_deprecated_styles
set_styles
set_title
set_subtitle
@@ -20,6 +20,14 @@ module ProMotion
protected
# TODO: Remove this in ProMotion 2.1. Just for migration purposes.
def check_deprecated_styles
whitelist = [ :title, :subtitle, :image, :remote_image, :accessory, :selection_style, :action, :arguments, :cell_style, :cell_class, :cell_identifier, :editing_style, :search_text, :keep_selection ]
if (data_cell.keys - whitelist).length > 0
PM.logger.deprecated("In #{self.table_screen.class.to_s}#table_data, you should set :#{(data_cell.keys - whitelist).join(", :")} in a `styles:` hash. See TableScreen documentation.")
end
end
def set_styles
set_attributes self, data_cell[:style] if data_cell[:style]
end

View File

@@ -1,11 +1,7 @@
module ProMotion
# @requires class:TableViewController
class GroupedTableScreen < TableViewController
# @requires module:ScreenModule
include ProMotion::ScreenModule
# @requires module:Table
include ProMotion::Table
# @requires module:GroupedTable
include ProMotion::GroupedTable
end
end

View File

@@ -1,14 +1,9 @@
module ProMotion
module Table
# @requires module:Styling
include ProMotion::Styling
# @requires module:Searchable
include ProMotion::Table::Searchable
# @requires module:Refreshable
include ProMotion::Table::Refreshable
# @requires module:Indexable
include ProMotion::Table::Indexable
# @requires module:Longpressable
include ProMotion::Table::Longpressable
attr_reader :promotion_table_data

View File

@@ -1,9 +1,6 @@
module ProMotion
# @requires class:TableViewController
class TableScreen < TableViewController
# @requires module:ScreenModule
include ProMotion::ScreenModule
# @requires module:Table
include ProMotion::Table
end
end

View File

@@ -1,9 +1,6 @@
module ProMotion
# requires class:ViewController
class WebScreen < ViewController
# requires module:ScreenModule
include ProMotion::ScreenModule
# requires module:WebScreenModule
include ProMotion::WebScreenModule
end
end