Skip to content
This repository has been archived by the owner on Mar 7, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' into 3.x.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	Form.podspec
  • Loading branch information
3lvis committed Apr 22, 2016
2 parents aaaab6d + 8b99bdd commit dcfeea6
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 25 deletions.
1 change: 1 addition & 0 deletions Basic-ObjC/Resources/forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"id":"display_name",
"title":"Display name",
"info":"This is the name that is going to be used across the application.",
"placeholder": "Display name",
"type":"text",
"size":{
"width":40,
Expand Down
5 changes: 5 additions & 0 deletions Basic-Swift/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
}
],
"info" : {
Expand Down
1 change: 1 addition & 0 deletions Basic-Swift/Resources/forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"id":"display_name",
"title":"Display name",
"info":"This is the name that is going to be used across the application.",
"placeholder": "Display name",
"type":"text",
"size":{
"width":40,
Expand Down
14 changes: 14 additions & 0 deletions Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = dwarf;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "Basic-ObjC/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -1927,6 +1928,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "Basic-ObjC/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -1943,6 +1945,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = dwarf;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "Basic-Swift/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -1960,6 +1963,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "Basic-Swift/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -1976,6 +1980,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = dwarf;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = CustomField/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -1993,6 +1998,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = CustomField/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -2010,6 +2016,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Payment/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -2029,6 +2036,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = Payment/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -2046,6 +2054,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = dwarf;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "iPhone-Storyboard/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -2062,6 +2071,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = "iPhone-Storyboard/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -2078,6 +2088,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = dwarf;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = ModalForm/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -2094,6 +2105,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = ModalForm/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand Down Expand Up @@ -2217,6 +2229,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = dwarf;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = LoginDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand All @@ -2233,6 +2246,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = LoginDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
Expand Down
2 changes: 1 addition & 1 deletion Form.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Form"
s.version = "3.9.0"
s.version = "3.10.0"
s.summary = "JSON driven form"
s.homepage = "https://github.com/hyperoslo/Form"
s.license = {
Expand Down
1 change: 1 addition & 0 deletions Source/Cells/Text/FORMTextFieldCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ - (void)updateWithField:(FORMField *)field {
self.textField.rawText = [self rawTextForField:field];
self.textField.info = field.info;
self.textField.styles = field.styles;
self.textField.placeholder = field.disabled ? nil : field.placeholder;
}

- (void)validate {
Expand Down
4 changes: 0 additions & 4 deletions Source/FORMData.m
Original file line number Diff line number Diff line change
Expand Up @@ -798,10 +798,6 @@ - (NSArray *)hideTargets:(NSArray *)targets {
}];
}

[resetSections enumerateObjectsUsingBlock:^(FORMSection *section, BOOL *stop) {
[section resetFieldPositions];
}];

for (FORMSection *section in deletedSections) {
FORMGroup *group = self.groups[[section.group.position integerValue]];

Expand Down
6 changes: 3 additions & 3 deletions Source/FORMDataSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ - (NSMutableArray *)collapsedGroups {
if (_collapsedGroups) return _collapsedGroups;

_collapsedGroups = [NSMutableArray new];

NSMutableArray *indexPaths = [NSMutableArray new];

[self.formData.groups enumerateObjectsUsingBlock:^(FORMGroup *formGroup, NSUInteger idx, BOOL *stop) {
if (formGroup.collapsed) {
if (![_collapsedGroups containsObject:@(idx)]) {
Expand Down Expand Up @@ -203,7 +203,7 @@ - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
if (kind == UICollectionElementKindSectionHeader) {
FORMGroup *group = self.formData.groups[indexPath.section];
FORMGroupHeaderView *headerView;

NSString *identifier = [NSString stringWithFormat:@"%@-%@", FORMHeaderReuseIdentifier, group.groupID];
[collectionView registerClass:[FORMGroupHeaderView class]
forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
Expand Down
2 changes: 1 addition & 1 deletion Source/FORMLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (instancetype)init {
return self;
}

#pragma mark - Overwrited Methods
#pragma mark - Overridden Methods

- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
CGRect bounds = self.collectionView.bounds;
Expand Down
1 change: 1 addition & 0 deletions Source/Models/FORMField.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ typedef NS_ENUM(NSInteger, FORMFieldType) {
@property (nonatomic) NSString *fieldID;
@property (nonatomic) NSString *title;
@property (nonatomic) NSString *info;
@property (nonatomic) NSString *placeholder;
@property (nonatomic) BOOL hidden;
@property (nonatomic) CGSize size;
@property (nonatomic) NSNumber *position;
Expand Down
5 changes: 3 additions & 2 deletions Source/Models/FORMField.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ - (instancetype)initWithDictionary:(NSDictionary *)dictionary
_type = [self typeFromTypeString:self.typeString];
_inputTypeString = [dictionary andy_valueForKey:@"input_type"];
_info = NSLocalizedString([dictionary andy_valueForKey:@"info"], nil);
_placeholder = NSLocalizedString([dictionary andy_valueForKey:@"placeholder"], nil);
NSNumber *width = [dictionary andy_valueForKey:@"size.width"] ?: @100;
NSNumber *height = [dictionary andy_valueForKey:@"size.height"]?: @1;
_size = CGSizeMake([width floatValue], [height floatValue]);
Expand Down Expand Up @@ -351,8 +352,8 @@ - (NSNumber *)sectionPosition {
}

- (NSString *)description {
return [NSString stringWithFormat:@"\n — Field: %@\n title: %@\n info: %@\n size: %@\n position: %@\n fieldValue: %@\n type: %@\n values: %@\n disabled: %@\n initiallyDisabled: %@\n minimumDate: %@\n maximumDate: %@\n validations: %@\n formula: %@\n valid: %@\n sectionSeparator: %@\n",
self.fieldID, self.title, self.info, NSStringFromCGSize(self.size), self.position,
return [NSString stringWithFormat:@"\n — Field: %@\n title: %@\n info: %@\n placeholder: %@\n size: %@\n position: %@\n fieldValue: %@\n type: %@\n values: %@\n disabled: %@\n initiallyDisabled: %@\n minimumDate: %@\n maximumDate: %@\n validations: %@\n formula: %@\n valid: %@\n sectionSeparator: %@\n",
self.fieldID, self.title, self.info, self.placeholder, NSStringFromCGSize(self.size), self.position,
self.value, self.typeString, self.values, (self.disabled) ? @"YES" : @"NO", (self.initiallyDisabled) ? @"YES" : @"NO", self.minimumDate,
self.maximumDate, self.validation, self.formula, (self.valid) ? @"YES" : @"NO", (self.sectionSeparator) ? @"YES" : @"NO"];
}
Expand Down
28 changes: 14 additions & 14 deletions Tests/FORMDataSourceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ - (void)testIndexInForms {
[dataSource processTargets:@[[FORMTarget showFieldTargetWithID:@"username"]]];
field = [dataSource fieldWithID:@"username" includingHiddenFields:YES];
index = [field indexInSectionUsingGroups:dataSource.groups];
XCTAssertEqual(index, 2);
XCTAssertEqual(index, 1);
[dataSource processTargets:[FORMTarget showFieldTargetsWithIDs:@[@"first_name",
@"address"]]];

Expand Down Expand Up @@ -790,7 +790,7 @@ - (void)testUpdatedFieldPositionWhenHidingAndShowingField {
[fieldPositions addObject:field.position];
}

NSArray *expectedUpdatedPositions = @[@0, @1, @2, @3, @4];
NSArray *expectedUpdatedPositions = @[@0, @1, @3, @4, @5];
XCTAssertEqualObjects(fieldPositions, expectedUpdatedPositions);

[dataSource processTargets:@[[FORMTarget showFieldTargetWithID:@"section-0-field-2"]]];
Expand Down Expand Up @@ -899,15 +899,15 @@ - (void)testDynamicFormulas {
- (void)testCollapseAllGroups{
NSArray *JSON = [NSJSONSerialization JSONObjectWithContentsOfFile:@"forms.json"
inBundle:[NSBundle bundleForClass:[self class]]];

FORMDataSource *dataSource = [[FORMDataSource alloc] initWithJSON:JSON
collectionView:nil
layout:nil
values:nil
disabled:YES];

[dataSource collapseAllGroupsForCollectionView:nil];

XCTAssertEqual([dataSource.collapsedGroups count], [dataSource.groups count]);
}

Expand All @@ -924,7 +924,7 @@ - (void)testStyleFields {
// Button Field Styles
FORMField *buttonField = [dataSource fieldWithID:@"styled_button" includingHiddenFields:NO];
XCTAssertNotNil(buttonField);

[dataSource fieldCell:nil updatedWithField:buttonField];
XCTAssertNotNil(buttonField.styles);
XCTAssertEqualObjects([buttonField.styles objectForKey:@"background_color"], @"#FF0000");
Expand All @@ -936,11 +936,11 @@ - (void)testStyleFields {
XCTAssertEqualObjects([buttonField.styles objectForKey:@"border_width"], @"1.0f");
XCTAssertEqualObjects([buttonField.styles objectForKey:@"font"], @"AvenirNext-DemiBold");
XCTAssertEqualObjects([buttonField.styles objectForKey:@"font_size"], @"16.0");

// Text Field Styles
FORMField *textField = [dataSource fieldWithID:@"styled_text_field" includingHiddenFields:NO];
XCTAssertNotNil(textField);

[dataSource fieldCell:nil updatedWithField:textField];
XCTAssertNotNil(textField.styles);
XCTAssertEqualObjects([textField.styles objectForKey:@"font"], @"AvenirNext-DemiBold");
Expand Down Expand Up @@ -969,8 +969,8 @@ - (void)testStyleFields {
XCTAssertEqualObjects([textField.styles objectForKey:@"clear_button_color"], @"#CCCCCC");
XCTAssertEqualObjects([textField.styles objectForKey:@"minus_button_color"], @"#FF0000");
XCTAssertEqualObjects([textField.styles objectForKey:@"plus_button_color"], @"#FF3333");


// Group Header Styles
NSArray *groups = [dataSource groups];
__block FORMGroup *group = nil;
Expand All @@ -979,9 +979,9 @@ - (void)testStyleFields {
group = formGroup;
}
}];

XCTAssertNotNil(group);

[dataSource fieldCell:nil updatedWithField:textField];
XCTAssertNotNil(group.styles);
XCTAssertEqualObjects([group.styles objectForKey:@"font"], @"AvenirNext-DemiBold");
Expand All @@ -1006,15 +1006,15 @@ - (void)testPreCollapsedGroups{
- (void)testCollapsibleGroups{
NSArray *JSON = [NSJSONSerialization JSONObjectWithContentsOfFile:@"collapsed-groups.json"
inBundle:[NSBundle bundleForClass:[self class]]];

FORMDataSource *dataSource = [[FORMDataSource alloc] initWithJSON:JSON
collectionView:nil
layout:nil
values:nil
disabled:YES];

XCTAssertEqual([dataSource.collapsedGroups count], 1);

[dataSource collapseAllGroups];
XCTAssertEqual([dataSource.collapsedGroups count], [dataSource.groups count] - 1);
}
Expand Down
4 changes: 4 additions & 0 deletions Tests/FORMFieldTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ - (void)testInitWithDictionary {
[NSTimeZone setDefaultTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
FORMField *field = [[FORMField alloc] initWithDictionary:@{@"id": @"first_name",
@"title": @"First name",
@"placeholder": @"placeholder",
@"info": @"info",
@"value": @"John Malkobitch",
@"type": @"name",
@"size": @{@"width": @30,
Expand All @@ -35,6 +37,8 @@ - (void)testInitWithDictionary {
XCTAssertEqualObjects(field.position, @0);
XCTAssertEqualObjects(field.fieldID, @"first_name");
XCTAssertEqualObjects(field.title, @"First name");
XCTAssertEqualObjects(field.placeholder, @"placeholder");
XCTAssertEqualObjects(field.info, @"info");
XCTAssertEqualObjects(field.value, @"John Malkobitch");
XCTAssertEqualObjects(field.typeString, @"name");
XCTAssertTrue(field.type == FORMFieldTypeText);
Expand Down

0 comments on commit dcfeea6

Please sign in to comment.