Skip to content

Commit

Permalink
Merge pull request #30 from kenleezle/selected-contact-bugs
Browse files Browse the repository at this point in the history
Selected contact bugs
  • Loading branch information
tristanhimmelman committed Mar 12, 2015
2 parents 09f0ccf + 0737f29 commit e498d87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Classes/THContactPickerView.m
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ - (void)addContact:(id)contact withName:(NSString *)name {
if (self.selectedContactView){
// if there is a selected contact, deselect it
[self.selectedContactView unSelect];
self.selectedContactView = nil;
[self selectTextView];
}

Expand Down Expand Up @@ -283,6 +284,11 @@ - (void)removeContactView:(THContactView *)contactView {
}

[self removeContactByKey:contact];
[self selectTextView];

if (self.selectedContactView == contactView) {
self.selectedContactView = nil;
}
}

- (void)removeContactByKey:(id)contactKey {
Expand All @@ -295,7 +301,6 @@ - (void)removeContactByKey:(id)contactKey {
[self.contactKeys removeObject:contactKey];

self.textField.text = @"";
[self selectTextView];

// update layout
[self layoutContactViews];
Expand Down Expand Up @@ -506,6 +511,10 @@ - (void)contactViewWasSelected:(THContactView *)contactView {
}

- (void)contactViewWasUnSelected:(THContactView *)contactView {
if (self.selectedContactView == contactView){
self.selectedContactView = nil;
}

[self selectTextView];
// transfer the text fromt he textField within the ContactView if there was any
// ***This is important if the user starts to type when a contact view is selected
Expand Down
4 changes: 4 additions & 0 deletions Classes/THContactView.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ - (void)select {
}

- (void)unSelect {
if ([self.delegate respondsToSelector:@selector(contactViewWasUnSelected:)]){
[self.delegate contactViewWasUnSelected:self];
}

CALayer *viewLayer = [self layer];
viewLayer.borderColor = self.style.borderColor.CGColor;

Expand Down

0 comments on commit e498d87

Please sign in to comment.