README.md in bubble-wrap-1.6.0 vs README.md in bubble-wrap-1.7.0

- old
+ new

@@ -1,10 +1,10 @@ # BubbleWrap for RubyMotion A collection of (tested) helpers and wrappers used to wrap Cocoa Touch and AppKit code and provide more Ruby like APIs. -[BubbleWrap website](http://bubblewrap.io) +[BubbleWrap website](http://rubymotion.github.io/BubbleWrap/) [BubbleWrap mailing list](https://groups.google.com/forum/#!forum/bubblewrap) [![Code Climate](https://codeclimate.com/github/rubymotion/BubbleWrap.png)](https://codeclimate.com/github/rubymotion/BubbleWrap) [![Build Status](https://travis-ci.org/rubymotion/BubbleWrap.svg?branch=master)](https://travis-ci.org/rubymotion/BubbleWrap) [![Dependency Status](https://gemnasium.com/rubymotion/BubbleWrap.png)](https://gemnasium.com/rubymotion/BubbleWrap) @@ -265,12 +265,26 @@ # Uses the photo library BW::Device.camera.any.picture(media_types: [:movie, :image]) do |result| image_view = UIImageView.alloc.initWithImage(result[:original_image]) end + +# Lets the user edit the photo (with access to the edited and original photos) +BW::Device.camera.any.picture(allows_editing: true, media_types: [:image]) do |result| + edited_image_view = UIImageView.alloc.initWithImage(result[:edited_image]) + original_image_view = UIImageView.alloc.initWithImage(result[:original_image]) +end ``` + +Options include: + +- `:allows_editing` - Boolean; whether a user can edit the photo/video before picking +- `:animated` - Boolean; whether to display the camera with an animation (default true) +- `:on_dismiss` - Lambda; called instead of the default dismissal logic +- `:media_types` - Array; containing any of `[:movie, :image]` + ### JSON `BW::JSON` wraps `NSJSONSerialization` available in iOS5 and offers the same API as Ruby's JSON std lib. For apps building for iOS4, we suggest a different JSON alternative, like [AnyJSON](https://github.com/mattt/AnyJSON). ```ruby @@ -329,10 +343,12 @@ # ['TF1', 'France 2', 'France 3'] > App::Persistence.delete('channels') # ['TF1', 'France 2', 'France 3'] > App::Persistence['something__new'] # something previously never stored # nil +> App::Persistence.all +# {'all':'values', 'stored':'by', 'bubblewrap':'as a hash!'} ``` ### Observers **Since: > version 0.4** @@ -387,11 +403,18 @@ ## Location Added interface for Ruby-like GPS and compass access: ```ruby -BW::Location.get do |result| +> BW::Location.enabled? # Whether location services are enabled on the device +=> true +> BW::Location.authorized? # If your app is authorized to use location services +=> false +``` + +```ruby +BW::Location.get(purpose: 'We need to use your GPS because...') do |result| p "From Lat #{result[:from].latitude}, Long #{result[:from].longitude}" p "To Lat #{result[:to].latitude}, Long #{result[:to].longitude}" end ``` @@ -402,12 +425,32 @@ p result[:accuracy] # Potential error between magnetic and true heading p result[:timestamp] # Timestamp of the heading calculation end ``` -Also available is `BW::Location.get_significant`, for monitoring significant location changes. +`BW::Location.get_significant` is also available, for monitoring significant location changes. +`BW::Location` also supports `get_once`-style methods, which will return the first result before ending the search: + +```ruby +BW::Location.get_once(desired_accuracy: :three_kilometers, ...) do |result| + if result.is_a?(CLLocation) + p result.coordinate.latitude + p result.coordinate.longitude + else + p "ERROR: #{result[:error]}" + end +end + +BW::Location.get_compass_once do |heading| + p result[:magnetic_heading] + p result[:true_heading] + p result[:accuracy] + p result[:timestamp] +end +``` + ## Media Added wrapper for playing remote and local media. Available are `modal` and custom presentation styles: ```ruby @@ -426,20 +469,20 @@ Wrapper for showing an in-app mail composer view. ```ruby # Opens as a modal in the current UIViewController -BW::Mail.compose { +BW::Mail.compose( delegate: self, # optional, defaults to rootViewController to: [ "tom@example.com" ], cc: [ "itchy@example.com", "scratchy@example.com" ], bcc: [ "jerry@example.com" ], html: false, subject: "My Subject", message: "This is my message. It isn't very long.", animated: false -} do |result, error| +) do |result, error| result.sent? # => boolean result.canceled? # => boolean result.saved? # => boolean result.failed? # => boolean error # => NSError @@ -1027,6 +1070,5 @@ Do you have a suggestion for a specific wrapper? Feel free to open an issue/ticket and tell us about what you are after. If you have a wrapper/helper you are using and are thinking that others might enjoy, please send a pull request (with tests if possible). -