Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e9de49db86 | |||
| 77db6b9492 | |||
| 74b26c1e64 | |||
| 085cf31e52 | |||
| 313e5d5d40 | |||
| f7777d9d27 | |||
| 578dea99dd |
@@ -57,6 +57,7 @@ NSString *const kCountDownTimer = @"countDownTimer";
|
||||
// Date
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kDateInline rowType:XLFormRowDescriptorTypeDateInline title:@"Date"];
|
||||
row.value = [NSDate new];
|
||||
[row.cellConfigAtConfigure setObject:[NSLocale localeWithLocaleIdentifier:@"FR_fr" ] forKey:@"locale"];
|
||||
[section addFormRow:row];
|
||||
|
||||
// Time
|
||||
|
||||
@@ -76,6 +76,7 @@ class DatesFormViewController: XLFormViewController {
|
||||
// Date
|
||||
row = XLFormRowDescriptor(tag: Tags.DateInline, rowType: XLFormRowDescriptorTypeDateInline, title:"Date")
|
||||
row.value = Date()
|
||||
row.cellConfigAtConfigure["locale"] = Locale(identifier: "FR_fr")
|
||||
section.addFormRow(row)
|
||||
|
||||
// Time
|
||||
|
||||
@@ -6,7 +6,7 @@ By [XMARTLABS](http://xmartlabs.com).
|
||||
[](https://travis-ci.org/xmartlabs/XLForm)
|
||||
<a href="https://cocoapods.org/pods/XLForm"><img src="https://img.shields.io/cocoapods/v/XLForm.svg" alt="CocoaPods compatible" /></a>
|
||||
|
||||
**If you are looking for Swift native implementation we have recently created [Eureka], a complete re-design of XLForm in Swift.** *Do not panic, We will continue maintaining and improving XLForm, obj-c rocks!!*
|
||||
**If you are working in Swift then you should have a look at [Eureka], a complete re-design of XLForm in Swift.** *Do not panic, we will continue maintaining and improving XLForm, obj-c rocks!!*
|
||||
|
||||
Purpose
|
||||
--------------
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
@implementation XLFormDateCell
|
||||
{
|
||||
UIColor * _beforeChangeColor;
|
||||
NSDateFormatter *_dateFormatter;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +110,7 @@
|
||||
{
|
||||
[super configure];
|
||||
self.formDatePickerMode = XLFormDateDatePickerModeGetFromRowDescriptor;
|
||||
_dateFormatter = [[NSDateFormatter alloc] init];
|
||||
}
|
||||
|
||||
-(void)update
|
||||
@@ -173,10 +175,14 @@
|
||||
}
|
||||
}
|
||||
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeDate] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeDateInline]){
|
||||
return [NSDateFormatter localizedStringFromDate:date dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle];
|
||||
_dateFormatter.dateStyle = NSDateFormatterMediumStyle;
|
||||
_dateFormatter.timeStyle = NSDateFormatterNoStyle;
|
||||
return [_dateFormatter stringFromDate:date];
|
||||
}
|
||||
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeTime] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeTimeInline]){
|
||||
return [NSDateFormatter localizedStringFromDate:date dateStyle:NSDateFormatterNoStyle timeStyle:NSDateFormatterShortStyle];
|
||||
_dateFormatter.dateStyle = NSDateFormatterNoStyle;
|
||||
_dateFormatter.timeStyle = NSDateFormatterShortStyle;
|
||||
return [_dateFormatter stringFromDate:date];
|
||||
}
|
||||
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeCountDownTimer] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeCountDownTimerInline]){
|
||||
NSCalendar *calendar = [NSCalendar currentCalendar];
|
||||
@@ -184,7 +190,9 @@
|
||||
NSDateComponents *time = [calendar components:NSCalendarUnitHour | NSCalendarUnitMinute fromDate:date];
|
||||
return [NSString stringWithFormat:@"%ld%@ %ldmin", (long)[time hour], (long)[time hour] == 1 ? @"hour" : @"hours", (long)[time minute]];
|
||||
}
|
||||
return [NSDateFormatter localizedStringFromDate:date dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle];
|
||||
_dateFormatter.dateStyle = NSDateFormatterShortStyle;
|
||||
_dateFormatter.timeStyle = NSDateFormatterShortStyle;
|
||||
return [_dateFormatter stringFromDate:date];
|
||||
}
|
||||
|
||||
-(void)setModeToDatePicker:(UIDatePicker *)datePicker
|
||||
@@ -228,6 +236,11 @@
|
||||
return _datePicker;
|
||||
}
|
||||
|
||||
-(void)setLocale:(NSLocale *)locale
|
||||
{
|
||||
_locale = locale;
|
||||
_dateFormatter.locale = locale;
|
||||
}
|
||||
|
||||
#pragma mark - Target Action
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
|
||||
@interface XLFormOptionsObject : NSObject <XLFormOptionObject,NSCoding>
|
||||
|
||||
@property (nonatomic) NSString * formDisplaytext;
|
||||
@property (nonatomic) id formValue;
|
||||
|
||||
+(XLFormOptionsObject *)formOptionsObjectWithValue:(id)value displayText:(NSString *)displayText;
|
||||
+(XLFormOptionsObject *)formOptionsOptionForValue:(id)value fromOptions:(NSArray *)options;
|
||||
+(XLFormOptionsObject *)formOptionsOptionForDisplayText:(NSString *)displayText fromOptions:(NSArray *)options;
|
||||
|
||||
@@ -26,10 +26,6 @@
|
||||
#import "XLFormOptionsObject.h"
|
||||
|
||||
@implementation XLFormOptionsObject
|
||||
{
|
||||
NSString * _formDisplaytext;
|
||||
id _formValue;
|
||||
}
|
||||
|
||||
+(XLFormOptionsObject *)formOptionsObjectWithValue:(id)value displayText:(NSString *)displayText
|
||||
{
|
||||
@@ -85,6 +81,7 @@
|
||||
{
|
||||
return _formValue;
|
||||
}
|
||||
|
||||
#pragma mark - NSCoding
|
||||
-(void)encodeWithCoder:(NSCoder *)encoder
|
||||
{
|
||||
@@ -94,6 +91,7 @@
|
||||
[encoder encodeObject:self.formDisplayText
|
||||
forKey:@"formDisplayText"];
|
||||
}
|
||||
|
||||
-(instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
if ((self=[super init])) {
|
||||
@@ -108,4 +106,5 @@
|
||||
return self;
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -52,6 +52,7 @@ typedef NS_ENUM(NSUInteger, XLFormRowNavigationDirection) {
|
||||
-(XLFormBaseCell *)updateFormRow:(XLFormRowDescriptor *)formRow;
|
||||
|
||||
-(NSDictionary *)formValues;
|
||||
-(NSDictionary *)formValuesIncludingHidden;
|
||||
-(NSDictionary *)httpParameters;
|
||||
|
||||
-(XLFormRowDescriptor *)formRowFormMultivaluedFormSection:(XLFormSectionDescriptor *)formSection;
|
||||
@@ -60,6 +61,7 @@ typedef NS_ENUM(NSUInteger, XLFormRowNavigationDirection) {
|
||||
|
||||
-(NSArray *)formValidationErrors;
|
||||
-(void)showFormValidationError:(NSError *)error;
|
||||
-(void)showFormValidationError:(NSError *)error withTitle:(NSString*)title;
|
||||
|
||||
-(UITableViewRowAnimation)insertRowAnimationForRow:(XLFormRowDescriptor *)formRow;
|
||||
-(UITableViewRowAnimation)deleteRowAnimationForRow:(XLFormRowDescriptor *)formRow;
|
||||
|
||||
@@ -346,6 +346,11 @@
|
||||
return [self.form formValues];
|
||||
}
|
||||
|
||||
-(NSDictionary *)formValuesIncludingHidden
|
||||
{
|
||||
return [self.form formValuesIncludingHidden];
|
||||
}
|
||||
|
||||
-(NSDictionary *)httpParameters
|
||||
{
|
||||
return [self.form httpParameters:self];
|
||||
@@ -492,6 +497,38 @@
|
||||
#endif
|
||||
}
|
||||
|
||||
-(void)showFormValidationError:(NSError *)error withTitle:(NSString*)title
|
||||
{
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 80000
|
||||
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(title, nil)
|
||||
message:error.localizedDescription
|
||||
delegate:self
|
||||
cancelButtonTitle:NSLocalizedString(@"OK", nil)
|
||||
otherButtonTitles:nil];
|
||||
[alertView show];
|
||||
#else
|
||||
if ([UIAlertController class]){
|
||||
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(title, nil)
|
||||
message:error.localizedDescription
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alertController addAction:[UIAlertAction actionWithTitle:@"OK"
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:nil]];
|
||||
[self presentViewController:alertController animated:YES completion:nil];
|
||||
}
|
||||
#ifndef XL_APP_EXTENSIONS
|
||||
else{
|
||||
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(title, nil)
|
||||
message:error.localizedDescription
|
||||
delegate:self
|
||||
cancelButtonTitle:NSLocalizedString(@"OK", nil)
|
||||
otherButtonTitles:nil];
|
||||
[alertView show];
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
-(void)performFormSelector:(SEL)selector withObject:(id)sender
|
||||
{
|
||||
UIResponder * responder = [self targetForAction:selector withSender:sender];;
|
||||
|
||||
@@ -82,6 +82,7 @@ typedef NS_OPTIONS(NSUInteger, XLFormRowNavigationOptions) {
|
||||
-(nullable NSIndexPath *)indexPathOfFormRow:(nonnull XLFormRowDescriptor *)formRow;
|
||||
|
||||
-(nonnull NSDictionary *)formValues;
|
||||
-(nonnull NSDictionary *)formValuesIncludingHidden;
|
||||
-(nonnull NSDictionary *)httpParameters:(nonnull XLFormViewController *)formViewController;
|
||||
|
||||
-(nonnull NSArray *)localValidationErrors:(nonnull XLFormViewController *)formViewController;
|
||||
|
||||
@@ -284,13 +284,25 @@ NSString * const XLValidationStatusErrorKey = @"XLValidationStatusErrorKey";
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(NSDictionary *)formValuesIncludingHidden
|
||||
{
|
||||
return [self formValuesWithHidden:YES];
|
||||
}
|
||||
|
||||
-(NSDictionary *)formValues
|
||||
{
|
||||
NSMutableDictionary * result = [NSMutableDictionary dictionary];
|
||||
for (XLFormSectionDescriptor * section in self.formSections) {
|
||||
return [self formValuesWithHidden:NO];
|
||||
}
|
||||
|
||||
-(NSDictionary *)formValuesWithHidden:(BOOL)includeHidden
|
||||
{
|
||||
NSArray* sections = includeHidden ? self.allSections : self.formSections;
|
||||
NSMutableDictionary* result = [NSMutableDictionary dictionary];
|
||||
for (XLFormSectionDescriptor * section in sections) {
|
||||
NSArray* rows = includeHidden ? section.allRows : section.formRows;
|
||||
if (section.multivaluedTag.length > 0){
|
||||
NSMutableArray * multiValuedValuesArray = [NSMutableArray new];
|
||||
for (XLFormRowDescriptor * row in section.formRows) {
|
||||
NSMutableArray* multiValuedValuesArray = [NSMutableArray new];
|
||||
for (XLFormRowDescriptor * row in rows) {
|
||||
if (row.value){
|
||||
[multiValuedValuesArray addObject:row.value];
|
||||
}
|
||||
@@ -298,7 +310,7 @@ NSString * const XLValidationStatusErrorKey = @"XLValidationStatusErrorKey";
|
||||
[result setObject:multiValuedValuesArray forKey:section.multivaluedTag];
|
||||
}
|
||||
else{
|
||||
for (XLFormRowDescriptor * row in section.formRows) {
|
||||
for (XLFormRowDescriptor * row in rows) {
|
||||
if (row.tag.length > 0){
|
||||
[result setObject:(row.value ?: [NSNull null]) forKey:row.tag];
|
||||
}
|
||||
|
||||
@@ -69,6 +69,6 @@ typedef NS_ENUM(NSUInteger, XLFormSectionInsertMode) {
|
||||
-(void)addFormRow:(nonnull XLFormRowDescriptor *)formRow beforeRow:(nonnull XLFormRowDescriptor *)beforeRow;
|
||||
-(void)removeFormRowAtIndex:(NSUInteger)index;
|
||||
-(void)removeFormRow:(nonnull XLFormRowDescriptor *)formRow;
|
||||
- (void)moveRowAtIndexPath:(NSIndexPath *)sourceIndex toIndexPath:(NSIndexPath *)destinationIndex;
|
||||
-(void)moveRowAtIndexPath:(nonnull NSIndexPath *)sourceIndex toIndexPath:(nonnull NSIndexPath *)destinationIndex;
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user