Created
January 30, 2013 08:28
-
-
Save dangalipo/4671642 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# app/views/wallet/EmptyWalletView.rb | |
class EmptyWalletView < WalletLayout | |
FROWN_IMAGE = 'T5F-CouponsEmpty-Icon-SadFace.png' | |
FROWN_IMAGE_X_PADDING = 60 | |
FROWN_IMAGE_Y_PADDING = 30 | |
FROWN_IMAGE_WIDTH = 82 | |
FROWN_IMAGE_HEIGHT = 82 | |
NEXT_BUTTON_X_PADDING = 0 | |
NEXT_BUTTON_Y_PADDING = 100 | |
NEXT_BUTTON_HEIGHT = 60 | |
NEXT_BUTTON_IMAGE = 'T5F-Uni-Blue-Bottom-Item-Background-Arrow.png' | |
SORRY_LABEL_X_PADDING = 20 | |
SORRY_LABEL_Y_PADDING = 130 | |
SORRY_LABEL_WIDTH = 250 | |
SORRY_LABEL_HEIGHT = 50 | |
SORRY_LABEL_FONT = "Arial-BoldMT" | |
SORRY_LABEL_FONT_SIZE = 16 | |
attr_accessor :controllerDelegate | |
def initWithFrame(frame, andDelegate: delegate) | |
super | |
self.initWithFrame(frame) | |
@controllerDelegate = delegate | |
setupFrownImage | |
setupSorryLabel | |
setupButton | |
self | |
end | |
def setupButton | |
nextButton = UIButton.alloc.initWithFrame( | |
CGRectMake( | |
NEXT_BUTTON_X_PADDING, | |
(self.size.height - NEXT_BUTTON_Y_PADDING), | |
self.size.width, | |
NEXT_BUTTON_HEIGHT | |
) | |
) | |
image = UIImage.alloc.initWithContentsOfFile(File.join(App.resources_path, NEXT_BUTTON_IMAGE)) | |
nextButton.setBackgroundImage image, forState: UIControlStateNormal | |
nextButton.setTitle 'Start earning coupons', forState: UIControlStateNormal | |
tapRecognizer = UITapGestureRecognizer.alloc.initWithTarget self.controllerDelegate, action: 'nextScreen' | |
nextButton.addGestureRecognizer tapRecognizer | |
self.addSubview nextButton | |
end | |
def setupFrownImage | |
img = UIImage.alloc.initWithContentsOfFile(File.join(App.resources_path, FROWN_IMAGE)) | |
frown = UIImageView.alloc.initWithImage(img) | |
frown.frame = CGRectMake( | |
FROWN_IMAGE_X_PADDING, | |
FROWN_IMAGE_Y_PADDING, | |
FROWN_IMAGE_WIDTH, | |
FROWN_IMAGE_HEIGHT | |
) | |
frown.contentMode = UIViewContentModeScaleAspectFit | |
frown.backgroundColor = UIColor.clearColor | |
self.addSubview frown | |
end | |
def setupSorryLabel | |
label = UILabel.alloc.initWithFrame( | |
CGRectMake( | |
SORRY_LABEL_X_PADDING, | |
SORRY_LABEL_Y_PADDING, | |
SORRY_LABEL_WIDTH, | |
SORRY_LABEL_HEIGHT | |
) | |
) | |
label.text = "Sorry, no coupons here." | |
label.textColor = UIColor.blackColor | |
label.backgroundColor = UIColor.clearColor | |
label.textAlignment = UITextAlignmentCenter | |
label.setFont UIFont.fontWithName(SORRY_LABEL_FONT, size: SORRY_LABEL_FONT_SIZE) | |
self.addSubview label | |
end | |
end |
This file contains hidden or 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
# app/lib/UIViewWithDelegate.rb | |
class UIViewWithDelegate < UIView | |
attr_accessor :controllerDelegate | |
def initWithFrame(frame, andDelegate: delegate) | |
self.initWithFrame(frame) | |
self.controllerDelegate = delegate | |
self | |
end | |
end |
This file contains hidden or 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
# app/controllers/WalletController.rb | |
class WalletController < BackgroundImageController | |
# UIViewController | |
def viewDidLoad | |
super | |
self.view.backgroundColor = UIColor.lightGrayColor | |
self.title = "My Coupon Wallet" | |
emptyWalletView = EmptyWalletView.alloc.initWithFrame(self.view.frame, andDelegate: self) | |
self.view = emptyWalletView | |
emptyWalletView.controllerDelegate = self | |
end | |
# UIButton | |
def nextScreen | |
self.navigationController.pushViewController(DetailsController.alloc.initWithNibName(nil, bundle: nil), animated: true) | |
end | |
end |
This file contains hidden or 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
# app/views/layouts/WalletLayout.rb | |
class WalletLayout < UIViewWithDelegate | |
BACK_BUTTON_BG_IMAGE = 'T5F-Uni-Back-Dark.png' | |
NAV_BAR_BG_IMAGE = 'T5F-CouponDetail-Header.png' | |
BACKGROUND_IMAGE = 'T5F-Uni-Background.png' | |
def initWithFrame(frame, andDelegate: delegate) | |
super | |
navBG = UIImage.alloc.initWithContentsOfFile(File.join(App.resources_path, NAV_BAR_BG_IMAGE)) | |
backBG = UIImage.alloc.initWithContentsOfFile(File.join(App.resources_path, BACK_BUTTON_BG_IMAGE)) | |
UINavigationBar.appearance.setBackgroundImage navBG, forBarMetrics:UIBarMetricsDefault | |
UIBarButtonItem.appearance.setBackButtonBackgroundImage backBG, forState:UIControlStateNormal, barMetrics:UIBarMetricsDefault | |
self.backgroundColor = UIColor.clearColor | |
backgroundImage = UIImageView.alloc.initWithImage(UIImage.alloc.initWithContentsOfFile(File.join(App.resources_path, BACKGROUND_IMAGE))) | |
self.addSubview backgroundImage | |
self.sendSubviewToBack backgroundImage | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment