Module: SugarCube::Modal
- Defined in:
- lib/ios/sugarcube-modal/modal.rb
Class Method Summary collapse
- .dismiss_modal(options = {}, &block) ⇒ Object
- .present_modal(view_ctlr, options = {}, &block) ⇒ Object
- .present_modal_in_nav(view_ctlr, options = {}, &block) ⇒ Object
Class Method Details
.dismiss_modal(options = {}, &block) ⇒ Object
35 36 37 38 39 |
# File 'lib/ios/sugarcube-modal/modal.rb', line 35 def dismiss_modal(={}, &block) target = .fetch(:target, UIApplication.sharedApplication.keyWindow.rootViewController) animated = .fetch(:animated, true) target.dismissViewControllerAnimated(animated, completion:block) end |
.present_modal(view_ctlr, options = {}, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ios/sugarcube-modal/modal.rb', line 4 def present_modal(view_ctlr, ={}, &block) target = [:target] || UIApplication.sharedApplication.keyWindow.rootViewController animated = .fetch(:animated, true) presentation_style = [:presentation] if presentation_style if presentation_style.respond_to?(:presentationstyle) presentation_style = presentation_style.presentationstyle end view_ctlr.modalPresentationStyle = presentation_style end transition_style = [:transition] if transition_style if transition_style.respond_to?(:transitionstyle) transition_style = transition_style.transitionstyle end view_ctlr.modalTransitionStyle = transition_style end target.presentViewController(view_ctlr, animated:animated, completion:block) end |
.present_modal_in_nav(view_ctlr, options = {}, &block) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ios/sugarcube-modal/modal.rb', line 27 def present_modal_in_nav(view_ctlr, ={}, &block) ctlr = UINavigationController.alloc.initWithRootViewController(view_ctlr) ctlr.modalTransitionStyle = UIModalTransitionStyleCoverVertical SugarCube::Modal.present_modal(ctlr, , &block) ctlr end |