Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

Commit

Permalink
Clean up whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Claude Sutterlin authored and josharian committed Jul 2, 2015
1 parent ca2ee05 commit 6732275
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 120 deletions.
112 changes: 56 additions & 56 deletions Classes/CardIODataEntryViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ - (id)initWithContext:(CardIOContext *)aContext withStatusBarHidden:(BOOL)status
_notificationSize = CGSizeZero;
_context = aContext;
_statusBarHidden = statusBarHidden;

// set self.title in -viewDidLoad. the title is localized, which requires
// access to the i18n context, but that is sometimes non-existent at this stage
// (the developer sometimes hasn't even had the opportunity to tell us yet!).
Expand All @@ -85,7 +85,7 @@ - (id)initWithContext:(CardIOContext *)aContext withStatusBarHidden:(BOOL)status

- (void)calculateRelevantViewFrame {
self.relevantViewFrame = self.view.bounds;

if (!iOS_7_PLUS) {
// On iOS 7, setting 'edgesForExtendedLayout = UIRectEdgeNone' takes care of the offset
if (self.navigationController.navigationBar.translucent) {
Expand Down Expand Up @@ -151,7 +151,7 @@ - (void)viewDidLoad {
self.collectPostalCode = pvc.collectPostalCode;

self.scrollView = [[UIScrollView alloc] initWithFrame:self.relevantViewFrame];

if(!self.manualEntry) {
self.cardView = [[UIImageView alloc] initWithImage:self.cardImage];
self.cardView.bounds = CGRectZeroWithSize(CGSizeMake((CGFloat)ceil(self.floatingCardView.bounds.size.width),
Expand All @@ -162,11 +162,11 @@ - (void)viewDidLoad {
self.cardView.layer.masksToBounds = YES;
self.cardView.layer.borderColor = [UIColor grayColor].CGColor;
self.cardView.layer.borderWidth = 2.0f;

self.cardView.hidden = YES;
[self.scrollView addSubview:self.cardView];
}

self.tableView = [[UITableView alloc] initWithFrame:self.scrollView.bounds style:UITableViewStyleGrouped];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
self.tableView.scrollEnabled = NO;
Expand Down Expand Up @@ -205,7 +205,7 @@ - (void)viewDidLoad {
self.numberTextField.backgroundColor = kColorDefaultCell;
self.numberTextField.textAlignment = [CardIOLocalizer textAlignmentForLanguageOrLocale:self.context.languageOrLocale];
self.numberTextField.autocorrectionType = UITextAutocorrectionTypeNo;

// For fancier masking (e.g., by number group rather than by individual digit),
// put fancier functionality into CardIONumbersTextFieldDelegate instead of setting secureTextEntry.
self.numberTextField.secureTextEntry = self.context.maskManualEntryDigits;
Expand Down Expand Up @@ -337,24 +337,24 @@ - (void)viewDidLoad {
self.tableView.backgroundView = background;

[self.scrollView addSubview:self.tableView];

if (iOS_7_PLUS) {
self.leftTableBorderForIOS7 = [[UIView alloc] init];
self.leftTableBorderForIOS7.backgroundColor = [UIColor colorWithWhite:kiOS7TableViewBorderColor alpha:1];
self.leftTableBorderForIOS7.hidden = YES;
[self.scrollView addSubview:self.leftTableBorderForIOS7];

self.rightTableBorderForIOS7 = [[UIView alloc] init];
self.rightTableBorderForIOS7.backgroundColor = [UIColor colorWithWhite:kiOS7TableViewBorderColor alpha:1];
self.rightTableBorderForIOS7.hidden = YES;
[self.scrollView addSubview:self.rightTableBorderForIOS7];
}

if (self.cardView) {
// Animations look better if the cardView is in front of the tableView
[self.scrollView bringSubviewToFront:self.cardView];
}

[self.view addSubview:self.scrollView];
}

Expand All @@ -363,9 +363,9 @@ - (void)viewWillAppear:(BOOL)animated {
// Force interface to rotate to match current device orientation, following portrait-only camera view.
[[NSNotificationCenter defaultCenter] postNotificationName:UIDeviceOrientationDidChangeNotification object:nil];
}

[super viewWillAppear:animated];

if (self.navigationController.modalPresentationStyle == UIModalPresentationFullScreen && !self.statusBarHidden) {
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
if (iOS_7_PLUS) {
Expand Down Expand Up @@ -417,25 +417,25 @@ - (void)viewDidAppear:(BOOL)animated {
}

[self layoutForCurrentOrientation];

if (self.floatingCardView) {
if (self.cardView) {
CGRect newCardViewFrame = self.cardView.frame; // as set above by [self layoutForCurrentOrientation]
CGRect cardFrameInView = [self.view convertRect:self.floatingCardView.frame fromView:self.floatingCardView.superview];
self.cardView.frame = cardFrameInView; // start the animation with the card appearing as in the CardIOTransitionView

self.cardView.hidden = NO;
self.floatingCardWindow.hidden = YES;
self.floatingCardView = nil;
self.floatingCardWindow = nil;
self.priorKeyWindow = nil;

if ([self.tableView numberOfRowsInSection:0] > 0) {
self.tableView.alpha = 0;
self.tableView.hidden = NO;
[self showTableBorders:NO];
}

[UIView animateWithDuration:0.4
animations:^{
self.cardView.frame = newCardViewFrame;
Expand Down Expand Up @@ -467,7 +467,7 @@ - (void)viewDidAppear:(BOOL)animated {
self.tableView.alpha = 0;
self.tableView.hidden = NO;
[self showTableBorders:NO];

[UIView animateWithDuration:0.4
animations:^{
self.tableView.alpha = 1;
Expand Down Expand Up @@ -571,15 +571,15 @@ - (void)showTableBorders:(BOOL)showTableBorders {

- (void)layoutForCurrentOrientation {
self.oldHeight = self.view.bounds.size.height;

[self calculateRelevantViewFrame];
self.scrollView.frame = self.relevantViewFrame;

if (self.cardView) {
CGRect cardViewFrame = self.cardView.frame;
CGRect tableViewFrame = self.tableView.frame;
BOOL showTableView = ([self.tableView numberOfRowsInSection:0] > 0);

if ([self isWideScreenMode]) {
cardViewFrame.size.width = (CGFloat)floor(MAX(self.scrollView.bounds.size.width, self.scrollView.bounds.size.height) * kLandscapeZoomedInCardImageSizePercent);
cardViewFrame.size.height = (CGFloat)floor(self.cardImage.size.height * (cardViewFrame.size.width / self.cardImage.size.width));
Expand All @@ -597,18 +597,18 @@ - (void)layoutForCurrentOrientation {
if ([self isWideScreenMode]) {
cardViewFrame.origin.x = kCardPadding;
cardViewFrame.origin.y = kCardPadding;

tableViewFrame.size.width = (CGFloat)(self.scrollView.bounds.size.width - cardViewFrame.size.width - 3 * kCardPadding);
tableViewFrame.size.height = self.scrollView.bounds.size.height;
tableViewFrame.origin.x = CGRectGetMaxX(self.scrollView.bounds) - tableViewFrame.size.width - kCardPadding;

if (iOS_7_PLUS) {
NSInteger lastSection = [self.tableView numberOfSections] - 1;
NSInteger lastRow = [self.tableView numberOfRowsInSection:lastSection] - 1;
UITableViewCell *firstCell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
UITableViewCell *lastCell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:lastRow inSection:lastSection]];
tableViewFrame.origin.y = kCardPadding - firstCell.frame.origin.y;

CGRect leftTableBorderFrame = self.leftTableBorderForIOS7.frame;
leftTableBorderFrame.origin.x = tableViewFrame.origin.x - 0.5f;
leftTableBorderFrame.origin.y = tableViewFrame.origin.y + firstCell.frame.origin.y;
Expand All @@ -627,7 +627,7 @@ - (void)layoutForCurrentOrientation {
else {
cardViewFrame.origin.x = (CGFloat)floor((self.scrollView.bounds.size.width - cardViewFrame.size.width) / 2);
cardViewFrame.origin.y = (CGFloat)floor(kCardPadding / 2);

tableViewFrame = self.scrollView.bounds;
tableViewFrame.origin.y = CGRectGetMaxY(cardViewFrame);

Expand All @@ -643,10 +643,10 @@ - (void)layoutForCurrentOrientation {
cardViewFrame.origin.y = (CGFloat)floor((self.scrollView.frame.size.height - cardViewFrame.size.height) / 3);
tableViewFrame = CGRectZero;
}

self.cardView.frame = cardViewFrame;
self.tableView.frame = tableViewFrame;

self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width,
MAX(self.tableView.frame.origin.y + CGRectGetMaxY([self.tableView rectForSection:0]), CGRectGetMaxY(self.cardView.frame)));
}
Expand All @@ -660,28 +660,28 @@ - (void)layoutForCurrentOrientation {
tableViewFrame.size.height = self.scrollView.bounds.size.height;
tableViewFrame.origin.x = (CGFloat)floor((self.scrollView.bounds.size.width - tableWidth) / 2);
tableViewFrame.origin.y = 0;

if (iOS_7_PLUS) {
NSInteger lastSection = [self.tableView numberOfSections] - 1;
NSInteger lastRow = [self.tableView numberOfRowsInSection:lastSection] - 1;
UITableViewCell *firstCell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
UITableViewCell *lastCell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:lastRow inSection:lastSection]];

CGRect leftTableBorderFrame = self.leftTableBorderForIOS7.frame;
leftTableBorderFrame.origin.x = tableViewFrame.origin.x - 0.5f;
leftTableBorderFrame.origin.y = tableViewFrame.origin.y + firstCell.frame.origin.y;
leftTableBorderFrame.size.height = lastCell.frame.origin.y + lastCell.frame.size.height - firstCell.frame.origin.y;
leftTableBorderFrame.size.width = 0.5f;
self.leftTableBorderForIOS7.frame = leftTableBorderFrame;

CGRect rightTableBorderFrame = leftTableBorderFrame;
rightTableBorderFrame.origin.x = tableViewFrame.origin.x + tableViewFrame.size.width;
self.rightTableBorderForIOS7.frame = rightTableBorderFrame;
}
}
else {
tableViewFrame = self.scrollView.bounds;

if (iOS_7_PLUS) {
CGRect tableBorderFrame = CGRectMake(0, 0, 0, 0);
self.leftTableBorderForIOS7.frame = tableBorderFrame;
Expand All @@ -690,7 +690,7 @@ - (void)layoutForCurrentOrientation {
}

self.tableView.frame = tableViewFrame;

self.scrollView.contentSize = CGSizeMake(self.scrollView.bounds.size.width,
self.tableView.frame.origin.y + CGRectGetMaxY([self.tableView rectForSection:0]));
}
Expand All @@ -711,7 +711,7 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrie

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];

if (self.view.bounds.size.height != self.oldHeight) {
[self showTableBorders:NO];

Expand Down Expand Up @@ -748,12 +748,12 @@ - (void)popToTop {
[field resignFirstResponder];
}
}

if (iOS_7_PLUS) {
// On iOS 7, looks better if we start sliding away the nav bar prior to transitioning to camera-view.
[self.navigationController setNavigationBarHidden:YES animated:YES];
}

((CardIOPaymentViewController *)self.navigationController).currentViewControllerIsDataEntry = NO;
((CardIOPaymentViewController *)self.navigationController).initialInterfaceOrientationForViewcontroller = [UIApplication sharedApplication].statusBarOrientation;
[self.navigationController popToRootViewControllerAnimated:YES];
Expand All @@ -768,10 +768,10 @@ - (void)done {
if(self.manualEntry) {
self.cardInfo.cardNumber = [CardIOCreditCardNumber stringByRemovingNonNumbers:self.numberTextField.text];
}

self.cardInfo.cvv = self.cvvTextField.text;
self.cardInfo.postalCode = [self.postalCodeTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

CardIOPaymentViewController *pvc = (CardIOPaymentViewController *)self.navigationController;
[pvc.paymentDelegate userDidProvideCreditCardInfo:self.cardInfo inPaymentViewController:pvc];
}
Expand Down Expand Up @@ -804,9 +804,9 @@ - (void)cardNumberDidChange:(id)sender {
if (recursionBlock) {
return;
}

BOOL fieldIsInFlux = ![self.numberRowTextFieldDelegate cleanupTextField:self.numberTextField];

CardIOCreditCardInfo *cleanedInfo = self.cardInfo;
[self.numberRowTextFieldDelegate.formatter getObjectValue:&cleanedInfo forString:self.numberTextField.text errorDescription:nil];
self.cardInfo = cleanedInfo;
Expand All @@ -826,10 +826,10 @@ - (void)cardNumberDidChange:(id)sender {
} else if ([self.cardInfo.cardNumber length] > 0 &&
((cardType == CardIOCreditCardTypeUnrecognized && [self.cardInfo.cardNumber length] == 16) ||
self.cardInfo.cardNumber.length == [CardIOCreditCardNumber numberLengthForCardNumber:self.cardInfo.cardNumber])) {
self.numberTextField.textColor = [UIColor redColor];
} else {
self.numberTextField.textColor = [CardIOTableViewCell defaultDetailTextLabelColorForCellStyle:[CardIOTableViewCell defaultCellStyle]];
}
self.numberTextField.textColor = [UIColor redColor];
} else {
self.numberTextField.textColor = [CardIOTableViewCell defaultDetailTextLabelColorForCellStyle:[CardIOTableViewCell defaultCellStyle]];
}

[self updateCardLogo];

Expand Down Expand Up @@ -864,9 +864,9 @@ - (void)expiryDidChange:(id)sender {
if (recursionBlock) {
return;
}

BOOL fieldIsInFlux = ![self.expiryTextFieldDelegate cleanupTextField:self.expiryTextField];

CardIOCreditCardInfo *cleanedInfo = self.cardInfo;
[self.expiryTextFieldDelegate.formatter getObjectValue:&cleanedInfo forString:self.expiryTextField.text errorDescription:nil];
self.cardInfo = cleanedInfo;
Expand All @@ -891,13 +891,13 @@ - (void)cvvDidChange:(id)sender {
self.cardInfo.cvv = self.cvvTextField.text;

[self updateCvvColor];

CardIOCreditCardType cardType = [CardIOCreditCardNumber cardTypeForCardNumber:self.cardInfo.cardNumber];
if(cardType != CardIOCreditCardTypeUnrecognized && cardType != CardIOCreditCardTypeAmbiguous &&
[CardIOCVVTextFieldDelegate isValidCVV:self.cardInfo.cvv forNumber:self.cardInfo.cardNumber]) {
[self advanceToNextEmptyFieldFrom:self.cvvTextField];
}

[self validate];
}

Expand All @@ -914,17 +914,17 @@ - (void)updateCvvColor {
- (void)postalCodeDidChange:(id)sender {
self.cardInfo.postalCode = [self.postalCodeTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

// For globalization, we can't be sure of a valid postalCode length. So for now we'll skip all of this.
//
// if([CardIOPostalCodeTextFieldDelegate isValidPostalCode:self.cardInfo.postalCode]) {
// [self advanceToNextEmptyFieldFrom:self.postalCodeTextField];
// self.postalCodeTextField.textColor = [CardIOTableViewCell defaultDetailTextLabelColorForCellStyle:[CardIOTableViewCell defaultCellStyle]];
// } else if(self.postalCodeTextField.text.length >= 5) {
// // probably won't reach this case, since length == 5 is the only validation rule, but we'll leave it here for consitency and for future enhancements.
// self.postalCodeTextField.textColor = [UIColor redColor];
// } else {
// self.postalCodeTextField.textColor = [CardIOTableViewCell defaultDetailTextLabelColorForCellStyle:[CardIOTableViewCell defaultCellStyle]];
// }
// For globalization, we can't be sure of a valid postalCode length. So for now we'll skip all of this.
//
// if([CardIOPostalCodeTextFieldDelegate isValidPostalCode:self.cardInfo.postalCode]) {
// [self advanceToNextEmptyFieldFrom:self.postalCodeTextField];
// self.postalCodeTextField.textColor = [CardIOTableViewCell defaultDetailTextLabelColorForCellStyle:[CardIOTableViewCell defaultCellStyle]];
// } else if(self.postalCodeTextField.text.length >= 5) {
// // probably won't reach this case, since length == 5 is the only validation rule, but we'll leave it here for consitency and for future enhancements.
// self.postalCodeTextField.textColor = [UIColor redColor];
// } else {
// self.postalCodeTextField.textColor = [CardIOTableViewCell defaultDetailTextLabelColorForCellStyle:[CardIOTableViewCell defaultCellStyle]];
// }

[self validate];
}
Expand Down
Loading

0 comments on commit 6732275

Please sign in to comment.