Browse Source

no message

Fenix Wang 8 years ago
parent
commit
8f7dccddc8

BIN
NIMDemo/NIM.xcworkspace/xcuserdata/Fenix.xcuserdatad/UserInterfaceState.xcuserstate


+ 21 - 1
NIMDemo/NIMDemo/Base.lproj/Main.storyboard

@@ -72,7 +72,7 @@
             <objects>
                 <navigationController storyboardIdentifier="NavController" id="ryW-gA-XNT" sceneMemberID="viewController">
                     <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
-                    <navigationBar key="navigationBar" contentMode="scaleToFill" id="Hk7-II-cEF">
+                    <navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" id="Hk7-II-cEF">
                         <rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
                         <autoresizingMask key="autoresizingMask"/>
                     </navigationBar>
@@ -496,6 +496,25 @@
                             </subviews>
                             <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                         </view>
+                        <view key="tableFooterView" contentMode="scaleToFill" id="651-BK-ThX">
+                            <rect key="frame" x="0.0" y="558" width="375" height="84"/>
+                            <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
+                            <subviews>
+                                <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Vfb-dR-d1T">
+                                    <rect key="frame" x="20" y="20" width="335" height="44"/>
+                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
+                                    <color key="backgroundColor" red="0.8941891193" green="0.36060550810000003" blue="0.39614191650000002" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                    <state key="normal" title="移出群组">
+                                        <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                    </state>
+                                    <connections>
+                                        <action selector="onTouchKick:" destination="q1S-BA-Jr7" eventType="touchUpInside" id="yr0-6e-QeQ"/>
+                                    </connections>
+                                </button>
+                            </subviews>
+                            <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                        </view>
                         <sections>
                             <tableViewSection id="J0V-mP-F0F">
                                 <cells>
@@ -592,6 +611,7 @@
                         <outlet property="giftBtn" destination="mAS-7k-NBD" id="ZrF-Vd-WSO"/>
                         <outlet property="hobbyLabel" destination="WXV-0R-YkL" id="YOU-6h-UJM"/>
                         <outlet property="idLabel" destination="w19-Gn-s38" id="OCB-UZ-J0s"/>
+                        <outlet property="kickBtn" destination="Vfb-dR-d1T" id="Smv-6E-QQI"/>
                         <outlet property="morePicLabel" destination="l3J-w9-W6C" id="jTO-JC-Jge"/>
                         <outlet property="msgBtn" destination="jgM-DB-GXw" id="qW1-Wv-vuS"/>
                         <outlet property="nickLabel" destination="XLf-WR-37C" id="wdt-Ju-GD7"/>

+ 9 - 3
NIMDemo/NIMDemo/Classes/Sections/Session/ViewController/NTESSessionViewController.m

@@ -606,10 +606,16 @@ NIMSessionDelegate>
 }
 
 - (BOOL)onTapAvatar:(NSString *)userId{
-    //UIViewController *vc = [[NTESPersonalCardViewController alloc] initWithUserId:userId];
-    //[self.navigationController pushViewController:vc animated:YES];
     
-    [User showUserInfo:userId viewController:self];
+    if(self.session.sessionType == NIMSessionTypeTeam && ![[User sharedInfo] isSystemTeam:self.session.sessionId])
+    {
+        NIMTeam *team = [[NIMSDK sharedSDK].teamManager teamById:self.session.sessionId];
+        [User showUserInfoWithTeam:userId team:team viewController:self];
+    }
+    else
+    {
+        [User showUserInfo:userId viewController:self];
+    }
     
     return YES;
 }

+ 9 - 0
NIMDemo/NIMDemo/FriendRequestTableViewCell.m

@@ -69,6 +69,15 @@
         _descLabel.text = friendRequestData.msg;
         
         _btn.hidden = NO;
+        
+        if(friendRequestData.type == 2)
+        {
+            [_btn setTitle:@"查看" forState:UIControlStateNormal];
+        }
+        else
+        {
+            [_btn setTitle:@"接受" forState:UIControlStateNormal];
+        }
     }
 //    else if([data isKindOfClass:[NIMSystemNotification class]])
 //    {

+ 14 - 1
NIMDemo/NIMDemo/FriendRequestViewController.m

@@ -149,7 +149,7 @@
     else if(friendRequestData.type == 1)
     {
         [SVProgressHUD show];
-        [[NIMSDK sharedSDK].teamManager applyToTeam:friendRequestData.extraId message:@"" completion:^(NSError *error, NIMTeamApplyStatus applyStatus) {
+        [[NIMSDK sharedSDK].teamManager applyToTeam:friendRequestData.extraId message:@"申请加入群" completion:^(NSError *error, NIMTeamApplyStatus applyStatus) {
             [SVProgressHUD dismiss];
             if (!error) {
                 switch (applyStatus) {
@@ -175,8 +175,21 @@
                     [wself.view makeToast:@"删除失败" duration:2.0 position:CSToastPositionCenter];
                 }];
             }
+            else
+            {
+                [wself.view makeToast:@"已经过期" duration:2.0 position:CSToastPositionCenter];
+                [[HttpRequest shared] deleteFriendRequest:friendRequestData.requestId success:^{
+                    [wself removeData:friendRequestData.requestId];
+                } failure:^{
+                    [wself.view makeToast:@"删除失败" duration:2.0 position:CSToastPositionCenter];
+                }];
+            }
         }];
     }
+    else if(friendRequestData.type == 2)
+    {
+        [User showUserInfo:friendRequestData.userId viewController:self];
+    }
 }
 
 

+ 6 - 0
NIMDemo/NIMDemo/GroupInfoViewController.m

@@ -221,6 +221,12 @@ UINavigationControllerDelegate>
     [self.navigationItem setTitle:navTitle];
 }
 
+- (void)viewDidAppear:(BOOL)animated{
+    [super viewDidAppear:animated];
+    
+    [self reloadData];
+}
+
 
 
 - (UITableView *)tableView

+ 4 - 1
NIMDemo/NIMDemo/SectionGroup/GroupMenberIcon.m

@@ -16,6 +16,7 @@
 
 @property (nonatomic, strong) NIMAvatarImageView            *avatarView;
 @property (nonatomic, strong) NSString                      *userId;
+@property (nonatomic, strong) NIMTeamMember                 *member;
 
 @end
 
@@ -43,13 +44,15 @@
     NSURL *url = info.avatarUrlString ? [NSURL URLWithString:info.avatarUrlString] : nil;
     [_avatarView nim_setImageWithURL:url placeholderImage:info.avatarImage];
     
+    _member = member;
     _userId = member.userId;
 }
 
 - (void)onTouchAvatar:(UITapGestureRecognizer *)gestureRecognizer{
     
     //UIView *viewClicked = [gestureRecognizer view];
-    [User showUserInfo:_userId viewController:self.viewController];
+    NIMTeam *team = [[NIMSDK sharedSDK].teamManager teamById:_member.teamId];
+    [User showUserInfoWithTeam:_userId team:team viewController:self.viewController];
     
 }
 

+ 20 - 2
NIMDemo/NIMDemo/SocialTableViewCell.m

@@ -31,6 +31,7 @@
 @property (nonatomic, strong) UIButton                  *likeBtn;
 @property (nonatomic, strong) UIButton                  *commentBtn;
 @property (nonatomic, strong) UIButton                  *deleteBtn;
+@property (nonatomic, strong) UIButton                  *locationBtn;
 
 @property (nonatomic, strong) UIView                    *likesContainer;
 @property (nonatomic, strong) UITextView                *likeUserNames;
@@ -88,6 +89,16 @@
     _picContainer = [[UIView alloc] initWithFrame:CGRectMake(contentX, _msgTxtView.bottom, cellWidth - 40 - contentX, 0)];
     [self addSubview:_picContainer];
     
+    _locationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    _locationBtn.frame = CGRectMake(contentX, _picContainer.bottom+5, 80, 24);
+    [_locationBtn setImage:[UIImage imageNamed:@"朋友圈发布_03"] forState:UIControlStateNormal];
+    _locationBtn.titleLabel.font = [UIFont systemFontOfSize:14];
+    _locationBtn.layer.cornerRadius = 12;
+    _locationBtn.layer.borderWidth = 1;
+    _locationBtn.layer.borderColor = UIColor.lightGrayColor.CGColor;
+    [_locationBtn setTitleColor:UIColor.lightGrayColor forState:UIControlStateNormal];
+    [self addSubview:_locationBtn];
+    
     _actionContainer = [[UIView alloc] initWithFrame:CGRectMake(contentX, _picContainer.bottom+5, cellWidth-contentX, 30)];
     [self addSubview:_actionContainer];
     
@@ -244,18 +255,25 @@
     
     _picContainer.top = _msgTxtView.bottom + 5;
     
+    [_locationBtn setTitle:_data.local forState:UIControlStateNormal];
+    [_locationBtn sizeToFit];
+    _locationBtn.width = _locationBtn.width + 12;
+    _locationBtn.height = 24;
+    
     if(_data.thumbArr.count > 0)
     {
         int rows = ceilf((float)_data.thumbArr.count / (float)columns);
         _picContainer.height = picSize * rows + picPadding * (rows - 1);
-        _actionContainer.top = _picContainer.bottom + 5;
+        _locationBtn.top = _picContainer.bottom + 5;
     }
     else
     {
         _picContainer.height = 0;
-        _actionContainer.top = _msgTxtView.bottom + 5;
+        _locationBtn.top = _msgTxtView.bottom + 5;
     }
     
+    _actionContainer.top = _locationBtn.bottom + 5;
+    
     [_timeLabel setText:_data.time];
     [_viewsBtn setTitle:[NSString stringWithFormat:@"%d", _data.views] forState:UIControlStateNormal];
     [_likeBtn setTitle:[NSString stringWithFormat:@"%d", _data.likes] forState:UIControlStateNormal];

+ 1 - 0
NIMDemo/NIMDemo/User.h

@@ -137,6 +137,7 @@
 + (NSString *_Nonnull)distance:(double)originLat originLng:(double)originLng targetLat:(double)targetLat targetLng:(double)targetLng;
 
 + (void)showUserInfo:(NSString *_Nullable)userId viewController:(UIViewController *_Nullable)viewController;
++ (void)showUserInfoWithTeam:(NSString *_Nullable)userId team:(NIMTeam *_Nullable)team viewController:(UIViewController *_Nullable)viewController;
 + (void)showUserInfoWithData:(UserInfo *_Nullable)userInfo viewController:(UIViewController *_Nullable)viewController;
 
 + (void)showTeamInfo:(NSString *_Nullable)teamId viewController:(UIViewController *_Nullable)viewController;

+ 25 - 1
NIMDemo/NIMDemo/User.m

@@ -144,6 +144,28 @@ int newCreateTeamId;
     }
 }
 
++ (void)showUserInfoWithTeam:(NSString *)userId team:(NIMTeam *)team viewController:(UIViewController *)viewController{
+    
+    NSLog(@"showUserInfo %@", userId);
+    
+    NSString *myUserId = [NIMSDK sharedSDK].loginManager.currentAccount;
+    if([userId isEqualToString:myUserId])
+    {
+        UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+        UIViewController *vc = [board instantiateViewControllerWithIdentifier:@"MyUserInfo"];
+        [viewController.navigationController pushViewController:vc animated:YES];
+    }
+    else
+    {
+        UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
+        UserInfoViewController *vc = [board instantiateViewControllerWithIdentifier:@"UserInfo"];
+        [vc setUserId:userId];
+        vc.team = team;
+        
+        [viewController.navigationController pushViewController:vc animated:YES];
+    }
+}
+
 + (void)showUserInfoWithData:(UserInfo *_Nullable)userInfo viewController:(UIViewController *_Nullable)viewController{
     NSString *myUserId = [NIMSDK sharedSDK].loginManager.currentAccount;
     if([userInfo.userId isEqualToString:myUserId])
@@ -163,6 +185,8 @@ int newCreateTeamId;
 }
 
 
+
+
 + (void)showTeamInfo:(NSString *_Nullable)teamId viewController:(UIViewController *_Nullable)viewController{
     
 //    if([[User sharedInfo] isSystemTeam:teamId])
@@ -708,7 +732,7 @@ int newCreateTeamId;
     
     NSString *alias = [[NIMKit sharedKit] getAlias:nimUser.userId];
     if(alias && alias.length > 0)
-        return nimUser.alias;
+        return alias;
     else if(nimUser.userInfo.nickName)
         return nimUser.userInfo.nickName;
     

+ 2 - 0
NIMDemo/NIMDemo/UserInfoViewController.h

@@ -11,6 +11,8 @@
 
 @interface UserInfoViewController : UITableViewController
 
+@property (nonatomic, strong) NIMTeam             *team;
+
 - (void)setUserId:(NSString *)userId;
 - (void)setUser:(UserInfo *)userInfo;
 

+ 49 - 0
NIMDemo/NIMDemo/UserInfoViewController.m

@@ -20,6 +20,8 @@
 #import "AddPhotoViewController.h"
 #import "ImagePagerViewController.h"
 #import "SocialTableViewController.h"
+#import "SVProgressHUD.h"
+#import "UIActionSheet+NTESBlock.h"
 
 @interface UserInfoViewController ()
 @property (weak, nonatomic) IBOutlet UIView *topView;
@@ -39,6 +41,7 @@
 @property (weak, nonatomic) IBOutlet UILabel *ageLabel;
 @property (weak, nonatomic) IBOutlet UILabel *hobbyLabel;
 @property (weak, nonatomic) IBOutlet UILabel *addressLabel;
+@property (weak, nonatomic) IBOutlet UIButton *kickBtn;
 
 
 @property (nonatomic, strong) NIMAvatarImageView  *avatar;
@@ -47,6 +50,7 @@
 @property (nonatomic, strong) UserInfo            *userInfo;
 @property (nonatomic, assign) int                 followState;
 
+
 @property (nonatomic, strong) NSMutableArray      *photoPicArr;
 @property (nonatomic, strong) NSMutableArray      *photoThumbArr;
 
@@ -74,6 +78,7 @@
     _msgBtn.layer.cornerRadius = _msgBtn.height/2;
     
     _giftBtn.layer.cornerRadius = _giftBtn.height/2;
+    _kickBtn.layer.cornerRadius = _kickBtn.height/2;
     
     if(_userInfo)
     {
@@ -134,6 +139,20 @@
     [self fetchNIMUser];
     [self fetchSocial];
     [self fetchGift];
+    [self checkTeamKick];
+}
+
+- (void)checkTeamKick
+{
+    if(_team == nil ||
+       ![_team.owner isEqualToString:[NIMSDK sharedSDK].loginManager.currentAccount] ||
+       [_team.owner isEqualToString:_userId])
+    {
+        _kickBtn.hidden = YES;
+        return;
+    }
+    
+    _kickBtn.hidden = NO;
 }
 
 - (void)fetchGift
@@ -405,4 +424,34 @@
     }
 }
 
+- (IBAction)onTouchKick:(id)sender {
+    if(_team == nil)
+    {
+        return;
+    }
+    
+    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"确定移除改成员?" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:nil, nil];
+    __weak UIActionSheet *wSheet;
+    __weak typeof(self) wself = self;
+    [sheet showInView:self.view completionHandler:^(NSInteger index) {
+        if (index == wSheet.destructiveButtonIndex) {
+            [wself removeMember];
+        }
+    }];
+    
+}
+
+- (void)removeMember{
+    [SVProgressHUD show];
+    [[NIMSDK sharedSDK].teamManager kickUsers:@[_userId] fromTeam:_team.teamId completion:^(NSError * _Nullable error) {
+        [SVProgressHUD dismiss];
+        if(!error) {
+            [self.view makeToast:@"移除成功"];
+            [self.navigationController popViewControllerAnimated:YES];
+        } else {
+            [self.view makeToast:@"移除失败"];
+        }
+    }];
+}
+
 @end