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

how to put slide menu for multi tabs screen #10

Closed gaurav6192 closed 10 years ago

gaurav6192 commented 10 years ago

My first screen is a login screen, which then leads to the screens where i want the slide menu.

a = AScreen.new(nav_bar: true) b = BScreen.new(nav_bar: true) c = CScreen.new(nav_bar: true) d = DScreen.new(nav_bar: true)

open_tab_bar a, b, c, d

how can i implement it?

macfanatic commented 10 years ago

I'm honestly not sure with the open_tab_bar PM method, b/c it's going to create a view controller & wire some stuff up for you.

Ultimately you're wanting to have a "left" & "right" view controller, so the right is the UITabBarController that PM will create

gaurav6192 commented 10 years ago

Is it possible to define the slide menu for individual screens rather than in the AppDelegate itself?

That way i can use it for limited number of screens. I don't want it for the login screen as it is to be filled with user specific data.

jamonholmgren commented 10 years ago

@ryanlntn just dealt with this.

gaurav6192 commented 10 years ago

@jamonholmgren how to deal with it?

jamonholmgren commented 10 years ago

I was hoping Ryan would answer. I'll PM him this link.

ryanlntn commented 10 years ago

I haven't actually dealt with open_tab_bar so I'm not sure how that would work specifically but I do have an open PR where I've implemented an easy way to do both right and left view controllers. That should make it easier to implement what @macfanatic is talking about.

gaurav6192 commented 10 years ago

Is it possible to make it available for all screens? Then maybe disable it or something for those screens i don't want it in.

gaurav6192 commented 10 years ago

The issue being i don't want it in my first screen (login screen) which i'm opening from delegate, but the subsequent screens after the user logins.

ryanlntn commented 10 years ago

Oh I see. That's exactly what I'm doing in the app I'm working on. Here's how I accomplished it:

# In app_delegate.rb
def on_load(app, options)
  set_appearance_defaults
  return open intro unless viewed_intro?
  return open LoginScreen.new unless logged_in?
  open_slide_menu StatsScreen.new(nav_bar: true), right: MenuScreen
end

# login_screen.rb
def login
  credentials = { username: @email_field.text, password: @password_field.text }
  BubbleWrap::HTTP.post("some_api_url", payload: credentials) do |response|
    json = BubbleWrap::JSON.parse(response.body.to_str)
    if response.ok?
      User.login(json)
      app_delegate.open_slide_menu StatsScreen.new(nav_bar: true), right: MenuScreen
    else
      App.alert(json[:error])
    end
  end
end

Note that this is using my fork of promotion_slide_menu so the order of arguments is different.

jamonholmgren commented 10 years ago

Yeah, ProMotion exposes app_delegate as a helper method in screens.

kevinmcnamee commented 10 years ago

I believe I found a simple work around to opening the slide menu with a TabBarController containing screens

def on_load(app, options)
  ### some stuff
  my_tabs = PM::TabBarController.new MyFirstScreen.new(nav_bar: true), MySecondScreen.new(nav_bar: true), MyThirdScreen
  open_slide_menu MenuScreen, my_tabs
end
jamonholmgren commented 10 years ago

Nice!

macfanatic commented 10 years ago

Both look like great solutions guys :)

gaurav6192 commented 10 years ago

@kevinmcnamee Thank you. It worked out quite well for me. Thanks a lot guys.