mirror of
https://github.com/moparisthebest/mailiverse
synced 2024-11-14 21:25:05 -05:00
72 lines
1.2 KiB
Plaintext
72 lines
1.2 KiB
Plaintext
|
/**
|
||
|
* Author: Timothy Prepscius
|
||
|
* License: BSD + keep my name in the code!
|
||
|
*/
|
||
|
|
||
|
#import "UIToggleBarButtonItem.h"
|
||
|
#include "mailiverse/utilities/Log.h"
|
||
|
|
||
|
@implementation UIToggleBarButtonItem
|
||
|
@synthesize state;
|
||
|
@synthesize toggleSelector;
|
||
|
@synthesize user;
|
||
|
|
||
|
- (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action user:(id)_user
|
||
|
{
|
||
|
LogDebug(ui::UIToggleBarButtonItem, "init");
|
||
|
|
||
|
if (self = [super initWithTitle:title style:style target:target action:action])
|
||
|
{
|
||
|
self.user = _user;
|
||
|
self.state = FALSE;
|
||
|
}
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (id)initWithCoder:(NSCoder *)aDecoder
|
||
|
{
|
||
|
LogDebug(ui::UIToggleBarButtonItem, "init");
|
||
|
|
||
|
if (self = [super initWithCoder:aDecoder])
|
||
|
{
|
||
|
self.state = FALSE;
|
||
|
self.user = nil;
|
||
|
}
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (void)dealloc
|
||
|
{
|
||
|
LogDebug(ui::UIToggleBarButtonItem, "dealloc");
|
||
|
}
|
||
|
|
||
|
- (BOOL) click
|
||
|
{
|
||
|
state = !state;
|
||
|
self.tintColor =
|
||
|
state ?
|
||
|
[UIColor blueColor] :
|
||
|
nil;
|
||
|
|
||
|
if (toggleSelector)
|
||
|
[self.target performSelector:toggleSelector withObject:self];
|
||
|
|
||
|
return state;
|
||
|
}
|
||
|
|
||
|
- (void) reset
|
||
|
{
|
||
|
if (state == FALSE)
|
||
|
return;
|
||
|
|
||
|
self.state = FALSE;
|
||
|
self.tintColor = nil;
|
||
|
|
||
|
if (toggleSelector)
|
||
|
[self.target performSelector:toggleSelector withObject:self];
|
||
|
}
|
||
|
|
||
|
@end
|