Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 2 button cell to CustomRowsViewController #917

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "FloatLabeledTextFieldCell.h"
#import "XLFormCustomCell.h"
#import "XLFormInlineSegmentedCell.h"
#import "XLFormMultipleButtonsCell.h"

static NSString * const kCustomRowFirstRatingTag = @"CustomRowFirstRatingTag";
static NSString * const kCustomRowSecondRatingTag = @"CustomRowSecondRatingTag";
Expand Down Expand Up @@ -115,7 +116,28 @@ -(void)initializeForm
customRowDescriptor.cellClass = [XLFormCustomCell class];
[section addFormRow:customRowDescriptor];

// Section Multiple Buttons
section = [XLFormSectionDescriptor formSectionWithTitle:@"Multiple Buttons"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttons" rowType:XLFormRowDescriptorTypeMultipleButtons title:nil];
row.selectorOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Zero"],
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"One"],
];
[section addFormRow:row];

row = [XLFormRowDescriptor formRowDescriptorWithTag:@"buttons" rowType:XLFormRowDescriptorTypeMultipleButtons title:nil];
row.selectorOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Done"],
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Cancel"],
];
[section addFormRow:row];
self.form = form;
}

-(void)didSelectFormRow:(XLFormRowDescriptor *)formRow {
[super didSelectFormRow:formRow];
if ([formRow.value intValue] == 1) {
[self.navigationController popViewControllerAnimated:YES];
}
}

@end
17 changes: 17 additions & 0 deletions Examples/Objective-C/Multiple Buttons/XLFormMultipleButtonsCell.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// XLFormMultipleButtonsCell.h
// XLForm
//
// Created by Saqib Saud on 27/12/16.
// Copyright © 2016 WiseSabre. All rights reserved.
//

#import "XLForm.h"
#import "XLFormBaseCell.h"
#import <UIKit/UIKit.h>

extern NSString * const XLFormRowDescriptorTypeMultipleButtons;
extern NSString * const XLFormRowDescriptorTypeMultipleButtonsControl;

@interface XLFormMultipleButtonsCell : XLFormBaseCell
@end
87 changes: 87 additions & 0 deletions Examples/Objective-C/Multiple Buttons/XLFormMultipleButtonsCell.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//
// XLFormMultipleButtonsCell..
// XLForm
//
// Created by Saqib Saud on 27/12/16.
// Copyright © 2016 WiseSabre. All rights reserved.
//

#import "XLFormRowDescriptor.h"
#import "XLFormMultipleButtonsCell.h"
#import <QuartzCore/QuartzCore.h>

NSString * const XLFormRowDescriptorTypeMultipleButtons = @"XLFormRowDescriptorTypeMultipleButtons";
NSString * const XLFormRowDescriptorTypeMultipleButtonsControl = @"XLFormRowDescriptorTypeMultipleButtonsControl";

@interface XLFormMultipleButtonsCell ()
-(UIButton *)buttonWithTitle:(NSString *) title;
@property (weak, nonatomic) IBOutlet UIButton *buttonCancel;
@property (weak, nonatomic) IBOutlet UIButton *buttonOk;

@end

@implementation XLFormMultipleButtonsCell
{
UITextField * _constraintTextField;
}

+(void)load
{
[XLFormViewController.cellClassesForRowDescriptorTypes setObject:NSStringFromClass([XLFormMultipleButtonsCell class]) forKey:XLFormRowDescriptorTypeMultipleButtons];
[XLFormViewController.inlineRowDescriptorTypesForRowDescriptorTypes setObject:XLFormRowDescriptorTypeMultipleButtonsControl forKey:XLFormRowDescriptorTypeMultipleButtons];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an inline row?

}

#pragma mark - Properties

-(UIButton *)buttonWithTitle:(NSString *) title;
{
UIButton *button = [[UIButton alloc] init];
[button setTitle:title forState:UIControlStateNormal];
[button setTitle:title forState:UIControlStateDisabled];
[button setTranslatesAutoresizingMaskIntoConstraints:NO];

[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor grayColor] forState:UIControlStateDisabled];
// [button setContentHuggingPriority:500 forAxis:UILayoutConstraintAxisHorizontal];
button.backgroundColor = [UIColor grayColor];
button.layer.cornerRadius = 5;
return button;
}


