Skip to content

Commit f912562

Browse files
author
Ben Guo
committed
adds nextFormField
1 parent a4a10a4 commit f912562

File tree

822 files changed

+266
-42652
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

822 files changed

+266
-42652
lines changed

.gitignore

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
.DS_Store
22
xcuserdata
3-
Pods/*
4-
build/*
5-
dogbuild/*
6-
cibuild/*
3+
SignupForm/Pods/*
74
*.xccheckout

BZGFormViewController/BZGFormFieldCell.m

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
//
66

77
#import "BZGFormFieldCell.h"
8-
#import "EXTScope.h"
98
#import "ReactiveCocoa.h"
9+
#import "EXTScope.h"
1010

1111
@implementation BZGFormFieldCell
1212

@@ -18,6 +18,7 @@ - (id)init
1818
self.textLabel.hidden = YES;
1919
self.detailTextLabel.hidden = YES;
2020
self.imageView.hidden = YES;
21+
self.selectionStyle = UITableViewCellSelectionStyleNone;
2122

2223
CGFloat activityIndicatorWidth = self.bounds.size.height*0.7;
2324
CGRect activityIndicatorFrame = CGRectMake(self.bounds.size.width - activityIndicatorWidth,
@@ -78,7 +79,7 @@ - (id)init
7879
}];
7980

8081
RAC(self, accessoryType) =
81-
[RACAble(self.validationState) map:^NSNumber *(NSNumber *validationState) {
82+
[RACObserve(self, validationState) map:^NSNumber *(NSNumber *validationState) {
8283
@strongify(self);
8384
if (validationState.integerValue == BZGValidationStateValid
8485
&& !self.textField.editing) {
@@ -89,7 +90,7 @@ - (id)init
8990
}];
9091

9192
RAC(self.activityIndicatorView, hidden) =
92-
[RACAble(self.validationState) map:^NSNumber *(NSNumber *validationState) {
93+
[RACObserve(self, validationState) map:^NSNumber *(NSNumber *validationState) {
9394
@strongify(self);
9495
if (validationState.integerValue == BZGValidationStateValidating) {
9596
[self.activityIndicatorView startAnimating];

BZGFormViewController/BZGFormInfoCell.m

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ - (id)initWithText:(NSString *)text
1616
self.textLabel.hidden = YES;
1717
self.detailTextLabel.hidden = YES;
1818
self.imageView.hidden = YES;
19+
self.selectionStyle = UITableViewCellSelectionStyleNone;
1920
self.backgroundColor = [UIColor groupTableViewBackgroundColor];
2021

2122
self.infoLabel = [[UILabel alloc] initWithFrame:self.bounds];

BZGFormViewController/BZGFormViewController.h

+10-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@
1717
@property (nonatomic, assign) NSUInteger formSection;
1818

1919
/**
20-
* Updates the display state of the info cell corresponding to the given form cell.
20+
* Updates the display state of the info cell below a form field cell.
2121
*
22-
* @param cell The given form cell.
22+
* @param cell an instance of BZGFormFieldCell in a BZGFormViewController's formFieldCells
2323
*/
24-
- (void)updateInfoCellBelowFormFieldCell:(BZGFormFieldCell *)cell;
24+
- (void)updateInfoCellBelowFormFieldCell:(BZGFormFieldCell *)fieldCell;
2525

26+
/**
27+
* Returns the next form field cell. (Useful for implementing textFieldShouldReturn.)
28+
*
29+
* @param cell The starting form field cell.
30+
* @return The next form field cell or nil if no cell is found.
31+
*/
32+
- (BZGFormFieldCell *)nextFormFieldCell:(BZGFormFieldCell *)fieldCell;
2633

2734
@end

BZGFormViewController/BZGFormViewController.m

+40-20
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ - (id)initWithStyle:(UITableViewStyle)style
4545
- (void)setup
4646
{
4747
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
48-
[self.tableView setAllowsSelection:NO];
49-
self.formFieldCells = [NSMutableArray new];
50-
self.formSection = 0;
48+
[self.tableView setTableFooterView:[UIView new]];
49+
self.tableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
5150
}
5251

