Skip to content

Commit

Permalink
Merge branch 'master' into section_title_view
Browse files Browse the repository at this point in the history
* master: (27 commits)
  Add property in XLFormTextViewCell to limit number of characters
  Add property in XLFormTextFieldCell to limit number of characters
  change XLFormUnspecifiedHeight constant to not collide with Automatic dimension
  datePicker.locale property public to developer,for example, _birthdayRow = [XLFormRowDescriptor formRowDescriptorWithTag:kBirthdayTag rowType:XLFormRowDescriptorTypeDateInline title:@"Birthday"]; [_birthdayRow.cellConfig setObject:[[NSLocale alloc] initWithLocaleIdentifier:@"en"] forKey:@"locale"];
  Refactored '-(id)init' to '- (instancetype)init'
  Update 'initializeForm' example.
  Update pod badge
  [fixes xmartlabs#452] respect the currentLocale when parsing decimal values
  Remove the fix for suppressing "Empty snapshot" warnings when presenting action sheets
  Updated code to actually use the optionTitle variable
  Fixed selector action sheet to use the row's value transformer
  update pod version
  added count to empty check. Helpful to validate multiple selectors being empty
  Fix decimal number formatting. closes xmartlabs#514
  Added height property to XLFormRowDescriptor
  updated readme with some comments. Fixes xmartlabs#771, fixes xmartlabs#727, fixes xmartlabs#696
  Add support for NSFormatter
  Do validation can be nullable. fixes xmartlabs#705
  fix crash when using cell style Value2. closes xmartlabs#770
  Fix when the textFieldPercentage is applied. Closes xmartlabs#776
  ...
  • Loading branch information
markrickert committed Sep 29, 2016
2 parents 47fac98 + bb81e88 commit 7338788
Show file tree
Hide file tree
Showing 39 changed files with 861 additions and 121 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.

### Latest:
* Added XL_APP_EXTENSIONS macro to allow app extensions (@MuscleRumble #357)
* Added shouldChangeTextInRange delegate call for UITextView. (@kiancheong #782)
* Added support for NSFormatter (@ziogaschr, @fwhenin, @bhirt-bpl #306)
* Added `height` property to XLFormRowDescriptor to allow setting height of individual cells.

### Version 3.1.2:
* Update row in `cellForRowAtIndexPath` instead of `willDisplayCell`
* Added cancel action to image selector (by koenpunt)
* Other minor fixes
Expand Down
7 changes: 7 additions & 0 deletions Examples/Objective-C/Examples/ExamplesFormViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#import "CustomRowsViewController.h"
#import "AccessoryViewFormViewController.h"
#import "PredicateFormViewController.h"
#import "FormattersViewController.h"

NSString * const kTextFieldAndTextView = @"TextFieldAndTextView";
NSString * const kSelectors = @"Selectors";
Expand All @@ -46,6 +47,7 @@
NSString * const kMultivaluedOnlyInsert = @"MultivaluedOnlyInsert";
NSString * const kMultivaluedOnlyDelete = @"MultivaluedOnlyDelete";
NSString * const kValidations= @"Validations";
NSString * const kFormatters = @"Formatters";

@interface ExamplesFormViewController ()

Expand Down Expand Up @@ -113,6 +115,11 @@ -(void)initializeForm
row.action.viewControllerClass = [DatesFormViewController class];
[section addFormRow:row];

// NSFormatters
row = [XLFormRowDescriptor formRowDescriptorWithTag:kFormatters rowType:XLFormRowDescriptorTypeButton title:@"NSFormatter Support"];
row.action.viewControllerClass = [FormattersViewController class];
[section addFormRow:row];

// Others
row = [XLFormRowDescriptor formRowDescriptorWithTag:kOthes rowType:XLFormRowDescriptorTypeButton title:@"Other Rows"];
row.action.formSegueIdentifier = @"OthersFormViewControllerSegue";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// FormattersViewController.h
// XLForm
//
// Created by Freddy Henin on 12/29/14.
// Copyright (c) 2014 Xmartlabs. All rights reserved.
//

#import "XLFormViewController.h"

@interface FormattersViewController : XLFormViewController

@end
115 changes: 115 additions & 0 deletions Examples/Objective-C/Examples/Formatters/FormattersViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//
// FormattersViewController.m
// XLForm
//
// Created by Freddy Henin on 12/29/14.
// Copyright (c) 2014 Xmartlabs. All rights reserved.
//

#import <Foundation/Foundation.h>


#import "XLForm.h"

#import "FormattersViewController.h"

#import <SHSPhoneComponent/SHSPhoneNumberFormatter+UserConfig.h>


// Simple little class to demonstraite currency formatting. Unfortunally we have to subclass
// NSNumberFormatter to work aroundn some long known rounding bugs with NSNumberFormatter
// http://stackoverflow.com/questions/12580162/nsstring-to-nsdate-conversion-issue
@interface CurrencyFormatter : NSNumberFormatter

@property (readonly) NSDecimalNumberHandler *roundingBehavior;

@end

@implementation CurrencyFormatter

- (id) init
{
self = [super init];
if (self) {
[self setNumberStyle: NSNumberFormatterCurrencyStyle];
[self setGeneratesDecimalNumbers:YES];

NSUInteger currencyScale = [self maximumFractionDigits];

_roundingBehavior = [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:NSRoundPlain scale:currencyScale raiseOnExactness:FALSE raiseOnOverflow:TRUE raiseOnUnderflow:TRUE raiseOnDivideByZero:TRUE];

}

return self;
}

//- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error
//{
// NSDecimalNumber *number;
// BOOL success = [super getObjectValue:&number forString:string errorDescription:error];
//
// if (success) {
// *anObject = [number decimalNumberByRoundingAccordingToBehavior:_roundingBehavior];
// }
// else {
// *anObject = nil;
// }
//
// return success;
//}

@end

@interface FormattersViewController ()
@end

@implementation FormattersViewController

-(id)init
{
XLFormDescriptor * formDescriptor = [XLFormDescriptor formDescriptorWithTitle:@"Text Fields"];
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;

formDescriptor.assignFirstResponderOnShow = NO;

section = [XLFormSectionDescriptor formSection];
section.title = @"NSFormatter Support";
section.footerTitle = @"Rows can be configured to use the formatter as you type or to toggle on and off during for display/editing. You will most likely need custom NSFormatter objects to do on the fly formatting since NSNumberFormatter is pretty limited in this regard.";
[formDescriptor addFormSection:section];

// Phone
SHSPhoneNumberFormatter *formatter = [[SHSPhoneNumberFormatter alloc] init];
[formatter setDefaultOutputPattern:@"(###) ###-####" imagePath:nil];
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"phone" rowType:XLFormRowDescriptorTypePhone title:@"US Phone"];
row.valueFormatter = formatter;
[row.cellConfigAtConfigure setObject:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];

row.useValueFormatterDuringInput = YES;
[section addFormRow:row];

// Currency
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"currency" rowType:XLFormRowDescriptorTypeDecimal title:@"USD"];
CurrencyFormatter *numberFormatter = [[CurrencyFormatter alloc] init];
row.valueFormatter = numberFormatter;
row.value = [NSDecimalNumber numberWithDouble:9.95];
[row.cellConfigAtConfigure setObject:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];
[section addFormRow:row];

// Accounting
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"percent" rowType:XLFormRowDescriptorTypeNumber title:@"Test Score"];
NSNumberFormatter *acctFormatter = [[NSNumberFormatter alloc] init];
[acctFormatter setNumberStyle:NSNumberFormatterPercentStyle];
row.valueFormatter = acctFormatter;
row.value = @(0.75);
[row.cellConfigAtConfigure setObject:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];
[section addFormRow:row];

section = [XLFormSectionDescriptor formSection];
[formDescriptor addFormSection:section];

return [super initWithForm:formDescriptor];

}

@end
2 changes: 1 addition & 1 deletion Examples/Objective-C/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ pod 'AFNetworking', '~> 2.0', :inhibit_warnings => true
pod 'XLData', :git => 'https://github.com/xmartlabs/XLData.git', :commit => '1f9019b56242a2019c7f7e11ec4ef823c397ebcf', :inhibit_warnings => true
pod 'JVFloatLabeledTextField', '1.0.2', :inhibit_warnings => true
pod 'AXRatingView', '1.0.3', :inhibit_warnings => true

pod 'SHSPhoneComponent'
end
78 changes: 78 additions & 0 deletions Examples/Objective-C/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
PODS:
- AFNetworking (2.6.3):
- AFNetworking/NSURLConnection (= 2.6.3)
- AFNetworking/NSURLSession (= 2.6.3)
- AFNetworking/Reachability (= 2.6.3)
- AFNetworking/Security (= 2.6.3)
- AFNetworking/Serialization (= 2.6.3)
- AFNetworking/UIKit (= 2.6.3)
- AFNetworking/NSURLConnection (2.6.3):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/NSURLSession (2.6.3):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/Reachability (2.6.3)
- AFNetworking/Security (2.6.3)
- AFNetworking/Serialization (2.6.3)
- AFNetworking/UIKit (2.6.3):
- AFNetworking/NSURLConnection
- AFNetworking/NSURLSession
- AXRatingView (1.0.3)
- JVFloatLabeledTextField (1.0.2)
- SHSPhoneComponent (2.15)
- XLData (2.0.0):
- XLData/Core (= 2.0.0)
- XLData/CoreData (= 2.0.0)
- XLData/CoreRemote (= 2.0.0)
- XLData/DataStore (= 2.0.0)
- XLData/RemoteCoreData (= 2.0.0)
- XLData/RemoteDataStore (= 2.0.0)
- XLData/Core (2.0.0)
- XLData/CoreData (2.0.0):
- XLData/Core
- XLData/CoreRemote (2.0.0):
- AFNetworking (~> 2.0)
- XLData/DataStore (2.0.0):
- XLData/Core
- XLData/RemoteCoreData (2.0.0):
- XLData/CoreData
- XLData/CoreRemote
- XLData/RemoteDataStore (2.0.0):
- XLData/CoreRemote
- XLData/DataStore
- XLForm (3.1.2)

DEPENDENCIES:
- AFNetworking (~> 2.0)
- AXRatingView (= 1.0.3)
- JVFloatLabeledTextField (= 1.0.2)
- SHSPhoneComponent
- XLData (from `https://github.com/xmartlabs/XLData.git`, commit `1f9019b56242a2019c7f7e11ec4ef823c397ebcf`)
- XLForm (from `../../`)

EXTERNAL SOURCES:
XLData:
:commit: 1f9019b56242a2019c7f7e11ec4ef823c397ebcf
:git: https://github.com/xmartlabs/XLData.git
XLForm:
:path: ../../

CHECKOUT OPTIONS:
XLData:
:commit: 1f9019b56242a2019c7f7e11ec4ef823c397ebcf
:git: https://github.com/xmartlabs/XLData.git

SPEC CHECKSUMS:
AFNetworking: cb8d14a848e831097108418f5d49217339d4eb60
AXRatingView: ccaadc1bbda99a4b7e1d556059482d2b933a9f4e
JVFloatLabeledTextField: 58a3a32cfb800e5b224f676987e7c13abf50a14d
SHSPhoneComponent: 4cec0653a150ad63cbc52b0c8b29ce2d3c9c26f0
XLData: df725c6179e2e0c80bf56a1ecad9afd169707a6d
XLForm: 6bb3c20857e2983cf494cb8b4d666c2a24673d5e

PODFILE CHECKSUM: 80615792e859be64c95add3bb57c1596234faf95

COCOAPODS: 1.0.0
Loading

0 comments on commit 7338788

Please sign in to comment.