I did an new project only with the code shown in the Promotion-Menu's Readme. I have this :
# app_delegate.rb
class AppDelegate < PM::Delegate
def on_load(app, options)
@menu = open MenuDrawer
end
def show_menu
@menu.show :left
end
end
#menu_drawer.rb
class MenuDrawer < PM::Menu::Drawer
def setup
self.center = HomeScreen.new(nav_bar: true)
self.left = NavigationScreen
self.to_show = [:pan_bezel, :pan_nav_bar]
self.transition_animation = :swinging_door
self.max_left_width = 250
self.shadow = false
end
end
#navigation_screen.rb
class NavigationScreen < ProMotion::TableScreen
def table_data
[{
title: nil,
cells: [{
title: 'OVERWRITE THIS METHOD',
action: :swap_center_controller,
arguments: HomeScreen
}]
}]
end
def swap_center_controller(screen_class)
app_delegate.menu.center_controller = screen_class
end
end
My app is running but there is no sidebar as you can see here :
Did I miss something ?
No. What you have there should be working. You'll have to pan the bezel or nav bar to reveal the left controller (which is hidden when you first open the app). I've been thinking about adding a menu button to the examples to make this a little bit clearer. Here's how that might work:
# home_screen.rb
class HomeScreen < PM::Screen
title "Home"
def on_load
set_nav_bar_button :right, title: "Menu", action: :open_menu
end
def open_menu
app_delegate.show_menu
end
end
# navigation_screen.rb
class NavigationScreen < ProMotion::TableScreen
def table_data
[{
title: nil,
cells: [{
title: 'HomeScreen',
action: :swap_center_controller,
arguments: HomeScreen.new(nav_bar: true)
},{
title: 'HelpScreen',
action: :swap_center_controller,
arguments: HelpScreen.new(nav_bar: true)
}]
}]
end
def swap_center_controller(screen)
app_delegate.menu.center_controller = screen
app_delegate.menu.hide
end
end
Your AppDelegate
and MenuDrawer
would remain unchanged.