5352
#pragma mark - Showing/hiding info cells
@@ -56,24 +55,24 @@ - (BZGFormInfoCell *)infoCellBelowFormFieldCell:(BZGFormFieldCell *)fieldCell
5655
{
5756
NSUInteger cellIndex = [self.formFieldCells indexOfObject:fieldCell];
5857
if (cellIndex == NSNotFound) return nil;
59-
if (cellIndex+1 > self.formFieldCells.count - 1) return nil;
58+
if (cellIndex + 1 >= self.formFieldCells.count) return nil;
6059

61-
UITableViewCell *cellBelow = self.formFieldCells[cellIndex+1];
60+
UITableViewCell *cellBelow = self.formFieldCells[cellIndex + 1];
6261
if ([cellBelow isKindOfClass:[BZGFormInfoCell class]]) {
6362
return (BZGFormInfoCell *)cellBelow;
6463
}
6564

6665
return nil;
6766
}
6867

69-
- (void)showInfoCellBelowFormFieldCell:(BZGFormFieldCell *)cell
68+
- (void)showInfoCellBelowFormFieldCell:(BZGFormFieldCell *)fieldCell
7069
text:(NSString *)text
7170
{
72-
NSUInteger cellIndex = [self.formFieldCells indexOfObject:cell];
71+
NSUInteger cellIndex = [self.formFieldCells indexOfObject:fieldCell];
7372
if (cellIndex == NSNotFound) return;
7473

7574
// if an info cell is already showing, update the cell's text
76-
BZGFormInfoCell *infoCell = [self infoCellBelowFormFieldCell:cell];
75+
BZGFormInfoCell *infoCell = [self infoCellBelowFormFieldCell:fieldCell];
7776
if (infoCell) {
7877
infoCell.infoLabel.text = text;
7978
return;
@@ -88,13 +87,13 @@ - (void)showInfoCellBelowFormFieldCell:(BZGFormFieldCell *)cell
8887
withRowAnimation:UITableViewRowAnimationAutomatic];
8988
}
9089

91-
- (void)removeInfoCellBelowFormFieldCell:(BZGFormFieldCell *)cell
90+
- (void)removeInfoCellBelowFormFieldCell:(BZGFormFieldCell *)fieldCell
9291
{
93-
NSUInteger cellIndex = [self.formFieldCells indexOfObject:cell];
92+
NSUInteger cellIndex = [self.formFieldCells indexOfObject:fieldCell];
9493
if (cellIndex == NSNotFound) return;
9594

9695
// if no info cell is showing, do nothing
97-
BZGFormInfoCell *infoCell = [self infoCellBelowFormFieldCell:cell];
96+
BZGFormInfoCell *infoCell = [self infoCellBelowFormFieldCell:fieldCell];
9897
if (!infoCell) return;
9998

10099
// otherwise, remove it
@@ -104,40 +103,61 @@ - (void)removeInfoCellBelowFormFieldCell:(BZGFormFieldCell *)cell
104103
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
105104
}
106105

