-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ecf133
commit 37cbea3
Showing
16 changed files
with
1,527 additions
and
1 deletion.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
examples/States (without wax.framework)/Classes/ProtocolLoader.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Many protocols will work from wax out of the box. But some need to be preloaded. | ||
// If the protocol you are using isn't found, just add the protocol to this object | ||
// | ||
// This seems to be a bug, or there is a runtime method I'm unaware of | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface ProtocolLoader : NSObject <UIApplicationDelegate, UIWebViewDelegate, UIActionSheetDelegate, UIAlertViewDelegate, UISearchBarDelegate, UITextViewDelegate, UITabBarControllerDelegate> {} | ||
@end | ||
|
||
@implementation ProtocolLoader | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>get-task-allow</key> | ||
<false/> | ||
</dict> | ||
</plist> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "wax/lib/project.rake" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>English</string> | ||
<key>CFBundleDisplayName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundleDocumentTypes</key> | ||
<array/> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIconFile</key> | ||
<string>Icon.png</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0</string> | ||
<key>LSRequiresIPhoneOS</key> | ||
<true/> | ||
</dict> | ||
</plist> |
730 changes: 730 additions & 0 deletions
730
examples/States (without wax.framework)/States.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// Prefix header for all source files of the 'States' target in the 'States' project | ||
// | ||
|
||
#ifdef __OBJC__ | ||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// main.m | ||
// States | ||
// | ||
// Created by Corey on 1/3/11. | ||
// Copyright me 2011. All rights reserved. | ||
// | ||
// This where the magic happens! | ||
// Wax doesn't use nibs to load the main view, everything is done within the | ||
// AppDelegate.lua file | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
#import "wax.h" | ||
#import "wax_http.h" | ||
#import "wax_json.h" | ||
#import "wax_xml.h" | ||
|
||
int main(int argc, char *argv[]) { | ||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | ||
|
||
wax_start("AppDelegate", luaopen_wax_http, luaopen_wax_json, luaopen_wax_xml, nil); | ||
|
||
int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate"); | ||
[pool release]; | ||
return retVal; | ||
} |
17 changes: 17 additions & 0 deletions
17
examples/States (without wax.framework)/scripts/AppDelegate.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require "StatesTable" | ||
require "CapitalsTable" | ||
|
||
waxClass{"AppDelegate", protocols = {"UIApplicationDelegate"}} | ||
|
||
function applicationDidFinishLaunching(self, application) | ||
local frame = UIScreen:mainScreen():bounds() | ||
self.window = UIWindow:initWithFrame(frame) | ||
self.window:setBackgroundColor(UIColor:orangeColor()) | ||
self.window:makeKeyAndVisible() | ||
|
||
local statesTable = StatesTable:init() | ||
self.navigationController = UINavigationController:initWithRootViewController(statesTable) | ||
|
||
self.window:addSubview(self.navigationController:view()) | ||
end | ||
|
36 changes: 36 additions & 0 deletions
36
examples/States (without wax.framework)/scripts/CapitalsTable.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
waxClass{"CapitalsTable", UITableViewController, protocols = {"UITableViewDataSource"}} | ||
|
||
function init(self, state) | ||
self.super:initWithStyle(UITableViewStyleGrouped) | ||
self.state = state | ||
self:setTitle(state.name) | ||
return self | ||
end | ||
|
||
|
||
function viewDidLoad(self) | ||
self:tableView():setDataSource(self) | ||
end | ||
|
||
-- DataSource | ||
------------- | ||
function numberOfSectionsInTableView(self, tableView) | ||
return 1 | ||
end | ||
|
||
function tableView_numberOfRowsInSection(self, tableView, section) | ||
return #table.keys(self.state) | ||
end | ||
|
||
function tableView_cellForRowAtIndexPath(self, tableView, indexPath) | ||
local identifier = "CapitalsTableCell" | ||
local cell = tableView:dequeueReusableCellWithIdentifier(identifier) or | ||
UITableViewCell:initWithStyle_reuseIdentifier(UITableViewCellStyleValue1, identifier) | ||
|
||
local key = table.keys(self.state)[indexPath:row() + 1] | ||
cell:detailTextLabel():setText(tostring(self.state[key])) | ||
cell:textLabel():setText(key) | ||
cell:setSelectionStyle(UITableViewCellSelectionStyleNone) | ||
|
||
return cell | ||
end |
50 changes: 50 additions & 0 deletions
50
examples/States (without wax.framework)/scripts/StatesTable.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
|
||
waxClass{"StatesTable", UITableViewController, protocols = {"UITableViewDataSource", "UITableViewDelegate"}} | ||
|
||
function init(self) | ||
self.super:init() | ||
|
||
-- Loads plist from bundle | ||
self.states = NSArray:arrayWithContentsOfFile("states.plist") | ||
|
||
self:setTitle("States") | ||
return self | ||
end | ||
|
||
function viewDidLoad(self) | ||
self:tableView():setDataSource(self) | ||
self:tableView():setDelegate(self) | ||
end | ||
|
||
-- DataSource | ||
------------- | ||
function numberOfSectionsInTableView(self, tableView) | ||
return 1 | ||
end | ||
|
||
function tableView_numberOfRowsInSection(self, tableView, section) | ||
return #self.states | ||
end | ||
|
||
function tableView_cellForRowAtIndexPath(self, tableView, indexPath) | ||
local identifier = "StateCell" | ||
local cell = tableView:dequeueReusableCellWithIdentifier(identifier) or | ||
UITableViewCell:initWithStyle_reuseIdentifier(UITableViewCellStyleDefault, identifier) | ||
|
||
local state = self.states[indexPath:row() + 1] | ||
cell:textLabel():setText(state["name"]) -- Must +1 because lua arrays are 1 based | ||
cell:setAccessoryType(UITableViewCellAccessoryDisclosureIndicator) | ||
|
||
return cell | ||
end | ||
|
||
-- Delegate | ||
----------- | ||
function tableView_didSelectRowAtIndexPath(self, tableView, indexPath) | ||
self:tableView():deselectRowAtIndexPath_animated(indexPath, true) | ||
local state = self.states[indexPath:row() + 1] | ||
|
||
local viewController = CapitalsTable:init(state) | ||
self:navigationController():pushViewController_animated(viewController, true) | ||
end |
Oops, something went wrong.