Skip to content

Commit

Permalink
Changes to the onValueChanged() function, bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
escoz committed Jan 13, 2013
1 parent cadea8d commit 86cb878
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion quickdialog/QBooleanElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ - (void)buttonPressed:(UIButton *)boolButton {
-(void)setBoolValue:(BOOL)boolValue {
_boolValue = boolValue;
if (self.onValueChanged!=nil){
self.onValueChanged();
self.onValueChanged(self);
}
}

Expand Down
2 changes: 1 addition & 1 deletion quickdialog/QDateEntryTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ - (void) dateChanged:(id)sender{
}
[self prepareForElement:_entryElement inTableView:_quickformTableView];
if (element.onValueChanged!=nil)
element.onValueChanged();
element.onValueChanged(_entryElement);

}

Expand Down
3 changes: 1 addition & 2 deletions quickdialog/QDecimalElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ - (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView contr
if (cell==nil){
cell = [[QDecimalTableViewCell alloc] init];
}
self.keyboardType = UIKeyboardTypeDecimalPad;
[cell prepareForElement:self inTableView:tableView];

cell.textLabel.textColor = self.enabled ? [UIColor blackColor] : [UIColor lightGrayColor];
cell.textField.userInteractionEnabled = self.enabled;

return cell;
Expand Down
3 changes: 2 additions & 1 deletion quickdialog/QEntryTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ - (void)prepareForElement:(QEntryElement *)element inTableView:(QuickDialogTable
_textField.secureTextEntry = _entryElement.secureTextEntry;
_textField.clearsOnBeginEditing = _entryElement.clearsOnBeginEditing;
_textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
_textField.textAlignment = _entryElement.appearance.valueAlignment;

_textField.returnKeyType = _entryElement.returnKeyType;
_textField.enablesReturnKeyAutomatically = _entryElement.enablesReturnKeyAutomatically;
Expand Down Expand Up @@ -173,7 +174,7 @@ - (void)handleEditingChanged
}

if(_entryElement.onValueChanged) {
_entryElement.onValueChanged();
_entryElement.onValueChanged(_entryElement);
}
}

Expand Down
2 changes: 1 addition & 1 deletion quickdialog/QFloatElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ - (void)valueChanged:(UISlider *)slider {
self.floatValue = slider.value;

if (self.onValueChanged!=nil)
self.onValueChanged();
self.onValueChanged(self);
}

- (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView controller:(QuickDialogController *)controller {
Expand Down
2 changes: 1 addition & 1 deletion quickdialog/QMultilineTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ - (void)textViewDidEndEditing:(UITextView *)textView {
}

if (_entryElement.onValueChanged) {
_entryElement.onValueChanged();
_entryElement.onValueChanged(_entryElement);
}
}

Expand Down
2 changes: 1 addition & 1 deletion quickdialog/QPickerTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row f
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
if (self.pickerElement.onValueChanged != nil) {
self.pickerElement.onValueChanged();
self.pickerElement.onValueChanged(self.pickerElement);
}

self.pickerElement.value = [self getPickerViewValue];
Expand Down
5 changes: 4 additions & 1 deletion quickdialog/QRootElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ typedef enum {
@property(assign) BOOL grouped;

@property(nonatomic, retain) NSString *controllerName;
@property(nonatomic, copy) void (^onValueChanged)(void);

@property(nonatomic, copy) NSString *emptyMessage;
@property(nonatomic) QPresentationMode presentationMode;

@property(nonatomic, strong) NSIndexPath *preselectedElementIndex;

@property(nonatomic, copy) void (^onValueChanged)(QRootElement *);

- (QRootElement *)init;

- (void)addSection:(QSection *)section;
Expand All @@ -67,4 +68,6 @@ typedef enum {

- (QSection *)sectionWithKey:(NSString *)key;
- (QElement *)elementWithKey:(NSString *)string;

- (QRootElement *)rootWithKey:(NSString *)string;
@end
6 changes: 5 additions & 1 deletion quickdialog/QRootElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ @implementation QRootElement {
@private
NSDictionary *_sectionTemplate;
QPresentationMode _presentationMode;
void (^_onValueChanged)();
}


Expand Down Expand Up @@ -168,4 +167,9 @@ - (QElement *)elementWithKey:(NSString *)elementKey {
}
return nil;
}

- (QRootElement *)rootWithKey:(NSString *)string {
return (QRootElement *) [self elementWithKey:string];

}
@end
2 changes: 1 addition & 1 deletion quickdialog/QSegmentedElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ - (QSegmentedElement *)init {
- (void)handleSegmentedControlValueChanged:(id)control {
_selected = ((UISegmentedControl *)control).selectedSegmentIndex - 1;
if (self.onValueChanged!=nil)
self.onValueChanged();
self.onValueChanged(self);

[self handleElementSelected:_controller];
}
Expand Down
6 changes: 3 additions & 3 deletions sample/SampleDataBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ + (QElement *)reallyLongList {
QBooleanElement *bool1 = [[QBooleanElement alloc] initWithTitle:[NSString stringWithFormat:@"Option %d", i] BoolValue:(i % 3 == 0)];
bool1.onImage = [UIImage imageNamed:@"imgOn"];
bool1.offImage = [UIImage imageNamed:@"imgOff"];
bool1.onValueChanged = ^{
bool1.onValueChanged = ^(QRootElement *el){
NSLog(@"Bool selected! ");
};
[subsection addElement:bool1];
Expand Down Expand Up @@ -281,7 +281,7 @@ + (QElement *)createPickerRoot
NSArray *component2 = @[@"A", @"B"];
QPickerElement *simplePickerEl = [[QPickerElement alloc] initWithTitle:@"Key" items:@[component1, component2] value:@"3\tB"];

simplePickerEl.onValueChanged = ^{
simplePickerEl.onValueChanged = ^(QRootElement *el){
NSLog(@"Selected indexes: %@", [simplePickerEl.selectedIndexes componentsJoinedByString:@","]);
};

Expand All @@ -299,7 +299,7 @@ + (QElement *)createPickerRoot
value:[NSNumber numberWithUnsignedInteger:NSMonthCalendarUnit]];

periodPickerEl.valueParser = periodParser;
periodPickerEl.onValueChanged = ^{ NSLog(@"New value: %@", periodPickerEl.value); };
periodPickerEl.onValueChanged = ^(QRootElement *el){ NSLog(@"New value: %@", periodPickerEl.value); };

[customParserSection addElement:periodPickerEl];
[root addSection:customParserSection];
Expand Down

0 comments on commit 86cb878

Please sign in to comment.