Class: ProMotionSlideMenu::SlideMenuScreen

Inherits:
PKRevealController
  • Object
show all
Includes:
ProMotion::ScreenModule
Defined in:
lib/pro_motion_slide_menu/slide_menu_screen.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(content, options = {}) ⇒ Object

SlideMenuScreen

This is added as the root view controller when using the ‘open_slide_menu` method in your application delegate.

Several properties are defined to get the underlying PKRevealController instance for additional configuration, the screen shown as the hidden menu, and the screen shown as the content controller.



15
16
17
18
19
20
21
22
23
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 15

def self.new(content, options={})
  screen = self.revealControllerWithFrontViewController(nil, leftViewController: nil, options: nil)
  screen.content_controller = content unless content.nil?
  screen.left_controller = options[:left] if options[:left]
  screen.right_controller = options[:right] if options[:right]
  screen_options = options.reject { |k,v| [:left, :right].include? k }
  screen.on_create(screen_options) if screen.respond_to?(:on_create)
  screen
end

Instance Method Details

#content_controllerObject



68
69
70
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 68

def content_controller
  self.frontViewController
end

#content_controller=(c) ⇒ Object



62
63
64
65
66
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 62

def content_controller=(c)
  controller = prepare_controller_for_pm(c)
  controller = controller.navigationController || controller
  self.setFrontViewController controller, focusAfterChange: true, completion: default_completion_block
end

#controller(side) ⇒ Object



80
81
82
83
84
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 80

def controller(side)
  self.left_controller if side == :left
  self.right_controller if side == :right
  self.content_controller if side == :content
end

#controller=(side = {}) ⇒ Object Also known as: controllers=



72
73
74
75
76
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 72

def controller=(side={})
  self.left_controller = side[:left] if side[:left]
  self.right_controller = side[:right] if side[:right]
  self.content_controller = side[:content] if side[:content]
end

#hide(animated = true) ⇒ Object



38
39
40
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 38

def hide(animated = true)
  self.showViewController content_controller, animated: animated, completion: default_completion_block
end

#left_controllerObject



48
49
50
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 48

def left_controller
  self.leftViewController
end

#left_controller=(c) ⇒ Object



42
43
44
45
46
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 42

def left_controller=(c)
  controller = prepare_controller_for_pm(c)
  controller = controller.navigationController || controller
  self.setLeftViewController controller, focusAfterChange: true, completion: default_completion_block
end

#right_controllerObject



58
59
60
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 58

def right_controller
  self.rightViewController
end

#right_controller=(c) ⇒ Object



52
53
54
55
56
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 52

def right_controller=(c)
  controller = prepare_controller_for_pm(c)
  controller = controller.navigationController || controller
  self.setRightViewController controller, focusAfterChange: true, completion: default_completion_block
end

#show(side, animated = true) ⇒ Object



25
26
27
28
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 25

def show(side, animated=true)
  self.show_left(animated) if side == :left
  self.show_right(animated) if side == :right
end

#show_left(animated = true) ⇒ Object



30
31
32
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 30

def show_left(animated = true)
  self.showViewController left_controller, animated: animated, completion: default_completion_block
end

#show_right(animated = true) ⇒ Object



34
35
36
# File 'lib/pro_motion_slide_menu/slide_menu_screen.rb', line 34

def show_right(animated = true)
  self.showViewController right_controller, animated: animated, completion: default_completion_block
end