107-
- (void)updateInfoCellBelowFormFieldCell:(BZGFormFieldCell *)cell
106+
- (void)updateInfoCellBelowFormFieldCell:(BZGFormFieldCell *)fieldCell
108107
{
109-
if (cell.validationState == BZGValidationStateInvalid || cell.validationState == BZGValidationStateWarning) {
110-
if (!cell.textField.editing) {
111-
[self showInfoCellBelowFormFieldCell:cell text:cell.infoText];
108+
if (fieldCell.validationState == BZGValidationStateInvalid || fieldCell.validationState == BZGValidationStateWarning) {
109+
if (!fieldCell.textField.editing) {
110+
[self showInfoCellBelowFormFieldCell:fieldCell text:fieldCell.infoText];
112111
}
113112
} else {
114-
[self removeInfoCellBelowFormFieldCell:cell];
113+
[self removeInfoCellBelowFormFieldCell:fieldCell];
114+
}
115+
}
116+
117+
- (BZGFormFieldCell *)nextFormFieldCell:(BZGFormFieldCell *)fieldCell
118+
{
119+
NSUInteger cellIndex = [self.formFieldCells indexOfObject:fieldCell];
120+
if (cellIndex == NSNotFound) return nil;
121+
122+
NSUInteger i = cellIndex + 1;
123+
while (i < self.formFieldCells.count) {
124+
UITableViewCell *cell = self.formFieldCells[i];
125+
if ([cell isKindOfClass:[BZGFormFieldCell class]]) {
126+
return (BZGFormFieldCell *)cell;
127+
}
115128
}
129+
return nil;
116130
}
117131

118132
#pragma mark - Table view data source
119133

120134
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
121135
{
122136
if (section == self.formSection) {
123-
return self.formFieldCells.count;
137+
if (self.formFieldCells) {
138+
return self.formFieldCells.count;
139+
}
124140
}
125141
return 0;
126142
}
127143

128144
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
129145
{
130146
if (indexPath.section == self.formSection) {
131-
return [self.formFieldCells objectAtIndex:indexPath.row];
147+
if (self.formFieldCells) {
148+
return [self.formFieldCells objectAtIndex:indexPath.row];
149+
}
132150
}
133151
return nil;
134152
}
135153

136154
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
137155
{
138156
if (indexPath.section == self.formSection) {
139-
UITableViewCell *cell = [self.formFieldCells objectAtIndex:indexPath.row];
140-
return cell.frame.size.height;
157+
if (self.formFieldCells) {
158+
UITableViewCell *cell = [self.formFieldCells objectAtIndex:indexPath.row];
159+
return cell.frame.size.height;
160+
}
141161
}
142162
return 0;
143163
}

BZGFormViewControllerTests/BZGFormFieldCellTests.m

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ - (void)tearDown
2929

3030
- (void)testDefaults
3131
{
32+
expect(formFieldCell.selectionStyle).to.equal(UITableViewCellSelectionStyleNone);
3233
expect(formFieldCell.validationState).to.equal(BZGValidationStateNone);
3334
expect(formFieldCell.textField.textColor).to.equal([UIColor blackColor]);
3435
expect(formFieldCell.activityIndicatorView.hidden).to.beTruthy;

SignupForm/Podfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
platform :ios, '5.0'
2-
pod 'ReactiveCocoa', '~>1.9.6'
3-
pod 'FrameAccessor'
4-
pod 'BZGMailgunEmailValidation', '1.0.0'
2+
pod 'ReactiveCocoa', '~>2.1.1'
3+
pod 'libextobjc', '~>0.3'
4+
pod 'BZGMailgunEmailValidation', '~>1.0.0'
55

66
target :SignupFormTests do
77
pod 'Expecta', '~>0.2.2'

SignupForm/Podfile.lock

+88-17
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,115 @@
11
PODS:
22
- BZGMailgunEmailValidation (1.0.0)
33
- Expecta (0.2.2)
4-
- FrameAccessor (1.2.0)
5-
- JRSwizzle (1.0)
4+
- libextobjc (0.3):
5+
- libextobjc/EXTADT
6+
- libextobjc/EXTAnnotation
7+
- libextobjc/EXTAspect
8+
- libextobjc/EXTBlockMethod
9+
- libextobjc/EXTBlockTarget
10+
- libextobjc/EXTConcreteProtocol
11+
- libextobjc/EXTDispatchObject
12+
- libextobjc/EXTFinalMethod
13+
- libextobjc/EXTKeyPathCoding
14+
- libextobjc/EXTMaybe
15+
- libextobjc/EXTMixin
16+
- libextobjc/EXTMultimethod
17+
- libextobjc/EXTMultiObject
18+
- libextobjc/EXTNil
19+
- libextobjc/EXTPassthrough
20+
- libextobjc/EXTPrivateMethod
21+
- libextobjc/EXTProtocolCategory
22+
- libextobjc/EXTSafeCategory
23+
- libextobjc/EXTScope
24+
- libextobjc/EXTSelectorChecking
25+
- libextobjc/EXTSwizzle
26+
- libextobjc/EXTSynthesize
27+
- libextobjc/EXTTuple
28+
- libextobjc/EXTVarargs
29+
- libextobjc/NSInvocation+EXT
30+
- libextobjc/NSMethodSignature+EXT
31+
- libextobjc/RuntimeExtensions
32+
- libextobjc/UmbrellaHeader
33+
- libextobjc/EXTADT (0.3):
34+
- libextobjc/RuntimeExtensions
35+
- libextobjc/EXTAnnotation (0.3):
36+
- libextobjc/RuntimeExtensions
37+
- libextobjc/EXTAspect (0.3):
38+
- libextobjc/RuntimeExtensions
39+
- libffi
40+
- libextobjc/EXTBlockMethod (0.3):
41+
- libextobjc/RuntimeExtensions
42+
- libextobjc/EXTBlockTarget (0.3):
43+
- libextobjc/RuntimeExtensions
644
- libextobjc/EXTConcreteProtocol (0.3):
745
- libextobjc/RuntimeExtensions
46+
- libextobjc/EXTDispatchObject (0.3):
47+
- libextobjc/RuntimeExtensions
48+
- libextobjc/EXTFinalMethod (0.3):
49+
- libextobjc/RuntimeExtensions
850
- libextobjc/EXTKeyPathCoding (0.3):
951
- libextobjc/RuntimeExtensions
52+
- libextobjc/EXTMaybe (0.3):
53+
- libextobjc/RuntimeExtensions
54+
- libextobjc/EXTMixin (0.3):
55+
- libextobjc/RuntimeExtensions
56+
- libextobjc/EXTMultimethod (0.3):
57+
- libextobjc/RuntimeExtensions
58+
- libextobjc/EXTMultiObject (0.3):
59+
- libextobjc/RuntimeExtensions
60+
- libextobjc/EXTNil (0.3):
61+
- libextobjc/RuntimeExtensions
62+
- libextobjc/EXTPassthrough (0.3):
63+
- libextobjc/RuntimeExtensions
64+
- libextobjc/EXTPrivateMethod (0.3):
65+
- libextobjc/RuntimeExtensions
66+
- libextobjc/EXTProtocolCategory (0.3):
67+
- libextobjc/RuntimeExtensions
68+
- libextobjc/EXTSafeCategory (0.3):
69+
- libextobjc/RuntimeExtensions
1070
- libextobjc/EXTScope (0.3):
1171
- libextobjc/RuntimeExtensions
72+
- libextobjc/EXTSelectorChecking (0.3):
73+
- libextobjc/RuntimeExtensions
74+
- libextobjc/EXTSwizzle (0.3):
75+
- libextobjc/RuntimeExtensions
76+
- libextobjc/EXTSynthesize (0.3):
77+
- libextobjc/RuntimeExtensions
78+
- libextobjc/EXTTuple (0.3):
79+
- libextobjc/RuntimeExtensions
80+
- libextobjc/EXTVarargs (0.3):
81+
- libextobjc/RuntimeExtensions
82+
- libextobjc/NSInvocation+EXT (0.3):
83+
- libextobjc/RuntimeExtensions
84+
- libextobjc/NSMethodSignature+EXT (0.3):
85+
- libextobjc/RuntimeExtensions
1286
- libextobjc/RuntimeExtensions (0.3)
87+
- libextobjc/UmbrellaHeader (0.3)
88+
- libffi (3.0.13)
1389
- OCHamcrest (3.0.0)
1490
- OCMockito (1.0.0):
1591
- OCHamcrest (~> 3.0)
16-
- ReactiveCocoa (1.9.7):
17-
- ReactiveCocoa/Core
18-
- ReactiveCocoa/RACExtensions
19-
- ReactiveCocoa/Core (1.9.7):
20-
- JRSwizzle (~> 1.0)
21-
- libextobjc/EXTConcreteProtocol (~> 0.3.0)
22-
- libextobjc/EXTKeyPathCoding (~> 0.3.0)
23-
- libextobjc/EXTScope (~> 0.3.0)
24-
- ReactiveCocoa/RACExtensions (1.9.7):
92+
- ReactiveCocoa (2.1.1):
2593
- ReactiveCocoa/Core
94+
- ReactiveCocoa/no-arc
95+
- ReactiveCocoa/Core (2.1.1):
96+
- ReactiveCocoa/no-arc
97+
- ReactiveCocoa/no-arc (2.1.1)
2698

2799
DEPENDENCIES:
28-
- BZGMailgunEmailValidation (= 1.0.0)
100+
- BZGMailgunEmailValidation (~> 1.0.0)
29101
- Expecta (~> 0.2.2)
30-
- FrameAccessor
102+
- libextobjc (~> 0.3)
31103
- OCMockito (~> 1.0.0)
32-
- ReactiveCocoa (~> 1.9.6)
104+
- ReactiveCocoa (~> 2.1.1)
33105

34106
SPEC CHECKSUMS:
35107
BZGMailgunEmailValidation: 7dc589ad0c982fa9d1f087c14edcf8419f5a5a98
36108
Expecta: 99adbb2e366a02796477523bfd426143350d9caf
37-
FrameAccessor: 9cab222a118092deba0ae186d07fa51d4830d3e4
38-
JRSwizzle: 6242ff38485d870fc2636899048ee1ab883ae587
39109
libextobjc: 820a79dbbbc498611e04fffd07d2d52a5588e7ac
110+
libffi: 64ef39353e747bb2b25e1026afd96a157bf9231c
40111
OCHamcrest: 739added27df87b26adb60ab5aa14b7e3cf58afe
41112
OCMockito: 8b6a244d7d81ba3cd2095bc357c20ae7b22c8977
42-
ReactiveCocoa: 86033375e366207afad5a5067f2dd10a1f2d8f32
113+
ReactiveCocoa: 1419dd4d49ffa6088e0b0b41b784b5bd9e60d6ff
43114

44115
COCOAPODS: 0.25.0

SignupForm/Pods/BZGMailgunEmailValidation/BZGMailgunEmailValidator.h

-18
This file was deleted.

0 commit comments

Comments
 (0)