-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTABillingInfoController.m
113 lines (91 loc) · 4.55 KB
/
TABillingInfoController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// TABillingInfoController.m
// Tohfa
//
// Created by Anupam Jindal on 4/6/13.
// Copyright (c) 2013 Tohfa. All rights reserved.
//
#import "TABillingInfoController.h"
#import "TAUtilities.h"
#import "TAOrderConfirmationController.h"
@implementation TABillingInfoController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[TAUtilities initTitle:@"Billing Info" on:self.navigationItem];
//[TAUtilities initBackButtonOn:self withAction:@selector(backButtonClicked)];
UIBarButtonItem *placeOrderButton = [[UIBarButtonItem alloc] initWithCustomView:[TAUtilities createRightContinueNavButtonWithTitle:@"Place Order" For:self withAction:@selector(placeOrder)]];
self.navigationItem.rightBarButtonItem = placeOrderButton;
self.navigationItem.leftBarButtonItem = nil;
self.navigationItem.hidesBackButton=YES;
}
return self;
}
-(void)viewDidLoad {
[super viewDidLoad];
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg.png"]];
[self.view addSubview:backgroundImageView];
[self.view sendSubviewToBack:backgroundImageView];
self.holderNameField.text = @"Test";
self.holderCardNumberField.text = @"123456789012";
self.holderCardExpirationField.text = @"01/01";
self.holderCVVField.text = @"123";
self.holderStreetAddressOneField.text = @"132 Main St.";
self.holderStreetAddressTwoField.text = @"";
self.holderCityField.text = @"San Francisco";
self.holderStateField.text = @"California";
self.holderZipField.text = @"12345";
self.holderCountryField.text = @"USA";
self.holderNameField.enabled = NO;
self.holderCardNumberField.enabled = NO;
self.holderCardExpirationField.enabled = NO;
self.holderCVVField.enabled = NO;
self.holderStreetAddressOneField.enabled = NO;
self.holderStreetAddressTwoField.enabled = NO;
self.holderCityField.enabled = NO;
self.holderStateField.enabled = NO;
self.holderZipField.enabled = NO;
self.holderCountryField.enabled = NO;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShowNotification:) name:UIKeyboardWillShowNotification object:self.view.window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShowNotification:) name:UIKeyboardDidShowNotification object:self.view.window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHideNotification:) name:UIKeyboardDidHideNotification object:self.view.window];
}
-(void) backButtonClicked {
[self.navigationController popViewControllerAnimated:YES];
}
-(void)placeOrder{
[self resignFirstResponder];
TAOrderConfirmationController *confirmOrder = [[TAOrderConfirmationController alloc] initWithNibName:@"TAOrderConfirmationController" bundle:nil];
[self.navigationController pushViewController:confirmOrder animated:YES];
}
//Keyboard will show notification just to get the keyboard height since we use this height to control scrolling
-(void)keyboardWillShowNotification:(NSNotification*)inNotification
{
NSDictionary* info = [inNotification userInfo];
CGRect keyboardFrame = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
mKeyBoardSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;
mKeyBoardSize = keyboardFrame.size;
}
//when the keyboard is hidden set the content offset of the scroll view to zero origin. Animate or not depending on whether the keyboard is hiding as a result of
//popping the view controller
/*-(void)keyboardDidHideNotification:(NSNotification *)inNotification
{
CGFloat totalHeight = 0;
totalHeight += self.editView.frame.origin.y + self.editView.frame.size.height + 8;
CGSize scrollViewSize = self.scrollView.contentSize;
scrollViewSize.height = totalHeight;
[self.scrollView setContentSize:scrollViewSize];
[self.scrollView setContentOffset:CGPointZero animated:!mShouldNotAnimateScrollView];
self.editing = NO;
}*/
//when the keyboard is shown increase the scroll view content size by the keyaboard height
-(void)keyboardDidShowNotification:(NSNotification *)inNotification
{
NSValue *keyBoardBoundsValue = (NSValue *)[[inNotification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyBoardBounds;
[keyBoardBoundsValue getValue:&keyBoardBounds];
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
self.editing = YES;
}
@end