Sha256: f9a2adcd2262d751b9f353c984ce1d672448222b58d078f1cd8bfe7083c36ade

Contents?: true

Size: 1.63 KB

Versions: 10

Compression:

Stored size: 1.63 KB

Contents

module BW
  class UIActivityViewController < ::UIActivityViewController
    class << self
      def new(options = {}, presenting_controller = nil, &block)
        options = {
          activities: nil,
          animated: true
        }.merge(options)

        if options[:item] || options[:items]
          items = Array(options[:item] || options[:items])
        else
          raise ArgumentError, "You must specify at least one item - #{options.inspect}"
        end

        vc = alloc.initWithActivityItems(items, applicationActivities:options[:activities])
        vc.excludedActivityTypes = BW::Constants.get("UIActivityType", Array(options[:excluded])) if options[:excluded]

        unless block.nil?
          block.weak! if BubbleWrap.use_weak_callbacks?
          vc.setCompletionHandler block
        end

        presenting_controller ||= App.window.rootViewController.presentedViewController # May be nil, but handles use case of container views
        presenting_controller ||= App.window.rootViewController

        presenting_controller.presentViewController(vc, animated:options[:animated], completion: lambda {})
        vc
      end

    end
  end

  # UIActivityTypes
  Constants.register(
    UIActivityTypePostToFacebook,
    UIActivityTypePostToTwitter,
    UIActivityTypePostToWeibo,
    UIActivityTypeMessage,
    UIActivityTypeMail,
    UIActivityTypePrint,
    UIActivityTypeCopyToPasteboard,
    UIActivityTypeAssignToContact,
    UIActivityTypeSaveToCameraRoll,
    UIActivityTypeAddToReadingList,
    UIActivityTypePostToFlickr,
    UIActivityTypePostToVimeo,
    UIActivityTypePostToTencentWeibo,
    UIActivityTypeAirDrop
  )
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bubble-wrap-1.9.7 motion/ui/ui_activity_view_controller_wrapper.rb
bubble-wrap-1.9.6 motion/ui/ui_activity_view_controller_wrapper.rb
bubble-wrap-1.9.5 motion/ui/ui_activity_view_controller_wrapper.rb
bubble-wrap-1.9.4 motion/ui/ui_activity_view_controller_wrapper.rb
bubble-wrap-1.9.3 motion/ui/ui_activity_view_controller_wrapper.rb
bubble-wrap-1.9.2 motion/ui/ui_activity_view_controller_wrapper.rb
bubble-wrap-1.9.1 motion/ui/ui_activity_view_controller_wrapper.rb
bubble-wrap-1.9.0 motion/ui/ui_activity_view_controller_wrapper.rb
bubble-wrap-1.6.0 motion/ui/ui_activity_view_controller_wrapper.rb
bubble-wrap-1.6.0.rc1 motion/ui/ui_activity_view_controller_wrapper.rb