Module: PrimeSlidingMenu::BaseAppDelegate

Defined in:
lib/prime_sliding_menu/app_delegate.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
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
32
33
34
35
# File 'lib/prime_sliding_menu/app_delegate.rb', line 4

def self.included(base)
  base.class_eval do
    alias_method :open_screen!, :open_screen
    def open_screen(screen, options = {})
      screen = prepare_screen_for_open(screen, options)
      if sidebar_option = options.delete(:sidebar)
        sidebar_option = :sidebar if sidebar_option == true
        sidebar = MotionPrime::Screen.create_with_options(sidebar_option, false, {})
        open_with_sidebar(screen, sidebar, options)
      else
        open_screen!(screen, options)
      end
    end

    alias_method :open_content_screen!, :open_content_screen
    def open_content_screen(screen, options = {})
      if sidebar?
        if options[:animated]
          UIView.transitionWithView @sidebar_container,
                  duration: 0.5,
                   options: UIViewAnimationOptionTransitionFlipFromLeft,
                animations: proc { @sidebar_container.content_controller = screen },
                completion: nil
        else
          @sidebar_container.content_controller = screen
        end
      else
        open_content_screen!(screen)
      end
    end
  end
end

Instance Method Details

#hide_sidebarObject



45
46
47
# File 'lib/prime_sliding_menu/app_delegate.rb', line 45

def hide_sidebar
  @sidebar_container.hide_sidebar
end

#show_sidebarObject



41
42
43
# File 'lib/prime_sliding_menu/app_delegate.rb', line 41

def show_sidebar
  @sidebar_container.show_sidebar
end

#sidebar?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/prime_sliding_menu/app_delegate.rb', line 37

def sidebar?
  self.window && self.window.rootViewController.is_a?(SidebarContainerScreen)
end

#toggle_sidebarObject



49
50
51
# File 'lib/prime_sliding_menu/app_delegate.rb', line 49

def toggle_sidebar
  @sidebar_container.toggle_sidebar
end