README.md in ProMotion-0.4.0 vs README.md in ProMotion-0.4.1

- old
+ new

@@ -11,20 +11,38 @@ Typical app file structure: app/ screens/ - photos/ - list_photos_screen.rb - show_photo_screen.rb - edit_photo_screen.rb + events/ + list_events_screen.rb + show_event_screen.rb + edit_event_screen.rb home_screen.rb settings_screen.rb models/ + event.rb views/ + buttons/ + save_event_button_view.rb app_delegate.rb +## What's New in 0.4.0? + +* Screens are now UIViewControllers (they used to contain UIViewControllers, but that got too funky) so you can do normal UIViewController stuff with them +* Screen functionality can also be inherited as a module in your own UIViewController, but you need to provide your own methods for viewDidLoad and whatnot. +* Tons of headlessCamelCaps methods are now properly_ruby_underscored (with an alias to the old name for compatibility) +* `open_screen` and `close_screen` can now just be `open` and `close` respectively +* Attempted to keep 100% compatibility with 0.3.x but no guarantees...report issues, please! +* Revamped the internal folder structure of the gem...more work on this to come +* Built in a few helpers that were external before, like `content_height(view)` +* More consistent calling of `on_load` (sometimes doesn't get called in 0.3.x) +* `fresh_start SomeScreen` is now `open_root_screen SomeScreen` +* Removed `set_view_controller` as we don't need it anymore +* Better documentation (still needs work), better error messages +* Deprecation warnings EVERYWHERE for older apps (upgrade already!) + ## Usage Loading your home screen: ```ruby @@ -162,21 +180,10 @@ end end end ``` -Use a custom view controller: - -```ruby -def on_load - set_view_controller MyCustomViewController - - # Note: on_appear will not fire when using a custom - # view controller. -end -``` - The helper add_element takes any view object and adds it to the current view. You can also use the helper ProMotion::ViewHelper.set_attributes(view, attributes) to do the same thing without adding it to the current view. Screens include this helper by default. ```ruby @@ -241,9 +248,64 @@ { title: "Cell with image", remoteImage: { url: "http://placekitten.com/200/300", placeholder: "some-local-image" } } ] +``` + +## Using your own UIViewController or Formotion + +Sometimes you want to inherit from a different UIViewController than that provided by ProMotion, +such as when using [Formotion](https://github.com/clayallsopp/formotion). RubyMotion doesn't currently allow us to override built-in methods +when including as a module, so there's a workaround for that. + +```ruby +class EventsScreen < Formotion::FormController # Can also be < UIViewController + include ProMotion::ScreenModule # Not TableScreenModule since we're using Formotion for that + + # Required functions for ProMotion to work properly + + def viewDidLoad + super + self.view_did_load if self.respond_to?(:view_did_load) + end + + def viewWillAppear(animated) + super + self.view_will_appear(animated) if self.respond_to?("view_will_appear:") + end + + def viewDidAppear(animated) + super + self.view_did_appear(animated) if self.respond_to?("view_did_appear:") + end + + def viewWillDisappear(animated) + self.view_will_disappear(animated) if self.respond_to?("view_will_disappear:") + super + end + + def viewDidDisappear(animated) + self.view_did_disappear(animated) if self.respond_to?("view_did_disappear:") + super + end + + def shouldAutorotateToInterfaceOrientation(orientation) + self.should_rotate(orientation) + end + + def shouldAutorotate + self.should_autorotate + end + + def willRotateToInterfaceOrientation(orientation, duration:duration) + self.will_rotate(orientation, duration) + end + + def didRotateFromInterfaceOrientation(orientation) + self.on_rotate + end +end ``` # Reference (not comprehensive yet...working on this)