Sha256: ee12091bbf514cee1e6fa0174e06c87714442d9984b036298ebd86e10e30a35e

Contents?: true

Size: 1.34 KB

Versions: 53

Compression:

Stored size: 1.34 KB

Contents

module SugarCube
  module Modal
    module_function
    def present_modal(view_ctlr, options={}, &block)
      target = options[:target] || UIApplication.sharedApplication.keyWindow.rootViewController
      animated = options.fetch(:animated, true)
      target.presentViewController(view_ctlr, animated:animated, completion:block)
    end

    def present_modal_in_nav(view_ctlr, options={}, &block)
      ctlr = UINavigationController.alloc.initWithRootViewController(view_ctlr)
      ctlr.modalTransitionStyle = UIModalTransitionStyleCoverVertical

      SugarCube::Modal.present_modal(ctlr, options, &block)
      ctlr
    end

    def dismiss_modal(options={}, &block)
      target = options.fetch(:target, UIApplication.sharedApplication.keyWindow.rootViewController)
      target.dismissViewControllerAnimated(true, completion:block)
    end
  end
end


class UIViewController

  def present_modal(view_ctlr, options={}, &block)
    options = options.merge(target: self)
    SugarCube::Modal.present_modal(view_ctlr, options, &block)
  end

  def present_modal_in_nav(view_ctlr, options={}, &block)
    options = options.merge(target: self)
    SugarCube::Modal.present_modal_in_nav(view_ctlr, options, &block)
  end

  def dismiss_modal(options={}, &block)
    options = options.merge(target: self)
    SugarCube::Modal.dismiss_modal(options, &block)
  end

end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
sugarcube-1.4.1 lib/sugarcube-modal/modal.rb
sugarcube-1.4.0 lib/sugarcube-modal/modal.rb
sugarcube-1.3.11 lib/sugarcube-modal/modal.rb
sugarcube-1.3.10 lib/sugarcube-modal/modal.rb
sugarcube-1.3.9 lib/sugarcube-modal/modal.rb
sugarcube-1.3.8 lib/sugarcube-modal/modal.rb
sugarcube-1.3.7 lib/sugarcube-modal/modal.rb
sugarcube-1.3.6 lib/sugarcube-modal/modal.rb
sugarcube-1.3.5 lib/sugarcube-modal/modal.rb
sugarcube-1.3.4 lib/sugarcube-modal/modal.rb
sugarcube-1.3.3 lib/sugarcube-modal/modal.rb
sugarcube-1.3.2 lib/sugarcube-modal/modal.rb
sugarcube-1.3.1 lib/sugarcube-modal/modal.rb
sugarcube-1.3.0 lib/sugarcube-modal/modal.rb
sugarcube-1.1.0 lib/sugarcube-modal/modal.rb
sugarcube-1.0.7 lib/sugarcube-modal/modal.rb
sugarcube-1.0.6 lib/sugarcube-modal/modal.rb
sugarcube-1.0.5 lib/sugarcube-modal/modal.rb
sugarcube-1.0.4 lib/sugarcube-modal/modal.rb
sugarcube-1.0.3 lib/sugarcube-modal/modal.rb