Skip to content

Commit

Permalink
Added showPlaceholderWhileEditing property
Browse files Browse the repository at this point in the history
  • Loading branch information
ppaulojr committed Jun 17, 2016
1 parent 1367f0f commit 42f7d1b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions PPJEmailPicker.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "PPJEmailPicker"
s.version = "1.0.6"
s.version = "1.0.7"
s.summary = "An UITextField replacement to select multiple e-mails"

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -70,7 +70,7 @@ The goal is to create a control similar to GMail, Outlook or Mail.app `from` fie
# Supports git, hg, bzr, svn and HTTP.
#

s.source = { :git => "https://github.com/ppaulojr/PPJEmailPicker.git", :tag => "1.0.6" }
s.source = { :git => "https://github.com/ppaulojr/PPJEmailPicker.git", :tag => "1.0.7" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
1 change: 1 addition & 0 deletions PPJEmailPicker/PPJEmailPicker.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
@property (strong, nonatomic) UIColor *pickerSelectedTextColor;
@property (strong, nonatomic) UIColor *pickerSelectedBackgroundColor;
@property (strong, nonatomic) UIFont *autoCompleteTextFont;
@property (assign, nonatomic) BOOL showPlaceholderWhileEditing;


//
Expand Down
28 changes: 27 additions & 1 deletion PPJEmailPicker/PPJEmailPicker.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ @interface PPJEmailPicker ()
@property (assign, nonatomic) CGSize originalShadowOffset;
@property (assign, nonatomic) CGFloat originalShadowOpacity;
@property (assign, nonatomic) CGFloat minimumHeightTextField;
@property (copy, nonatomic) NSString *tmpPlaceholder;
@end

@implementation PPJEmailPicker {
Expand Down Expand Up @@ -176,6 +177,20 @@ - (void)setDelegate:(id<UITextFieldDelegate>)delegate
return _privateDelegate->_userDelegate;
}

- (NSString *) placeholder
{
return super.placeholder;
}

- (void) setPlaceholder:(NSString *)placeholder
{
if (super.placeholder != nil)
{
_tmpPlaceholder = super.placeholder;
}
super.placeholder = placeholder;
}

-(void) setSelectedEmailList:(NSMutableArray *)selectedEmailList
{
if (![_selectedEmailList isEqual:selectedEmailList]) {
Expand Down Expand Up @@ -268,7 +283,10 @@ -(void) renderList
[lbl sizeToFit];
[self.selectedEmailUI addObject:lbl];
[self addSubview:lbl];
}
if (!self.showPlaceholderWhileEditing) {
self.placeholder = nil;
}
}
}

#pragma mark - Filter Array
Expand Down Expand Up @@ -347,6 +365,9 @@ - (void) addString:(NSString *)str
[lbl sizeToFit];
[self.selectedEmailUI addObject:lbl];
[self addSubview:lbl];
if (!self.showPlaceholderWhileEditing) {
self.placeholder = nil;
}
if ([self.pickerDelegate respondsToSelector:@selector(picker:haveArrayOfEmails:)]) {
[self.pickerDelegate picker:self haveArrayOfEmails:[self.selectedEmailList copy]];
}
Expand All @@ -363,6 +384,11 @@ - (void) removeCurrentSelectedEmail
[self.currentSelectedEmail removeFromSuperview];
[self layoutSubviews];
self.currentSelectedEmail = nil;
if (self.selectedEmailUI.count == 0) {
if (!self.showPlaceholderWhileEditing) {
super.placeholder = self.tmpPlaceholder;
}
}
if ([self.pickerDelegate respondsToSelector:@selector(picker:haveArrayOfEmails:)]) {
[self.pickerDelegate picker:self haveArrayOfEmails:[self.selectedEmailList copy]];
}
Expand Down
1 change: 1 addition & 0 deletions PPJEmailPickerDemo/TableViewControllerDemo.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ -(PPJEmailPicker *) createAutoCompleteFieldWithFrame:(CGRect)frame
// Cells and Table color
actf.possibleStrings = [[ListOfEmails emails] mutableCopy];
actf.placeholder = NSLocalizedString(@"Type e-mail to send recognition", nil);
actf.showPlaceholderWhileEditing = YES;

actf.pickerTextColor = [UIColor colorWithRed:0.9 green:0.8 blue:0.9 alpha:1.0];
actf.pickerBackgroundColor = [UIColor colorWithRed:0.0 green:0.5 blue:0.2 alpha:1.0];
Expand Down

0 comments on commit 42f7d1b

Please sign in to comment.