Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
@@ -0,0 +1,15 @@
//
// NTESJionTeamViewController.h
// NIM
//
// Created by Xuhui on 15/3/19.
// Copyright (c) 2015年 Netease. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NTESJionTeamViewController : UIViewController
@property (nonatomic, strong) NIMTeam *joinTeam;
@end
@@ -0,0 +1,87 @@
//
// NTESJionTeamViewController.m
// NIM
//
// Created by Xuhui on 15/3/19.
// Copyright (c) 2015年 Netease. All rights reserved.
//
#import "NTESJionTeamViewController.h"
#import "SVProgressHUD.h"
#import "Toast+UIView.h"
//#import "NTESSessionViewController.h"
#import "IfishSessionViewController.h"
#import "UIAlertView+NTESBlock.h"
@interface NTESJionTeamViewController ()
@property (strong, nonatomic) IBOutlet UIImageView *imageView;
@property (strong, nonatomic) IBOutlet UILabel *teamNameLabel;
@property (strong, nonatomic) IBOutlet UIButton *jionTeamBtn;
@property (strong, nonatomic) IBOutlet UILabel *teamIdLabel;
@end
@implementation NTESJionTeamViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.navigationItem.title = @"加入群组";
self.teamNameLabel.text = self.joinTeam.teamName;
self.teamIdLabel.text = [NSString stringWithFormat:@"群号:%@", self.joinTeam.teamId];
if(self.joinTeam.joinMode == NIMTeamJoinModeRejectAll) {
[self.jionTeamBtn setTitle:@"该群无法申请加入" forState:UIControlStateNormal];
self.jionTeamBtn.userInteractionEnabled = NO;
}
}
- (IBAction)onJionTeamBtnClick:(id)sender {
__weak typeof(self) wself = self;
if(self.joinTeam.joinMode == NIMTeamJoinModeNoAuth) {
[self joinTeam:self.joinTeam.teamId withMessage:@""];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"输入验证信息" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert showAlertWithCompletionHandler:^(NSInteger index) {
NSString *message = [alert textFieldAtIndex:0].text ? : @"";
[wself joinTeam:wself.joinTeam.teamId withMessage:message];
}];
}
}
- (void)joinTeam:(NSString *)teamId withMessage:(NSString *)message {
[SVProgressHUD show];
[[NIMSDK sharedSDK].teamManager applyToTeam:self.joinTeam.teamId message:message completion:^(NSError *error,NIMTeamApplyStatus applyStatus) {
[SVProgressHUD dismiss];
if (!error) {
switch (applyStatus) {
case NIMTeamApplyStatusAlreadyInTeam:{
NIMSession *session = [NIMSession session:self.joinTeam.teamId type:NIMSessionTypeTeam];
IfishSessionViewController * vc = [[IfishSessionViewController alloc] initWithSession:session];
[self.navigationController pushViewController:vc animated:YES];
break;
}
case NIMTeamApplyStatusWaitForPass:
[self.view makeToast:@"申请成功,等待验证" ];
default:
break;
}
}else{
NSLog(@"Jion team failed: %@", error.localizedDescription);
switch (error.code) {
case NIMRemoteErrorCodeTeamAlreadyIn:
[self.view makeToast:@"已经在群里" ];
break;
default:
[self.view makeToast:@"群申请失败" ];
break;
}
}
NSLog(@"Jion team status: %zd", applyStatus);
}];
}
@end
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="NTESJionTeamViewController">
<connections>
<outlet property="imageView" destination="Z3H-L8-FB3" id="EDI-he-FVa"/>
<outlet property="jionTeamBtn" destination="eZV-LA-DJB" id="sJL-3I-rVb"/>
<outlet property="teamIdLabel" destination="VYu-pZ-RXs" id="nsd-ll-Jgs"/>
<outlet property="teamNameLabel" destination="tRI-15-kCr" id="D8d-Hn-bp5"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="范冰冰粉丝群" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="tRI-15-kCr">
<rect key="frame" x="0.0" y="170" width="320" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="VYu-pZ-RXs">
<rect key="frame" x="0.0" y="197" width="320" height="13"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" red="0.6705882352941176" green="0.6705882352941176" blue="0.6705882352941176" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar_team.png" id="Z3H-L8-FB3">
<rect key="frame" x="140" y="106" width="49" height="49"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="eZV-LA-DJB">
<rect key="frame" x="8" y="265" width="305" height="45"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="19"/>
<state key="normal" title="申请加入" backgroundImage="icon_cell_red_normal.png">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="onJionTeamBtnClick:" destination="-1" eventType="touchUpInside" id="ryP-9H-fMB"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<point key="canvasLocation" x="271" y="254"/>
</view>
</objects>
<resources>
<image name="avatar_team.png" width="50" height="50"/>
<image name="icon_cell_red_normal.png" width="304" height="45"/>
</resources>
</document>
@@ -0,0 +1,19 @@
//
// NTESPersonalCardViewController.h
// NIM
//
// Created by chris on 15/8/18.
// Copyright (c) 2015年 Netease. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ContactDataMember;
@interface NTESPersonalCardViewController : UIViewController
- (instancetype)initWithUserId:(NSString *)userId;
@property (nonatomic, strong) UITableView *tableView;
@end
@@ -0,0 +1,346 @@
//
// NTESPersonCardViewController.m
// NIM
//
// Created by chris on 15/8/18.
// Copyright (c) 2015年 Netease. All rights reserved.
//
#import "NTESPersonalCardViewController.h"
#import "NIMCommonTableDelegate.h"
#import "NIMCommonTableData.h"
#import "Toast+UIView.h"
#import "SVProgressHUD.h"
#import "NTESColorButtonCell.h"
#import "UIView+NTES.h"
//#import "NTESSessionViewController.h"
#import "IfishSessionViewController.h"
#import "NTESBundleSetting.h"
#import "UIAlertView+NTESBlock.h"
#import "NTESUserUtil.h"
//#import "NTESUserInfoSettingViewController.h"
//#import "NTESAliasSettingViewController.h"
@interface NTESPersonalCardViewController ()
@property (nonatomic,strong) NIMCommonTableDelegate *delegator;
@property (nonatomic,copy ) NSArray *data;
@property (nonatomic,copy ) NSString *userId;
@property (nonatomic,strong) NIMUser *user;
@property (nonatomic,strong) UILongPressGestureRecognizer *longPressGesture;
@end
@implementation NTESPersonalCardViewController
- (instancetype)initWithUserId:(NSString *)userId{
self = [super initWithNibName:nil bundle:nil];
if (self) {
_userId = userId;
}
return self;
}
- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpNav];
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onUserInfoHasUpdatedNotification:) name:NIMKitUserInfoHasUpdatedNotification object:nil];
__weak typeof(self) wself = self;
self.delegator = [[NIMCommonTableDelegate alloc] initWithTableData:^NSArray *{
return wself.data;
}];
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.tableView];
self.tableView.backgroundColor = UIColorFromRGB(0xe3e6ea);
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.delegate = self.delegator;
self.tableView.dataSource = self.delegator;
[self refresh];
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
self.longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onLongPressNavbar:)];
[self.navigationController.navigationBar addGestureRecognizer:self.longPressGesture];
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar removeGestureRecognizer:self.longPressGesture];
}
- (void)setUpNav{
self.navigationItem.title = @"个人名片";
if ([self.userId isEqualToString:[[NIMSDK sharedSDK].loginManager currentAccount]]) {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"编辑" style:UIBarButtonItemStyleDone target:self action:@selector(onActionEditMyInfo:)];
self.navigationItem.rightBarButtonItem.tintColor = [UIColor blackColor];
}
}
- (void)refresh{
self.user = [[NIMSDK sharedSDK].userManager userInfo:self.userId];
[self buildData];
[self.tableView reloadData];
}
- (void)buildData{
BOOL isMe = [self.userId isEqualToString:[NIMSDK sharedSDK].loginManager.currentAccount];
BOOL isMyFriend = [NTESUserUtil isMyFriend:self.userId];
BOOL isInBlackList = [[NIMSDK sharedSDK].userManager isUserInBlackList:self.userId];
BOOL needNotify = [[NIMSDK sharedSDK].userManager notifyForNewMsg:self.userId];
NSArray *data = @[
@{
HeaderTitle:@"",
RowContent :@[
@{
ExtraInfo : self.userId.length ? self.user.userId : [NSNull null],
CellClass : @"NTESCardPortraitCell",
RowHeight : @(100),
},
],
FooterTitle:@""
},
@{
HeaderTitle:@"",
RowContent :@[
@{
Title : @"备注名",
DetailTitle : self.user.alias.length ? self.user.alias : @"",
CellAction : @"onActionEditAlias:",
ShowAccessory: @(YES),
Disable : @(!isMyFriend),
},
@{
Title : @"生日",
DetailTitle : self.user.userInfo.birth.length ? self.user.userInfo.birth : @"",
Disable : @(!self.user.userInfo.birth.length),
},
@{
Title : @"手机",
DetailTitle : self.user.userInfo.mobile.length ? self.user.userInfo.mobile : @"",
Disable : @(!self.user.userInfo.mobile.length),
},
@{
Title : @"邮箱",
DetailTitle : self.user.userInfo.email.length ? self.user.userInfo.email : @"",
Disable : @(!self.user.userInfo.email.length),
},
@{
Title : @"签名",
DetailTitle : self.user.userInfo.sign.length ? self.user.userInfo.sign : @"",
Disable : @(!self.user.userInfo.sign.length),
},
],
FooterTitle:@""
},
@{
HeaderTitle:@"",
RowContent :@[
@{
Title : @"消息提醒",
CellClass : @"NTESSettingSwitcherCell",
CellAction : @"onActionNeedNotifyValueChange:",
ExtraInfo : @(needNotify),
Disable : @(isMe),
ForbidSelect : @(YES)
},
],
FooterTitle:@""
},
@{
HeaderTitle:@"",
RowContent :@[
@{
Title : @"黑名单",
CellClass : @"NTESSettingSwitcherCell",
CellAction : @"onActionBlackListValueChange:",
ExtraInfo : @(isInBlackList),
Disable : @(isMe),
ForbidSelect : @(YES)
},
],
FooterTitle:@""
},
@{
HeaderTitle:@"",
RowContent :@[
@{
Title : @"聊天",
CellClass : @"NTESColorButtonCell",
CellAction : @"chat",
ExtraInfo : @(ColorButtonCellStyleBlue),
Disable : @(isMe),
RowHeight : @(60),
ForbidSelect : @(YES),
SepLeftEdge : @(self.view.width),
},
@{
Title : @"删除好友",
CellClass : @"NTESColorButtonCell",
CellAction : @"deleteFriend",
ExtraInfo : @(ColorButtonCellStyleRed),
Disable : @(!isMyFriend || isMe),
RowHeight : @(60),
ForbidSelect : @(YES),
SepLeftEdge : @(self.view.width),
},
@{
Title : @"添加好友",
CellClass : @"NTESColorButtonCell",
CellAction : @"addFriend",
ExtraInfo : @(ColorButtonCellStyleBlue),
Disable : @(isMyFriend || isMe),
RowHeight : @(60),
ForbidSelect : @(YES),
SepLeftEdge : @(self.view.width),
},
],
FooterTitle:@"",
},
];
self.data = [NIMCommonTableSection sectionsWithData:data];
}
#pragma mark - Action
- (void)onActionEditAlias:(id)sender{
// NTESAliasSettingViewController *vc = [[NTESAliasSettingViewController alloc] initWithUserId:self.userId];
//[self.navigationController pushViewController:vc animated:YES];
}
- (void)onActionEditMyInfo:(id)sender{
//NTESUserInfoSettingViewController *vc = [[NTESUserInfoSettingViewController alloc] initWithNibName:nil bundle:nil];
//[self.navigationController pushViewController:vc animated:YES];
}
- (void)onActionBlackListValueChange:(id)sender{
UISwitch *switcher = sender;
[SVProgressHUD show];
__weak typeof(self) wself = self;
if (switcher.on) {
[[NIMSDK sharedSDK].userManager addToBlackList:self.userId completion:^(NSError *error) {
[SVProgressHUD dismiss];
if (!error) {
[wself.view makeToast:@"拉黑成功"];
}else{
[wself.view makeToast:@"拉黑失败"];
[wself refresh];
}
}];
}else{
[[NIMSDK sharedSDK].userManager removeFromBlackBlackList:self.userId completion:^(NSError *error) {
[SVProgressHUD dismiss];
if (!error) {
[wself.view makeToast:@"移除黑名单成功"];
}else{
[wself.view makeToast:@"移除黑名单失败"];
[wself refresh];
}
}];
}
}
- (void)onActionNeedNotifyValueChange:(id)sender{
UISwitch *switcher = sender;
[SVProgressHUD show];
__weak typeof(self) wself = self;
[[NIMSDK sharedSDK].userManager updateNotifyState:switcher.on forUser:self.userId completion:^(NSError *error) { [SVProgressHUD dismiss];
if (error) {
[wself.view makeToast:@"操作失败"];
[wself refresh];
}
}];
}
- (void)chat{
UINavigationController *nav = self.navigationController;
NIMSession *session = [NIMSession session:self.userId type:NIMSessionTypeP2P];
IfishSessionViewController *vc = [[IfishSessionViewController alloc] initWithSession:session];
[nav pushViewController:vc animated:YES];
UIViewController *root = nav.viewControllers[0];
nav.viewControllers = @[root,vc];
}
- (void)addFriend{
NIMUserRequest *request = [[NIMUserRequest alloc] init];
request.userId = self.userId;
request.operation = NIMUserOperationAdd;
if ([[NTESBundleSetting sharedConfig] needVerifyForFriend]) {
request.operation = NIMUserOperationRequest;
request.message = @"跪求通过";
}
NSString *successText = request.operation == NIMUserOperationAdd ? @"添加成功" : @"请求成功";
NSString *failedText = request.operation == NIMUserOperationAdd ? @"添加失败" : @"请求失败";
__weak typeof(self) wself = self;
[SVProgressHUD show];
[[NIMSDK sharedSDK].userManager requestFriend:request completion:^(NSError *error) {
[SVProgressHUD dismiss];
if (!error) {
[wself.view makeToast:successText
];
[wself refresh];
}else{
[wself.view makeToast:failedText
];
}
}];
}
- (void)deleteFriend{
__weak typeof(self) wself = self;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"删除好友" message:@"删除好友后,将同时解除双方的好友关系" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alert showAlertWithCompletionHandler:^(NSInteger index) {
if (index == 1) {
[SVProgressHUD show];
[[NIMSDK sharedSDK].userManager deleteFriend:wself.userId completion:^(NSError *error) {
[SVProgressHUD dismiss];
if (!error) {
[wself.view makeToast:@"删除成功"];
[wself refresh];
}else{
[wself.view makeToast:@"删除失败"];
}
}];
}
}];
}
- (void)onUserInfoHasUpdatedNotification:(NSNotification *)notification{
NSDictionary *userInfo = notification.userInfo;
//NSArray *userInfos = userInfo[NIMKitInfoKey];
//if ([userInfos containsObject:self.userId]) {
// [self refresh];
// }
}
#pragma mark - Private
- (void)onLongPressNavbar:(UIGestureRecognizer *)gesture{
if (gesture.state == UIGestureRecognizerStateBegan) {
NSString *title = self.user.description;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"个人信息" message:title delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
[alert show];
}
}
#pragma mark - 旋转处理 (iOS7)
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[self.tableView reloadData];
}
@end
@@ -0,0 +1,13 @@
//
// NTESSearchTeamViewController.h
// NIM
//
// Created by Xuhui on 15/3/19.
// Copyright (c) 2015年 Netease. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NTESSearchTeamViewController : UIViewController
@end
@@ -0,0 +1,54 @@
//
// NTESSearchTeamViewController.m
// NIM
//
// Created by Xuhui on 15/3/19.
// Copyright (c) 2015年 Netease. All rights reserved.
//
#import "NTESSearchTeamViewController.h"
#import "SVProgressHUD.h"
#import "Toast+UIView.h"
#import "NTESJionTeamViewController.h"
@interface NTESSearchTeamViewController () <UITextFieldDelegate>
@property (strong, nonatomic) IBOutlet UITextField *textField;
@end
@implementation NTESSearchTeamViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.navigationItem.title = @"搜索加入群组";
self.textField.delegate = self;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[self.textField endEditing:YES];
[SVProgressHUD show];
[[NIMSDK sharedSDK].teamManager fetchTeamInfo:textField.text completion:^(NSError *error, NIMTeam *team) {
[SVProgressHUD dismiss];
if(!error) {
NTESJionTeamViewController *vc = [[NTESJionTeamViewController alloc] initWithNibName:nil bundle:nil];
vc.joinTeam = team;
[self.navigationController pushViewController:vc animated:YES];
} else {
[self.view makeToast:error.localizedDescription];
NSLog(@"Fetch team info failed: %@", error.localizedDescription);
}
}];
return YES;
}
@end
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="NTESSearchTeamViewController">
<connections>
<outlet property="textField" destination="9Be-s1-ci0" id="1Vd-FS-SoI"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" id="DRj-Rf-1SB">
<rect key="frame" x="0.0" y="106" width="320" height="51"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入群号进行搜索" minimumFontSize="17" clearButtonMode="whileEditing" id="9Be-s1-ci0">
<rect key="frame" x="15" y="0.0" width="283" height="51"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation" returnKeyType="search"/>
</textField>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" red="0.86274509803921573" green="0.8784313725490196" blue="0.89803921568627454" alpha="1" colorSpace="calibratedRGB"/>
<point key="canvasLocation" x="271" y="254"/>
</view>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>
@@ -0,0 +1,17 @@
//
// NTESSessionCardViewController.h
// NIM
//
// Created by chris on 15/10/20.
// Copyright © 2015年 Netease. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NTESSessionCardViewController : UIViewController
@property (nonatomic,strong) UITableView *tableView;
- (instancetype)initWithSession:(NIMSession *)session;
@end
@@ -0,0 +1,158 @@
//
// NTESSessionCardViewController.m
// NIM
//
// Created by chris on 15/10/20.
// Copyright © 2015年 Netease. All rights reserved.
//
#import "NTESSessionCardViewController.h"
#import "NIMCommonTableDelegate.h"
#import "NIMCommonTableData.h"
#import "SVProgressHUD.h"
#import "Toast+UIView.h"
#import "NIMMemberGroupView.h"
#import "UIView+NTES.h"
#import "NIMContactSelectConfig.h"
#import "NIMContactSelectViewController.h"
//#import "NTESSessionViewController.h"
#import "IfishSessionViewController.h"
@interface NTESSessionCardViewController ()<NIMMemberGroupViewDelegate,NIMContactSelectDelegate>
@property (nonatomic,strong) NIMCommonTableDelegate *delegator;
@property (nonatomic,copy ) NSArray *data;
@property (nonatomic,strong) NIMSession *session;
@property (nonatomic,strong) NIMMemberGroupView *headerView;
@end
@implementation NTESSessionCardViewController
- (instancetype)initWithSession:(NIMSession *)session{
self = [super initWithNibName:nil bundle:nil];
if (self) {
_session = session;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"聊天信息";
__weak typeof(self) wself = self;
self.delegator = [[NIMCommonTableDelegate alloc] initWithTableData:^NSArray *{
return wself.data;
}];
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableView.backgroundColor = [UIColor colorWithRed:236.0/255.0 green:241.0/255.0 blue:245.0/255.0 alpha:1];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.delegate = self.delegator;
self.tableView.dataSource = self.delegator;
[self.view addSubview:self.tableView];
[self refresh];
}
- (void)refresh{
[self buildData];
[self bulidTableHeader:self.view.width];
[self.tableView reloadData];
}
- (void)buildData{
BOOL needNotify = [[NIMSDK sharedSDK].userManager notifyForNewMsg:self.session.sessionId];
NSArray *data = @[
@{
HeaderTitle:@"",
RowContent :@[
@{
Title : @"消息提醒",
CellClass : @"NTESSettingSwitcherCell",
RowHeight : @(50),
CellAction : @"onActionNeedNotifyValueChange:",
ExtraInfo : @(needNotify),
ForbidSelect : @(YES)
},
],
},
];
self.data = [NIMCommonTableSection sectionsWithData:data];
}
- (void)bulidTableHeader:(CGFloat)width{
self.headerView = [[NIMMemberGroupView alloc] initWithFrame:CGRectZero];
self.headerView.delegate = self;
[self.headerView refreshUids:@[self.session.sessionId] operators:CardHeaderOpeatorAdd];
[self.headerView setTitle:@"创建讨论组" forOperator:CardHeaderOpeatorAdd];
CGSize size = [self.headerView sizeThatFits:CGSizeMake(width, CGFLOAT_MAX)];
self.headerView.size = size;
self.tableView.tableHeaderView = self.headerView;
}
- (void)onActionNeedNotifyValueChange:(id)sender{
UISwitch *switcher = sender;
[SVProgressHUD show];
__weak typeof(self) wself = self;
[[NIMSDK sharedSDK].userManager updateNotifyState:switcher.on forUser:self.session.sessionId completion:^(NSError *error) {
[SVProgressHUD dismiss];
if (error) {
[wself.view makeToast:@"操作失败"];
[wself refresh];
}
}];
}
- (void)didSelectOperator:(NIMKitCardHeaderOpeator )opera{
if (opera == CardHeaderOpeatorAdd) {
NSMutableArray *users = [[NSMutableArray alloc] init];
NSString *currentUserID = [[[NIMSDK sharedSDK] loginManager] currentAccount];
[users addObject:currentUserID];
NIMContactFriendSelectConfig *config = [[NIMContactFriendSelectConfig alloc] init];
config.filterIds = users;
config.needMutiSelected = YES;
config.alreadySelectedMemberId = @[self.session.sessionId];
NIMContactSelectViewController *vc = [[NIMContactSelectViewController alloc] initWithConfig:config];
vc.delegate = self;
[vc show];
}
}
#pragma mark - ContactSelectDelegate
- (void)didFinishedSelect:(NSArray *)selectedContacts{
if (!selectedContacts.count) {
return;
}
NSString *uid = [[NIMSDK sharedSDK].loginManager currentAccount];
NSArray *users = [@[uid] arrayByAddingObjectsFromArray:selectedContacts];
NIMCreateTeamOption *option = [[NIMCreateTeamOption alloc] init];
option.name = @"讨论组";
option.type = NIMTeamTypeNormal;
__weak typeof(self) wself = self;
[SVProgressHUD show];
[[NIMSDK sharedSDK].teamManager createTeam:option
users:users
completion:^(NSError *error, NSString *teamId) {
[SVProgressHUD dismiss];
if (!error) {
NIMSession *session = [NIMSession session:teamId type:NIMSessionTypeTeam];
UINavigationController *nav = wself.navigationController;
[nav popToRootViewControllerAnimated:NO];
IfishSessionViewController *vc = [[IfishSessionViewController alloc] initWithSession:session];
[nav pushViewController:vc animated:YES];
}else{
[wself.view makeToast:@"创建讨论组失败" ];
}
}];
}
@end
@@ -0,0 +1,24 @@
//
// NTESTeamListViewController.h
// NIM
//
// Created by Xuhui on 15/3/3.
// Copyright (c) 2015年 Netease. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface NTESTeamListViewController : UIViewController
@end
@interface NTESAdvancedTeamListViewController : NTESTeamListViewController
@end
@interface NTESNormalTeamListViewController : NTESTeamListViewController
@end
@@ -0,0 +1,178 @@
//
// NTESTeamListViewController.m
// NIM
//
// Created by Xuhui on 15/3/3.
// Copyright (c) 2015年 Netease. All rights reserved.
//
#import "NTESTeamListViewController.h"
#import "IfishSessionViewController.h"
#import <NIMSDK/NIMSDK.h>
@interface NTESTeamListViewController () <UITableViewDelegate, UITableViewDataSource,NIMTeamManagerDelegate> {
}
@property (strong, nonatomic) IBOutlet UITableView *tableView;
@property (strong, nonatomic) NSMutableArray *myTeams;
@end
@implementation NTESTeamListViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)dealloc{
[[NIMSDK sharedSDK].teamManager removeDelegate:self];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.myTeams = [self fetchTeams];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.tableFooterView = [[UIView alloc]init];
[[NIMSDK sharedSDK].teamManager addDelegate:self];
}
- (NSMutableArray *)fetchTeams{
//subclass override
return nil;
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _myTeams.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TeamListCell"];
if(!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TeamListCell"];
}
NIMTeam *team = [_myTeams objectAtIndex:indexPath.row];
cell.textLabel.text = team.teamName;
return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 55.f;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
NIMTeam *team = [_myTeams objectAtIndex:indexPath.row];
NIMSession *session = [NIMSession session:team.teamId type:NIMSessionTypeTeam];
IfishSessionViewController *vc = [[IfishSessionViewController alloc] initWithSession:session];
[self.navigationController pushViewController:vc animated:YES];
}
@end
@implementation NTESAdvancedTeamListViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
self = [super initWithNibName:@"NTESTeamListViewController" bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad{
[super viewDidLoad];
self.navigationItem.title = @"高级群组";
}
- (NSMutableArray *)fetchTeams{
NSMutableArray *myTeams = [[NSMutableArray alloc]init];
for (NIMTeam *team in [NIMSDK sharedSDK].teamManager.allMyTeams) {
if (team.type == NIMTeamTypeAdvanced) {
[myTeams addObject:team];
}
}
return myTeams;
}
- (void)onTeamAdded:(NIMTeam *)team{
if (team.type == NIMTeamTypeAdvanced) {
self.myTeams = [self fetchTeams];
}
[self.tableView reloadData];
}
- (void)onTeamUpdated:(NIMTeam *)team{
if (team.type == NIMTeamTypeAdvanced) {
self.myTeams = [self fetchTeams];
}
[self.tableView reloadData];
}
- (void)onTeamRemoved:(NIMTeam *)team{
if (team.type == NIMTeamTypeAdvanced) {
self.myTeams = [self fetchTeams];
}
[self.tableView reloadData];
}
@end
@implementation NTESNormalTeamListViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
self = [super initWithNibName:@"NTESTeamListViewController" bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad{
[super viewDidLoad];
self.navigationItem.title = @"讨论组";
}
- (NSMutableArray *)fetchTeams{
NSMutableArray *myTeams = [[NSMutableArray alloc]init];
for (NIMTeam *team in [NIMSDK sharedSDK].teamManager.allMyTeams) {
if (team.type == NIMTeamTypeNormal) {
[myTeams addObject:team];
}
}
return myTeams;
}
- (void)onTeamUpdated:(NIMTeam *)team{
if (team.type == NIMTeamTypeNormal) {
self.myTeams = [self fetchTeams];
}
[self.tableView reloadData];
}
- (void)onTeamRemoved:(NIMTeam *)team{
if (team.type == NIMTeamTypeNormal) {
self.myTeams = [self fetchTeams];
}
[self.tableView reloadData];
}
- (void)onTeamAdded:(NIMTeam *)team{
if (team.type == NIMTeamTypeNormal) {
self.myTeams = [self fetchTeams];
}
[self.tableView reloadData];
}
@end
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="NTESTeamListViewController">
<connections>
<outlet property="tableView" destination="x6B-rS-SVj" id="IKV-Hp-LJq"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="x6B-rS-SVj">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<point key="canvasLocation" x="309" y="273"/>
</view>
</objects>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
</document>