linphone-ios/Classes/ContactDetailsLabelView.m
Gautier Pelloux-Prayer 08f819e332 checkbox tv
2015-09-29 16:59:10 +02:00

115 lines
3.5 KiB
Objective-C

/* ContactDetailsLabelViewController.m
*
* Copyright (C) 2012 Belledonne Comunications, Grenoble, France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#import "ContactDetailsLabelView.h"
#import "UACellBackgroundView.h"
#import "Utils.h"
#import "PhoneMainView.h"
@implementation ContactDetailsLabelView
@synthesize dataList;
@synthesize tableView;
@synthesize selectedData;
@synthesize delegate;
#pragma mark - UICompositeViewDelegate Functions
static UICompositeViewDescription *compositeDescription = nil;
+ (UICompositeViewDescription *)compositeViewDescription {
if (compositeDescription == nil) {
compositeDescription = [[UICompositeViewDescription alloc] init:self.class
statusBar:StatusBarView.class
tabBar:TabBarView.class
fullscreen:false
landscapeMode:LinphoneManager.runningOnIpad
portraitMode:true];
}
return compositeDescription;
}
- (UICompositeViewDescription *)compositeViewDescription {
return self.class.compositeViewDescription;
}
#pragma mark -
- (void)dismiss {
if ([[PhoneMainView.instance currentView] equal:ContactDetailsLabelView.compositeViewDescription]) {
[PhoneMainView.instance popCurrentView];
}
}
#pragma mark - Property Functions
- (void)setDataList:(NSDictionary *)adatalist {
if ([dataList isEqualToDictionary:adatalist]) {
return;
}
dataList = adatalist;
[tableView reloadData];
}
- (void)setSelectedData:(NSString *)aselectedData {
selectedData = [[NSString alloc] initWithString:aselectedData];
[tableView reloadData];
}
#pragma mark - UITableViewDataSource Functions
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [dataList count];
}
- (UITableViewCell *)tableView:(UITableView *)atableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *kCellId = @"ContactDetailsLabelCell";
UITableViewCell *cell = [atableView dequeueReusableCellWithIdentifier:kCellId];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:kCellId];
}
NSString *key = [[dataList allKeys] objectAtIndex:[indexPath row]];
[cell.textLabel setText:[dataList objectForKey:key]];
if ([key compare:selectedData] == 0) {
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
} else {
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *key = [[dataList allKeys] objectAtIndex:[indexPath row]];
[self setSelectedData:key];
[delegate changeContactDetailsLabel:key];
[self dismiss];
}
#pragma mark - Action Functions
- (IBAction)onBackClick:(id)event {
[self dismiss];
}
@end