Skip to content

Commit

Permalink
Add SimpleMenu example app
Browse files Browse the repository at this point in the history
  • Loading branch information
dam13n committed Aug 12, 2015
1 parent b3039de commit e05af50
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -200,6 +200,7 @@ class NavigationScreen < ProMotion::TableScreen
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

Expand All @@ -215,7 +216,7 @@ Be sure to check out more documenation from the [cocoapod itself](http://cocoado
ProMotion is not only an easy DSL to get started. The community is very helpful and
welcoming to new RubyMotion developers. We don't mind newbie questions.

If you need help, feel free to open an issue on GitHub. If we don't respond within a day, tweet us a link to the issue -- sometimes we get busy.
If you need help, feel free to open an issue on GitHub. If we don't respond within a day, tweet us a link to the issue -- sometimes we get busy.

A [very minimal ProMotion-menu sample](https://github.com/ryanlntn/pm-menu-issue-44) is available for reference.

Expand Down
5 changes: 5 additions & 0 deletions examples/SimpleMenu/.gitignore
@@ -0,0 +1,5 @@
.repl_history
build
vendor
resources
.DS_Store
5 changes: 5 additions & 0 deletions examples/SimpleMenu/Gemfile
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gem "rake"
gem "ProMotion", "~> 2.4.2"
gem "ProMotion-menu"
14 changes: 14 additions & 0 deletions examples/SimpleMenu/Rakefile
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios'

begin
require 'bundler'
Bundler.require
rescue LoadError
end

Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'SimpleMenu'
end
5 changes: 5 additions & 0 deletions examples/SimpleMenu/app/app_delegate.rb
@@ -0,0 +1,5 @@
class AppDelegate < PM::Delegate
def on_load(app, options)
open_menu HomeScreen.new(nav_bar: true), left: NavigationScreen, to_show: :pan_nav_bar, to_hide: [:pan_nav_bar, :tap_nav_bar, :tap_center]
end
end
13 changes: 13 additions & 0 deletions examples/SimpleMenu/app/screens/home_screen.rb
@@ -0,0 +1,13 @@
class HomeScreen < PM::Screen
title "Home"

def on_load
set_nav_bar_button :left, title: "Menu", action: :nav_left_button
end

def nav_left_button
# toggle left will allow the nav button to open and close the menu
app_delegate.menu.toggle_left
end

end
20 changes: 20 additions & 0 deletions examples/SimpleMenu/app/screens/navigation_screen.rb
@@ -0,0 +1,20 @@
class NavigationScreen < ProMotion::TableScreen

def table_data
[{
title: nil,
cells: [{
title: 'Home',
action: :swap_center_controller,
arguments: HomeScreen
}]
}]
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.new(nav_bar: true)
app_delegate.menu.toggle_left
end

end
9 changes: 9 additions & 0 deletions examples/SimpleMenu/spec/main_spec.rb
@@ -0,0 +1,9 @@
describe "Application 'SimpleMenu'" do
before do
@app = UIApplication.sharedApplication
end

it "has one window" do
@app.windows.size.should == 1
end
end

0 comments on commit e05af50

Please sign in to comment.