#pragma mark - XLFormDescriptorCell

-(void)configure
{
[super configure];
self.buttonOk.layer.cornerRadius = 5;
self.buttonCancel.layer.cornerRadius = 5;


}

-(void)update
{
[super update];
if (self.rowDescriptor.selectorOptions.count == 2) { // We have only 2 buttons
[self.buttonCancel setTitle:[self.rowDescriptor.selectorOptions[0] displayText] forState:UIControlStateNormal];
[self.buttonCancel setTitle:[self.rowDescriptor.selectorOptions[0] displayText] forState:UIControlStateDisabled];
[self.buttonOk setTitle:[self.rowDescriptor.selectorOptions[1] displayText] forState:UIControlStateNormal];
[self.buttonOk setTitle:[self.rowDescriptor.selectorOptions[1] displayText] forState:UIControlStateDisabled];
}
self.selectionStyle = self.rowDescriptor.isDisabled ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
}


#pragma mark - Actions


-(IBAction)buttonPressed:(UIButton *)button
{
self.rowDescriptor.value = @(button.tag);
[self.formViewController didSelectFormRow:self.rowDescriptor];
}



@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="OGo-4x-YLf" customClass="XLFormMultipleButtonsCell">
<rect key="frame" x="0.0" y="0.0" width="478" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" tableViewCell="OGo-4x-YLf" id="hV6-xt-6pq">
<rect key="frame" x="0.0" y="0.0" width="478" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Lfa-iz-sZq">
<rect key="frame" x="8" y="6" width="228" height="30"/>
<color key="backgroundColor" red="0.86443984510000005" green="0.42204666140000002" blue="0.033364512030000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="buttonPressed:" destination="OGo-4x-YLf" eventType="touchUpInside" id="7iV-yk-qPj"/>
</connections>
</button>
<button opaque="NO" tag="1" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PL0-NR-Mqc">
<rect key="frame" x="242" y="7" width="228" height="30"/>
<color key="backgroundColor" red="0.59602659940000002" green="0.59611284730000003" blue="0.59599941970000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="buttonPressed:" destination="OGo-4x-YLf" eventType="touchUpInside" id="1fF-U4-B11"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="Lfa-iz-sZq" firstAttribute="width" secondItem="PL0-NR-Mqc" secondAttribute="width" id="2ql-Mj-WGu"/>
<constraint firstItem="PL0-NR-Mqc" firstAttribute="centerY" secondItem="hV6-xt-6pq" secondAttribute="centerY" id="3vY-wa-g6v"/>
<constraint firstAttribute="leadingMargin" secondItem="Lfa-iz-sZq" secondAttribute="leading" id="5xP-sB-mgf"/>
<constraint firstItem="PL0-NR-Mqc" firstAttribute="leading" secondItem="Lfa-iz-sZq" secondAttribute="trailing" constant="6" id="9fb-uN-tSr"/>
<constraint firstItem="Lfa-iz-sZq" firstAttribute="centerY" secondItem="hV6-xt-6pq" secondAttribute="centerY" id="faP-c7-6Pe"/>
<constraint firstAttribute="trailingMargin" secondItem="PL0-NR-Mqc" secondAttribute="trailing" id="imo-tP-SRZ"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="buttonCancel" destination="Lfa-iz-sZq" id="gXi-cB-5qb"/>
<outlet property="buttonOk" destination="PL0-NR-Mqc" id="VcO-11-Ycj"/>
</connections>
<point key="canvasLocation" x="301" y="260"/>
</tableViewCell>
</objects>
</document>
6 changes: 3 additions & 3 deletions Examples/Objective-C/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ PODS:
- XLData/RemoteDataStore (2.0.0):
- XLData/CoreRemote
- XLData/DataStore
- XLForm (3.1.2)
- XLForm (3.3.0)

