infinitered / ProMotion-menu

RubyMotion gem allowing you to easily setup a facebook or Path style hidden slide menu easily with the ProMotion gem.
74 stars 29 forks source link

Is it possible to pass parameters into a PM::Menu::Drawer? #58

Closed eliduke closed 9 years ago

eliduke commented 9 years ago

I am using a PM::Menu::Drawer class called Navigation that looks like this:

class Navigation < PM::Menu::Drawer

  def setup
    self.center = ProfileScreen.new(nav_bar: true)
    self.left = NavigationScreen.new(nav_bar: true)
    self.to_show = [:pan_bezel, :pan_nav_bar]
    self.to_hide = [:pan_nav_bar, :tap_nav_bar, :tap_center]
    self.transition_animation = :parallax_5
    self.max_left_width = 310
    self.shadow = true
  end

end

And I am opening it in my app_delegate with a super simple open Navigation. It’s amazing. Sometimes I can't believe how simple it all is. Anyhoo, I am wondering if it’s possible to pass something into that open command so I could have access to in my Navigation class?

I tried open Navigation.new(user: "Username") in my app_delegate, put a attr_accessor :user in my Navigation class, but I keep getting this error:

screen_navigation.rb:98:in 'set_up_screen_for_open:': undefined method 'hidesBottomBarWhenPushed=' for {...}:Hash (NoMethodError)

It's as if a PM::Menu::Drawer can't receive parameters and so ProMotion thinks it's Screen and not a Menu? Thoughts? Anyone?

eliduke commented 9 years ago

I checked the source code and figured it out. I just needed to pass in nil for the first argument.

open Navigation.new(nil, user: user)

https://github.com/infinitered/ProMotion-menu/blob/master/lib/ProMotion/menu/drawer.rb#L9

def self.new(center=nil, options={})
  menu = alloc.init
  menu.send(:auto_setup, center, options)
  menu
end
cmckni3 commented 5 years ago

Issue has been fixed in master as of today

Apologize about bringing up old issue