做抽屜

iOS guide 04 - 图1

步驟:

Step 1:

安裝 Gem

  1. gem "ProMotion-menu"
  2. gem "motion-fontawesome"
  • bundle install
  • rake pod:install

Step 2 :

  • 修改 app/screens/home_screen.rb
  1. class HomeScreen < PM::TableScreen
  2. title "職缺一覽"
  3. stylesheet HomeScreenStylesheet
  4. include NavigationHelper
  5. def on_load
  6. add_side_menu
  7. @jobs = []
  8. load_jobs
  9. end
  10. def sign_out_button
  11. Auth.sign_out do
  12. app.delegate.open_authenticated_root
  13. end
  14. end
  15. def sign_in_button
  16. open SignInScreen.new(nav_bar: true)
  17. end

Step 3 :

  • touch app/helpers/navigation_helpper.rb
  1. module NavigationHelper
  2. def add_side_menu
  3. label = UILabel.alloc.initWithFrame([[0, 0], [20, 20]])
  4. label.font = FontAwesome.fontWithSize(16.0)
  5. label.text = FontAwesome.icon("list")
  6. label.color = rmq.color.black
  7. set_nav_bar_button :left, custom_view: label, action: :tapped_left_nav
  8. rmq(label).on(:tap) do |_sender|
  9. app_delegate.menu.show(:left)
  10. end
  11. end
  12. def tapped_left_nav
  13. app_delegate.show_menu
  14. end
  15. end

Step 4:

修改 app/app_delegate.rb

  1. class AppDelegate < PM::Delegate
  2. include CDQ # Remove this if you aren't using CDQ
  3. status_bar true, animation: :fade
  4. # Without this, settings in StandardAppearance will not be correctly applied
  5. # Remove this if you aren't using StandardAppearance
  6. ApplicationStylesheet.new(nil).application_setup
  7. def on_load(_app, _options)
  8. cdq.setup # Remove this if you aren't using CDQ
  9. open_authenticated_root
  10. end
  11. def show_menu
  12. @menu.show :left
  13. end
  14. # Remove this if you are only supporting portrait
  15. def application(_application, willChangeStatusBarOrientation: new_orientation, duration: duration)
  16. # Manually set RMQ's orientation before the device is actually oriented
  17. # So that we can do stuff like style views before the rotation begins
  18. device.orientation = new_orientation
  19. end
  20. def open_authenticated_root
  21. open_tab_bar HomeScreen.new(nav_bar: true)
  22. @menu = open MenuDrawer
  23. end
  24. end

Step 5 :

  • touch app/drawers/menu_drawer.rb
  1. class MenuDrawer < PM::Menu::Drawer
  2. def setup
  3. self.center = HomeScreen.new(nav_bar: true)
  4. self.left = NavigationScreen
  5. self.to_show = [:pan_bezel, :pan_center]
  6. self.transition_animation = :slide
  7. self.max_left_width = 200
  8. self.shadow = false
  9. end
  10. end

Step 6 :

  • rake