mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Improve Contact details view
This commit is contained in:
parent
ec2a7a6856
commit
2dffddd07b
4 changed files with 39 additions and 28 deletions
|
|
@ -56,12 +56,13 @@
|
|||
@implementation ContactDetailsTableViewController
|
||||
|
||||
enum _ContactSections {
|
||||
ContactSections_Number = 0,
|
||||
ContactSections_None = 0,
|
||||
ContactSections_Number,
|
||||
ContactSections_Sip,
|
||||
ContactSections_MAX
|
||||
};
|
||||
|
||||
static const int contactSections[ContactSections_MAX] = {ContactSections_Number, ContactSections_Sip};
|
||||
static const int contactSections[ContactSections_MAX] = {ContactSections_None, ContactSections_Number, ContactSections_Sip};
|
||||
|
||||
@synthesize footerController;
|
||||
@synthesize headerController;
|
||||
|
|
@ -370,6 +371,7 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number,
|
|||
}
|
||||
self->contact = acontact;
|
||||
[self loadData];
|
||||
[headerController setContact:contact];
|
||||
}
|
||||
|
||||
- (void)addSipField:(NSString*)address {
|
||||
|
|
@ -551,18 +553,23 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number,
|
|||
if(!editing) {
|
||||
[ContactDetailsTableViewController findAndResignFirstResponder:[self tableView]];
|
||||
}
|
||||
|
||||
[super setEditing:editing animated:animated];
|
||||
|
||||
[headerController setEditing:editing animated:animated];
|
||||
[footerController setEditing:editing animated:animated];
|
||||
|
||||
if(animated) {
|
||||
[self.tableView beginUpdates];
|
||||
}
|
||||
if(editing) {
|
||||
for (int section = 0; section <[self numberOfSectionsInTableView:[self tableView]]; ++section) {
|
||||
for (int section = 0; section < [self numberOfSectionsInTableView:[self tableView]]; ++section) {
|
||||
if(contactSections[section] == ContactSections_Number ||
|
||||
contactSections[section] == ContactSections_Sip)
|
||||
[self addEntry:self.tableView section:section animated:animated];
|
||||
}
|
||||
} else {
|
||||
for (int section = 0; section <[self numberOfSectionsInTableView:[self tableView]]; ++section) {
|
||||
for (int section = 0; section < [self numberOfSectionsInTableView:[self tableView]]; ++section) {
|
||||
if(contactSections[section] == ContactSections_Number ||
|
||||
contactSections[section] == ContactSections_Sip)
|
||||
[self removeEmptyEntry:self.tableView section:section animated:animated];
|
||||
}
|
||||
}
|
||||
|
|
@ -570,8 +577,10 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number,
|
|||
[self.tableView endUpdates];
|
||||
}
|
||||
|
||||
[headerController setEditing:editing animated:animated];
|
||||
[footerController setEditing:editing animated:animated];
|
||||
[super setEditing:editing animated:animated];
|
||||
if(contactDetailsDelegate != nil) {
|
||||
[contactDetailsDelegate onModification:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
|
|
@ -583,11 +592,8 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number,
|
|||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
||||
if(section == 0) {
|
||||
UIView *headerView = [headerController view];
|
||||
[headerController setContact:contact];
|
||||
[headerController setEditing:[self isEditing] animated:FALSE];
|
||||
return headerView;
|
||||
if(section == ContactSections_None) {
|
||||
return [headerController view];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
|
|
@ -595,8 +601,7 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number,
|
|||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
|
||||
if(section == (ContactSections_MAX - 1)) {
|
||||
UIView *footerView = [footerController view];
|
||||
return footerView;
|
||||
return [footerController view];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
|
|
@ -606,7 +611,7 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number,
|
|||
if(contactSections[section] == ContactSections_Number) {
|
||||
return NSLocalizedString(@"Phone numbers", nil);
|
||||
} else if(contactSections[section] == ContactSections_Sip) {
|
||||
return NSLocalizedString(@"SIP", nil);
|
||||
return NSLocalizedString(@"SIP addresses", nil);
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
|
@ -616,8 +621,8 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number,
|
|||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
||||
if(section == 0) {
|
||||
return [UIContactDetailsHeader height:[self isEditing]];
|
||||
if(section == ContactSections_None) {
|
||||
return [UIContactDetailsHeader height:[headerController isEditing]];
|
||||
} else {
|
||||
// Hide section if nothing in it
|
||||
if([[self getSectionData:section] count] > 0)
|
||||
|
|
@ -628,8 +633,10 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_Number,
|
|||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
|
||||
if(section != 0) {
|
||||
return [UIContactDetailsFooter height:[self isEditing]];
|
||||
if(section == (ContactSections_MAX - 1)) {
|
||||
return [UIContactDetailsFooter height:[footerController isEditing]];
|
||||
} else if(section == ContactSections_None) {
|
||||
return 0.000001f; // Hack UITableView = 0
|
||||
}
|
||||
return 10.0f;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
propertyList = [[NSArray alloc] initWithObjects:
|
||||
[NSNumber numberWithInt:kABPersonFirstNameProperty],
|
||||
[NSNumber numberWithInt:kABPersonLastNameProperty], nil];
|
||||
editing = FALSE;
|
||||
}
|
||||
|
||||
- (id)init {
|
||||
|
|
@ -83,6 +84,9 @@
|
|||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
removeTableBackground(tableView); // Can't do it in Xib: issue with ios4
|
||||
[normalView setAlpha:1.0f];
|
||||
[editView setAlpha:0.0f];
|
||||
[tableView setEditing:TRUE animated:false];
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -159,16 +163,11 @@
|
|||
[UIView beginAnimations:nil context:nil];
|
||||
[UIView setAnimationDuration:0.3];
|
||||
}
|
||||
[tableView setEditing:editing animated:animated];
|
||||
if(editing) {
|
||||
CGRect frame = [editView frame];
|
||||
frame.size.height = [UIContactDetailsHeader height:editing];
|
||||
[editView setFrame:frame];
|
||||
[editView setAlpha:1.0f];
|
||||
[normalView setAlpha:0.0f];
|
||||
} else {
|
||||
CGRect frame = [editView frame];
|
||||
frame.size.height = 0;
|
||||
[editView setFrame:frame];
|
||||
[editView setAlpha:0.0f];
|
||||
[normalView setAlpha:1.0f];
|
||||
}
|
||||
if(animated) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
</object>
|
||||
<object class="IBUIView" id="1033790597">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">290</int>
|
||||
<int key="NSvFlags">274</int>
|
||||
<array class="NSMutableArray" key="NSSubviews">
|
||||
<object class="IBUIImageView" id="452773126">
|
||||
<reference key="NSNextResponder" ref="1033790597"/>
|
||||
|
|
@ -378,6 +378,7 @@ AAgACAAIAAEAAQABAAE</bytes>
|
|||
<dictionary class="NSMutableDictionary" key="outlets">
|
||||
<string key="addressLabel">UILabel</string>
|
||||
<string key="avatarImage">UIImageView</string>
|
||||
<string key="contactDetailsDelegate">id</string>
|
||||
<string key="editView">UIView</string>
|
||||
<string key="normalView">UIView</string>
|
||||
<string key="tableView">UITableView</string>
|
||||
|
|
@ -391,6 +392,10 @@ AAgACAAIAAEAAQABAAE</bytes>
|
|||
<string key="name">avatarImage</string>
|
||||
<string key="candidateClassName">UIImageView</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="contactDetailsDelegate">
|
||||
<string key="name">contactDetailsDelegate</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo" key="editView">
|
||||
<string key="name">editView</string>
|
||||
<string key="candidateClassName">UIView</string>
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Reference in a new issue