-
-
Notifications
You must be signed in to change notification settings - Fork 953
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
saqib-saud
wants to merge
2
commits into
xmartlabs:master
Choose a base branch
from
saqib-saud:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Examples/Objective-C/Multiple Buttons/XLFormMultipleButtonsCell.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
87
Examples/Objective-C/Multiple Buttons/XLFormMultipleButtonsCell.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
} | ||
|
||
#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 |
59 changes: 59 additions & 0 deletions
59
Examples/Objective-C/Multiple Buttons/XLFormMultipleButtonsCell.xib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?