Created
April 12, 2011 22:52
-
-
Save probablycorey/916626 to your computer and use it in GitHub Desktop.
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
waxClass{"AppDelegate", protocols = {"UIApplicationDelegate"}} | |
function applicationDidFinishLaunching(self, application) | |
-- wax.cache.clearAll() | |
CurrentLocation:sharedInstance():start(60, nil) | |
local frame = UIScreen:mainScreen():bounds() | |
self.window = UIWindow:initWithFrame(frame) | |
self.window:makeKeyAndVisible() | |
self.tabBarController = UITabBarController:init() | |
self.window:addSubview(self.tabBarController:view()) | |
Area:preload() | |
self:prepControllers() | |
self:updateSearchIcon(Search:cached() or Search:initForSales()) | |
puts("Version %s", wax.appVersion) | |
end | |
function applicationDidBecomeActive(self, application) | |
GoogleTracker:start() | |
end | |
function applicationWillResignActive(self, application) | |
GoogleTracker:stop() | |
end | |
-- Search icon changes from sales to rentals, this method helps with that. | |
function updateSearchIcon(self, search) | |
local tabBarItem = self.tabBarController:tabBar():items()[2] | |
tabBarItem:setImage(UIImage:imageNamed(search:isRental() and "tabRentals.png" or "tabSales.png")) | |
end | |
function updateSearch(self, search) | |
self.tabBarController:setSelectedIndex(1) | |
local searchController = self.tabBarController:viewControllers()[2]:topViewController() | |
searchController:view() -- Hack! Makes sure the view is loaded | |
searchController:reset(search) | |
end | |
function prepControllers(self) | |
local homeController = self:buildNavController(HomeController) | |
local searchController = self:buildNavController(SearchController) | |
local folderController = self:buildNavController(SavedListsController) | |
self.tabBarController:setViewControllers({homeController, searchController, folderController}) | |
end | |
function buildNavController(self, viewControllerClass) | |
local viewController = viewControllerClass:init() | |
local navigationController = UINavigationController:initWithRootViewController(viewController) | |
return navigationController | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment