Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
coderZsq committed Sep 29, 2019
1 parent 572634e commit 5c96cc4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ - (void)viewDidLoad {
self.tableView.backgroundColor = [UIColor colorWithHexString:@"f8f8f8"];
[self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([SQConnectionPropertyCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([SQConnectionPropertyCell class])];
self.headerView = [SQProfileHeaderView headerView];
self.headerView.profileImageView.image = [UIImage imageWithData:self.connection.profile];;
__weak typeof(self) weakSelf = self;
[self.headerView whenTapped:^{
UIImagePickerController *imagePickerVc = [[UIImagePickerController alloc] init];
Expand Down Expand Up @@ -91,9 +92,13 @@ - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSIntege

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.section == 0) {
UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:[NSString stringWithFormat:@"请输入 - %@", self.dataSource[indexPath.section][indexPath.row]] preferredStyle:(UIAlertControllerStyleAlert)];
[alertVc addTextFieldWithConfigurationHandler:nil];
if (indexPath.section == 0 && indexPath.row < 5) {
NSString *string = self.dataSource[indexPath.section][indexPath.row];
UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:string preferredStyle:(UIAlertControllerStyleAlert)];
[alertVc addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.text = [self mapConnectionModelFor:string];
textField.placeholder = [NSString stringWithFormat:@"请输入%@", string];
}];
[alertVc addAction:[UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil]];
__weak typeof(alertVc) weakSelf = alertVc;
[alertVc addAction:[UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
Expand All @@ -104,6 +109,16 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
}

- (NSString *)mapConnectionModelFor:(NSString *)key {
return @{
@"姓名" : self.connection.name,
@"角色" : self.connection.role,
@"职业" : self.connection.occupation,
@"地区" : self.connection.region,
@"行业" : self.connection.industry
}[key];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissViewControllerAnimated:YES completion:nil];
self.headerView.profileImageView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
Expand Down
1 change: 1 addition & 0 deletions SQManagement/SQManagement/Connections/SQConnectionModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface SQConnectionModel : NSObject

@property (nonatomic, strong) NSData *profile;
@property (nonatomic, copy) NSString *identifier;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *role;
@property (nonatomic, copy) NSString *occupation;
Expand Down
13 changes: 13 additions & 0 deletions SQManagement/SQManagement/Connections/SQConnectionModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ typedef NS_ENUM(NSInteger, SQConnectionProperty) {

@implementation SQConnectionModel

- (instancetype)init
{
self = [super init];
if (self) {
self.name = @"";
self.role = @"";
self.occupation= @"";
self.region = @"";
self.industry = @"";
}
return self;
}

- (void)map:(NSUInteger)row bind:(UIView *)view {
switch (row) {
case SQConnectionName:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ - (void)viewDidLoad {
[SQAuthorizationTool fetchContacts:^(NSArray * _Nonnull contacts) {
for (SQContact *contact in contacts) {
SQConnectionModel *model = [SQConnectionModel new];
model.profile = contact.imageData;
model.identifier = contact.identifier;
model.profile = contact.thumbnailImageData;
model.name = [NSString stringWithFormat:@"%@%@", contact.familyName, contact.givenName];
model.occupation = contact.jobTitle;
[self.dataSource addObject:model];
Expand Down
20 changes: 16 additions & 4 deletions SQManagement/SQManagement/Tools/SQAuthorizationTool.m
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,22 @@ + (void)fetchContacts:(void (^)(NSArray * _Nonnull))callback{
[dates addObject:[NSString stringWithFormat:@"%@: %@", label, [dateFormatter stringFromDate:value]]];
}
obj.dates = dates;
// obj.urlAddresses = contact.urlAddresses;
// obj.contactRelations = contact.contactRelations;
// obj.socialProfiles = contact.socialProfiles;
// obj.instantMessageAddresses = contact.instantMessageAddresses;
NSMutableArray *urlAddresses = @[].mutableCopy;
for (CNLabeledValue *urlAddress in contact.urlAddresses) {
[urlAddresses addObject:[CNLabeledValue localizedStringForLabel:urlAddress.label]];
}
obj.urlAddresses = urlAddresses;
NSMutableArray *socialProfiles = @[].mutableCopy;
for (CNLabeledValue *socialProfile in contact.socialProfiles) {
[urlAddresses addObject:[CNLabeledValue localizedStringForLabel:socialProfile.label]];
}
obj.socialProfiles = socialProfiles;
NSMutableArray *instantMessageAddresses = @[].mutableCopy;
for (CNLabeledValue *instantMessageAddress in contact.instantMessageAddresses) {
[instantMessageAddresses addObject:[CNLabeledValue localizedStringForLabel:instantMessageAddress.label]];
}
obj.socialProfiles = socialProfiles;
obj.instantMessageAddresses = instantMessageAddresses;
[array addObject:obj];
}];
if (callback) {
Expand Down

0 comments on commit 5c96cc4

Please sign in to comment.