Skip to content

Commit

Permalink
Merge commit '62d12adddd5d5e6e846a2b50bf20d0f749886818'
Browse files Browse the repository at this point in the history
  • Loading branch information
fourplusone committed Nov 26, 2011
2 parents 4f7238f + 62d12ad commit 828da2c
Show file tree
Hide file tree
Showing 20 changed files with 232 additions and 60 deletions.
25 changes: 25 additions & 0 deletions QuickDialog.podspec
@@ -0,0 +1,25 @@
Pod::Spec.new do |s|
s.name = 'QuickDialog'
s.version = '0.1'
s.license = 'Apache License, Version 2.0'
s.summary = 'Quick and easy dialog screens for iOS'
s.homepage = 'http://escoz.com/quickdialog-released/'
s.author = { 'Eduardo Scoz' => 'eduardoscoz@gmail.com' }
s.source = { :git => 'git://github.com/escoz/QuickDialog.git', :tag => '0.1' }

s.description = 'QuickDialog allows you to create HIG-compliant iOS forms for your apps without ' \
'having to directly deal with UITableViews, delegates and data sources. Fast ' \
'and efficient, you can create forms with multiple text fields, or with ' \
'thousands of items with no sweat!'

s.source_files = 'quickdialog'
s.clean_paths = 'sample', '*.xc*', 'libQuickDialog', 'other'
s.requires_arc = true

