Class: PrimeResideMenu::SidebarContainerScreen

Inherits:
RESideMenu
  • Object
show all
Includes:
MotionPrime::ScreenBaseMixin
Defined in:
lib/prime_reside_menu/sidebar_container_screen.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

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



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/prime_reside_menu/sidebar_container_screen.rb', line 5

def self.new(menu, content, options = {})
  screen = self.alloc.initWithContentViewController(nil, menuViewController: nil)
  screen.parallaxEnabled = false
  screen.panFromEdge = options[:pan_from_edge] if options.has_key?(:pan_from_edge)

  if !Prime::Config.sidebar_container.background_image.nil?
    screen.backgroundImage = Prime::Config.sidebar_container.background_image
  end

  full_width = UIScreen.mainScreen.bounds.size.width

  if scale = options[:content_scale_value]
    screen.contentViewScaleValue = scale
  end
  x_offset = options[:x_offset] || 45
  screen.contentViewInPortraitOffsetCenterX = full_width*(1 + screen.contentViewScaleValue/2) - x_offset

  if y_offset = options[:y_offset]
    screen.contentViewInPortraitOffsetCenterY = UIScreen.mainScreen.bounds.size.height/2 + y_offset
  end

  screen.on_create(options.merge(navigation: false)) if screen.respond_to?(:on_create)
  screen.menu_controller = menu unless menu.nil?
  screen.content_controller = content unless content.nil?

  screen
end

Instance Method Details

#content_controllerObject



64
65
66
# File 'lib/prime_reside_menu/sidebar_container_screen.rb', line 64

def content_controller
  self.contentViewController
end

#content_controller=(c) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/prime_reside_menu/sidebar_container_screen.rb', line 50

def content_controller=(c)
  @content_controller_ref = prepare_controller(c)
  if should_reinit_content?(@content_controller_ref)
    self.setContentViewController(@content_controller_ref)
  else
    content_controller.viewControllers = [@content_controller_ref]
  end
  hide_sidebar
end

#hide_sidebarObject



37
38
39
# File 'lib/prime_reside_menu/sidebar_container_screen.rb', line 37

def hide_sidebar
  self.hideMenuViewController
end


60
61
62
# File 'lib/prime_reside_menu/sidebar_container_screen.rb', line 60

def menu_controller
  self.menuViewController
end


45
46
47
48
# File 'lib/prime_reside_menu/sidebar_container_screen.rb', line 45

def menu_controller=(c)
  @menu_controller_ref = prepare_controller(c)
  self.setMenuViewController(@menu_controller_ref)
end

#show_sidebarObject



33
34
35
# File 'lib/prime_reside_menu/sidebar_container_screen.rb', line 33

def show_sidebar
  self.presentMenuViewController
end

#toggle_sidebarObject



41
42
43
# File 'lib/prime_reside_menu/sidebar_container_screen.rb', line 41

def toggle_sidebar
  self.presentMenuViewController
end