Skip to content

Commit 384b3a4

Browse files
author
mengyaoyao
committed
UI部分更新
1 parent eb4ce8c commit 384b3a4

File tree

18 files changed

+1286
-13
lines changed

18 files changed

+1286
-13
lines changed

CocoaAsyncSocket_TCP.xcodeproj/project.pbxproj

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
B86DF3711EA0DB4A0089A05F /* CocoaAsyncSocket_TCPUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = B86DF3701EA0DB4A0089A05F /* CocoaAsyncSocket_TCPUITests.m */; };
4949
B86DF3811EA0DF990089A05F /* ChatHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = B86DF3801EA0DF990089A05F /* ChatHandler.m */; };
5050
B86DF3851EA0E72E0089A05F /* ChatModel.m in Sources */ = {isa = PBXBuildFile; fileRef = B86DF3841EA0E72E0089A05F /* ChatModel.m */; };
51+
B8843D5B1EC873A0006A01A4 /* MYCoreTextLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = B8843D561EC873A0006A01A4 /* MYCoreTextLabel.m */; };
52+
B8843D5C1EC873A0006A01A4 /* MYCoretextResultTool.m in Sources */ = {isa = PBXBuildFile; fileRef = B8843D581EC873A0006A01A4 /* MYCoretextResultTool.m */; };
53+
B8843D5D1EC873A0006A01A4 /* MYSubCoretextResult.m in Sources */ = {isa = PBXBuildFile; fileRef = B8843D5A1EC873A0006A01A4 /* MYSubCoretextResult.m */; };
54+
B8843D601EC8787C006A01A4 /* NSString+extension.m in Sources */ = {isa = PBXBuildFile; fileRef = B8843D5F1EC8787C006A01A4 /* NSString+extension.m */; };
5155
B8A7A0671EA9384000A75239 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B8A7A0661EA9384000A75239 /* SystemConfiguration.framework */; };
5256
C85C5D0ED7B51EAA0D860FC1 /* Pods_CocoaAsyncSocket_TCP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F875622A8064877AC67AF7B5 /* Pods_CocoaAsyncSocket_TCP.framework */; };
5357
/* End PBXBuildFile section */
@@ -155,6 +159,14 @@
155159
B86DF3801EA0DF990089A05F /* ChatHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatHandler.m; sourceTree = "<group>"; };
156160
B86DF3831EA0E72E0089A05F /* ChatModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatModel.h; sourceTree = "<group>"; };
157161
B86DF3841EA0E72E0089A05F /* ChatModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatModel.m; sourceTree = "<group>"; };
162+
B8843D551EC873A0006A01A4 /* MYCoreTextLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYCoreTextLabel.h; sourceTree = "<group>"; };
163+
B8843D561EC873A0006A01A4 /* MYCoreTextLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYCoreTextLabel.m; sourceTree = "<group>"; };
164+
B8843D571EC873A0006A01A4 /* MYCoretextResultTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYCoretextResultTool.h; sourceTree = "<group>"; };
165+
B8843D581EC873A0006A01A4 /* MYCoretextResultTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYCoretextResultTool.m; sourceTree = "<group>"; };
166+
B8843D591EC873A0006A01A4 /* MYSubCoretextResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYSubCoretextResult.h; sourceTree = "<group>"; };
167+
B8843D5A1EC873A0006A01A4 /* MYSubCoretextResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYSubCoretextResult.m; sourceTree = "<group>"; };
168+
B8843D5E1EC8787C006A01A4 /* NSString+extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+extension.h"; sourceTree = "<group>"; };
169+
B8843D5F1EC8787C006A01A4 /* NSString+extension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+extension.m"; sourceTree = "<group>"; };
158170
B8A7A0661EA9384000A75239 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
159171
CAE613590B9AA7B46799B48A /* Pods-CocoaAsyncSocket_TCP.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CocoaAsyncSocket_TCP.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CocoaAsyncSocket_TCP/Pods-CocoaAsyncSocket_TCP.debug.xcconfig"; sourceTree = "<group>"; };
160172
F875622A8064877AC67AF7B5 /* Pods_CocoaAsyncSocket_TCP.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CocoaAsyncSocket_TCP.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -199,6 +211,7 @@
199211
B84506211EC59D83004366C3 /* Comon */ = {
200212
isa = PBXGroup;
201213
children = (
214+
B8843D531EC87366006A01A4 /* Helper */,
202215
B845068B1EC5AB8E004366C3 /* Category */,
203216
B84506221EC59D83004366C3 /* Account */,
204217
B84506271EC59D83004366C3 /* BaseController */,
@@ -366,6 +379,8 @@
366379
B84506931EC5AD49004366C3 /* UIImage+colorImage.m */,
367380
B84506981EC5B277004366C3 /* NSDate+extension.h */,
368381
B84506991EC5B277004366C3 /* NSDate+extension.m */,
382+
B8843D5E1EC8787C006A01A4 /* NSString+extension.h */,
383+
B8843D5F1EC8787C006A01A4 /* NSString+extension.m */,
369384
);
370385
path = Category;
371386
sourceTree = "<group>";
@@ -456,6 +471,27 @@
456471
path = ChatModel;
457472
sourceTree = "<group>";
458473
};
474+
B8843D531EC87366006A01A4 /* Helper */ = {
475+
isa = PBXGroup;
476+
children = (
477+
B8843D541EC873A0006A01A4 /* MYCoreTextLabel */,
478+
);
479+
path = Helper;
480+
sourceTree = "<group>";
481+
};
482+
B8843D541EC873A0006A01A4 /* MYCoreTextLabel */ = {
483+
isa = PBXGroup;
484+
children = (
485+
B8843D551EC873A0006A01A4 /* MYCoreTextLabel.h */,
486+
B8843D561EC873A0006A01A4 /* MYCoreTextLabel.m */,
487+
B8843D571EC873A0006A01A4 /* MYCoretextResultTool.h */,
488+
B8843D581EC873A0006A01A4 /* MYCoretextResultTool.m */,
489+
B8843D591EC873A0006A01A4 /* MYSubCoretextResult.h */,
490+
B8843D5A1EC873A0006A01A4 /* MYSubCoretextResult.m */,
491+
);
492+
path = MYCoreTextLabel;
493+
sourceTree = "<group>";
494+
};
459495
DE44A4FA10870B8DE9660954 /* Frameworks */ = {
460496
isa = PBXGroup;
461497
children = (
@@ -670,16 +706,20 @@
670706
B84506551EC59D83004366C3 /* ReachState.m in Sources */,
671707
B84506791EC59DEF004366C3 /* ChatFileCell.m in Sources */,
672708
B84506651EC59DD1004366C3 /* ChatViewController.m in Sources */,
709+
B8843D5B1EC873A0006A01A4 /* MYCoreTextLabel.m in Sources */,
673710
B86DF3811EA0DF990089A05F /* ChatHandler.m in Sources */,
711+
B8843D5C1EC873A0006A01A4 /* MYCoretextResultTool.m in Sources */,
674712
B845064F1EC59D83004366C3 /* AccountTool.m in Sources */,
675713
B86DF3851EA0E72E0089A05F /* ChatModel.m in Sources */,
676714
B84506541EC59D83004366C3 /* FSMStateUtil.m in Sources */,
677715
B84506941EC5AD49004366C3 /* UIImage+colorImage.m in Sources */,
716+
B8843D5D1EC873A0006A01A4 /* MYSubCoretextResult.m in Sources */,
678717
B845065B1EC59D83004366C3 /* PingFoundation.m in Sources */,
679718
B84506871EC59E1F004366C3 /* AppDelegate.m in Sources */,
680719
B845067B1EC59DEF004366C3 /* ChatTextCell.m in Sources */,
681720
B845068E1EC5ABB5004366C3 /* UIImageView+SDWebImage.m in Sources */,
682721
B84506521EC59D83004366C3 /* LocalConnection.m in Sources */,
722+
B8843D601EC8787C006A01A4 /* NSString+extension.m in Sources */,
683723
B86DF34D1EA0DB4A0089A05F /* main.m in Sources */,
684724
B84506581EC59D83004366C3 /* ReachStateUnReachable.m in Sources */,
685725
B845067C1EC59DEF004366C3 /* ChatTipCell.m in Sources */,

CocoaAsyncSocket_TCP/ChatHandler/ChatUtil.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
#import <Foundation/Foundation.h>
1010

11+
@class ChatModel;
12+
1113
@interface ChatUtil : NSObject
1214

15+
//消息高度计算
16+
+ (CGFloat)heightForMessage:(ChatModel *)currentChatmodel premodel:(ChatModel *)premodel;
17+
1318
@end

CocoaAsyncSocket_TCP/ChatHandler/ChatUtil.m

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,59 @@
77
//
88

99
#import "ChatUtil.h"
10+
#import "ChatModel.h"
1011

1112
@implementation ChatUtil
1213

14+
+ (void)shouldShowTime:(ChatModel *)currentmodel premodel:(ChatModel *)premodel
15+
{
16+
if (!premodel) {
17+
currentmodel.showTime = !premodel;
18+
}
19+
//取最后两个时间戳比较时间
20+
NSInteger length = (currentmodel.sendTime.longLongValue-premodel.sendTime.longLongValue)/1000; //socket处时间戳多了三位
21+
22+
if (length>60) {
23+
24+
currentmodel.showTime = YES;
25+
}else{
26+
currentmodel.showTime = NO;
27+
}
28+
}
29+
30+
#pragma mark - 消息高度计算
31+
+ (CGFloat)heightForMessage:(ChatModel *)currentChatmodel premodel:(ChatModel *)premodel
32+
{
33+
//是否显示时间
34+
[self shouldShowTime:currentChatmodel premodel:premodel];
35+
36+
CGFloat height = 0.f;
37+
//文本,表情
38+
if (hashEqual(currentChatmodel.contenType, Content_Text)) {
39+
40+
return currentChatmodel.messageHeight = currentChatmodel.shouldShowTime ? height + 40 : height;
41+
//语音
42+
}else if (hashEqual(currentChatmodel.contenType, Content_Audio)){
43+
44+
return currentChatmodel.messageHeight = currentChatmodel.shouldShowTime ? height + 40 : height;
45+
//图片
46+
}else if (hashEqual(currentChatmodel.contenType, Content_Picture)){
47+
48+
return currentChatmodel.messageHeight = currentChatmodel.shouldShowTime ? height + 40 : height;
49+
//视频
50+
}else if (hashEqual(currentChatmodel.contenType, Content_Video)){
51+
52+
return currentChatmodel.messageHeight = currentChatmodel.shouldShowTime ? height + 40 : height;
53+
//文件
54+
}else if (hashEqual(currentChatmodel.contenType, Content_File)){
55+
56+
return currentChatmodel.messageHeight = currentChatmodel.shouldShowTime ? height + 40 : height;
57+
//提示语
58+
}else{
59+
60+
return currentChatmodel.messageHeight = currentChatmodel.shouldShowTime ? height + 40 : height;;
61+
}
62+
}
63+
64+
1365
@end

CocoaAsyncSocket_TCP/ChatModel/ChatModel.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ typedef NS_ENUM(NSInteger){
8787

8888
@property (nonatomic, strong) NSNumber *isRead; //是否已读
8989

90-
@property (nonatomic, copy) NSString *senTime; //时间戳
90+
@property (nonatomic, copy) NSString *sendTime; //时间戳
9191

9292
@property (nonatomic, copy) NSString *beatID; //心跳标识
9393

@@ -107,6 +107,13 @@ typedef NS_ENUM(NSInteger){
107107
@property (nonatomic, copy) NSString *lastMessage; //最后一条消息
108108
@property (nonatomic, copy) NSString *lastTimeString; //最后一条消息时间
109109

110+
111+
112+
113+
#pragma mark - 额外需要部分属性
114+
@property (nonatomic , assign) CGFloat messageHeight; //消息高度
115+
@property (nonatomic, assign,getter=shouldShowTime) BOOL showTime; // 是否展示时间
116+
110117
@end
111118

112119

CocoaAsyncSocket_TCP/ChatModel/ChatModel.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ - (void)setValue:(id)value forUndefinedKey:(NSString *)key
1717
- (instancetype)init
1818
{
1919
if (self = [super init]) {
20-
self.senTime = getSendTime();
20+
self.sendTime = getSendTime();
2121
}
2222
return self;
2323
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// NSString+extension.h
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/14.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface NSString (extension)
12+
13+
- (CGSize)sizeWithFont:(UIFont *)font maxSize:(CGSize)maxSize;
14+
15+
16+
+ (CGSize)stringSizeWithContainer:(UIView *)container maxSize:(CGSize)maxSize;
17+
18+
@end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// NSString+extension.m
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/14.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import "NSString+extension.h"
10+
11+
@implementation NSString (extension)
12+
13+
- (CGSize)sizeWithFont:(UIFont *)font maxSize:(CGSize)maxSize
14+
{
15+
NSDictionary *dict = @{NSFontAttributeName: font};
16+
CGSize textSize = [self boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil].size;
17+
return textSize;
18+
}
19+
20+
21+
+ (CGSize)stringSizeWithContainer:(UIView *)container maxSize:(CGSize)maxSize
22+
{
23+
if (!container) {
24+
return CGSizeZero;
25+
}
26+
CGSize needSize = [container sizeThatFits:maxSize];
27+
return needSize;
28+
}
29+
30+
@end

CocoaAsyncSocket_TCP/Comon/Constant.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ static NSString *Content_Audio = @"audio"; //语音消息
3737
static NSString *Content_Picture = @"picture"; //图片消息
3838
static NSString *Content_Video = @"video"; //视频消息
3939
static NSString *Content_File = @"file"; //文件消息
40-
static NSString *Content_Repeal = @"repeal"; //撤回消息
41-
static NSString *Content_Tip = @"tip"; //提示消息
40+
static NSString *Content_Tip = @"tip"; //提示消息(欢迎XX加入群 , XX撤回了一条消息等)
4241

4342

4443
/*
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
//
2+
// MYCoreTextLabel.h
3+
// 图文混排demo
4+
//
5+
// Created by 孟遥 on 2017/2/5.
6+
// Copyright © 2017年 孟遥. All rights reserved.
7+
8+
/**
9+
10+
Github地址 : https://github.com/coderMyy/MYCoreTextLabel 求Star , Fork .....
11+
博客地址 : http://blog.csdn.net/codermy , 偶尔会记录一下学习的东西 .
12+
13+
*/
14+
15+
#import <UIKit/UIKit.h>
16+
#import "MYCoretextResultTool.h"
17+
/**
18+
事件回调
19+
20+
@param linkString <#linkString description#>
21+
*/
22+
typedef void(^eventCallback)(NSString *linkString);
23+
24+
@protocol MYCoreTextLabelDelegate <NSObject>
25+
26+
@optional
27+
28+
- (void)linkText:(NSString *)clickString type:(MYLinkType)linkType;
29+
30+
@end
31+
32+
@interface MYCoreTextLabel : UIView
33+
34+
/**
35+
链接属性 ,如不设置 , 默认14号字体 , 默认链接字颜色为蓝色 , 内容字颜色为黑色
36+
*/
37+
//@property (nonatomic, strong) MYAttributeModel *attribute;
38+
39+
/**
40+
代理
41+
*/
42+
@property (nonatomic, weak) id<MYCoreTextLabelDelegate> delegate;
43+
44+
/**
45+
表情/图片尺寸大小 ,默认和字体一致
46+
*/
47+
@property (nonatomic, assign) CGSize imageSize;
48+
49+
/**
50+
是否需要隐藏常规链接 如 http @xx #话题# 默认为NO ,如不需要展示常规链接,必须赋值为YES
51+
*/
52+
@property (nonatomic, assign) BOOL hiddenNormalLink;
53+
/**
54+
链接点中背景透明度
55+
*/
56+
@property (nonatomic, assign) CGFloat linkBackAlpha;
57+
58+
#pragma mark ---------------*******************************---------------- 普通文本部分属性
59+
/**
60+
内容字体大小(除开链接特殊字以外内容的字体大小),默认14.f
61+
*/
62+
@property (nonatomic, strong) UIFont *textFont;
63+
64+
/**
65+
内容字体颜色(除开链接特殊字以外的内容),默认黑色
66+
*/
67+
@property (nonatomic, strong) UIColor *textColor;
68+
69+
/**
70+
内容行间距
71+
*/
72+
@property (nonatomic, assign) CGFloat lineSpacing;
73+
74+
/**
75+
字间距
76+
*/
77+
@property (nonatomic, assign) CGFloat wordSpacing;
78+
79+
#pragma mark ---------------*******************************---------------- 常规链接部分属性
80+
/**
81+
常规链接字体颜色 http @xx #话题# 默认蓝色
82+
*/
83+
@property (nonatomic, strong) UIColor *norLinkColor;
84+
85+
/**
86+
常规链接字体大小 http @xx #话题# 默认14.f
87+
*/
88+
@property (nonatomic, strong) UIFont *norLinkFont;
89+
/**
90+
常规链接选中背景色 http @xx #话题# 默认蓝色 , 透明度 0.5
91+
*/
92+
@property (nonatomic, strong) UIColor *norLinkBackColor;
93+
94+
#pragma mark ---------------*******************************---------------- 自定义链接部分属性
95+
/**
96+
额外指定链接文字颜色 默认蓝色
97+
*/
98+
@property (nonatomic, strong) UIColor *customLinkColor;
99+
100+
/**
101+
额外指定链接文字大小 , 默认 14.f
102+
*/
103+
@property (nonatomic, strong) UIFont *customLinkFont;
104+
105+
/**
106+
额外指定链接文字选中背景 , 默认蓝色
107+
*/
108+
@property (nonatomic, strong) UIColor *customLinkBackColor;
109+
110+
#pragma mark ---------------*******************************---------------- 关键字部分属性
111+
112+
/**
113+
关键字颜色,默认黑色
114+
*/
115+
@property (nonatomic, strong) UIColor *keyWordColor;
116+
117+
/**
118+
关键字背景色 , 默认黄色
119+
*/
120+
@property (nonatomic, strong) UIColor *keyWordBackColor;
121+
122+
/**
123+
内容添加链接 , 如不需要额外的指定链接 , customLinks传nil ,默认显示常规链接 @ #话题# web
124+
你可以通过attribute的shouldShowNormLink属性设置是否显示最常规的链接
125+
126+
@param text <#text description#>
127+
@param customLinks <#otherlinks description#>
128+
*/
129+
- (void)setText:(NSString *)text customLinks:(NSArray<NSString *> *)customLinks keywords:(NSArray<NSString *> *)keywords;
130+
131+
@end

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy