Skip to content

Commit

Permalink
some API cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
atomkirk committed Aug 8, 2015
1 parent 609f63b commit 91eaef0
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 66 deletions.
2 changes: 0 additions & 2 deletions MYSForms/MYSForms/MYSFormButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,3 @@ - (void)layoutSubviews
}

@end


2 changes: 1 addition & 1 deletion MYSForms/MYSForms/MYSFormButtonCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ - (void)populateWithElement:(MYSFormButtonElement *)element

for (MYSFormButton *button in self.buttons) {
[button removeFromSuperview];
if ([[button actionsForTarget:self forControlEvent:UIControlEventTouchUpInside] count] == 0) {
if (![[button actionsForTarget:self forControlEvent:UIControlEventTouchUpInside] count] == 0) {
[button removeTarget:self action:@selector(buttonWasTapped:) forControlEvents:UIControlEventTouchUpInside];
}
}
Expand Down
2 changes: 1 addition & 1 deletion MYSForms/MYSForms/MYSFormCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@

- (UIView *)textInput;

- (void)didChangeValueAtValueKeyPath;
- (void)modelValueDidChange;

@end
2 changes: 1 addition & 1 deletion MYSForms/MYSForms/MYSFormCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ - (UIView *)textInput
return nil;
}

- (void)didChangeValueAtValueKeyPath
- (void)modelValueDidChange
{

}
Expand Down
2 changes: 1 addition & 1 deletion MYSForms/MYSForms/MYSFormDatePickerCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ - (NSString *)valueKeyPath
return @"selectedDate";
}

- (void)didChangeValueAtValueKeyPath
- (void)modelValueDidChange
{
if (!self.dateFormatter) {
self.dateFormatter = [NSDateFormatter new];
Expand Down
5 changes: 0 additions & 5 deletions MYSForms/MYSForms/MYSFormDatePickerElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ - (BOOL)isEditable
return YES;
}

- (void)beginEditing
{
[self.delegate formElementDidRequestResignationOfFirstResponder:self];
}


#pragma mark - Actions

Expand Down
9 changes: 0 additions & 9 deletions MYSForms/MYSForms/MYSFormElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@
*/
- (void)configureCellBlock:(void (^)(id))block;

/**
Returns YES if this is the type of form element that accepts text input.
*/
- (BOOL)isTextInput;

/**
Returns YES if the element has a value that can be edited.
*/
Expand Down Expand Up @@ -153,8 +148,6 @@

- (void)formElement:(MYSFormElement *)formElement valueDidChange:(id)value;

- (void)formElementNeedsLayout:(MYSFormElement *)formElement;

- (void)formElement:(MYSFormElement *)formElement didRequestPresentationOfActionSheet:(UIActionSheet *)actionSheet;

- (void)formElement:(MYSFormElement *)formElement didRequestPresentationOfViewController:(UIViewController *)viewController
Expand All @@ -165,8 +158,6 @@

- (void)formElement:(MYSFormElement *)formElement didRequestDismissalOfChildView:(UIView *)childView;

- (void)formElementDidRequestResignationOfFirstResponder:(MYSFormElement *)formElement;

- (void)formElement:(MYSFormElement *)formElement didRequestPushOfViewController:(UIViewController *)viewController;

- (MYSFormTheme *)formElementFormTheme;
Expand Down
7 changes: 1 addition & 6 deletions MYSForms/MYSForms/MYSFormElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ - (void)updateCell
if ([self isModelKeyPathValid]) {
id modelValue = [self transformedModelValue];
[self.cell setValue:modelValue forKeyPath:[self.cell valueKeyPath]];
[self.cell didChangeValueAtValueKeyPath];
[self.cell modelValueDidChange];
}
}

Expand All @@ -102,11 +102,6 @@ - (void)configureCellBlock:(void (^)(id))block
self.cellConfigurationBlock = block;
}

- (BOOL)isTextInput
{
return NO;
}

- (BOOL)isEditable
{
return NO;
Expand Down
2 changes: 1 addition & 1 deletion MYSForms/MYSForms/MYSFormImagePickerCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ + (CGSize)sizeRequiredForElement:(MYSFormImagePickerElement *)element width:(CGF
return CGSizeMake(width, insets.top + 100 + insets.bottom);
}

- (void)didChangeValueAtValueKeyPath
- (void)modelValueDidChange
{
if (!self.imageView.image) {
self.imageView.image = self.placeholderImage;
Expand Down
2 changes: 1 addition & 1 deletion MYSForms/MYSForms/MYSFormPickerCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ - (NSString *)valueKeyPath
return @"selectedValue";
}

- (void)didChangeValueAtValueKeyPath
- (void)modelValueDidChange
{
[self.button setTitle:self.selectedValue forState:UIControlStateNormal];
}
Expand Down
5 changes: 0 additions & 5 deletions MYSForms/MYSForms/MYSFormPickerElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ - (BOOL)isEditable
return YES;
}

- (void)beginEditing
{
[self.delegate formElementDidRequestResignationOfFirstResponder:self];
}

- (void)setValues:(NSArray *)values
{
self.data = [values mutableCopy];
Expand Down
2 changes: 1 addition & 1 deletion MYSForms/MYSForms/MYSFormTextFieldCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ - (UIView *)textInput
return self.textField;
}

- (void)didChangeValueAtValueKeyPath
- (void)modelValueDidChange
{
if (self.window) {
[self layoutLabelAndTextFieldWithText:self.textField.text];
Expand Down
7 changes: 0 additions & 7 deletions MYSForms/MYSForms/MYSFormTextViewElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,12 @@ - (void)beginEditing
}




#pragma mark - DELEGATE text view cell

- (void)textViewFormCell:(MYSFormTextViewCell *)cell textDidChange:(NSString *)text
{
[self.delegate formElement:self valueDidChange:text];
}

- (NSString *)textViewFormCellCurrentModelValue:(MYSFormTextViewCell *)cell
{
return [self.dataSource modelValueForFormElement:self];
}

@end

5 changes: 0 additions & 5 deletions MYSForms/MYSForms/MYSFormToggleElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ - (BOOL)isEditable
return YES;
}

- (void)beginEditing
{
[self.delegate formElementDidRequestResignationOfFirstResponder:self];
}


#pragma mark - DELEGATE toggle cell

Expand Down
36 changes: 16 additions & 20 deletions MYSForms/MYSForms/MYSFormViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,6 @@ - (void)configureForm
// overriden by subclasses
}

- (void)registerElementCellsForReuse
{
for (MYSFormElement *element in self.elements) {
[self registerCellForClass:[element cellClass]];
}

// register metadata cells
[self registerCellForClass:[MYSFormMessageChildCell class]];
[self registerCellForClass:[MYSFormLoadingChildCell class]];

// register view child cell
[self.collectionView registerClass:[MYSFormViewChildCell class] forCellWithReuseIdentifier:NSStringFromClass([MYSFormViewChildCell class])];
}

- (void)addFormElement:(MYSFormElement *)element
{
[self addFormElement:element atIndex:[self.elements count]];
Expand Down Expand Up @@ -273,7 +259,7 @@ - (void)showView:(UIView *)view

- (void)hideViewRelativeToElement:(MYSFormElement *)element completion:(void (^)(void))completion
{
[self hideChildrenOfElements:@[element] type:MYSFormChildElementTypeView completion:nil];
[self hideChildrenOfElements:@[element] type:MYSFormChildElementTypeView completion:completion];
}


Expand Down Expand Up @@ -425,11 +411,6 @@ - (void)formElement:(MYSFormElement *)formElement didRequestDismissalOfChildView
[self hideChildrenOfElements:@[formElement] type:MYSFormChildElementTypeView completion:nil];
}

- (void)formElementDidRequestResignationOfFirstResponder:(MYSFormElement *)formElement
{
[self attemptToDismissKeyboard];
}

- (void)formElement:(MYSFormElement *)formElement didRequestPushOfViewController:(UIViewController *)viewController
{
[self.navigationController pushViewController:viewController animated:YES];
Expand Down Expand Up @@ -645,6 +626,7 @@ - (void)setupKeyboardNotifications
if (element) {
MYSFormElement *nextElement = [self elementAfter:element];
if (nextElement) {
[self attemptToDismissKeyboard];
[nextElement beginEditing];
}
else {
Expand Down Expand Up @@ -727,6 +709,20 @@ - (void)registerCellForClass:(Class)cellClass
[self.collectionView registerNib:nib forCellWithReuseIdentifier:NSStringFromClass(cellClass)];
}

- (void)registerElementCellsForReuse
{
for (MYSFormElement *element in self.elements) {
[self registerCellForClass:[element cellClass]];
}

// register metadata cells
[self registerCellForClass:[MYSFormMessageChildCell class]];
[self registerCellForClass:[MYSFormLoadingChildCell class]];

// register view child cell
[self.collectionView registerClass:[MYSFormViewChildCell class] forCellWithReuseIdentifier:NSStringFromClass([MYSFormViewChildCell class])];
}

#pragma mark (helpers)

- (NSIndexPath *)indexPathOfElement:(MYSFormElement *)element
Expand Down

0 comments on commit 91eaef0

Please sign in to comment.