Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds BW::UIActivityViewController for a more Ruby-like interface to activity view controllers #335

Merged
merged 18 commits into from
Mar 6, 2014
Merged

Conversation

markrickert
Copy link
Collaborator

This is my first attempt. Some guidance on how the DSL should work would be greatly appreciated. I'll write tests once I've nailed down functionality.

Usage:

# Without a completion handler
BW::UIActivityViewController.new(
  items: "Some Text", # or ["Some Text", NSURL.URLWithString('http://www.rubymotion.com')] or a UIImage
  excluded: :add_to_reading_list
)

# With completion handler
BW::UIActivityViewController.new(
  items: "Some Text",
  excluded: [:add_to_reading_list, :print, :air_drop]
) do |activity_type, completed|
  puts "completed with activity: #{activity_type} - finished?: #{completed}"
end

Let me know if i'm on the right track here.

@markrickert
Copy link
Collaborator Author

I just patched BW::Constants.get() so that it doesn't try and bitwise an array of strings like ["com.apple.UIKit.activity.AirDrop", "com.apple.UIKit.activity.Print"]

I suppose the next step could be to have helper methods like BW::UIActivityViewController.email() and BW::UIActivityViewController.airdrop() that only allow that one activity type.

@markrickert
Copy link
Collaborator Author

Huh... Travis returned back this error:

  - should return an array of string constant values [ERROR: NameError - uninitialized constant Kernel::UIActivityTypeAirDrop]
NameError: uninitialized constant Kernel::UIActivityTypeAirDrop
    constants.rb:41:in `get:': .get - should return an array of string constant values
    constants.rb:32:in `get:'
    spec.rb:314:in `block in run_spec_block'
    spec.rb:438:in `execute_block'
    spec.rb:314:in `run_spec_block'
    spec.rb:329:in `run'
222 specifications (496 requirements), 0 failures, 1 errors

Wonder why, when I'm initializing those constants in the module?

* refs/heads/master:
  Do not show warnings about iOS when building for OSX
  Renamed method physical_camera to available in camera_wrapper.
  Added method to check if device has a physical camera.
@markrickert
Copy link
Collaborator Author

Any feedback on this feature @colinta, @clayallsopp or @supermarin ?

@colinta
Copy link
Contributor

colinta commented Feb 26, 2014

The API looks solid, I wonder if Travis is running an old version, and doesn't have that AirDrop constant...

@colinta
Copy link
Contributor

colinta commented Feb 26, 2014

items: "string" looks funny to me, seems like it should require an array; item: "string" would then delegate to items: [..]

@clayallsopp
Copy link
Contributor

Yeah, +1 on @colinta's thoughts. seems like :items or :item should be valid options, for readability

Also editing the readme would be 👍

Travis is yelling because on OS X the Airdrop constant doesn't exist; you should do something like this in the specs:

if App.ios?
  it "should bitmask array values" do
   #...
  end
end

@markrickert
Copy link
Collaborator Author

Aha! Thanks for the tip on the tests. I'll try and get it refactored a bit and get the tests working on Travis here in the next few days. FYI, I'm using this code in production in my Textables app to display the UIActivityViewController.

@markrickert
Copy link
Collaborator Author

Is there a preferred way to accept both item and items?

something like:

items = Array(options[:items] || options[:item])

??

@clayallsopp
Copy link
Contributor

Yup, that looks good to me

* refs/heads/master:
  Update readme
  BubbleWrap 1.5.0
  deprecate App.user_cache; fixes #346
  add BW::Deprecated helper so we can deprecate methods
  Changes to readme: add get_compass documentation.
  Typo in get_compass spec.
  Add test to make sure BW::Location.stop stops updating the compass heading.
  Adds BW::Location.get_compass & BW::Location.get_compass_once
  fix /core and /http to be able to load separately
  1.5.0.rc1
  Add more support for #weak!. Fixes #344
  Remove Motion::Project::Config patch
  Add when_screen_edge_panned for UIScreenEdgePanGestureRecognizer
  Correct bubble-wrap/media dependencies. fixes #339
…erridden:

17 (which doesn't exist in the UIModalTransitionStyle enum declaration).
…roller

* refs/heads/activity-controller:
  Add tests for UIActivityViewController.
  Turns out Apple auto-sets a private transition style that can't be overridden:
  Passing test for constants change.
  Adds the ability to return an array of constants if the Constant.get doesn't return a number.
  Adds UIActivityController wrapper.

Conflicts:
	motion/ui/ui_activity_view_controller_wrapper.rb
	motion/util/constants.rb
	spec/motion/util/constants_spec.rb
@markrickert
Copy link
Collaborator Author

Once Travis passes, this is good to go! Working tests: 809 specifications (1202 requirements), 0 failures, 0 errors

@markrickert
Copy link
Collaborator Author

✨ It passed :)

@clayallsopp
Copy link
Contributor

Awesome - update the README as well?

@markrickert
Copy link
Collaborator Author

Done. Added it to the UI section of the readme.

@clayallsopp
Copy link
Contributor

👍 most excellent, great work!

clayallsopp added a commit that referenced this pull request Mar 6, 2014
Adds BW::UIActivityViewController for a more Ruby-like interface to activity view controllers
@clayallsopp clayallsopp merged commit a7e69a1 into rubymotion-community:master Mar 6, 2014
@markrickert markrickert deleted the uiactivityviewcontroller branch March 6, 2014 20:04
@markrickert
Copy link
Collaborator Author

Thanks! Glad to contribute!

clayallsopp added a commit that referenced this pull request Apr 16, 2014
- 'bubble-wrap/http' is now deprecated and will be removed in 2.0, see #308

+ `BW::UIActivityViewController` wrapper added, see #335

+ `BW::NetworkIndicator` added, see #349

 + `BW::Location.get_compass` & `BW::Location.get_compass_once`see #348

+ `NSString#to_color` ARGB support, see #350

+ `Object#method` support for `BW::Reactor`, see #359

* Prevented a possible exception when stopping `BW::Location`, see #358

* Fixed a bug when requiring just 'bubble-wrap/ui'
@markrickert
Copy link
Collaborator Author

✨ YAY!

tutuming pushed a commit to tutuming/BubbleWrap that referenced this pull request Apr 21, 2014
- 'bubble-wrap/http' is now deprecated and will be removed in 2.0, see rubymotion-community#308

+ `BW::UIActivityViewController` wrapper added, see rubymotion-community#335

+ `BW::NetworkIndicator` added, see rubymotion-community#349

 + `BW::Location.get_compass` & `BW::Location.get_compass_once`see rubymotion-community#348

+ `NSString#to_color` ARGB support, see rubymotion-community#350

+ `Object#method` support for `BW::Reactor`, see rubymotion-community#359

* Prevented a possible exception when stopping `BW::Location`, see rubymotion-community#358

* Fixed a bug when requiring just 'bubble-wrap/ui'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants