Selaa lähdekoodia

【名片】UI显示及点击处理

heavyrain2012 4 vuotta sitten
vanhempi
sitoutus
bbfbbab6bb

+ 8 - 0
wfuikit/WFChatUIKit.xcodeproj/project.pbxproj

@@ -32,6 +32,8 @@
 		2B46D4DD24ACC9B900721792 /* MediaMessageGridViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B46D4DB24ACC9B900721792 /* MediaMessageGridViewCell.m */; };
 		2B63367E24716864008D6B38 /* ZCCCircleProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B63367C24716864008D6B38 /* ZCCCircleProgressView.m */; };
 		2B63367F24716864008D6B38 /* ZCCCircleProgressView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B63367D24716864008D6B38 /* ZCCCircleProgressView.h */; };
+		2B97D4892505C7BE00162A2B /* WFCUCardCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B97D4872505C7BE00162A2B /* WFCUCardCell.h */; };
+		2B97D48A2505C7BE00162A2B /* WFCUCardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B97D4882505C7BE00162A2B /* WFCUCardCell.m */; };
 		2BB4191624ED212200ABFEF1 /* WFCUUserMessageListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BB4191424ED212200ABFEF1 /* WFCUUserMessageListViewController.h */; };
 		2BB4191724ED212200ABFEF1 /* WFCUUserMessageListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2BB4191524ED212200ABFEF1 /* WFCUUserMessageListViewController.m */; };
 		2BD671A42336E821007A9FEC /* WFCUConfigManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BD671A22336E821007A9FEC /* WFCUConfigManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -460,6 +462,8 @@
 		2B46D4DB24ACC9B900721792 /* MediaMessageGridViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MediaMessageGridViewCell.m; sourceTree = "<group>"; };
 		2B63367C24716864008D6B38 /* ZCCCircleProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZCCCircleProgressView.m; sourceTree = "<group>"; };
 		2B63367D24716864008D6B38 /* ZCCCircleProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZCCCircleProgressView.h; sourceTree = "<group>"; };
+		2B97D4872505C7BE00162A2B /* WFCUCardCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WFCUCardCell.h; sourceTree = "<group>"; };
+		2B97D4882505C7BE00162A2B /* WFCUCardCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WFCUCardCell.m; sourceTree = "<group>"; };
 		2BB4191424ED212200ABFEF1 /* WFCUUserMessageListViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WFCUUserMessageListViewController.h; sourceTree = "<group>"; };
 		2BB4191524ED212200ABFEF1 /* WFCUUserMessageListViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WFCUUserMessageListViewController.m; sourceTree = "<group>"; };
 		2BCEC52D232E10DF00D55E0D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/wfc.strings; sourceTree = "<group>"; };
@@ -1143,6 +1147,8 @@
 				2B46D4DB24ACC9B900721792 /* MediaMessageGridViewCell.m */,
 				2F1EB5C12499AFF900FD3575 /* WFCUConferenceInviteCell.h */,
 				2F1EB5C22499AFF900FD3575 /* WFCUConferenceInviteCell.m */,
+				2B97D4872505C7BE00162A2B /* WFCUCardCell.h */,
+				2B97D4882505C7BE00162A2B /* WFCUCardCell.m */,
 			);
 			path = Cell;
 			sourceTree = "<group>";
@@ -1932,6 +1938,7 @@
 				2F551160217F5CC200F56C26 /* SDBrowserImageView.h in Headers */,
 				2F5510E4217F5CC200F56C26 /* WFCULocationPoint.h in Headers */,
 				2F5511DE217F5CC300F56C26 /* TYAlertScaleFadeAnimation.h in Headers */,
+				2B97D4892505C7BE00162A2B /* WFCUCardCell.h in Headers */,
 				2F5511C0217F5CC300F56C26 /* SDWebImageManager.h in Headers */,
 				2F551164217F5CC200F56C26 /* AFNetworkReachabilityManager.h in Headers */,
 				2F55110E217F5CC200F56C26 /* VideoPlayerSampleView.h in Headers */,
@@ -2228,6 +2235,7 @@
 				2F55110D217F5CC200F56C26 /* AirplayActiveView.m in Sources */,
 				2F5511D3217F5CC300F56C26 /* TYAlertScaleFadeAnimation.m in Sources */,
 				2F5511E2217F5CC300F56C26 /* YLImageView.m in Sources */,
+				2B97D48A2505C7BE00162A2B /* WFCUCardCell.m in Sources */,
 				2F55115B217F5CC200F56C26 /* SDPhotoBrowser.m in Sources */,
 				2F5511E8217F5CC300F56C26 /* WFCUShareMessageView.m in Sources */,
 				2F55121B217F5CC300F56C26 /* WFCUMessageNotificationViewController.m in Sources */,

+ 12 - 0
wfuikit/WFChatUIKit/MessageList/Cell/WFCUCardCell.h

@@ -0,0 +1,12 @@
+//
+//  WFCUCardCell.h
+//  WFChat UIKit
+//
+//  Created by WF Chat on 2017/9/1.
+//  Copyright © 2017年 WildFireChat. All rights reserved.
+//
+
+#import "WFCUMessageCell.h"
+
+@interface WFCUCardCell : WFCUMessageCell
+@end

+ 102 - 0
wfuikit/WFChatUIKit/MessageList/Cell/WFCUCardCell.m

@@ -0,0 +1,102 @@
+//
+//  WFCUCardCell.m
+//  WFChat UIKit
+//
+//  Created by WF Chat on 2017/9/1.
+//  Copyright © 2017年 WildFireChat. All rights reserved.
+//
+
+#import "WFCUCardCell.h"
+#import <WFChatClient/WFCChatClient.h>
+#import "WFCUUtilities.h"
+#import "UILabel+YBAttributeTextTapAction.h"
+#import "SDWebImage.h"
+
+
+#define TEXT_TOP_PADDING 6
+#define TEXT_BUTTOM_PADDING 6
+#define TEXT_LEFT_PADDING 8
+#define TEXT_RIGHT_PADDING 8
+
+
+#define TEXT_LABEL_TOP_PADDING TEXT_TOP_PADDING + 4
+#define TEXT_LABEL_BUTTOM_PADDING TEXT_BUTTOM_PADDING + 4
+#define TEXT_LABEL_LEFT_PADDING 30
+#define TEXT_LABEL_RIGHT_PADDING 30
+
+@interface WFCUCardCell ()
+@property (nonatomic, strong)UIImageView *cardPortrait;
+@property (nonatomic, strong)UILabel *cardDisplayName;
+@property (nonatomic, strong)UILabel *cardName;
+@property (nonatomic, strong)UIView *cardSeparateLine;
+@property (nonatomic, strong)UILabel *cardHint;
+@end
+
+@implementation WFCUCardCell
+
++ (CGSize)sizeForClientArea:(WFCUMessageModel *)msgModel withViewWidth:(CGFloat)width {
+    return CGSizeMake(width, 100);
+}
+
+- (void)setModel:(WFCUMessageModel *)model {
+    [super setModel:model];
+    
+    WFCCCardMessageContent *content = (WFCCCardMessageContent *)model.message.content;
+    
+    self.cardDisplayName.text = content.displayName;
+    self.cardName.text = content.name;
+    [self.cardPortrait sd_setImageWithURL:[NSURL URLWithString:content.portrait] placeholderImage:[UIImage imageNamed:@"PersonalChat"]];
+    
+    [self cardSeparateLine];
+    [self cardHint];
+}
+
+- (UIImageView *)cardPortrait {
+    if (!_cardPortrait) {
+        _cardPortrait = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 56, 56)];
+        [self.contentArea addSubview:_cardPortrait];
+    }
+    return _cardPortrait;
+}
+
+- (UILabel *)cardDisplayName {
+    if (!_cardDisplayName) {
+        CGRect bounds = self.contentArea.bounds;
+        _cardDisplayName = [[UILabel alloc] initWithFrame:CGRectMake(72, 10, bounds.size.width - 72 - 8, 24)];
+        [self.contentArea addSubview:_cardDisplayName];
+    }
+    return _cardDisplayName;
+}
+
+- (UILabel *)cardName {
+    if (!_cardName) {
+        CGRect bounds = self.contentArea.bounds;
+        _cardName = [[UILabel alloc] initWithFrame:CGRectMake(72, 40, bounds.size.width - 72 - 8, 18)];
+        _cardName.font = [UIFont systemFontOfSize:14];
+        _cardName.textColor = [UIColor grayColor];
+        [self.contentArea addSubview:_cardName];
+    }
+    return _cardName;
+}
+
+- (UIView *)cardSeparateLine {
+    if (!_cardSeparateLine) {
+        CGRect bounds = self.contentArea.bounds;
+        _cardSeparateLine = [[UIView alloc] initWithFrame:CGRectMake(8, 78, bounds.size.width - 8 - 8, 1)];
+        _cardSeparateLine.backgroundColor = [UIColor grayColor];
+        [self.contentArea addSubview:_cardSeparateLine];
+    }
+    return _cardSeparateLine;
+}
+
+- (UILabel *)cardHint {
+    if (!_cardHint) {
+        _cardHint = [[UILabel alloc] initWithFrame:CGRectMake(8, 84, 80, 12)];
+        _cardHint.font = [UIFont systemFontOfSize:10];
+        _cardHint.text = @"个人名片";
+        _cardHint.textColor = [UIColor grayColor];
+        [self.contentArea addSubview:_cardHint];
+    }
+    return _cardHint;
+}
+@end

+ 14 - 0
wfuikit/WFChatUIKit/MessageList/ViewController/WFCUMessageListViewController.m

@@ -22,6 +22,7 @@
 #import "WFCUVideoCell.h"
 #import "WFCURecallCell.h"
 #import "WFCUConferenceInviteCell.h"
+#import "WFCUCardCell.h"
 #import "WFCUBrowserViewController.h"
 #import <WFChatClient/WFCChatClient.h>
 #import "WFCUProfileTableViewController.h"
@@ -688,6 +689,7 @@
     [self registerCell:[WFCUInformationCell class] forContent:[WFCCUnknownMessageContent class]];
     [self registerCell:[WFCURecallCell class] forContent:[WFCCRecallMessageContent class]];
     [self registerCell:[WFCUConferenceInviteCell class] forContent:[WFCCConferenceInviteMessageContent class]];
+    [self registerCell:[WFCUCardCell class] forContent:[WFCCCardMessageContent class]];
     
     
     [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"HeaderView"];
@@ -1460,6 +1462,16 @@
         
         WFCUConferenceViewController *vc = [[WFCUConferenceViewController alloc] initWithInvite:invite];
         [[WFAVEngineKit sharedEngineKit] presentViewController:vc];
+    } else if([model.message.content isKindOfClass:[WFCCCardMessageContent class]]) {
+        WFCCCardMessageContent *card = (WFCCCardMessageContent *)model.message.content;
+        
+        WFCCUserInfo *userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:card.userId refresh:NO];
+        if (!userInfo.deleted) {
+            WFCUProfileTableViewController *vc = [[WFCUProfileTableViewController alloc] init];
+            vc.userId = card.userId;
+            vc.hidesBottomBarWhenPushed = YES;
+            [self.navigationController pushViewController:vc animated:YES];
+        }
     }
 }
 
@@ -1883,6 +1895,8 @@
         [msg.content isKindOfClass:[WFCCLocationMessageContent class]] ||
         [msg.content isKindOfClass:[WFCCFileMessageContent class]] ||
         [msg.content isKindOfClass:[WFCCVideoMessageContent class]] ||
+        [msg.content isKindOfClass:[WFCUConferenceInviteCell class]] ||
+        [msg.content isKindOfClass:[WFCUCardCell class]] ||
         //        [msg.content isKindOfClass:[WFCCSoundMessageContent class]] || //语音消息禁止转发,出于安全原因考虑,微信就禁止转发。如果您能确保安全,可以把这行注释打开
         [msg.content isKindOfClass:[WFCCStickerMessageContent class]]) {
         [items addObject:forwardItem];