README.md in bubble-wrap-1.5.0 vs README.md in bubble-wrap-1.6.0.rc1

- old
+ new

@@ -24,11 +24,11 @@ ``` If you using Bundler: ```ruby -gem "bubble-wrap", "~> 1.4.0" +gem "bubble-wrap", "~> 1.5.0" ``` BubbleWrap is split into multiple modules so that you can easily choose which parts are included at compile-time. @@ -91,10 +91,16 @@ ```ruby require 'bubble-wrap/sms' ``` +If you wish to only include the `NetworkIndicator` wrapper: + +```ruby +require 'bubble-wrap/network-indicator' +``` + If you want to include everything (ie kitchen sink mode) you can save time and do: ```ruby require 'bubble-wrap/all' ``` @@ -144,10 +150,12 @@ => #<UICachedDeviceRGBColor:0xda535c0> 'dark_gray'.to_color => #<UICachedDeviceWhiteColor:0x8bb5be0> '#FF8A19'.to_color => #<UIDeviceRGBColor:0x8d54110> +'#88FF8A19'.to_color # ARGB format +=> #<UIDeviceRGBColor:0xca0fe00> ``` Debug flag: ```ruby BubbleWrap.debug? @@ -176,11 +184,14 @@ > App.alert("BubbleWrap is awesome!", {cancel_button_title: "I know it is!", message: "Like, seriously awesome."}) # creates and shows an alert message with optional parameters. > App.run_after(0.5) { p "It's #{Time.now}" } # Runs the block after 0.5 seconds. > App.open_url("http://matt.aimonetti.net") -# Opens the url using the device's browser. (accepts a string url or an instance of `NSURL`. +> App.open_url("tel://123456789") +# Opens the url using the device's browser. Can also open custom URL schemas (accepts a string url or an instance of `NSURL`.) +> App.can_open_url("tel://") +# Returns whether the app can open a given URL resource. > App::Persistence['channels'] # application specific persistence storage # ['NBC', 'ABC', 'Fox', 'CBS', 'PBS'] > App::Persistence['channels'] = ['TF1', 'France 2', 'France 3'] # ['TF1', 'France 2', 'France 3'] > App.environment @@ -373,19 +384,28 @@ => 2012-05-31 21:41:33 +0200 ``` ## Location -Added interface for Ruby-like GPS access: +Added interface for Ruby-like GPS and compass access: ```ruby BW::Location.get do |result| p "From Lat #{result[:from].latitude}, Long #{result[:from].longitude}" p "To Lat #{result[:to].latitude}, Long #{result[:to].longitude}" end ``` +```ruby +BW::Location.get_compass do |result| + p result[:magnetic_heading] # Heading towards magnetic north + p result[:true_heading] # Heading towards true north + 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. ## Media Added wrapper for playing remote and local media. Available are `modal` and custom presentation styles: @@ -441,13 +461,42 @@ }) {|result, error| result.sent? # => boolean result.canceled? # => boolean result.failed? # => boolean error # => NSError - } + } ``` +## NetworkIndicator + +Wrapper for showing and hiding the network indicator (the status bar spinner). + +```ruby + BW::NetworkIndicator.show # starts the spinner + BW::NetworkIndicator.hide # stops it + + # the nice thing is if you call 'show' multiple times, the 'hide' method will + # not have any effect until you've called it the same number of times. + BW::NetworkIndicator.show + # ...somewhere else + BW::NetworkIndicator.show + + # ...down the line + BW::NetworkIndicator.hide + # indicator is still visible + + BW::NetworkIndicator.hide + # NOW the indicator is hidden! + + # If you *really* want to hide the indicator immediately, you can call `reset!` + # but this is in no way encouraged. + BW::NetworkIndicator.reset! + + # and for completeness, a check to see if the indicator is visible + BW::NetworkIndicator.visible? +``` + ## UI ### Gestures Extra methods on `UIView` for working with gesture recognizers. A gesture recognizer can be added using a normal Ruby block, like so: @@ -592,10 +641,54 @@ :undo :redo :page_curl ``` +### UIActivityViewController + +`BW::UIActivityViewController` is a subclass of `UIActivityViewController` with an natural Ruby syntax. + +You can initiate a `UIActivityViewController` with or without a completion handler block. For more information on `UIActivityViewController`s, see [Apple's documentation](https://developer.apple.com/library/ios/documentation/uikit/reference/UIActivityViewController_Class/Reference/Reference.html). + +```ruby +# Without a completion handler +BW::UIActivityViewController.new( + items: "Some Text", # or ["Some Text", NSURL.URLWithString('http://www.rubymotion.com')] or a UIImage + animated: true, # Defaults to true + excluded: :add_to_reading_list # One item or an array +) + +# With completion handler +BW::UIActivityViewController.new( + items: "Some Text", + animated: true, + excluded: [:add_to_reading_list, :print, :air_drop] +) do |activity_type, completed| + puts "completed with activity: #{activity_type} - finished?: #{completed}" +end +``` + +Built in activities that can be passed to the `excluded` option are defined as `UIActivity` class `UIActivityType` constants: + +```ruby +:post_to_facebook +:post_to_twitter +:post_to_weibo +:message +:mail +:print +:copy_to_pasteboard +:assign_to_contact +:save_to_camera_roll +:add_to_reading_list +:post_to_flickr +:post_to_vimeo +:post_to_tencent_weibo +:air_drop +``` + + ## HTTP `BW::HTTP` wraps `NSURLRequest`, `NSURLConnection` and friends to provide Ruby developers with a more familiar and easier to use API. The API uses async calls and blocks to stay as simple as possible. @@ -675,10 +768,10 @@ class HttpClient def get_user(user_id, &callback) BW::HTTP.get(user_url(user_id)) do |response| # .. end - end + end end ``` This class should be invoked in your code as: