forked from rpetrich/AppList
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#import <UIKit/UIKit.h> | ||
|
||
@protocol ALValueCellDelegate; | ||
|
||
@interface ALValueCell : UITableViewCell { | ||
@private | ||
id<ALValueCellDelegate> _delegate; | ||
} | ||
|
||
@property (nonatomic, assign) id<ALValueCellDelegate> delegate; | ||
|
||
- (void)loadValue:(id)value; | ||
|
||
- (void)didSelect; | ||
|
||
@end | ||
|
||
@protocol ALValueCellDelegate <NSObject> | ||
@required | ||
- (void)valueCell:(ALValueCell *)valueCell didChangeToValue:(id)newValue; | ||
@end | ||
|
||
@interface ALSwitchCell : ALValueCell { | ||
@private | ||
UISwitch *switchView; | ||
} | ||
|
||
@property (nonatomic, readonly) UISwitch *switchView; | ||
|
||
@end | ||
|
||
@interface ALCheckCell : ALValueCell { | ||
} | ||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#import "ALValueCell.h" | ||
|
||
@implementation ALValueCell | ||
|
||
@synthesize delegate; | ||
|
||
- (void)loadValue:(id)value | ||
{ | ||
} | ||
|
||
- (void)didSelect | ||
{ | ||
} | ||
|
||
@end | ||
|
||
@implementation ALSwitchCell | ||
|
||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier | ||
{ | ||
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { | ||
switchView = [[UISwitch alloc] initWithFrame:CGRectZero]; | ||
[switchView addTarget:self action:@selector(valueChanged) forControlEvents:UIControlEventValueChanged]; | ||
[self setAccessoryView:switchView]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[switchView release]; | ||
[super dealloc]; | ||
} | ||
|
||
@synthesize switchView = _switchView; | ||
|
||
- (void)loadValue:(id)value | ||
{ | ||
switchView.on = [value boolValue]; | ||
} | ||
|
||
- (void)valueChanged | ||
{ | ||
id value = [NSNumber numberWithBool:switchView.on]; | ||
[[self delegate] valueCell:self didChangeToValue:value]; | ||
} | ||
|
||
@end | ||
|
||
@implementation ALCheckCell | ||
|
||
- (void)loadValue:(id)value | ||
{ | ||
[self setAccessoryType:[value boolValue] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone]; | ||
} | ||
|
||
- (void)didSelect | ||
{ | ||
UITableViewCellAccessoryType type = [self accessoryType]; | ||
[self setAccessoryType:(type == UITableViewCellAccessoryNone) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone]; | ||
id value = [NSNumber numberWithBool:type == UITableViewCellAccessoryNone]; | ||
[[self delegate] valueCell:self didChangeToValue:value]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters