Skip to content

Commit

Permalink
Merge pull request #24 from Eldorado234/auto-layout
Browse files Browse the repository at this point in the history
Auto layout
  • Loading branch information
simonseyer committed Apr 29, 2015
2 parents 8f1d90c + af4d825 commit 5940a2f
Show file tree
Hide file tree
Showing 63 changed files with 3,440 additions and 3,161 deletions.
4 changes: 0 additions & 4 deletions Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
370BE0AB190AB82200954747 /* PAYValidationsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 370BE0AA190AB82200954747 /* PAYValidationsViewController.m */; };
370BE0AE190AB85A00954747 /* PAYCustomizationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 370BE0AD190AB85A00954747 /* PAYCustomizationViewController.m */; };
372EF9B218F460E8004D9D78 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 372EF9B118F460E8004D9D78 /* Images.xcassets */; };
373806011925043E00F20161 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 373806001925043E00F20161 /* SenTestingKit.framework */; };
3786EC39191D21E400EC1FBB /* PAYValidationsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3786EC38191D21E400EC1FBB /* PAYValidationsTest.m */; };
37906D3818F4349F00FC3CC8 /* Main_Iphone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 37906D3718F4349F00FC3CC8 /* Main_Iphone.storyboard */; };
3796520C18F426A00022151B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3796520B18F426A00022151B /* Foundation.framework */; };
Expand Down Expand Up @@ -56,7 +55,6 @@
370BE0AC190AB85A00954747 /* PAYCustomizationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PAYCustomizationViewController.h; sourceTree = "<group>"; };
370BE0AD190AB85A00954747 /* PAYCustomizationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PAYCustomizationViewController.m; sourceTree = "<group>"; };
372EF9B118F460E8004D9D78 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
373806001925043E00F20161 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
3786EC37191D21E400EC1FBB /* PAYValidationsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PAYValidationsTest.h; sourceTree = "<group>"; };
3786EC38191D21E400EC1FBB /* PAYValidationsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PAYValidationsTest.m; sourceTree = "<group>"; };
37906D3718F4349F00FC3CC8 /* Main_Iphone.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main_Iphone.storyboard; sourceTree = "<group>"; };
Expand Down Expand Up @@ -102,7 +100,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
373806011925043E00F20161 /* SenTestingKit.framework in Frameworks */,
3796522718F426A00022151B /* UIKit.framework in Frameworks */,
3796522618F426A00022151B /* Foundation.framework in Frameworks */,
D672E4652B0B25A59CCB88CE /* libPods-ExampleTests.a in Frameworks */,
Expand Down Expand Up @@ -162,7 +159,6 @@
isa = PBXGroup;
children = (
C3E0019A1AE4FB44009A5286 /* XCTest.framework */,
373806001925043E00F20161 /* SenTestingKit.framework */,
3796520B18F426A00022151B /* Foundation.framework */,
3796520D18F426A00022151B /* CoreGraphics.framework */,
3796520F18F426A00022151B /* UIKit.framework */,
Expand Down
8 changes: 5 additions & 3 deletions Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3796522218F426A00022151B"
BuildableName = "ExampleTests.octest"
BuildableName = "ExampleTests.xctest"
BlueprintName = "ExampleTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
Expand Down Expand Up @@ -63,7 +63,8 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3796520718F426A00022151B"
Expand All @@ -81,7 +82,8 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3796520718F426A00022151B"
Expand Down
10 changes: 5 additions & 5 deletions Example.xcodeproj/xcshareddata/xcschemes/ExampleTests.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3796522218F426A00022151B"
BuildableName = "ExampleTests.octest"
BuildableName = "ExampleTests.xctest"
BlueprintName = "ExampleTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
Expand All @@ -33,7 +33,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3796522218F426A00022151B"
BuildableName = "ExampleTests.octest"
BuildableName = "ExampleTests.xctest"
BlueprintName = "ExampleTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
Expand All @@ -43,7 +43,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3796522218F426A00022151B"
BuildableName = "ExampleTests.octest"
BuildableName = "ExampleTests.xctest"
BlueprintName = "ExampleTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
Expand All @@ -62,7 +62,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3796522218F426A00022151B"
BuildableName = "ExampleTests.octest"
BuildableName = "ExampleTests.xctest"
BlueprintName = "ExampleTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
Expand All @@ -80,7 +80,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3796522218F426A00022151B"
BuildableName = "ExampleTests.octest"
BuildableName = "ExampleTests.xctest"
BlueprintName = "ExampleTests"
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
Expand Down
53 changes: 28 additions & 25 deletions Example/PAYControlsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,47 @@ @implementation PAYControlsViewController


- (void)loadStructure:(PAYFormTableBuilder *)tableBuilder {

[tableBuilder addSectionWithName:@"Simple buttons"
contentBlock:^(PAYFormSectionBuilder * sectionBuilder) {
[sectionBuilder addButtonWithText:@"Button style centered"
style:PAYFormButtonStyleCentered
selectionBlock:nil];
[sectionBuilder addButtonWithText:@"Button style disabled centered"
style:PAYFormButtonStyleDisabledCentered
selectionBlock:nil];
[sectionBuilder addButtonWithText:@"Button style hilighted centered"
style:PAYFormButtonStyleHilightedCentered
selectionBlock:nil];
[sectionBuilder addButtonWithText:@"Button style primary centered"
style:PAYFormButtonStylePrimaryCentered
[sectionBuilder addButtonWithText:@"Default button"
style:PAYFormButtonStyleDefault
selectionBlock:nil];
[sectionBuilder addButtonWithText:nil
style:PAYFormButtonStyleEmpty
selectionBlock:nil];
[sectionBuilder addButtonWithText:@"Button style disclosure"
[sectionBuilder addButtonWithText:@"Disclosure button"
style:PAYFormButtonStyleDisclosure
selectionBlock:nil];
[sectionBuilder addButtonWithText:@"Button style disclosure"
[sectionBuilder addButtonWithText:@"Disclosure button"
detailText:@"with details"
style:PAYFormButtonStyleDisclosure
selectionBlock:nil];
[sectionBuilder addButtonWithText:@"Button style selection"
[sectionBuilder addButtonWithText:@"Selection button"
style:PAYFormButtonStyleSelection
selectionBlock:nil];
[sectionBuilder addButtonWithText:@"Button style icon disclosure"
style:PAYFormButtonStyleIconDisclosure
[sectionBuilder addButtonWithText:@"Disclosure button with icon"
icon:[UIImage imageNamed:@"de"]
style:PAYFormButtonStyleDisclosure
selectionBlock:nil];
[sectionBuilder addButtonWithText:@"Button icon selection"
style:PAYFormButtonStyleIconSelection
[sectionBuilder addButtonWithText:@"Selection button with icon"
icon:[UIImage imageNamed:@"usa"]
style:PAYFormButtonStyleSelection
selectionBlock:nil];
}];

[tableBuilder addSectionWithContentBlock:^(PAYFormSectionBuilder * sectionBuilder) {
[sectionBuilder addButtonWithText:@"Centered button"
style:PAYFormButtonStyleCentered
selectionBlock:nil];
}];
[tableBuilder addSectionWithContentBlock:^(PAYFormSectionBuilder * sectionBuilder) {
[sectionBuilder addButtonWithText:@"Primary button"
style:PAYFormButtonStylePrimary
selectionBlock:nil];
}];
[tableBuilder addSectionWithContentBlock:^(PAYFormSectionBuilder * sectionBuilder) {
[sectionBuilder addButtonWithText:@"Hilighted button"
style:PAYFormButtonStyleHilighted
selectionBlock:nil];
}];

NSArray *countries = @[@[@"United States", @"usa"], @[@"Germany", @"de"], @[@"Spain", @"es"]];

[tableBuilder addSectionWithName:@"Single selection button group"
Expand Down Expand Up @@ -88,9 +91,9 @@ - (void)loadStructure:(PAYFormTableBuilder *)tableBuilder {
}];

tableBuilder.formSuccessBlock = ^{
// NSLog(@"%@", self.countryButtonGroup.values);
// NSLog(@"%@", self.formSwitch.value ? @"YES" : @"NO");
// [self performSegueWithIdentifier:@"next" sender:self];
// NSLog(@"%@", self.countryButtonGroup.values);
// NSLog(@"%@", self.formSwitch.value ? @"YES" : @"NO");
// [self performSegueWithIdentifier:@"next" sender:self];
};
}

Expand Down
37 changes: 24 additions & 13 deletions Example/PAYCustomizationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,33 @@ - (void)loadStructure:(PAYFormTableBuilder *)tableBuilder {
style:PAYFormButtonStyleEmpty
selectionBlock:nil
configureBlock:^(PAYFormButton *formButton) {
CGRect frame = CGRectInset(formButton.view.frame, 40, 0);
UIView *formView = formButton.view;

UILabel *label1 = [[UILabel alloc]initWithFrame:frame];
UILabel *label1 = [UILabel new];
label1.text = @"Custom button";
label1.textColor = [UIColor colorFromHex:0xB8E62E];
[formButton.view addSubview:label1];
label1.translatesAutoresizingMaskIntoConstraints = NO;
[formView addSubview:label1];

UILabel *label2 = [[UILabel alloc]initWithFrame:frame];
UILabel *label2 = [UILabel new];
label2.text = @"empty style";
label2.textColor = [UIColor colorFromHex:0xFF6600];
label2.textAlignment = NSTextAlignmentRight;
[formButton.view addSubview:label2];
label2.translatesAutoresizingMaskIntoConstraints = NO;
[formView addSubview:label2];

[formView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|-[label1][label2]-|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(formView, label1, label2)]];
[formView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[label1]-|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(formView, label1)]];
[formView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[label2]-|"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(formView, label2)]];
}];
}];
[tableBuilder addSectionWithName:@"For all row types you could add in the section builder, there is at least one method which exepts a configureBlock. In this block different holder objects are passed, which contains the cell, elements of the row and often some usefull configuration options. All parameters of a row could be changed this way."
Expand All @@ -50,23 +65,19 @@ - (void)loadStructure:(PAYFormTableBuilder *)tableBuilder {
headerBlock:^(PAYFormHeader *formHeader) {
formHeader.label.textColor = [UIColor colorFromHex:0x0357AB];
} contentBlock:^(PAYFormSectionBuilder * sectionBuilder) {
[sectionBuilder addButtonWithText:@"Section header with blue text"
style:PAYFormButtonStyleDisabledCentered
[sectionBuilder addButtonWithText:@"Blue description style section label"
style:PAYFormButtonStyleDefault
selectionBlock:nil];
}];

[tableBuilder addSectionWithName:@"To change the default styles, use the theming API described in the README file."
labelStyle:PAYFormTableLabelStyleDescriptionWide
contentBlock:nil];

PAYTextLabel *tableHeaderLabel = [[PAYTextLabel alloc]initWithFrame:self.view.frame];
tableHeaderLabel.style = PAYFormTableLabelStyleDescriptionWide;
PAYTextLabel *tableHeaderLabel = [[PAYTextLabel alloc]initWithStyle:PAYFormTableLabelStyleDescriptionWide];
tableHeaderLabel.text = @"You could still use the table view header and footer view as normal. You could use the PAYTextLabel to easily apply a default style. You have to call sizeToFit manually after you set all parameters.";

UIView *headerView = [UIView new];
headerView.frame = CGRectMake(0, 0, self.view.frame.size.width, CGRectGetMaxY(tableHeaderLabel.frame));
[headerView addSubview:tableHeaderLabel];
self.tableView.tableHeaderView = headerView;
self.tableView.tableHeaderView = tableHeaderLabel;
}

@end
Loading

0 comments on commit 5940a2f

Please sign in to comment.