|
@@ -26,6 +26,9 @@
|
|
|
#import "AMCommHeadCell.h"
|
|
#import "AMCommHeadCell.h"
|
|
|
#import "AMCommContentCell.h"
|
|
#import "AMCommContentCell.h"
|
|
|
|
|
|
|
|
|
|
+#import <Contacts/Contacts.h>
|
|
|
|
|
+#import <ContactsUI/ContactsUI.h>
|
|
|
|
|
+
|
|
|
#define COMM_ID_HEAD @"COMM_ID_HEAD"
|
|
#define COMM_ID_HEAD @"COMM_ID_HEAD"
|
|
|
#define COMM_ID_CONTENT @"COMM_ID_CONTENT"
|
|
#define COMM_ID_CONTENT @"COMM_ID_CONTENT"
|
|
|
#define COMM_ID_EDIT @"COMM_ID_EDIT"
|
|
#define COMM_ID_EDIT @"COMM_ID_EDIT"
|
|
@@ -112,7 +115,7 @@
|
|
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
-@interface DetailPageViewController () <QLPreviewControllerDataSource,QLPreviewControllerDelegate,DetailKVCellTapDelegate,AMCommHeadCellDelegate,AMCommContentCellDelegate,AMCommEditCellDelegate>
|
|
|
|
|
|
|
+@interface DetailPageViewController () <QLPreviewControllerDataSource,QLPreviewControllerDelegate,DetailKVCellTapDelegate,AMCommHeadCellDelegate,AMCommContentCellDelegate,AMCommEditCellDelegate,CNContactPickerDelegate>
|
|
|
|
|
|
|
|
@property (nonatomic,strong) MyQLPreviewController *quickLook;
|
|
@property (nonatomic,strong) MyQLPreviewController *quickLook;
|
|
|
@property (nonatomic,copy) NSString *documentPath;
|
|
@property (nonatomic,copy) NSString *documentPath;
|
|
@@ -125,6 +128,7 @@
|
|
|
|
|
|
|
|
@property (nonatomic,weak) UITableViewCell *editingCell;
|
|
@property (nonatomic,weak) UITableViewCell *editingCell;
|
|
|
@property (nonatomic,strong) NSIndexPath *editingIndexPath;
|
|
@property (nonatomic,strong) NSIndexPath *editingIndexPath;
|
|
|
|
|
+@property (nonatomic,strong) NSIndexPath *contactSelectIndexPath;
|
|
|
@property (nonatomic,weak) UITapGestureRecognizer *tap;
|
|
@property (nonatomic,weak) UITapGestureRecognizer *tap;
|
|
|
@property (nonatomic,assign) BOOL showKeyboard;
|
|
@property (nonatomic,assign) BOOL showKeyboard;
|
|
|
|
|
|
|
@@ -311,6 +315,9 @@
|
|
|
if (self.showMap) {
|
|
if (self.showMap) {
|
|
|
[self.params setObject:@(YES) forKey:@"request_location"];
|
|
[self.params setObject:@(YES) forKey:@"request_location"];
|
|
|
}
|
|
}
|
|
|
|
|
+ if ([[self.params objectForKey:@"action_type"] isEqualToString:@"Detail"]) {
|
|
|
|
|
+ [self.params setObject:@(YES) forKey:@"request_communication"];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
|
|
|
|
@@ -1645,16 +1652,7 @@
|
|
|
|
|
|
|
|
NSIndexPath *indexPath = [self.table indexPathForCell:cell];
|
|
NSIndexPath *indexPath = [self.table indexPathForCell:cell];
|
|
|
|
|
|
|
|
- NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
|
|
|
|
|
- if (cc && cc.length > 0) {
|
|
|
|
|
- [segment setValue:cc forKey:@"cc"];
|
|
|
|
|
- } else {
|
|
|
|
|
- [segment removeObjectForKey:@"cc"];
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- NSMutableArray *arr = [self.content.segments mutableCopy];
|
|
|
|
|
- [arr replaceObjectAtIndex:indexPath.section withObject:segment];
|
|
|
|
|
- self.content.segments = arr;
|
|
|
|
|
|
|
+ [self cc:cc changedForIndexPath:indexPath];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)commHeadCell:(AMCommHeadCell *)cell didBeginEditing:(UITextField *)textField {
|
|
- (void)commHeadCell:(AMCommHeadCell *)cell didBeginEditing:(UITextField *)textField {
|
|
@@ -1667,10 +1665,35 @@
|
|
|
self.editingIndexPath = nil;
|
|
self.editingIndexPath = nil;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+- (void)commHeadCell:(AMCommHeadCell *)cell didClickContactButton:(UIButton *)button {
|
|
|
|
|
+
|
|
|
|
|
+ self.contactSelectIndexPath = [self.table indexPathForCell:cell];
|
|
|
|
|
+
|
|
|
|
|
+ CNContactPickerViewController *contactVC = [[CNContactPickerViewController alloc] init];
|
|
|
|
|
+ contactVC.delegate = self;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ [self presentViewController:contactVC animated:YES completion:nil];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
#pragma mark - COMM Content Delegate
|
|
#pragma mark - COMM Content Delegate
|
|
|
|
|
|
|
|
- (void)commContentCell:(AMCommContentCell *)cell sendEmail:(NSString *)email {
|
|
- (void)commContentCell:(AMCommContentCell *)cell sendEmail:(NSString *)email {
|
|
|
|
|
|
|
|
|
|
+// MFMailComposeViewController *emailVC = [[MFMailComposeViewController alloc] init];
|
|
|
|
|
+// if (!emailVC) {
|
|
|
|
|
+//
|
|
|
|
|
+// return;
|
|
|
|
|
+// }
|
|
|
|
|
+// [emailVC setMessageBody:[NSString stringWithFormat:@"<a>%@</a>",email] isHTML:YES];
|
|
|
|
|
+//
|
|
|
|
|
+// [self presentViewController:emailVC animated:YES completion:nil];
|
|
|
|
|
+
|
|
|
|
|
+ NSURL *url = [NSURL URLWithString:email];
|
|
|
|
|
+ if ([[UIApplication sharedApplication] canOpenURL:url]) {
|
|
|
|
|
+ [[UIApplication sharedApplication] openURL:url];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - COMM Edit Delegate
|
|
#pragma mark - COMM Edit Delegate
|
|
@@ -1718,9 +1741,11 @@
|
|
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:@"send email" preferredStyle:UIAlertControllerStyleAlert];
|
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:@"send email" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
[self presentViewController:alert animated:YES completion:nil];
|
|
[self presentViewController:alert animated:YES completion:nil];
|
|
|
|
|
|
|
|
|
|
+ NSString *serialNo = [segment objectForKey:@"serial_no"];
|
|
|
|
|
+
|
|
|
__weak typeof(self) weakSelf = self;
|
|
__weak typeof(self) weakSelf = self;
|
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
- NSDictionary *sendResponse = [RANetwork sendEmail:email CC:cc];
|
|
|
|
|
|
|
+ NSDictionary *sendResponse = [RANetwork sendEmail:email CC:cc SerialNo:serialNo];
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
|
|
[alert dismissViewControllerAnimated:YES completion:^{
|
|
[alert dismissViewControllerAnimated:YES completion:^{
|
|
@@ -1790,6 +1815,40 @@
|
|
|
self.editingIndexPath = nil;
|
|
self.editingIndexPath = nil;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#pragma mark - Contact Picker Delegate
|
|
|
|
|
+
|
|
|
|
|
+- (void)contactPickerDidCancel:(CNContactPickerViewController *)picker {
|
|
|
|
|
+
|
|
|
|
|
+ self.contactSelectIndexPath = nil;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContact:(CNContact *)contact {
|
|
|
|
|
+
|
|
|
|
|
+ [self handleSelectContact:contact];
|
|
|
|
|
+
|
|
|
|
|
+ self.contactSelectIndexPath = nil;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContacts:(NSArray<CNContact *> *)contacts {
|
|
|
|
|
+
|
|
|
|
|
+ for (CNContact *contact in contacts) {
|
|
|
|
|
+ [self handleSelectContact:contact];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ self.contactSelectIndexPath = nil;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperty:(CNContactProperty *)contactProperty {
|
|
|
|
|
+
|
|
|
|
|
+ self.contactSelectIndexPath = nil;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)contactPicker:(CNContactPickerViewController *)picker didSelectContactProperties:(NSArray<CNContactProperty *> *)contactProperties {
|
|
|
|
|
+
|
|
|
|
|
+ self.contactSelectIndexPath = nil;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
#pragma mark - Utils
|
|
#pragma mark - Utils
|
|
|
|
|
|
|
|
- (BOOL)validateEmail:(NSString *)email {
|
|
- (BOOL)validateEmail:(NSString *)email {
|
|
@@ -1801,4 +1860,54 @@
|
|
|
return [emailTest evaluateWithObject:email];
|
|
return [emailTest evaluateWithObject:email];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+- (void)handleSelectContact:(CNContact *)contact {
|
|
|
|
|
+
|
|
|
|
|
+ NSArray *emailArr = [contact emailAddresses];
|
|
|
|
|
+ for (CNLabeledValue *value in emailArr) {
|
|
|
|
|
+ if ([value.label isEqualToString:CNLabelWork]) {
|
|
|
|
|
+ [self appendCC:[NSString stringWithFormat:@"%@;",value.value] forIndexPath:self.contactSelectIndexPath];
|
|
|
|
|
+ [self.table reloadRowsAtIndexPaths:@[self.contactSelectIndexPath] withRowAnimation:UITableViewRowAnimationNone];
|
|
|
|
|
+ AMCommHeadCell *cell = [self.table cellForRowAtIndexPath:self.contactSelectIndexPath];
|
|
|
|
|
+ [cell beginEditing];
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)appendCC:(NSString *)cc forIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
+ if (indexPath == nil || cc == nil || cc.length == 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
|
|
|
|
|
+ NSString *oldCC = [segment objectForKey:@"cc"];
|
|
|
|
|
+ if (oldCC == nil) {
|
|
|
|
|
+ oldCC = cc;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if ([[oldCC substringFromIndex:oldCC.length - 1] isEqualToString:@";"]) {
|
|
|
|
|
+ oldCC = [oldCC stringByAppendingString:cc];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ oldCC = [oldCC stringByAppendingString:[NSString stringWithFormat:@";%@",cc]];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ [self cc:oldCC changedForIndexPath:indexPath];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)cc:(NSString *)cc changedForIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
+ if (indexPath == nil) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ NSMutableDictionary* segment = [self.content.segments[indexPath.section] mutableCopy];
|
|
|
|
|
+ if (cc && cc.length > 0) {
|
|
|
|
|
+ [segment setValue:cc forKey:@"cc"];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ [segment removeObjectForKey:@"cc"];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ NSMutableArray *arr = [self.content.segments mutableCopy];
|
|
|
|
|
+ [arr replaceObjectAtIndex:indexPath.section withObject:segment];
|
|
|
|
|
+ self.content.segments = arr;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
@end
|
|
@end
|