rubymotionr 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +24 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/lib/rubymotionr.rb +7 -0
- data/lib/rubymotionr/project.rb +18 -0
- data/lib/rubymotionr/repo.rb +18 -0
- data/lib/rubymotionr/version.rb +3 -0
- data/rubymotionr.gemspec +19 -0
- data/spec/.DS_Store +0 -0
- data/spec/multiple-rubymotion-apps/Beers/README +5 -0
- data/spec/multiple-rubymotion-apps/Beers/Rakefile +8 -0
- data/spec/multiple-rubymotion-apps/Beers/app/app_delegate.rb +16 -0
- data/spec/multiple-rubymotion-apps/Beers/app/beer.rb +22 -0
- data/spec/multiple-rubymotion-apps/Beers/app/beer_details_controller.rb +15 -0
- data/spec/multiple-rubymotion-apps/Beers/app/beer_list_controller.rb +40 -0
- data/spec/multiple-rubymotion-apps/Beers/app/beer_map_controller.rb +51 -0
- data/spec/multiple-rubymotion-apps/Beers/resources/.gitignore +0 -0
- data/spec/multiple-rubymotion-apps/Beers/resources/list.png +0 -0
- data/spec/multiple-rubymotion-apps/Beers/resources/map.png +0 -0
- data/spec/multiple-rubymotion-apps/CircleLayout/.gitignore +5 -0
- data/spec/multiple-rubymotion-apps/CircleLayout/README +5 -0
- data/spec/multiple-rubymotion-apps/CircleLayout/Rakefile +9 -0
- data/spec/multiple-rubymotion-apps/CircleLayout/app/app_delegate.rb +8 -0
- data/spec/multiple-rubymotion-apps/CircleLayout/app/cell.rb +13 -0
- data/spec/multiple-rubymotion-apps/CircleLayout/app/circle_layout.rb +41 -0
- data/spec/multiple-rubymotion-apps/CircleLayout/app/view_controller.rb +33 -0
- data/spec/multiple-rubymotion-apps/Fonts/README +7 -0
- data/spec/multiple-rubymotion-apps/Fonts/Rakefile +8 -0
- data/spec/multiple-rubymotion-apps/Fonts/app/app_delegate.rb +9 -0
- data/spec/multiple-rubymotion-apps/Fonts/app/detail_controller.rb +50 -0
- data/spec/multiple-rubymotion-apps/Fonts/app/root_controller.rb +65 -0
- data/spec/multiple-rubymotion-apps/Fonts/resources/.gitkeep +0 -0
- data/spec/multiple-rubymotion-apps/GestureTable/README +8 -0
- data/spec/multiple-rubymotion-apps/GestureTable/Rakefile +8 -0
- data/spec/multiple-rubymotion-apps/GestureTable/app/UIColor_extensions.rb +32 -0
- data/spec/multiple-rubymotion-apps/GestureTable/app/UITableView_extensions.rb +7 -0
- data/spec/multiple-rubymotion-apps/GestureTable/app/app_delegate.rb +9 -0
- data/spec/multiple-rubymotion-apps/GestureTable/app/gesture_recognizer.rb +361 -0
- data/spec/multiple-rubymotion-apps/GestureTable/app/transformable_cells.rb +92 -0
- data/spec/multiple-rubymotion-apps/GestureTable/app/view_controller.rb +173 -0
- data/spec/multiple-rubymotion-apps/GestureTable/resources/.gitignore +0 -0
- data/spec/multiple-rubymotion-apps/Hello/README +3 -0
- data/spec/multiple-rubymotion-apps/Hello/Rakefile +8 -0
- data/spec/multiple-rubymotion-apps/Hello/app/app_delegate.rb +9 -0
- data/spec/multiple-rubymotion-apps/Hello/app/hello_view.rb +33 -0
- data/spec/multiple-rubymotion-apps/Hello/app/hello_view_controller.rb +5 -0
- data/spec/multiple-rubymotion-apps/Hello/resources/.gitignore +0 -0
- data/spec/multiple-rubymotion-apps/Hello/resources/icon.png +0 -0
- data/spec/multiple-rubymotion-apps/HelloGL/README +9 -0
- data/spec/multiple-rubymotion-apps/HelloGL/Rakefile +11 -0
- data/spec/multiple-rubymotion-apps/HelloGL/app/app_delegate.rb +16 -0
- data/spec/multiple-rubymotion-apps/HelloGL/app/index_data.rb +19 -0
- data/spec/multiple-rubymotion-apps/HelloGL/app/motiongl_controller.rb +139 -0
- data/spec/multiple-rubymotion-apps/HelloGL/app/vertex_data.rb +22 -0
- data/spec/multiple-rubymotion-apps/HelloGL/resources/rubymotion.png +0 -0
- data/spec/multiple-rubymotion-apps/Locations/README +3 -0
- data/spec/multiple-rubymotion-apps/Locations/Rakefile +8 -0
- data/spec/multiple-rubymotion-apps/Locations/app/app_delegate.rb +11 -0
- data/spec/multiple-rubymotion-apps/Locations/app/location.rb +21 -0
- data/spec/multiple-rubymotion-apps/Locations/app/locations_controller.rb +66 -0
- data/spec/multiple-rubymotion-apps/Locations/app/locations_store.rb +61 -0
- data/spec/multiple-rubymotion-apps/Locations/resources/.gitignore +0 -0
- data/spec/multiple-rubymotion-apps/Mustache/README +5 -0
- data/spec/multiple-rubymotion-apps/Mustache/Rakefile +10 -0
- data/spec/multiple-rubymotion-apps/Mustache/app/app_delegate.rb +9 -0
- data/spec/multiple-rubymotion-apps/Mustache/app/mustache_view_controller.rb +99 -0
- data/spec/multiple-rubymotion-apps/Mustache/resources/.gitignore +0 -0
- data/spec/multiple-rubymotion-apps/Mustache/resources/guido.jpg +0 -0
- data/spec/multiple-rubymotion-apps/Mustache/resources/jmccolor.jpg +0 -0
- data/spec/multiple-rubymotion-apps/Mustache/resources/kay.jpg +0 -0
- data/spec/multiple-rubymotion-apps/Mustache/resources/matz.jpg +0 -0
- data/spec/multiple-rubymotion-apps/Mustache/resources/mustache.png +0 -0
- data/spec/multiple-rubymotion-apps/Paint/README +3 -0
- data/spec/multiple-rubymotion-apps/Paint/Rakefile +8 -0
- data/spec/multiple-rubymotion-apps/Paint/app/app_delegate.rb +9 -0
- data/spec/multiple-rubymotion-apps/Paint/app/paint_view.rb +57 -0
- data/spec/multiple-rubymotion-apps/Paint/app/paint_view_controller.rb +13 -0
- data/spec/multiple-rubymotion-apps/Paint/resources/.gitignore +0 -0
- data/spec/multiple-rubymotion-apps/Paint/resources/erase.caf +0 -0
- data/spec/multiple-rubymotion-apps/PaintHTML/README +8 -0
- data/spec/multiple-rubymotion-apps/PaintHTML/Rakefile +10 -0
- data/spec/multiple-rubymotion-apps/PaintHTML/app/app_delegate.rb +10 -0
- data/spec/multiple-rubymotion-apps/PaintHTML/app/web_view_controller.rb +48 -0
- data/spec/multiple-rubymotion-apps/PaintHTML/resources/index.html +211 -0
- data/spec/multiple-rubymotion-apps/PaintHTML/resources/index2.html +14 -0
- data/spec/multiple-rubymotion-apps/README.rdoc +47 -0
- data/spec/multiple-rubymotion-apps/StoryboardCustoms/README.md +42 -0
- data/spec/multiple-rubymotion-apps/StoryboardCustoms/Rakefile +7 -0
- data/spec/multiple-rubymotion-apps/StoryboardCustoms/app/app_delegate.rb +12 -0
- data/spec/multiple-rubymotion-apps/StoryboardCustoms/app/custom_view_controller1.rb +31 -0
- data/spec/multiple-rubymotion-apps/StoryboardCustoms/app/custom_view_controller2.rb +29 -0
- data/spec/multiple-rubymotion-apps/StoryboardCustoms/app/helpers.rb +4 -0
- data/spec/multiple-rubymotion-apps/StoryboardCustoms/resources/Master.storyboard +127 -0
- data/spec/multiple-rubymotion-apps/TicTacToe/.gitignore +5 -0
- data/spec/multiple-rubymotion-apps/TicTacToe/Rakefile +7 -0
- data/spec/multiple-rubymotion-apps/TicTacToe/app/app_delegate.rb +8 -0
- data/spec/multiple-rubymotion-apps/TicTacToe/app/board.rb +59 -0
- data/spec/multiple-rubymotion-apps/TicTacToe/app/board_view_controller.rb +86 -0
- data/spec/multiple-rubymotion-apps/Timer/README +3 -0
- data/spec/multiple-rubymotion-apps/Timer/Rakefile +7 -0
- data/spec/multiple-rubymotion-apps/Timer/app/app_delegate.rb +9 -0
- data/spec/multiple-rubymotion-apps/Timer/app/timer_controller.rb +38 -0
- data/spec/multiple-rubymotion-apps/Timer/resources/.gitignore +0 -0
- data/spec/multiple-rubymotion-apps/Trollify/README +6 -0
- data/spec/multiple-rubymotion-apps/Trollify/Rakefile +9 -0
- data/spec/multiple-rubymotion-apps/Trollify/app/app_delegate.rb +9 -0
- data/spec/multiple-rubymotion-apps/Trollify/app/image_composition_controller.rb +193 -0
- data/spec/multiple-rubymotion-apps/Trollify/app/uiimage_extension.rb +27 -0
- data/spec/multiple-rubymotion-apps/Trollify/resources/.gitignore +0 -0
- data/spec/multiple-rubymotion-apps/Trollify/resources/ballmer.jpg +0 -0
- data/spec/multiple-rubymotion-apps/Trollify/resources/icon.png +0 -0
- data/spec/multiple-rubymotion-apps/Trollify/resources/icon@2x.png +0 -0
- data/spec/multiple-rubymotion-apps/Trollify/resources/trollface.png +0 -0
- data/spec/multiple-rubymotion-apps/Tweets/README +3 -0
- data/spec/multiple-rubymotion-apps/Tweets/Rakefile +7 -0
- data/spec/multiple-rubymotion-apps/Tweets/app/app_delegate.rb +9 -0
- data/spec/multiple-rubymotion-apps/Tweets/app/data_parser.rb +10 -0
- data/spec/multiple-rubymotion-apps/Tweets/app/json_parser.rb +12 -0
- data/spec/multiple-rubymotion-apps/Tweets/app/tweet.rb +11 -0
- data/spec/multiple-rubymotion-apps/Tweets/app/tweet_cell.rb +51 -0
- data/spec/multiple-rubymotion-apps/Tweets/app/tweets_controller.rb +72 -0
- data/spec/multiple-rubymotion-apps/Tweets/resources/.gitignore +0 -0
- data/spec/repo_spec.rb +27 -0
- data/spec/rubymotion-example/.DS_Store +0 -0
- data/spec/rubymotion-example/README +3 -0
- data/spec/rubymotion-example/Rakefile +7 -0
- data/spec/rubymotion-example/app/app_delegate.rb +9 -0
- data/spec/rubymotion-example/app/data_parser.rb +10 -0
- data/spec/rubymotion-example/app/json_parser.rb +12 -0
- data/spec/rubymotion-example/app/tweet.rb +11 -0
- data/spec/rubymotion-example/app/tweet_cell.rb +51 -0
- data/spec/rubymotion-example/app/tweets_controller.rb +72 -0
- data/spec/rubymotion-example/resources/.gitignore +0 -0
- data/spec/spec_helper.rb +9 -0
- metadata +309 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
rubymotionr (0.0.1)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
diff-lcs (1.1.3)
|
|
10
|
+
rspec (2.12.0)
|
|
11
|
+
rspec-core (~> 2.12.0)
|
|
12
|
+
rspec-expectations (~> 2.12.0)
|
|
13
|
+
rspec-mocks (~> 2.12.0)
|
|
14
|
+
rspec-core (2.12.2)
|
|
15
|
+
rspec-expectations (2.12.1)
|
|
16
|
+
diff-lcs (~> 1.1.3)
|
|
17
|
+
rspec-mocks (2.12.1)
|
|
18
|
+
|
|
19
|
+
PLATFORMS
|
|
20
|
+
ruby
|
|
21
|
+
|
|
22
|
+
DEPENDENCIES
|
|
23
|
+
rspec
|
|
24
|
+
rubymotionr!
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Marko Iskander
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Rubymotionr
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
Add this line to your application's Gemfile:
|
|
6
|
+
|
|
7
|
+
gem 'rubymotionr'
|
|
8
|
+
|
|
9
|
+
And then execute:
|
|
10
|
+
|
|
11
|
+
$ bundle
|
|
12
|
+
|
|
13
|
+
Or install it yourself as:
|
|
14
|
+
|
|
15
|
+
$ gem install rubymotionr
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
``` ruby
|
|
20
|
+
repo = Rubymotionr::Rep.new("/absolute/path/to/repo")
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This will return the repo object with projects (repo.projects) within it. Each project has an attribute path (i.e repo.projects.path) which is a path to the root of a RubyMotion project.
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
|
|
27
|
+
1. Fork it
|
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/rubymotionr.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Rubymotionr
|
|
2
|
+
class Project
|
|
3
|
+
|
|
4
|
+
attr_reader :gem_prereqs, :path
|
|
5
|
+
|
|
6
|
+
def initialize(path)
|
|
7
|
+
@path = path
|
|
8
|
+
#TODO: Find, parse and return gem prereqs
|
|
9
|
+
#TODO: Consider CocoPods
|
|
10
|
+
#@gem_prereqs = get_prereqs
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.is_rubymotion_app?(path)
|
|
14
|
+
rakefile = File.read(path)
|
|
15
|
+
rakefile.include?(%{require 'motion/project'})
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Rubymotionr
|
|
2
|
+
class Repo
|
|
3
|
+
|
|
4
|
+
attr_reader :path, :projects
|
|
5
|
+
|
|
6
|
+
def initialize(path)
|
|
7
|
+
@path = path
|
|
8
|
+
@projects = find_projects(path)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
def find_projects(path)
|
|
13
|
+
Dir.glob(File.join(path, "**/Rakefile")).collect { |loc|
|
|
14
|
+
Project.new(loc.gsub("Rakefile", "")) if Project.is_rubymotion_app?(loc)
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/rubymotionr.gemspec
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'rubymotionr/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
gem.name = "rubymotionr"
|
|
8
|
+
gem.version = Rubymotionr::VERSION
|
|
9
|
+
gem.authors = ["Marko Iskander"]
|
|
10
|
+
gem.email = ["markoiskander@gmail.com"]
|
|
11
|
+
gem.description = %q{Find rubymotion projects within a directory}
|
|
12
|
+
gem.summary = %q{Find rubymotion projects within a directory }
|
|
13
|
+
gem.homepage = "https://github.com/miskander/rubymotionr"
|
|
14
|
+
|
|
15
|
+
gem.files = `git ls-files`.split($/)
|
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
gem.require_paths = ["lib"]
|
|
19
|
+
end
|
data/spec/.DS_Store
ADDED
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class AppDelegate
|
|
2
|
+
def application(application, didFinishLaunchingWithOptions:launchOptions)
|
|
3
|
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
|
4
|
+
tabbar = UITabBarController.alloc.init
|
|
5
|
+
tabbar.viewControllers = [BeerMapController.alloc.init, BeerListController.alloc.init]
|
|
6
|
+
tabbar.selectedIndex = 0
|
|
7
|
+
@window.rootViewController = UINavigationController.alloc.initWithRootViewController(tabbar)
|
|
8
|
+
@window.rootViewController.wantsFullScreenLayout = true
|
|
9
|
+
@window.makeKeyAndVisible
|
|
10
|
+
true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def beer_details_controller
|
|
14
|
+
@beer_details_controller ||= BeerDetailsController.alloc.init
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class Beer
|
|
2
|
+
def initialize(lat, long, name, link)
|
|
3
|
+
@name = name
|
|
4
|
+
@coordinate = CLLocationCoordinate2D.new
|
|
5
|
+
@coordinate.latitude = lat
|
|
6
|
+
@coordinate.longitude = long
|
|
7
|
+
@url = NSURL.alloc.initWithString(link)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def title; @name; end
|
|
11
|
+
def coordinate; @coordinate; end
|
|
12
|
+
def url; @url; end
|
|
13
|
+
|
|
14
|
+
All = [
|
|
15
|
+
Beer.new(50.016667, 4.316667, 'Chimay', 'http://en.wikipedia.org/wiki/Chimay_Brewery'),
|
|
16
|
+
Beer.new(49.639722, 5.348889, 'Orval', 'http://en.wikipedia.org/wiki/Orval_Brewery'),
|
|
17
|
+
Beer.new(50.178162, 5.219879, 'Rochefort', 'http://en.wikipedia.org/wiki/Rochefort_Brewery'),
|
|
18
|
+
Beer.new(51.284720, 4.656670, 'Westmalle', 'http://en.wikipedia.org/wiki/Westmalle_Brewery'),
|
|
19
|
+
Beer.new(50.895942, 2.721262, 'Westvleteren', 'http://en.wikipedia.org/wiki/Westvleteren_Brewery'),
|
|
20
|
+
Beer.new(51.298800, 5.488570, 'Achel', 'http://en.wikipedia.org/wiki/Achel_Brewery')
|
|
21
|
+
]
|
|
22
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class BeerDetailsController < UIViewController
|
|
2
|
+
def loadView
|
|
3
|
+
self.view = UIWebView.alloc.init
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def viewWillAppear(animated)
|
|
7
|
+
navigationController.setNavigationBarHidden(false, animated:true)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def showDetailsForBeer(beer)
|
|
11
|
+
navigationItem.title = beer.title
|
|
12
|
+
request = NSURLRequest.requestWithURL(beer.url)
|
|
13
|
+
view.loadRequest(request)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
class BeerListController < UITableViewController
|
|
2
|
+
def init
|
|
3
|
+
if super
|
|
4
|
+
self.tabBarItem = UITabBarItem.alloc.initWithTitle('List', image:UIImage.imageNamed('list.png'), tag:1)
|
|
5
|
+
end
|
|
6
|
+
self
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def viewDidLoad
|
|
10
|
+
view.dataSource = view.delegate = self
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def viewWillAppear(animated)
|
|
14
|
+
navigationController.setNavigationBarHidden(true, animated:true)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def tableView(tableView, numberOfRowsInSection:section)
|
|
18
|
+
Beer::All.size
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
CELLID = 'CellIdentifier'
|
|
22
|
+
def tableView(tableView, cellForRowAtIndexPath:indexPath)
|
|
23
|
+
cell = tableView.dequeueReusableCellWithIdentifier(CELLID) || begin
|
|
24
|
+
cell = UITableViewCell.alloc.initWithStyle(UITableViewCellStyleDefault, reuseIdentifier:CELLID)
|
|
25
|
+
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton
|
|
26
|
+
cell
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
beer = Beer::All[indexPath.row]
|
|
30
|
+
cell.textLabel.text = beer.title
|
|
31
|
+
cell
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def tableView(tableView, accessoryButtonTappedForRowWithIndexPath:indexPath)
|
|
35
|
+
beer = Beer::All[indexPath.row]
|
|
36
|
+
controller = UIApplication.sharedApplication.delegate.beer_details_controller
|
|
37
|
+
navigationController.pushViewController(controller, animated:true)
|
|
38
|
+
controller.showDetailsForBeer(beer)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
class BeerMapController < UIViewController
|
|
2
|
+
def init
|
|
3
|
+
if super
|
|
4
|
+
self.tabBarItem = UITabBarItem.alloc.initWithTitle('Map', image:UIImage.imageNamed('map.png'), tag:1)
|
|
5
|
+
end
|
|
6
|
+
self
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def loadView
|
|
10
|
+
self.view = MKMapView.alloc.init
|
|
11
|
+
view.delegate = self
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def viewDidLoad
|
|
15
|
+
view.frame = tabBarController.view.bounds
|
|
16
|
+
|
|
17
|
+
# Center on Brussels.
|
|
18
|
+
region = MKCoordinateRegionMake(CLLocationCoordinate2D.new(50.85, 4.35), MKCoordinateSpanMake(3.1, 3.1))
|
|
19
|
+
self.view.setRegion(region)
|
|
20
|
+
|
|
21
|
+
Beer::All.each { |beer| self.view.addAnnotation(beer) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def viewWillAppear(animated)
|
|
25
|
+
navigationController.setNavigationBarHidden(true, animated:true)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
ViewIdentifier = 'ViewIdentifier'
|
|
29
|
+
def mapView(mapView, viewForAnnotation:beer)
|
|
30
|
+
if view = mapView.dequeueReusableAnnotationViewWithIdentifier(ViewIdentifier)
|
|
31
|
+
view.annotation = beer
|
|
32
|
+
else
|
|
33
|
+
view = MKPinAnnotationView.alloc.initWithAnnotation(beer, reuseIdentifier:ViewIdentifier)
|
|
34
|
+
view.canShowCallout = true
|
|
35
|
+
view.animatesDrop = true
|
|
36
|
+
button = UIButton.buttonWithType(UIButtonTypeDetailDisclosure)
|
|
37
|
+
button.addTarget(self, action: :'showDetails:', forControlEvents:UIControlEventTouchUpInside)
|
|
38
|
+
view.rightCalloutAccessoryView = button
|
|
39
|
+
end
|
|
40
|
+
view
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def showDetails(sender)
|
|
44
|
+
if view.selectedAnnotations.size == 1
|
|
45
|
+
beer = view.selectedAnnotations[0]
|
|
46
|
+
controller = UIApplication.sharedApplication.delegate.beer_details_controller
|
|
47
|
+
navigationController.pushViewController(controller, animated:true)
|
|
48
|
+
controller.showDetailsForBeer(beer)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class AppDelegate
|
|
2
|
+
def application(application, didFinishLaunchingWithOptions:launchOptions)
|
|
3
|
+
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
|
|
4
|
+
@window.rootViewController = ViewController.alloc.initWithCollectionViewLayout(CircleLayout.new)
|
|
5
|
+
@window.makeKeyAndVisible
|
|
6
|
+
true
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class Cell < UICollectionViewCell
|
|
2
|
+
def initWithFrame(frame)
|
|
3
|
+
if super
|
|
4
|
+
contentView.layer.tap do |obj|
|
|
5
|
+
obj.cornerRadius = 35.0
|
|
6
|
+
obj.borderWidth = 1.0
|
|
7
|
+
obj.borderColor = UIColor.whiteColor.CGColor
|
|
8
|
+
end
|
|
9
|
+
contentView.backgroundColor = UIColor.underPageBackgroundColor
|
|
10
|
+
end
|
|
11
|
+
self
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
class CircleLayout < UICollectionViewLayout
|
|
2
|
+
ItemSize = 70.0
|
|
3
|
+
|
|
4
|
+
def prepareLayout
|
|
5
|
+
super
|
|
6
|
+
size = collectionView.frame.size
|
|
7
|
+
@cell_count = collectionView.numberOfItemsInSection(0)
|
|
8
|
+
@center = CGPoint.new(size.width / 2.0, size.height / 2.0)
|
|
9
|
+
@radius = [size.width, size.height].min / 2.5
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def collectionViewContentSize
|
|
13
|
+
collectionView.frame.size
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def layoutAttributesForItemAtIndexPath(path)
|
|
17
|
+
UICollectionViewLayoutAttributes.layoutAttributesForCellWithIndexPath(path).tap do |obj|
|
|
18
|
+
obj.size = [ItemSize, ItemSize]
|
|
19
|
+
obj.center = [@center.x + @radius * Math.cos(2 * path.item * Math::PI / @cell_count), @center.y + @radius * Math.sin(2 * path.item * Math::PI / @cell_count)]
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def layoutAttributesForElementsInRect(rect)
|
|
24
|
+
(0...@cell_count).map { |i| layoutAttributesForItemAtIndexPath(NSIndexPath.indexPathForItem(i, inSection:0)) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def initialLayoutAttributesForInsertedItemAtIndexPath(path)
|
|
28
|
+
layoutAttributesForItemAtIndexPath(path).tap do |obj|
|
|
29
|
+
obj.alpha = 0.0
|
|
30
|
+
obj.center = @center
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def finalLayoutAttributesForDeletedItemAtIndexPath(path)
|
|
35
|
+
layoutAttributesForItemAtIndexPath(path).tap do |obj|
|
|
36
|
+
obj.alpha = 0.0
|
|
37
|
+
obj.center = @center
|
|
38
|
+
obj.transform3D = CATransform3DMakeScale(0.1, 0.1, 1.0)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class ViewController < UICollectionViewController
|
|
2
|
+
CellIdentifier = 'MyCell'
|
|
3
|
+
|
|
4
|
+
def viewDidLoad
|
|
5
|
+
@cell_count = 20
|
|
6
|
+
tap = UITapGestureRecognizer.alloc.initWithTarget(self, action: :'handleTapGesture:')
|
|
7
|
+
collectionView.addGestureRecognizer(tap)
|
|
8
|
+
collectionView.registerClass(Cell, forCellWithReuseIdentifier:CellIdentifier)
|
|
9
|
+
collectionView.backgroundColor = UIColor.scrollViewTexturedBackgroundColor
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def collectionView(view, numberOfItemsInSection:section)
|
|
13
|
+
@cell_count
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def collectionView(view, cellForItemAtIndexPath:path)
|
|
17
|
+
view.dequeueReusableCellWithReuseIdentifier(CellIdentifier, forIndexPath:path)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def handleTapGesture(sender)
|
|
21
|
+
if sender.state == UIGestureRecognizerStateEnded
|
|
22
|
+
pinch_point = sender.locationInView(collectionView)
|
|
23
|
+
path = collectionView.indexPathForItemAtPoint(pinch_point)
|
|
24
|
+
if path
|
|
25
|
+
@cell_count -= 1
|
|
26
|
+
collectionView.performBatchUpdates(lambda { collectionView.deleteItemsAtIndexPaths([path]) }, completion:nil)
|
|
27
|
+
else
|
|
28
|
+
@cell_count += 1
|
|
29
|
+
collectionView.performBatchUpdates(lambda { collectionView.insertItemsAtIndexPaths([NSIndexPath.indexPathForItem(0, inSection:0)]) }, completion:nil)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|