Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ios-guide-04.md #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions ios-guide-04.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,123 @@ end

## Step 6 :

* potion g screen navigation

修改 app/screens/navigation_screen.rb
```
class NavigationScreen < PM::TableScreen

def on_load
rmq.stylesheet = NavigationScreenStylesheet
end

def table_data

[{
title: nil,
cells: [
{ title: '' },
{ title: sign_in_out_title ,
action: :sign_in_out_button,
},
{ title: 'Sign Up',
action: :sign_up_button,
},
add_credit_card_menu
]
}]
end

def add_credit_card_menu
if Auth.signed_in?
{ title: "Add Credit Card", action: :add_credit_card_action }
end
end

def sign_in_out_title
if Auth.signed_in?
"Logout"
else
"Sign In"
end
end

def sign_in_out_button
if Auth.signed_in?
sign_out_button
else
sign_in_button
end
end

def sign_in_button
open SignInScreen.new(nav_bar: true)
end

def sign_up_button
open SignUpScreen.new(nav_bar: true)
end

def sign_out_button
Auth.sign_out do
app.delegate.open_authenticated_root
end
end

def add_credit_card_action
open AddCreditCardScreen.new(nav_bar: true)
# open PaymentViewController.new
# mp StripeConnection.connectionWithPublishableKey("pk_test_APfRAnKNxAO78IG481nvbXqq")
end


def swap_center_controller(screen_class)
# Just use screen_class if you don't need a navigation bar
app_delegate.menu.center_controller = screen_class
end


# You don't have to reapply styles to all UIViews, if you want to optimize, another way to do it
# is tag the views you need to restyle in your stylesheet, then only reapply the tagged views, like so:
# def logo(st)
# st.frame = {t: 10, w: 200, h: 96}
# st.centered = :horizontal
# st.image = image.resource('logo')
# st.tag(:reapply_style)
# end
#
# Then in will_animate_rotate
# find(:reapply_style).reapply_styles#

# Remove the following if you're only using portrait
def will_animate_rotate(orientation, duration)
reapply_styles
end
end

```

修改 app/stylesheets/navigation_screen_stylesheet.rb

```
class NavigationScreenStylesheet < ApplicationStylesheet
# Add your view stylesheets here. You can then override styles if needed,
# example: include FooStylesheet

def setup
# Add stylesheet specific setup stuff here.
# Add application specific setup stuff in application_stylesheet.rb
end

def root_view(st)
st.background_color = color.white
end

end

```


## Step 7 :

* rake