def s.post_install(target)
prefix_header = config.project_pods_root + target.prefix_header_filename
prefix_header.open('a') do |file|
file.puts(%{#ifdef __OBJC__\n#import "QuickDialog.h"\n#endif})
end
end
end
12 changes: 8 additions & 4 deletions QuickDialog.xcodeproj/project.pbxproj
Expand Up @@ -98,11 +98,12 @@
D86035C413E0538600CB1785 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D86035C313E0538600CB1785 /* CoreLocation.framework */; };
D86035C613E0539A00CB1785 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D86035C513E0539A00CB1785 /* MapKit.framework */; };
D8A3DD87146045F000DE3528 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D8A3DD86146045F000DE3528 /* Localizable.strings */; };
D8A3DD9814604C9F00DE3528 /* form.json in Resources */ = {isa = PBXBuildFile; fileRef = D8F180E813F0599A009B0C9F /* form.json */; };
D8A3DD9814604C9F00DE3528 /* loginform.json in Resources */ = {isa = PBXBuildFile; fileRef = D8F180E813F0599A009B0C9F /* loginform.json */; };
D8F180E713F0599A009B0C96 /* quickdialog.png in Resources */ = {isa = PBXBuildFile; fileRef = D8F180E513F0599A009B0C96 /* quickdialog.png */; };
D8F180E813F0599A009B0C96 /* quickdialog@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D8F180E613F0599A009B0C96 /* quickdialog@2x.png */; };
D8F180E813F0599A009B0CA2 /* QRootElement+JSONBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = D8F180E813F0599A009B0CA1 /* QRootElement+JSONBuilder.m */; };
D8F180E813F0599A009B0CA4 /* QRootElement+JSONBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = D8F180E813F0599A009B0CA3 /* QRootElement+JSONBuilder.h */; settings = {ATTRIBUTES = (Public, ); }; };
D8F180E813F0599A009B0CA6 /* sample.json in Resources */ = {isa = PBXBuildFile; fileRef = D8F180E813F0599A009B0CA5 /* sample.json */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -219,9 +220,10 @@
D8F180E813F0599A009B0C9A /* QDecimalTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = QDecimalTableViewCell.m; path = quickdialog/QDecimalTableViewCell.m; sourceTree = SOURCE_ROOT; };
D8F180E813F0599A009B0C9C /* QDecimalTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = QDecimalTableViewCell.h; path = quickdialog/QDecimalTableViewCell.h; sourceTree = SOURCE_ROOT; };
D8F180E813F0599A009B0C9E /* QuickDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QuickDialog.h; path = quickdialog/QuickDialog.h; sourceTree = SOURCE_ROOT; };
D8F180E813F0599A009B0C9F /* form.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = form.json; sourceTree = "<group>"; };
D8F180E813F0599A009B0C9F /* loginform.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = loginform.json; sourceTree = "<group>"; };
D8F180E813F0599A009B0CA1 /* QRootElement+JSONBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "QRootElement+JSONBuilder.m"; path = "quickdialog/QRootElement+JSONBuilder.m"; sourceTree = SOURCE_ROOT; };
D8F180E813F0599A009B0CA3 /* QRootElement+JSONBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "QRootElement+JSONBuilder.h"; path = "quickdialog/QRootElement+JSONBuilder.h"; sourceTree = SOURCE_ROOT; };
D8F180E813F0599A009B0CA5 /* sample.json */ = {isa = PBXFileReference; lastKnownFileType = file.json; path = sample.json; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -336,7 +338,8 @@
D811F8EF13EC907200E3922B /* Resources */ = {
isa = PBXGroup;
children = (
D8F180E813F0599A009B0C9F /* form.json */,
D8F180E813F0599A009B0CA5 /* sample.json */,
D8F180E813F0599A009B0C9F /* loginform.json */,
D8F180E513F0599A009B0C96 /* quickdialog.png */,
D8F180E613F0599A009B0C96 /* quickdialog@2x.png */,
D811F8F013EC907200E3922B /* footer.png */,
Expand Down Expand Up @@ -545,7 +548,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D8A3DD9814604C9F00DE3528 /* form.json in Resources */,
D8A3DD9814604C9F00DE3528 /* loginform.json in Resources */,
D811F90413EC907200E3922B /* footer.png in Resources */,
D811F90513EC907200E3922B /* footer@2x.png in Resources */,
D811F90613EC907200E3922B /* imgOff.png in Resources */,
Expand All @@ -558,6 +561,7 @@
D8F180E713F0599A009B0C96 /* quickdialog.png in Resources */,
D8F180E813F0599A009B0C96 /* quickdialog@2x.png in Resources */,
D8A3DD87146045F000DE3528 /* Localizable.strings in Resources */,
D8F180E813F0599A009B0CA6 /* sample.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
1 change: 1 addition & 0 deletions quickdialog/QBadgeElement.m
Expand Up @@ -17,6 +17,7 @@
#import "QBadgeElement.h"

@implementation QBadgeElement

@synthesize badgeColor = _badgeColor;
@synthesize badge = _badge;

Expand Down
4 changes: 1 addition & 3 deletions quickdialog/QLabelElement.h
Expand Up @@ -15,9 +15,7 @@

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@class QElement;
@class QRootElement;
#import "QRootElement.h"

@interface QLabelElement : QRootElement {

Expand Down
8 changes: 8 additions & 0 deletions quickdialog/QMapElement.h
Expand Up @@ -24,5 +24,13 @@
CLLocationCoordinate2D _coordinate;
}

@property(nonatomic) CLLocationCoordinate2D coordinate;

- (QMapElement *)initWithTitle:(NSString *)string coordinate:(CLLocationCoordinate2D)param;

- (void)setLat:(double)lat;

- (void)setLng:(double)lng;


@end
16 changes: 15 additions & 1 deletion quickdialog/QMapElement.m
Expand Up @@ -17,14 +17,28 @@

@implementation QMapElement

@synthesize coordinate = _coordinate;

- (QMapElement *)init {
self = [self initWithTitle:@"" coordinate:CLLocationCoordinate2DMake(0, 0)];
return self;
}

- (QMapElement *)initWithTitle:(NSString *)title coordinate:(CLLocationCoordinate2D)coordinate {
self = [super init];
_title = title;
_coordinate = coordinate;

return self;
}

- (void)setLat:(double) lat {
_coordinate.latitude = lat;
}

- (void)setLng:(double) lng {
_coordinate.longitude = lng;
}

- (void)selected:(QuickDialogTableView *)tableView controller:(QuickDialogController *)controller indexPath:(NSIndexPath *)path {
QMapViewController *mapController = [[QMapViewController alloc] initWithTitle:_title coordinate:_coordinate];
[controller displayViewController:mapController];
Expand Down
3 changes: 1 addition & 2 deletions quickdialog/QRadioElement.h
Expand Up @@ -15,13 +15,12 @@
#import "QuickDialogTableView.h"

@interface QRadioElement : QRootElement {

NSArray *_items;
NSArray *_values;
NSInteger _selected;
}

@property(nonatomic, readonly) NSArray *items;
@property(nonatomic, retain) NSArray *items;
@property(nonatomic, assign, readwrite) NSInteger selected;
@property(nonatomic, retain) NSArray *values;

Expand Down
19 changes: 6 additions & 13 deletions quickdialog/QRadioElement.m
Expand Up @@ -12,15 +12,12 @@
// permissions and limitations under the License.
//

#import "QRootElement.h"
#import "QRadioElement.h"
#import "QRadioItemElement.h"

@implementation QRadioElement {

}
@synthesize selected = _selected;
@synthesize values = _values;
@synthesize items = _items;


- (void)createElements {
Expand All @@ -34,10 +31,6 @@ - (void)createElements {
}
}

- (NSArray *)items {
return _items;
}

- (QRadioElement *)initWithItems:(NSArray *)stringArray selected:(NSInteger)selected {
self = [self initWithItems:stringArray selected:selected title:nil];
return self;
Expand All @@ -46,8 +39,8 @@ - (QRadioElement *)initWithItems:(NSArray *)stringArray selected:(NSInteger)sele
- (QRadioElement *)initWithItems:(NSArray *)stringArray selected:(NSInteger)selected title:(NSString *)title {
self = [super init];
if (self!=nil){
_items = stringArray;
_selected = selected;
self.items = stringArray;
self.selected = selected;
[self createElements];
self.title = title;
}
Expand Down Expand Up @@ -82,12 +75,12 @@ - (void)fetchValueIntoObject:(id)obj {
return;

if (_values==nil){
[obj setObject:[NSNumber numberWithInt:_selected] forKey:_key];
[obj setValue:[NSNumber numberWithInt:_selected] forKey:_key];
} else {
[obj setObject:[_values objectAtIndex:(NSUInteger) _selected] forKey:_key];
[obj setValue:[_values objectAtIndex:(NSUInteger) _selected] forKey:_key];
}
}



@end
@end
91 changes: 81 additions & 10 deletions quickdialog/QRootElement+JSONBuilder.m
Expand Up @@ -2,31 +2,43 @@
// Created by escoz on 11/1/11.
//

#import <Foundation/Foundation.h>
#import <objc/runtime.h>
#import "QRootElement.h"

NSDictionary * QRootElementJSONBuilderConversionDict;

@interface QRootElement ()
- (void)initializeMappings;

@end

@implementation QRootElement (JSONBuilder)

- (void)updateObject:(id)section withPropertiesFrom:(NSDictionary *)dict {
- (void)updateObject:(id)obj withPropertiesFrom:(NSDictionary *)dict {
for (NSString *key in dict.allKeys){
if ([key isEqualToString:@"type"])
continue;

id value = [dict valueForKey:key];
if ([value isKindOfClass:[NSString class]] && [section respondsToSelector:NSSelectorFromString(key)]) {
[section setValue:value forKey:key];
if ([value isKindOfClass:[NSString class]] && [obj respondsToSelector:NSSelectorFromString(key)]) {
[obj setValue:value forKey:key];
if ([QRootElementJSONBuilderConversionDict objectForKey:key]!=nil) {
[obj setValue:[[QRootElementJSONBuilderConversionDict objectForKey:key] objectForKey:value] forKey:key];
}
} else if ([value isKindOfClass:[NSNumber class]]){
[obj setValue:value forKey:key];
}
}
}

- (QElement *)buildElementWithJson:(NSDictionary *)dict {
NSLog(@"element %@", dict);
QElement *element = [[NSClassFromString([dict valueForKey:@"type"]) alloc] init];
if (element==nil)
return nil;
[self updateObject:element withPropertiesFrom:dict];
return element;
}

- (void)buildSectionWithJson:(NSDictionary *)dict {
- (void)buildSectionWithJSON:(NSDictionary *)dict {
QSection *sect = [[QSection alloc] init];
[self updateObject:sect withPropertiesFrom:dict];
[self addSection:sect];
Expand All @@ -37,9 +49,8 @@ - (void)buildSectionWithJson:(NSDictionary *)dict {

- (void)buildRootWithJSON:(NSDictionary *)dict {
[self updateObject:self withPropertiesFrom:dict];
self.grouped = [[dict valueForKey:@"grouped"] boolValue];
for (id section in (NSArray *)[dict valueForKey:@"root"]){
[self buildSectionWithJson:section];
[self buildSectionWithJSON:section];
}
}

Expand All @@ -51,12 +62,72 @@ - (id)initWithJSONFile:(NSString *)jsonPath {
NSAssert(JSONSerialization != NULL, @"No JSON serializer available!");

if (self!=nil){
if (QRootElementJSONBuilderConversionDict==nil)
[self initializeMappings];

NSError *jsonParsingError = nil;
NSString *filePath = [[NSBundle mainBundle] pathForResource:jsonPath ofType:@"json"];
NSDictionary *jsonRoot = [JSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:filePath] options:0 error:&jsonParsingError];
[self buildRootWithJSON:jsonRoot];
}
return self;}
return self;
}


- (void)initializeMappings {
QRootElementJSONBuilderConversionDict = [[NSDictionary alloc] initWithObjectsAndKeys:

[[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:UITextAutocapitalizationTypeNone], @"None",
[NSNumber numberWithInt:UITextAutocapitalizationTypeWords], @"Words",
[NSNumber numberWithInt:UITextAutocapitalizationTypeSentences], @"Sentences",
[NSNumber numberWithInt:UITextAutocapitalizationTypeAllCharacters], @"AllCharacters",
nil], @"autocapitalizationType",

[[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:UITextAutocorrectionTypeDefault], @"Default",
[NSNumber numberWithInt:UITextAutocorrectionTypeNo], @"No",
[NSNumber numberWithInt:UITextAutocorrectionTypeYes], @"Yes",
nil], @"autocorrectionType",



[[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:UIKeyboardTypeDefault], @"Default",
[NSNumber numberWithInt:UIKeyboardTypeASCIICapable], @"ASCIICapable",
[NSNumber numberWithInt:UIKeyboardTypeNumbersAndPunctuation], @"NumbersAndPunctuation",
[NSNumber numberWithInt:UIKeyboardTypeURL], @"URL",
[NSNumber numberWithInt:UIKeyboardTypeNumberPad], @"NumberPad",
[NSNumber numberWithInt:UIKeyboardTypePhonePad], @"PhonePad",
[NSNumber numberWithInt:UIKeyboardTypeNamePhonePad], @"NamePhonePad",
[NSNumber numberWithInt:UIKeyboardTypeEmailAddress], @"EmailAddress",
[NSNumber numberWithInt:UIKeyboardTypeDecimalPad], @"DecimalPad",
[NSNumber numberWithInt:UIKeyboardTypeTwitter], @"Twitter",
[NSNumber numberWithInt:UIKeyboardTypeAlphabet], @"Alphabet",
nil], @"keyboardType",

[[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:UIKeyboardAppearanceDefault], @"Default",
[NSNumber numberWithInt:UIKeyboardAppearanceAlert], @"Alert",
nil], @"keyboardAppearance",


[[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:UIReturnKeyDefault], @"Default",
[NSNumber numberWithInt:UIReturnKeyGo], @"Go",
[NSNumber numberWithInt:UIReturnKeyGoogle], @"Google",
[NSNumber numberWithInt:UIReturnKeyJoin], @"Join",
[NSNumber numberWithInt:UIReturnKeyNext], @"Next",
[NSNumber numberWithInt:UIReturnKeyRoute], @"Route",
[NSNumber numberWithInt:UIReturnKeySearch], @"Search",
[NSNumber numberWithInt:UIReturnKeySend], @"Send",
[NSNumber numberWithInt:UIReturnKeyYahoo], @"Yahoo",
[NSNumber numberWithInt:UIReturnKeyDone], @"Done",
[NSNumber numberWithInt:UIReturnKeyEmergencyCall], @"EmergencyCall",
nil], @"returnKeyType",

nil];
}


@end
3 changes: 3 additions & 0 deletions quickdialog/QRootElement.h
Expand Up @@ -31,6 +31,9 @@

@property(nonatomic, retain) NSString *controllerName;


- (QRootElement *)init;

- (void)addSection:(QSection *)section;
- (QSection *)getSectionForIndex:(NSInteger)index;
- (NSInteger)numberOfSections;
Expand Down
7 changes: 4 additions & 3 deletions quickdialog/QRootElement.m
Expand Up @@ -12,16 +12,17 @@
// permissions and limitations under the License.
//

#import "QElement.h"
#import "QRootElement.h"

@implementation QRootElement

@synthesize title = _title;
@synthesize sections = _sections;
@synthesize grouped = _grouped;
@synthesize controllerName = _controllerName;

- (QRootElement *)init {
self = [super init];
return self;
}
- (void)addSection:(QSection *)section {
if (_sections==nil)
_sections = [[NSMutableArray alloc] init];
Expand Down
7 changes: 7 additions & 0 deletions quickdialog/QSection.h
Expand Up @@ -41,9 +41,16 @@
@property(nonatomic, readonly) BOOL needsEditing;

@property(nonatomic, retain) UIView *headerView;
@property(nonatomic, retain) NSString *headerImage;

@property(nonatomic, retain) UIView *footerView;
@property(nonatomic, retain) NSString *footerImage;

@property(nonatomic) CGRect entryPosition;




- (QSection *)initWithTitle:(NSString *)string;

- (void)addElement:(QElement *)element;
Expand Down

0 comments on commit 828da2c

Please sign in to comment.