Closed gaurav6192 closed 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
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.
@ryanlntn just dealt with this.
@jamonholmgren how to deal with it?
I was hoping Ryan would answer. I'll PM him this link.
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.
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.
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.
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.
Yeah, ProMotion exposes app_delegate
as a helper method in screens.
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
Nice!
Both look like great solutions guys :)
@kevinmcnamee Thank you. It worked out quite well for me. Thanks a lot guys.
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?