forked from tbl00c/TLChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
103 changed files
with
1,101 additions
and
1,042 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
...ules/Contacts/TLContactsSearchResultViewController/TLContactsSearchResultViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// TLContactsSearchResultViewController.h | ||
// TLChat | ||
// | ||
// Created by 李伯坤 on 16/1/25. | ||
// Copyright © 2016年 李伯坤. All rights reserved. | ||
// | ||
|
||
#import "TLViewController.h" | ||
#import "TLSearchControllerProtocol.h" | ||
|
||
#define HEIGHT_FRIEND_CELL 54.0f | ||
|
||
@class TLUser; | ||
@interface TLContactsSearchResultViewController : TLViewController <TLSearchControllerProtocol> | ||
|
||
@property (nonatomic, copy) void (^itemSelectedAction)(TLContactsSearchResultViewController *searchVC, TLUser *userModel); | ||
|
||
@end |
87 changes: 87 additions & 0 deletions
87
...ules/Contacts/TLContactsSearchResultViewController/TLContactsSearchResultViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// | ||
// TLContactsSearchResultViewController.m | ||
// TLChat | ||
// | ||
// Created by 李伯坤 on 16/1/25. | ||
// Copyright © 2016年 李伯坤. All rights reserved. | ||
// | ||
|
||
#import "TLContactsSearchResultViewController.h" | ||
#import "TLContactsItemCell.h" | ||
#import "TLFriendHelper.h" | ||
|
||
@interface TLContactsSearchResultViewController () | ||
|
||
@property (nonatomic, strong) UITableView *tableView; | ||
|
||
@property (nonatomic, strong) ZZFLEXAngel *tableViewAngel; | ||
|
||
@property (nonatomic, strong) NSMutableArray *friendsData; | ||
|
||
@end | ||
|
||
@implementation TLContactsSearchResultViewController | ||
|
||
- (void)loadView | ||
{ | ||
[super loadView]; | ||
[self setStatusBarStyle:UIStatusBarStyleDefault]; | ||
|
||
self.tableView = self.view.addTableView(1) | ||
.backgroundColor([UIColor colorGrayBG]).separatorStyle(UITableViewCellSeparatorStyleNone) | ||
.tableFooterView([UIView new]) | ||
.estimatedRowHeight(0).estimatedSectionFooterHeight(0).estimatedSectionHeaderHeight(0) | ||
.masonry(^ (MASConstraintMaker *make) { | ||
make.edges.mas_equalTo(0); | ||
}) | ||
.view; | ||
|
||
self.tableViewAngel = [[ZZFLEXAngel alloc] initWithHostView:self.tableView]; | ||
} | ||
|
||
- (void)viewDidLoad | ||
{ | ||
[super viewDidLoad]; | ||
|
||
self.friendsData = [TLFriendHelper sharedFriendHelper].friendsData; | ||
} | ||
|
||
//MARK: UISearchResultsUpdating | ||
- (void)updateSearchResultsForSearchController:(UISearchController *)searchController | ||
{ | ||
TLContactsItemModel *(^createContactsItemModelWithUserModel)(TLUser *userModel) = ^TLContactsItemModel *(TLUser *userModel){ | ||
TLContactsItemModel *model = createContactsItemModel(userModel.avatarPath, userModel.avatarURL, userModel.showName, userModel.detailInfo.remarkInfo, userModel); | ||
return model; | ||
}; | ||
|
||
// 查找数据 | ||
NSString *searchText = [searchController.searchBar.text lowercaseString]; | ||
NSMutableArray *data = [[NSMutableArray alloc] init]; | ||
for (TLUser *user in self.friendsData) { | ||
if ([user.remarkName containsString:searchText] || [user.username containsString:searchText] || [user.nikeName containsString:searchText] || [user.pinyin containsString:searchText] || [user.pinyinInitial containsString:searchText]) { | ||
TLContactsItemModel *model = createContactsItemModelWithUserModel(user); | ||
[data addObject:model]; | ||
} | ||
} | ||
|
||
// 更新UI | ||
self.tableViewAngel.clear(); | ||
if (data.count > 0) { | ||
self.tableViewAngel.addSection(0); | ||
self.tableViewAngel.setHeader(@"TLContactsHeaderView").toSection(0).withDataModel(@"联系人"); | ||
self.tableViewAngel.addCells(@"TLContactsItemCell").toSection(0).withDataModelArray(data).selectedAction(^ (TLContactsItemModel *model) { | ||
if (self.itemSelectedAction) { | ||
self.itemSelectedAction(self, model.userInfo); | ||
} | ||
}); | ||
} | ||
[self.tableView reloadData]; | ||
} | ||
|
||
//MARK: UISearchBarDelegate | ||
- (void)searchBarBookmarkButtonClicked:(UISearchBar *)searchBar | ||
{ | ||
[TLUIUtility showAlertWithTitle:@"语音搜索按钮"]; | ||
} | ||
|
||
@end |
32 changes: 32 additions & 0 deletions
32
TLChat/Modules/Contacts/TLContactsViewController/TLContactsAngel.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// TLContactsAngel.h | ||
// TLChat | ||
// | ||
// Created by 李伯坤 on 2018/1/8. | ||
// Copyright © 2018年 李伯坤. All rights reserved. | ||
// | ||
|
||
#import <ZZFlexibleLayoutFramework/ZZFlexibleLayoutFramework.h> | ||
|
||
typedef NS_ENUM(NSInteger, TLContactsVCSectionType) { | ||
TLContactsVCSectionTypeFuncation = -1, | ||
TLContactsVCSectionTypeEnterprise = -2, | ||
}; | ||
|
||
typedef NS_ENUM(NSInteger, TLContactsVCCellType) { | ||
TLContactsVCCellTypeNew = -1, | ||
TLContactsVCCellTypeGroup = -2, | ||
TLContactsVCCellTypeTag = -3, | ||
TLContactsVCCellTypePublic = -4, | ||
}; | ||
|
||
@interface TLContactsAngel : ZZFLEXAngel | ||
|
||
/// pushAction | ||
@property (nonatomic, copy) void (^pushAction)(__kindof UIViewController *vc); | ||
|
||
- (void)resetListWithContactsData:(NSArray *)contactsData sectionHeaders:(NSArray *)sectionHeaders; | ||
|
||
- (instancetype)initWithHostView:(__kindof UIScrollView *)hostView pushAction:(void (^)(__kindof UIViewController *vc))pushAction; | ||
|
||
@end |
120 changes: 120 additions & 0 deletions
120
TLChat/Modules/Contacts/TLContactsViewController/TLContactsAngel.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
// | ||
// TLContactsAngel.m | ||
// TLChat | ||
// | ||
// Created by 李伯坤 on 2018/1/8. | ||
// Copyright © 2018年 李伯坤. All rights reserved. | ||
// | ||
|
||
#import "TLContactsAngel.h" | ||
#import "TLUserGroup.h" | ||
#import "TLContactsItemCell.h" | ||
|
||
#import "TLNewFriendViewController.h" | ||
#import "TLGroupViewController.h" | ||
#import "TLTagsViewController.h" | ||
#import "TLServiceAccountViewController.h" | ||
#import "TLUserDetailViewController.h" | ||
|
||
@interface TLContactsAngel () | ||
|
||
/// header | ||
@property (nonatomic, strong) NSArray *sectionHeaders; | ||
|
||
@end | ||
|
||
@implementation TLContactsAngel | ||
|
||
- (instancetype)initWithHostView:(__kindof UIScrollView *)hostView pushAction:(void (^)(__kindof UIViewController *vc))pushAction | ||
{ | ||
if (self = [super initWithHostView:hostView]) { | ||
self.pushAction = pushAction; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)resetListWithContactsData:(NSArray *)contactsData sectionHeaders:(NSArray *)sectionHeaders | ||
{ | ||
@weakify(self); | ||
self.clear(); | ||
|
||
/// 功能 | ||
self.addSection(TLContactsVCSectionTypeFuncation); | ||
{ | ||
TLContactsItemModel *newModel = createContactsItemModelWithTag(TLContactsVCCellTypeNew, @"friends_new", nil, LOCSTR(@"新的朋友"), nil, nil); | ||
TLContactsItemModel *groupModel = createContactsItemModelWithTag(TLContactsVCCellTypeGroup, @"friends_group", nil, LOCSTR(@"群聊"), nil, nil); | ||
TLContactsItemModel *tagModel = createContactsItemModelWithTag(TLContactsVCCellTypeTag, @"friends_tag", nil, LOCSTR(@"标签"), nil, nil); | ||
TLContactsItemModel *publicModel = createContactsItemModelWithTag(TLContactsVCCellTypePublic, @"friends_public", nil, LOCSTR(@"公共号"), nil, nil); | ||
NSArray *funcationData = @[newModel, groupModel, tagModel, publicModel]; | ||
self.addCells(NSStringFromClass([TLContactsItemCell class])).toSection(TLContactsVCSectionTypeFuncation).withDataModelArray(funcationData).selectedAction(^ (TLContactsItemModel *model) { | ||
@strongify(self); | ||
if (model.tag == TLContactsVCCellTypeNew) { | ||
TLNewFriendViewController *newFriendVC = [[TLNewFriendViewController alloc] init]; | ||
[self tryPushVC:newFriendVC]; | ||
} | ||
else if (model.tag == TLContactsVCCellTypeGroup) { | ||
TLGroupViewController *groupVC = [[TLGroupViewController alloc] init]; | ||
[self tryPushVC:groupVC]; | ||
} | ||
else if (model.tag == TLContactsVCCellTypeTag) { | ||
TLTagsViewController *tagsVC = [[TLTagsViewController alloc] init]; | ||
[self tryPushVC:tagsVC]; | ||
} | ||
else if (model.tag == TLContactsVCCellTypePublic) { | ||
TLServiceAccountViewController *publicServerVC = [[TLServiceAccountViewController alloc] init]; | ||
[self tryPushVC:publicServerVC]; | ||
} | ||
}); | ||
} | ||
// 企业 | ||
self.addSection(TLContactsVCSectionTypeEnterprise); | ||
|
||
// 好友 | ||
TLContactsItemModel *(^createContactsItemModelWithUserModel)(TLUser *userModel) = ^TLContactsItemModel *(TLUser *userModel){ | ||
TLContactsItemModel *model = createContactsItemModel(userModel.avatarPath, userModel.avatarURL, userModel.showName, userModel.detailInfo.remarkInfo, userModel); | ||
return model; | ||
}; | ||
for (TLUserGroup *group in contactsData) { | ||
NSInteger sectionTag = group.tag; | ||
self.addSection(sectionTag); | ||
self.setHeader(@"TLContactsHeaderView").toSection(sectionTag).withDataModel(group.groupName); | ||
|
||
NSMutableArray *data = [[NSMutableArray alloc]initWithCapacity:group.users.count]; | ||
for (TLUser *user in group.users) { | ||
TLContactsItemModel *newModel = createContactsItemModelWithUserModel(user); | ||
[data addObject:newModel]; | ||
} | ||
self.addCells(NSStringFromClass([TLContactsItemCell class])).toSection(sectionTag).withDataModelArray(data).selectedAction(^ (TLContactsItemModel *data) { | ||
@strongify(self); | ||
TLUser *user = data.userInfo; | ||
TLUserDetailViewController *detailVC = [[TLUserDetailViewController alloc] initWithUserModel:user]; | ||
[self tryPushVC:detailVC]; | ||
}); | ||
} | ||
} | ||
|
||
- (void)tryPushVC:(__kindof UIViewController *)vc | ||
{ | ||
if (self.pushAction) { | ||
self.pushAction(vc); | ||
} | ||
} | ||
|
||
#pragma mark - # Delegate | ||
// 拼音首字母检索 | ||
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView | ||
{ | ||
return self.sectionHeaders; | ||
} | ||
|
||
// 检索时空出搜索框 | ||
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index | ||
{ | ||
if(index == 0) { | ||
[tableView scrollRectToVisible:CGRectMake(0, 0, tableView.width, tableView.height) animated:NO]; | ||
return -1; | ||
} | ||
return index; | ||
} | ||
|
||
@end |
14 changes: 14 additions & 0 deletions
14
TLChat/Modules/Contacts/TLContactsViewController/TLContactsViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// TLContactsViewController.h | ||
// TLChat | ||
// | ||
// Created by 李伯坤 on 16/1/23. | ||
// Copyright © 2016年 李伯坤. All rights reserved. | ||
// | ||
|
||
#import "TLViewController.h" | ||
|
||
@interface TLContactsViewController : TLViewController | ||
|
||
|
||
@end |
Oops, something went wrong.