Skip to content

Commit

Permalink
Lots of small bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
escoz committed Sep 13, 2011
1 parent 876e3d3 commit 98dbeed
Show file tree
Hide file tree
Showing 24 changed files with 154 additions and 57 deletions.
2 changes: 1 addition & 1 deletion quickdialog/QBadgeElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
NSString *_badge;
}

@property(nonatomic, strong) UIColor *badgeColor;
@property(nonatomic, retain) UIColor *badgeColor;
@property(nonatomic, strong) NSString *badge;


Expand Down
2 changes: 1 addition & 1 deletion quickdialog/QBadgeTableCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
- (QBadgeTableCell *)init;


@property(nonatomic, strong) UIColor *badgeColor;
@property(nonatomic, retain) UIColor *badgeColor;
@property(nonatomic, readonly, strong) UILabel *badgeLabel;

@end
4 changes: 2 additions & 2 deletions quickdialog/QBooleanElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
UIImage *_offImage;
}

@property(nonatomic, strong) UIImage *onImage;
@property(nonatomic, strong) UIImage *offImage;
@property(nonatomic, retain) UIImage *onImage;
@property(nonatomic, retain) UIImage *offImage;
@property (nonatomic) BOOL boolValue;
@property(nonatomic) BOOL enabled;

Expand Down
4 changes: 1 addition & 3 deletions quickdialog/QButtonElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ - (QButtonElement *)initWithTitle:(NSString *)title {
- (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView controller:(QuickDialogController *)controller {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QuickformButtonElement"];
if (cell == nil){
cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TODO"];
cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"QuickformButtonElement"];
}
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
cell.textLabel.text = _title;
Expand All @@ -35,8 +35,6 @@ - (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView contr

- (void)selected:(QuickDialogTableView *)tableView controller:(QuickDialogController *)controller indexPath:(NSIndexPath *)indexPath {
[super selected:tableView controller:controller indexPath:indexPath];


[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

Expand Down
2 changes: 1 addition & 1 deletion quickdialog/QDateEntryTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
}
@property(nonatomic, strong) UIDatePicker *pickerView;

@property(nonatomic, strong) UILabel *centeredLabel;
@property(nonatomic, retain) UILabel *centeredLabel;

@end
4 changes: 3 additions & 1 deletion quickdialog/QDateTimeElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
UIDatePickerMode _mode;
}

@property(nonatomic, strong) NSDate *dateValue;
@property(nonatomic, retain) NSDate *dateValue;

@property (assign) UIDatePickerMode mode;

- (QDateTimeElement *)init;

- (QDateTimeElement *)initWithTitle:(NSString *)string date:(NSDate *)date;

@end
25 changes: 16 additions & 9 deletions quickdialog/QDateTimeElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,20 @@ - (UIDatePickerMode)mode {
return _mode;
}

- (QDateTimeElement *)initWithTitle:(NSString *)title date:(NSDate *)date {
- (QDateTimeElement *)init {
self = [super init];
_grouped = YES;
_mode = UIDatePickerModeDateAndTime;
[self initializeRoot];
return self;
}

- (QDateTimeElement *)initWithTitle:(NSString *)title date:(NSDate *)date {
self = [self init];
if (self!=nil){
_title = title;
_dateValue = date;
_grouped = YES;
_mode = UIDatePickerModeDateAndTime;

[self initializeRoot];
[self initializeRoot];
}
return self;
}
Expand Down Expand Up @@ -83,17 +88,20 @@ - (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView contr

cell.detailTextLabel.text = [dateFormatter stringFromDate:_dateValue];


return cell;
}


- (void)initializeRoot {
NSDate *dateForSection = _dateValue;
if (dateForSection==nil){
dateForSection = NSDate.date;
}
QSection *section = [[QSection alloc] initWithTitle:(_mode == UIDatePickerModeDateAndTime ? @"\n" : @"\n\n")];

if (_mode == UIDatePickerModeDate || _mode == UIDatePickerModeDateAndTime){
QDateTimeInlineElement *dateElement = (QDateTimeInlineElement *) [[QDateTimeInlineElement alloc] initWithKey:@"date"];
dateElement.dateValue = _dateValue;
dateElement.dateValue = dateForSection;
dateElement.centerLabel = YES;
dateElement.mode = UIDatePickerModeDate;
dateElement.hiddenToolbar = YES;
Expand All @@ -102,7 +110,7 @@ - (void)initializeRoot {
}
if (_mode == UIDatePickerModeTime || _mode == UIDatePickerModeDateAndTime){
QDateTimeInlineElement *timeElement = (QDateTimeInlineElement *) [[QDateTimeInlineElement alloc] initWithKey:@"time"];
timeElement.dateValue = _dateValue;
timeElement.dateValue = dateForSection;
timeElement.centerLabel = YES;
timeElement.mode = UIDatePickerModeTime;
timeElement.hiddenToolbar = YES;
Expand Down Expand Up @@ -154,7 +162,6 @@ - (void)selected:(QuickDialogTableView *)tableView controller:(QuickDialogContro
[components setHour:[timeComponents hour]];
[components setMinute:[timeComponents minute]];
[components setSecond:[timeComponents second]];

self.dateValue = [[NSCalendar currentCalendar] dateFromComponents:components];
};

Expand Down
2 changes: 1 addition & 1 deletion quickdialog/QDateTimeInlineElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
BOOL _centerLabel;
}

@property(nonatomic, strong) NSDate *dateValue;
@property(nonatomic, retain) NSDate *dateValue;

@property (assign) UIDatePickerMode mode;

Expand Down
9 changes: 6 additions & 3 deletions quickdialog/QElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
}

@property(nonatomic, copy) void (^onSelected)(void);
@property(nonatomic, strong) NSString *controllerAction;
@property(nonatomic, strong) QSection *parentSection;
@property(nonatomic, strong) NSString *key;
@property(nonatomic, retain) NSString *controllerAction;


@property(nonatomic, retain) QSection *parentSection;

@property(nonatomic, retain) NSString *key;

- (QElement *)initWithKey:(NSString *)key;

Expand Down
23 changes: 23 additions & 0 deletions quickdialog/QEmptyListElement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//
// Copyright 2011 ESCOZ Inc - http://escoz.com
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
// ANY KIND, either express or implied. See the License for the specific language governing
// permissions and limitations under the License.
//

#import "QLabelElement.h"

@interface QEmptyListElement : QLabelElement {

}

- (QEmptyListElement *)init;

@end
41 changes: 41 additions & 0 deletions quickdialog/QEmptyListElement.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// Copyright 2011 ESCOZ Inc - http://escoz.com
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
// file except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under
// the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
// ANY KIND, either express or implied. See the License for the specific language governing
// permissions and limitations under the License.
//

#import "QEmptyListElement.h"

@implementation QEmptyListElement

- (QEmptyListElement *)init {
self = [super initWithTitle:@"Empty" Value:nil];
return self;
}

- (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView controller:(QuickDialogController *)controller {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QEmptyListElement"];
if (cell == nil){
cell= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"QEmptyListElement"];
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.text = _title;
cell.textLabel.textAlignment = UITextAlignmentCenter;
cell.textLabel.textColor = [UIColor colorWithWhite:0.7f alpha:1.0f];
cell.textLabel.font = [UIFont boldSystemFontOfSize:15];
return cell;
}

- (void)selected:(QuickDialogTableView *)tableView controller:(QuickDialogController *)controller indexPath:(NSIndexPath *)indexPath {
}


@end
2 changes: 1 addition & 1 deletion quickdialog/QEntryTableViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
- (QEntryElement *)findNextElementToFocusOn;
- (QEntryElement *)findPreviousElementToFocusOn;

- (void)recalculatePositioning;
- (void)recalculateEntryFieldPosition;


@end
11 changes: 5 additions & 6 deletions quickdialog/QEntryTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,17 @@ - (CGRect)calculateFrameForEntryElement {
CGFloat titleWidth = 0;

if (CGRectEqualToRect(CGRectZero, _entryElement.parentSection.entryPosition)) {

for (QElement *el in _entryElement.parentSection.elements){
if ([el isKindOfClass:[QEntryElement class]]){
CGFloat fontSize = self.textLabel.font.lineHeight == 0? 18 : self.textLabel.font.lineHeight;
CGSize size = [((QEntryElement *)el).title sizeWithFont:[UIFont systemFontOfSize:fontSize] forWidth:CGFLOAT_MAX lineBreakMode:UILineBreakModeWordWrap] ;
CGFloat fontSize = self.textLabel.font.pointSize == 0? 18 : self.textLabel.font.pointSize;
CGSize size = [((QEntryElement *)el).title sizeWithFont:[self.textLabel.font fontWithSize:fontSize] forWidth:CGFLOAT_MAX lineBreakMode:UILineBreakModeWordWrap] ;
if (size.width>titleWidth)
titleWidth = size.width;
}
}

CGFloat separator = titleWidth > 0 ? 20 : 0;
_entryElement.parentSection.entryPosition = CGRectMake(titleWidth+separator,11,totalWidth-titleWidth-22-separator,24);
_entryElement.parentSection.entryPosition = CGRectMake(titleWidth+separator,11,totalWidth-titleWidth-(separator*2),24);
}

return _entryElement.parentSection.entryPosition;
Expand All @@ -95,7 +94,7 @@ - (void)prepareForElement:(QEntryElement *)element inTableView:(QuickDialogTable

_quickformTableView = tableView;
_entryElement = element;
[self recalculatePositioning];
[self recalculateEntryFieldPosition];
_textField.text = _entryElement.textValue;
_textField.placeholder = _entryElement.placeholder;
_textField.secureTextEntry = _entryElement.isPassword;
Expand All @@ -106,7 +105,7 @@ - (void)prepareForElement:(QEntryElement *)element inTableView:(QuickDialogTable
}
}

-(void)recalculatePositioning {
-(void)recalculateEntryFieldPosition {
_entryElement.parentSection.entryPosition = CGRectZero;
_textField.frame = [self calculateFrameForEntryElement];
}
Expand Down
2 changes: 0 additions & 2 deletions quickdialog/QLabelElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ @implementation QLabelElement
@synthesize image = _image;
@synthesize value = _value;


- (QLabelElement *)initWithTitle:(NSString *)title Value:(NSString *)value {
self = [super init];
_title = title;
Expand All @@ -36,7 +35,6 @@ - (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView contr
cell.textLabel.text = _title;
cell.detailTextLabel.text = _value;
cell.imageView.image = _image;
cell.accessoryView = nil;
cell.accessoryType = self.sections!= nil || self.controllerAction!=nil ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;
cell.selectionStyle = self.sections!= nil || self.controllerAction!=nil ? UITableViewCellSelectionStyleBlue: UITableViewCellSelectionStyleNone;

Expand Down
6 changes: 4 additions & 2 deletions quickdialog/QRadioElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
@interface QRadioElement : QRootElement {

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

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

- (QRadioElement *)initWithItems:(NSArray *)stringArray selected:(NSUInteger)selected;
- (QRadioElement *)initWithItems:(NSArray *)stringArray selected:(NSUInteger)selected title:(NSString *)title;
Expand Down
23 changes: 19 additions & 4 deletions quickdialog/QRadioElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
#import "QRadioElement.h"
#import "QRadioItemElement.h"

@implementation QRadioElement
@implementation QRadioElement {

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


- (void)createElements {
_sections = nil;
Expand Down Expand Up @@ -55,13 +58,17 @@ - (QRadioElement *)initWithItems:(NSArray *)stringArray selected:(NSUInteger)sel
- (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView controller:(QuickDialogController *)controller {
UITableViewCell *cell = [super getCellForTableView:tableView controller:controller];

NSString *selectedValue = nil;
if (_selected >= 0 && _selected <_items.count)
selectedValue = [[_items objectAtIndex:_selected] description];

if (self.title == NULL){
cell.textLabel.text = [[_items objectAtIndex:_selected] description];
cell.textLabel.text = selectedValue;
cell.detailTextLabel.text = nil;
cell.imageView.image = nil;
} else {
cell.textLabel.text = _title;
cell.detailTextLabel.text = [[_items objectAtIndex:_selected] description];
cell.detailTextLabel.text = selectedValue;
cell.imageView.image = nil;
}
return cell;
Expand All @@ -70,7 +77,15 @@ - (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView contr
- (void)fetchValueIntoObject:(id)obj {
if (_key==nil)
return;
[obj setObject:[NSNumber numberWithInt:_selected] forKey:_key];

if (_selected < 0 || _selected >= (_values == nil ? _values : _items).count)
return;

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


Expand Down
4 changes: 2 additions & 2 deletions quickdialog/QRootElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
NSString *_controllerName;
}

@property(nonatomic, strong) NSString *title;
@property(nonatomic, retain) NSString *title;
@property(nonatomic, strong) NSMutableArray *sections;
@property(assign) BOOL grouped;

@property(nonatomic, strong) NSString *controllerName;
@property(nonatomic, retain) NSString *controllerName;

- (void)addSection:(QSection *)section;
- (QSection *)getSectionForIndex:(NSInteger)index;
Expand Down
Loading

0 comments on commit 98dbeed

Please sign in to comment.