Skip to content

Commit 0aa609e

Browse files
author
mengyaoyao
committed
UI部分实现 , 结构调整
1 parent 2b381d7 commit 0aa609e

File tree

104 files changed

+2698
-722
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+2698
-722
lines changed

CocoaAsyncSocket_TCP.xcodeproj/project.pbxproj

Lines changed: 310 additions & 142 deletions
Large diffs are not rendered by default.

CocoaAsyncSocket_TCP/.DS_Store

2 KB
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// AppDelegate+main.h
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/12.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import "AppDelegate.h"
10+
11+
@interface AppDelegate (main)
12+
13+
- (void)initMainController;
14+
15+
@end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// AppDelegate+main.m
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/12.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import "AppDelegate+main.h"
10+
#import "ChatNavigationController.h"
11+
#import "ChatListViewController.h"
12+
13+
@implementation AppDelegate (main)
14+
15+
- (void)initMainController
16+
{
17+
self.window = [[UIWindow alloc]initWithFrame:SCREEN_BOUNDS];
18+
ChatListViewController *chatlistVC= [[ChatListViewController alloc]init];
19+
ChatNavigationController *nav = [[ChatNavigationController alloc]initWithRootViewController:chatlistVC];
20+
self.window.rootViewController = nav;
21+
[self.window makeKeyAndVisible];
22+
}
23+
24+
25+
26+
@end

CocoaAsyncSocket_TCP/AppDelegate.m renamed to CocoaAsyncSocket_TCP/AppDelegate/AppDelegate.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#import "AppDelegate.h"
1010
#import "RealReachability.h"
11-
11+
#import "AppDelegate+main.h"
1212

1313
@interface AppDelegate ()
1414

@@ -19,6 +19,8 @@ @implementation AppDelegate
1919

2020
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
2121

22+
//加载主控制器
23+
[self initMainController];
2224
//开启网络监听
2325
[GLobalRealReachability startNotifier];
2426

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "universal",
9+
"filename" : "grey_bell@2x.png",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"filename" : "grey_bell@3x.png",
15+
"scale" : "3x"
16+
}
17+
],
18+
"info" : {
19+
"version" : 1,
20+
"author" : "xcode"
21+
}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"scale" : "1x"
6+
},
7+
{
8+
"idiom" : "universal",
9+
"filename" : "userhead@2x.png",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"filename" : "userhead@3x.png",
15+
"scale" : "3x"
16+
}
17+
],
18+
"info" : {
19+
"version" : 1,
20+
"author" : "xcode"
21+
}
22+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ChatUtil.h
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/12.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface ChatUtil : NSObject
12+
13+
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ChatUtil.m
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/12.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import "ChatUtil.h"
10+
11+
@implementation ChatUtil
12+
13+
@end

CocoaAsyncSocket_TCP/ChatModel/ChatModel.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,15 @@ typedef NS_ENUM(NSInteger){
9797

9898
@property (nonatomic, copy) NSString *nickName; //好友昵称
9999

100-
@property (nonatomic, strong) NSNumber *noDisturb; //免打扰状态
100+
@property (nonatomic, strong) NSNumber *noDisturb; //免打扰状态 , 1为正常接收 , 2为免打扰状态 , 3为屏蔽状态
101101

102-
@property (nonatomic, copy) ChatContentModel *content; //内容
102+
@property (nonatomic, strong) ChatContentModel *content; //内容
103+
104+
105+
#pragma mark - chatlist独有部分
106+
@property (nonatomic, strong) NSNumber *unreadCount; //未读数
107+
@property (nonatomic, copy) NSString *lastMessage; //最后一条消息
108+
@property (nonatomic, copy) NSString *lastTimeString; //最后一条消息时间
103109

104110
@end
105111

CocoaAsyncSocket_TCP/ChatModel/ChatModel.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,34 @@
99

1010
@implementation ChatModel
1111

12+
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
13+
{
14+
15+
}
16+
17+
- (instancetype)init
18+
{
19+
if (self = [super init]) {
20+
self.senTime = getSendTime();
21+
}
22+
return self;
23+
}
24+
25+
NS_INLINE NSString *getSendTime() {
26+
UInt64 recordTime = [[NSDate date] timeIntervalSince1970]*1000;
27+
return [NSString stringWithFormat:@"%llu",recordTime];
28+
}
29+
30+
@end
31+
32+
33+
@implementation ChatContentModel
34+
35+
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
36+
{
37+
}
38+
39+
1240

1341

1442
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ChatBaseController.h
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/12.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface ChatBaseController : UIViewController
12+
13+
@end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// ChatBaseController.m
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/12.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import "ChatBaseController.h"
10+
11+
@interface ChatBaseController ()
12+
13+
@end
14+
15+
@implementation ChatBaseController
16+
17+
- (void)viewDidLoad {
18+
[super viewDidLoad];
19+
20+
self.view.backgroundColor = UIMainWhiteColor;
21+
}
22+
23+
24+
@end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// NSDate+extension.h
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/12.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface NSDate (extension)
12+
13+
//判断时间戳是否为当天,昨天,一周内,年月日
14+
+ (NSString *)timeStringWithTimeInterval:(NSString *)timeInterval;
15+
16+
@end
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
//
2+
// NSDate+extension.m
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/12.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import "NSDate+extension.h"
10+
11+
@implementation NSDate (extension)
12+
13+
+ (NSString *)timeStringWithTimeInterval:(NSString *)timeInterval
14+
{
15+
NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeInterval.longLongValue/1000]; //此处根据项目需求,选择是否除以1000 , 如果时间戳精确到秒则去掉1000
16+
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
17+
18+
//今天
19+
if ([date isToday]) {
20+
21+
formatter.dateFormat = @"HH:mm";
22+
23+
return [formatter stringFromDate:date];
24+
}else{
25+
26+
//昨天
27+
if ([date isYesterday]) {
28+
29+
formatter.dateFormat = @"昨天 HH:mm";
30+
return [formatter stringFromDate:date];
31+
32+
//一周内 [date weekdayStringFromDate]
33+
}else if ([date isSameWeek]){
34+
35+
formatter.dateFormat = [NSString stringWithFormat:@"%@ %@",[date weekdayStringFromDate],@"HH:mm"];
36+
return [formatter stringFromDate:date];
37+
38+
//直接显示年月日
39+
}else{
40+
41+
formatter.dateFormat = @"yy-MM-dd HH:mm";
42+
return [formatter stringFromDate:date];
43+
}
44+
}
45+
return nil;
46+
}
47+
48+
//是否在同一周
49+
- (BOOL)isSameWeek
50+
{
51+
NSCalendar *calendar = [NSCalendar currentCalendar];
52+
int unit = NSCalendarUnitWeekday | NSCalendarUnitMonth | NSCalendarUnitYear ;
53+
NSDateComponents *nowCmps = [calendar components:unit fromDate:[NSDate date]];
54+
NSDateComponents *selfCmps = [calendar components:unit fromDate:self];
55+
return (selfCmps.year == nowCmps.year) && (selfCmps.month == nowCmps.month) && (selfCmps.day == nowCmps.day);
56+
}
57+
58+
59+
//根据日期求星期几
60+
- (NSString *)weekdayStringFromDate{
61+
62+
NSArray *weekdays = [NSArray arrayWithObjects: [NSNull null], @"星期天", @"星期一", @"星期二", @"星期三", @"星期四", @"星期五", @"星期六", nil];
63+
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
64+
NSTimeZone *timeZone = [[NSTimeZone alloc] initWithName:@"Asia/Shanghai"];
65+
[calendar setTimeZone: timeZone];
66+
NSCalendarUnit calendarUnit = NSCalendarUnitWeekday;
67+
NSDateComponents *theComponents = [calendar components:calendarUnit fromDate:self];
68+
return [weekdays objectAtIndex:theComponents.weekday];
69+
}
70+
71+
72+
//是否为今天
73+
- (BOOL)isToday
74+
{
75+
NSCalendar *calendar = [NSCalendar currentCalendar];
76+
int unit = NSCalendarUnitDay | NSCalendarUnitMonth | NSCalendarUnitYear ;
77+
NSDateComponents *nowCmps = [calendar components:unit fromDate:[NSDate date]];
78+
NSDateComponents *selfCmps = [calendar components:unit fromDate:self];
79+
return (selfCmps.year == nowCmps.year) && (selfCmps.month == nowCmps.month) && (selfCmps.day == nowCmps.day);
80+
}
81+
82+
83+
84+
//是否为昨天
85+
- (BOOL)isYesterday
86+
{
87+
88+
NSDate *nowDate = [[NSDate date] dateWithYMD];
89+
NSDate *selfDate = [self dateWithYMD];
90+
NSCalendar *calendar = [NSCalendar currentCalendar];
91+
NSDateComponents *cmps = [calendar components:NSCalendarUnitDay fromDate:selfDate toDate:nowDate options:0];
92+
return cmps.day == 1;
93+
}
94+
95+
//格式化
96+
- (NSDate *)dateWithYMD
97+
{
98+
NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
99+
fmt.dateFormat = @"yyyy-MM-dd";
100+
NSString *selfStr = [fmt stringFromDate:self];
101+
return [fmt dateFromString:selfStr];
102+
}
103+
104+
@end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// UIImage+colorImage.h
3+
// CocoaAsyncSocket_TCP
4+
//
5+
// Created by 孟遥 on 2017/5/12.
6+
// Copyright © 2017年 mengyao. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface UIImage (colorImage)
12+
13+
+ (UIImage *)imageFromContextWithColor:(UIColor *)color; //一像素图片
14+
15+
+ (UIImage *)imageFromContextWithColor:(UIColor *)color size:(CGSize)size;
16+
17+
@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