Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonporritt committed Oct 23, 2012
0 parents commit 775e9d9
Show file tree
Hide file tree
Showing 420 changed files with 37,078 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .gitignore
@@ -0,0 +1,24 @@
.DS_Store
.repl_history
.dat*
*~
*.sw?
tags

build
resources/*.nib
resources/*.momd
resources/*.storyboardc

vendor/Pods/Pods.bridgesupport
/vendor/Pods/Pods.xcodeproj/project.pbxproj
/vendor/Pods/Pods-Acknowledgements.*
/vendor/Pods/Pods.xcconfig
/vendor/Pods/PodsDummy_Pods.m
/vendor/Pods/build-iPhoneOS/libPods.a
/vendor/Pods/build-iPhoneSimulator/libPods.a

vendor/*/build-iPhoneSimulator
vendor/*/build-iPhoneOS
vendor/*/build
vendor/*/.build
3 changes: 3 additions & 0 deletions .rvmrc
@@ -0,0 +1,3 @@
rvm_install_on_use_flag=1
rvm_gemset_create_on_use_flag=1
rvm use ruby-1.9.3-p125
6 changes: 6 additions & 0 deletions Gemfile
@@ -0,0 +1,6 @@
source :rubygems

gem 'rake'
gem 'cocoapods'
gem 'motion-cocoapods'

48 changes: 48 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,48 @@
GEM
remote: http://rubygems.org/
specs:
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.3.2)
cocoapods (0.15.2)
activesupport (~> 3.2.6)
colored (~> 1.2)
escape (~> 0.0.4)
faraday (~> 0.8.1)
json (~> 1.7.3)
octokit (~> 1.7)
open4 (~> 1.3.0)
rake (~> 0.9.0)
xcodeproj (~> 0.3.5)
colored (1.2)
escape (0.0.4)
faraday (0.8.4)
multipart-post (~> 1.1)
faraday_middleware (0.8.8)
faraday (>= 0.7.4, < 0.9)
hashie (1.2.0)
i18n (0.6.1)
json (1.7.5)
motion-cocoapods (1.2.1)
cocoapods (>= 0.14.0)
multi_json (1.3.6)
multipart-post (1.1.5)
octokit (1.18.0)
addressable (~> 2.2)
faraday (~> 0.8)
faraday_middleware (~> 0.8)
hashie (~> 1.2)
multi_json (~> 1.3)
open4 (1.3.0)
rake (0.9.2.2)
xcodeproj (0.3.5)
activesupport (~> 3.2.6)

PLATFORMS
ruby

DEPENDENCIES
cocoapods
motion-cocoapods
rake
14 changes: 14 additions & 0 deletions Rakefile
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")

require 'motion/project'
require 'motion-cocoapods'

Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'NimbusTableViewExample'

app.pods do
pod "Nimbus"
end
end
9 changes: 9 additions & 0 deletions app/app_delegate.rb
@@ -0,0 +1,9 @@
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
mainViewController = MainViewController.new
@window.rootViewController = mainViewController
@window.makeKeyAndVisible
true
end
end
23 changes: 23 additions & 0 deletions app/element_table_view_cell.rb
@@ -0,0 +1,23 @@
class ElementTableViewCell < UITableViewCell

# From the NICell protocol (optional)
# def self.heightForObject(object, atIndexPath: indexPath, tableView: tableView)
# 75
# end

# From the NICell protocol (required)
# Receives the model object, ElementViewModel in our case, that contains the
# data for the cell. Update the cell UI elements with the new data.
def shouldUpdateCellWithObject(object)
textLabel.text = "#{object.atomicNumber} - #{object.symbol}"
textLabel.font = UIFont.boldSystemFontOfSize(13)
textLabel.textColor = UIColor.blackColor
textLabel.backgroundColor = UIColor.clearColor

detailTextLabel.text = object.name
detailTextLabel.textColor = UIColor.blackColor
detailTextLabel.backgroundColor = UIColor.clearColor
return true
end
end

25 changes: 25 additions & 0 deletions app/element_table_view_model.rb
@@ -0,0 +1,25 @@
class ElementTableViewModel < NITableViewModel

# NITableViewModel already implements the UITableViewDataSource protocol and so is able to
# fulfill the obligations of the dataSource.

# As in the UITableViewDelegate protocol
def tableView(tableView, heightForRowAtIndexPath: indexPath)
75
end

# As in the UITableViewDelegate protocol
def tableView(tableView, didSelectRowAtIndexPath: indexPath)
object = self.objectAtIndexPath(indexPath)
av = UIAlertView.alloc.initWithTitle(
"You clicked #{object.name}",
message: "Its symbol is '#{object.symbol}'",
delegate: nil,
cancelButtonTitle: "Ok",
otherButtonTitles: nil)
av.show

# Delesect it now, so it's not "sticky"
tableView.deselectRowAtIndexPath(indexPath, animated: true)
end
end
26 changes: 26 additions & 0 deletions app/element_view_model.rb
@@ -0,0 +1,26 @@
class ElementViewModel

# Our model data
attr_accessor :symbol, :name, :atomicNumber

def initialize(symbol, name, number)
@symbol = symbol
@name = name
@atomicNumber = number
self
end

# From the NICellObject protocol
# The Nimbus table view cell factory, NICellFactory, calls this to
# determine what class to create for an instance of this model class
def cellClass
ElementTableViewCell
end

# From the NICellObject protocol
# NICellFactory calls cellStyle to determine what style to apply for
# cells created for instances of this class
def cellStyle
UITableViewCellStyleSubtitle
end
end
40 changes: 40 additions & 0 deletions app/main_view_controller.rb
@@ -0,0 +1,40 @@
class MainViewController < UIViewController

def viewDidLoad
super

# Create a small set of elements to load into our table view
items = [
ElementViewModel.new('H', 'Hydrogen', 1),
ElementViewModel.new('He', 'Helium', 2),
ElementViewModel.new('Li', 'Lithium', 3),
ElementViewModel.new('Be', 'Beryllium', 4),
ElementViewModel.new('B', 'Boron', 5),
ElementViewModel.new('C', 'Carbon', 6),
ElementViewModel.new('N', 'Nitrogen', 7),
ElementViewModel.new('O', 'Oxygen', 8),
ElementViewModel.new('F', 'Fluorine', 9),
ElementViewModel.new('Ne', 'Neon', 10),
]

# Use a plain-old UITableViewController with whatever style you prefer
@tableViewController = UITableViewController.alloc.initWithStyle(UITableViewStylePlain)

# Create an instance of our custom table view model. Setting the delegate to NICellFactory
# works because this is a relatively simple case and we're happy with its implementation of
# tableViewModel:cellForTableView:atIndexPath:withObject:
@elementTableVM = ElementTableViewModel.alloc.initWithListArray(items, delegate: NICellFactory)

addChildViewController(@tableViewController)
view.addSubview(@tableViewController.view)
end

def viewWillAppear(animated)
# Set the table view model as the dataSource and delegate of the table view. The dataSource
# and delegate can be different objects, but they're combined in this example.
@tableViewController.tableView.dataSource = @elementTableVM
@tableViewController.tableView.delegate = @elementTableVM
@tableViewController.view.frame = [[0, 0], [view.size.width, view.size.height]]
end

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

it "has one window" do
@app.windows.size.should == 1
end
end
70 changes: 70 additions & 0 deletions vendor/Podfile.lock
@@ -0,0 +1,70 @@

PODS:
- JSONKit (1.5pre)
- Nimbus (0.9.3):
- Nimbus/AttributedLabel (= 0.9.3)
- Nimbus/CSS (= 0.9.3)
- Nimbus/Core (= 0.9.3)
- Nimbus/Interapp (= 0.9.3)
- Nimbus/Launcher (= 0.9.3)
- Nimbus/Models (= 0.9.3)
- Nimbus/NetworkControllers (= 0.9.3)
- Nimbus/NetworkImage (= 0.9.3)
- Nimbus/Operations (= 0.9.3)
- Nimbus/Overview (= 0.9.3)
- Nimbus/PagingScrollView (= 0.9.3)
- Nimbus/Photos (= 0.9.3)
- Nimbus/WebController (= 0.9.3)
- Nimbus/AttributedLabel (0.9.3):
- Nimbus/Core
- Nimbus/CSS (0.9.3):
- Nimbus/Core
- Nimbus/Core (0.9.3)
- Nimbus/Interapp (0.9.3):
- Nimbus/Core
- Nimbus/Launcher (0.9.3):
- Nimbus/Core
- Nimbus/Models (0.9.3):
- Nimbus/Core
- Nimbus/NetworkControllers (0.9.3):
- Nimbus/Core
- Nimbus/NetworkImage (0.9.3):
- Nimbus/Core
- Nimbus/Operations (0.9.3):
- Nimbus/Core
- Nimbus/Operations/JSON (= 0.9.3)
- Nimbus/Operations/JSON (0.9.3):
- JSONKit
- Nimbus/Core
- Nimbus/Overview (0.9.3):
- Nimbus/Core
- Nimbus/PagingScrollView (0.9.3):
- Nimbus/Core
- Nimbus/Photos (0.9.3):
- Nimbus/Core
- Nimbus/PagingScrollView
- Nimbus/WebController (0.9.3):
- Nimbus/Core

DEPENDENCIES:
- Nimbus

SPEC CHECKSUMS:
JSONKit: a01a22c75f27eae76b4badd55a91c20fe6e86477
Nimbus: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/AttributedLabel: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/CSS: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/Core: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/Interapp: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/Launcher: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/Models: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/NetworkControllers: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/NetworkImage: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/Operations: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/Operations/JSON: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/Overview: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/PagingScrollView: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/Photos: 6a35688977607cda01be9027699a9e64bd08fb99
Nimbus/WebController: 6a35688977607cda01be9027699a9e64bd08fb99

COCOAPODS: 0.15.2
1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/JSONKit/JSONKit.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/CSSTokens.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIAttributedLabel.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIBlocks.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NICSSParser.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NICSSRuleset.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NICellCatalog.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NICellFactory.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIChameleonObserver.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NICommonMetrics.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIDOM.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIDataStructures.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIDebuggingTools.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIDeviceInfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIDeviceOrientation.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIError.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIFormCellCatalog.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIFoundationMethods.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIInMemoryCache.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NIInterapp.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NILauncherView.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NILauncherViewController.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NINavigationAppearance.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NINetworkActivity.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NINetworkImageRequest.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NINetworkImageView.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/Pods/BuildHeaders/Nimbus/NINetworkJSONRequest.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 775e9d9

Please sign in to comment.