DEPENDENCIES:
- AFNetworking (~> 2.0)
Expand Down Expand Up @@ -71,8 +71,8 @@ SPEC CHECKSUMS:
JVFloatLabeledTextField: 58a3a32cfb800e5b224f676987e7c13abf50a14d
SHSPhoneComponent: 4cec0653a150ad63cbc52b0c8b29ce2d3c9c26f0
XLData: df725c6179e2e0c80bf56a1ecad9afd169707a6d
XLForm: 6bb3c20857e2983cf494cb8b4d666c2a24673d5e
XLForm: d5c391dfc62865927b5bcab0a5a0dbfb3e02b0ec

PODFILE CHECKSUM: 80615792e859be64c95add3bb57c1596234faf95

COCOAPODS: 1.0.0
COCOAPODS: 1.0.1
36 changes: 27 additions & 9 deletions Examples/Objective-C/XLForm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
BF9DB1D61AE0436600B985E7 /* PredicateFormViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BF9DB1D41AE0436600B985E7 /* PredicateFormViewController.m */; };
BFA5F4B11BB48F8E00D045BD /* XLFormRatingCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3C3B01D41AB741EF0027CD45 /* XLFormRatingCell.xib */; };
BFE91AFB1AE159B200DE5231 /* BasicPredicateViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BFE91AFA1AE159B200DE5231 /* BasicPredicateViewController.m */; };
C1914A771E12D9550096F672 /* XLFormMultipleButtonsCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C1914A761E12D9550096F672 /* XLFormMultipleButtonsCell.m */; };
C196986A1E13A7D000EA014D /* XLFormMultipleButtonsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C19698691E13A7D000EA014D /* XLFormMultipleButtonsCell.xib */; };
D51B8B2C19126664008C0478 /* XLFormCustomCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D51B8B2B19126664008C0478 /* XLFormCustomCell.m */; };
DEA6EF911B57D6CC000F4893 /* HTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DEA6EF901B57D6CC000F4893 /* HTTPSessionManager.m */; };
DEB8235C1AD5529A00AF9FE2 /* FormattersViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DEB8235B1AD5529A00AF9FE2 /* FormattersViewController.m */; };
Expand Down Expand Up @@ -125,6 +127,9 @@
BF9DB1D41AE0436600B985E7 /* PredicateFormViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PredicateFormViewController.m; path = Examples/PredicateExamples/PredicateFormViewController.m; sourceTree = SOURCE_ROOT; };
BFE91AF91AE159B200DE5231 /* BasicPredicateViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BasicPredicateViewController.h; path = Examples/PredicateExamples/BasicPredicateViewController.h; sourceTree = SOURCE_ROOT; };
BFE91AFA1AE159B200DE5231 /* BasicPredicateViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BasicPredicateViewController.m; path = Examples/PredicateExamples/BasicPredicateViewController.m; sourceTree = SOURCE_ROOT; };
C1914A751E12D9550096F672 /* XLFormMultipleButtonsCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XLFormMultipleButtonsCell.h; sourceTree = "<group>"; };
C1914A761E12D9550096F672 /* XLFormMultipleButtonsCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XLFormMultipleButtonsCell.m; sourceTree = "<group>"; };
C19698691E13A7D000EA014D /* XLFormMultipleButtonsCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = XLFormMultipleButtonsCell.xib; sourceTree = "<group>"; };
D51B8B2A19126664008C0478 /* XLFormCustomCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLFormCustomCell.h; path = Examples/Others/CustomCells/XLFormCustomCell.h; sourceTree = "<group>"; };
D51B8B2B19126664008C0478 /* XLFormCustomCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLFormCustomCell.m; path = Examples/Others/CustomCells/XLFormCustomCell.m; sourceTree = "<group>"; };
DEA6EF8F1B57D6CC000F4893 /* HTTPSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPSessionManager.h; path = Examples/Selectors/HTTPSessionManager.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -414,6 +419,7 @@
3CDAFC741AB0AEE5000F75B6 /* CustomRows */ = {
isa = PBXGroup;
children = (
C1914A741E12D9550096F672 /* Multiple Buttons */,
BF01E9251C21F02D00BDE045 /* Inline Segmented */,
3C3B01D01AB741C40027CD45 /* Rating */,
3C3B01E31AB74AC10027CD45 /* FloatLabeledTextField */,
Expand Down Expand Up @@ -456,6 +462,16 @@
path = Examples/PredicateDisabling;
sourceTree = "<group>";
};
C1914A741E12D9550096F672 /* Multiple Buttons */ = {
isa = PBXGroup;
children = (
C19698691E13A7D000EA014D /* XLFormMultipleButtonsCell.xib */,
C1914A751E12D9550096F672 /* XLFormMultipleButtonsCell.h */,
C1914A761E12D9550096F672 /* XLFormMultipleButtonsCell.m */,
);
path = "Multiple Buttons";
sourceTree = "<group>";
};
DEA6EF8E1B57D698000F4893 /* SessionManager */ = {
isa = PBXGroup;
children = (
Expand All @@ -482,12 +498,12 @@
isa = PBXNativeTarget;
buildConfigurationList = 2850C62418D0F707002B7D0A /* Build configuration list for PBXNativeTarget "XLForm" */;
buildPhases = (
EBE0335CCC7588D83B89A92A /* 📦 Check Pods Manifest.lock */,
EBE0335CCC7588D83B89A92A /* [CP] Check Pods Manifest.lock */,
2850C5F418D0F706002B7D0A /* Sources */,
2850C5F518D0F706002B7D0A /* Frameworks */,
2850C5F618D0F706002B7D0A /* Resources */,
32EB30E0A90A4E91864B1D3C /* 📦 Embed Pods Frameworks */,
DE3D12F5596780A66C6C3D4A /* 📦 Copy Pods Resources */,
32EB30E0A90A4E91864B1D3C /* [CP] Embed Pods Frameworks */,
DE3D12F5596780A66C6C3D4A /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -530,6 +546,7 @@
buildActionMask = 2147483647;
files = (
28468EA718EF594900DBB015 /* Localizable.strings in Resources */,
C196986A1E13A7D000EA014D /* XLFormMultipleButtonsCell.xib in Resources */,
2850C60618D0F706002B7D0A /* InfoPlist.strings in Resources */,
BFA5F4B11BB48F8E00D045BD /* XLFormRatingCell.xib in Resources */,
28815E2E1A8589F600B674D2 /* MapViewController.xib in Resources */,
Expand All @@ -542,44 +559,44 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
32EB30E0A90A4E91864B1D3C /* 📦 Embed Pods Frameworks */ = {
32EB30E0A90A4E91864B1D3C /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Embed Pods Frameworks";
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-XLForm/Pods-XLForm-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
DE3D12F5596780A66C6C3D4A /* 📦 Copy Pods Resources */ = {
DE3D12F5596780A66C6C3D4A /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Copy Pods Resources";
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-XLForm/Pods-XLForm-resources.sh\"\n";
showEnvVarsInLog = 0;
};
EBE0335CCC7588D83B89A92A /* 📦 Check Pods Manifest.lock */ = {
EBE0335CCC7588D83B89A92A /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "📦 Check Pods Manifest.lock";
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -603,6 +620,7 @@
2850C60818D0F706002B7D0A /* main.m in Sources */,
D51B8B2C19126664008C0478 /* XLFormCustomCell.m in Sources */,
3C3B01F01AB74BDC0027CD45 /* FloatLabeledTextFieldCell.m in Sources */,
C1914A771E12D9550096F672 /* XLFormMultipleButtonsCell.m in Sources */,
28DBB04118D76FDC00FB8A8B /* MultivaluedFormViewController.m in Sources */,
28A85D5918E346C100E81A26 /* XLFormImageSelectorCell.m in Sources */,
28468E9818EC686500DBB015 /* NativeEventFormViewController.m in Sources */,
Expand Down
Loading