Browse Source

【名片】添加输入扩展按钮即处理

heavyrain2012 4 years ago
parent
commit
7b38480c9b

+ 46 - 1
wfuikit/WFChatUIKit/Vendor/ChatInputBar/WFCUChatInputBar.m

@@ -28,7 +28,9 @@
 #import "DNImagePickerController.h"
 #import "DNAsset.h"
 #import <Photos/Photos.h>
-
+#import "WFCUShareMessageView.h"
+#import "TYAlertController.h"
+#import "UIView+TYAlertView.h"
 
 #define CHAT_INPUT_BAR_PADDING 8
 #define CHAT_INPUT_BAR_ICON_SIZE (CHAT_INPUT_BAR_HEIGHT - CHAT_INPUT_BAR_PADDING - CHAT_INPUT_BAR_PADDING)
@@ -1034,6 +1036,49 @@
         
         [self notifyTyping:4];
         
+    } else if(itemTag == 6) {
+        WFCUContactListViewController *pvc = [[WFCUContactListViewController alloc] init];
+        pvc.selectContact = YES;
+        pvc.multiSelect = NO;
+        
+        pvc.withoutCheckBox = YES;
+        
+        __weak typeof(self)ws = self;
+        
+        pvc.selectResult = ^(NSArray<NSString *> *contacts) {
+            if (contacts.count == 1) {
+                WFCCCardMessageContent *card = [WFCCCardMessageContent cardWithUserId:contacts[0]];
+                WFCCMessage *message = [[WFCCMessage alloc] init];
+                message.content = card;
+                
+                
+                WFCUShareMessageView *shareView = [WFCUShareMessageView createViewFromNib];
+                    
+                shareView.conversation = ws.conversation;
+                shareView.message = message;
+                shareView.forwardDone = ^(BOOL success) {
+                    if (success) {
+                        [[ws.delegate requireNavi] dismissViewControllerAnimated:YES completion:nil];
+                    } else {
+                        [ws makeToast:WFCString(@"SendFailure") duration:1 position:CSToastPositionCenter];
+                    }
+                };
+            
+                TYAlertController *alertController = [TYAlertController alertControllerWithAlertView:shareView preferredStyle:TYAlertControllerStyleAlert];
+
+                dispatch_async(dispatch_get_main_queue(), ^{
+                    [[ws.delegate requireNavi] presentViewController:alertController animated:YES completion:nil];
+                });
+            }
+        };
+        
+        pvc.cancelSelect = ^(void) {
+            NSLog(@"canceled");
+        };
+        
+        
+        UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:pvc];
+        [[self.delegate requireNavi] presentViewController:navi animated:YES completion:nil];
     }
 }
 

+ 4 - 2
wfuikit/WFChatUIKit/Vendor/ChatInputBar/WFCUPluginBoardView.m

@@ -93,14 +93,16 @@
 #if WFCU_SUPPORT_VOIP
                               [[PluginItem alloc] initWithTitle:@"视频通话" image:[UIImage imageNamed:@"chat_input_plugin_video_call"] tag:4],
 #endif
-                              [[PluginItem alloc] initWithTitle:@"文件" image:[UIImage imageNamed:@"chat_input_plugin_file"] tag:5]
+                              [[PluginItem alloc] initWithTitle:@"文件" image:[UIImage imageNamed:@"chat_input_plugin_file"] tag:5],
+                              [[PluginItem alloc] initWithTitle:@"名片" image:[UIImage imageNamed:@"chat_input_plugin_file"] tag:6]
                               ] mutableCopy];
         } else {
             _pluginItems = [@[
                               [[PluginItem alloc] initWithTitle:WFCString(@"Album") image:[UIImage imageNamed:@"chat_input_plugin_album"] tag:1],
                               [[PluginItem alloc] initWithTitle:@"拍摄" image:[UIImage imageNamed:@"chat_input_plugin_camera"] tag:2],
                               [[PluginItem alloc] initWithTitle:@"位置" image:[UIImage imageNamed:@"chat_input_plugin_location"] tag:3],
-                              [[PluginItem alloc] initWithTitle:@"文件" image:[UIImage imageNamed:@"chat_input_plugin_file"] tag:5]
+                              [[PluginItem alloc] initWithTitle:@"文件" image:[UIImage imageNamed:@"chat_input_plugin_file"] tag:5],
+                              [[PluginItem alloc] initWithTitle:@"名片" image:[UIImage imageNamed:@"chat_input_plugin_file"] tag:6]
                               ] mutableCopy];
         }