From 37d4f2a4e286f876a46cb602769e2c73cca9372e Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Mon, 27 Jun 2022 20:04:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=88=86=E4=BA=AB=E4=B8=BE?= =?UTF-8?q?=E6=8A=A5=E7=82=B9=E5=87=BB=E6=9F=A5=E7=9C=8B=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios.xcodeproj/project.pbxproj | 12 + .../UI/ShareView/Model/XPShareInfoModel.h | 7 + xplan-ios/Base/UI/ShareView/XPShareView.m | 17 +- xplan-ios/Global/XPEnum.h | 8 + xplan-ios/Global/XPHtmlUrl.h | 4 +- xplan-ios/Global/XPHtmlUrl.m | 3 +- .../SessionContent/ContentShareMonentsModel.h | 27 +++ .../SessionContent/ContentShareMonentsModel.m | 12 + .../Main/Mine/Model/Friend/FansInfoModel.h | 2 +- .../Friend/XPMineAttentionTableViewCell.m | 2 +- .../Cell/Friend/XPMineFansTableViewCell.m | 4 +- .../Friend/XPMineAttentionViewController.h | 13 +- .../Friend/XPMineAttentionViewController.m | 16 +- .../View/Friend/XPMineContactViewController.m | 6 +- .../View/Friend/XPMineFansViewController.h | 14 +- .../View/Friend/XPMineFansViewController.m | 15 +- .../View/Friend/XPMineFriendViewController.h | 12 +- .../View/Friend/XPMineFriendViewController.m | 16 +- .../View/Friend/XPMineShareViewController.h | 24 ++ .../View/Friend/XPMineShareViewController.m | 224 ++++++++++++++++++ .../Main/Monents/Model/MonentsInfoModel.h | 2 +- .../View/Cell/XPMonentsTableViewCell.m | 26 +- .../View/SubViews/XPMonentsPhotoView.h | 10 +- .../View/SubViews/XPMonentsPhotoView.m | 46 ++++ .../View/SubViews/XPMonentsTooBarView.m | 24 +- .../View/XPMonentsAttentionViewController.m | 22 +- .../View/XPMonentsDetailViewController.m | 23 +- .../View/XPMonentsLatestViewController.m | 9 +- .../View/XPMonentsRecommendViewController.m | 6 +- 29 files changed, 559 insertions(+), 47 deletions(-) create mode 100644 xplan-ios/Main/Message/Model/SessionContent/ContentShareMonentsModel.h create mode 100644 xplan-ios/Main/Message/Model/SessionContent/ContentShareMonentsModel.m create mode 100644 xplan-ios/Main/Mine/View/Friend/XPMineShareViewController.h create mode 100644 xplan-ios/Main/Mine/View/Friend/XPMineShareViewController.m diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index ccdd804d..588d53eb 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -953,6 +953,8 @@ E8F1558D28124D5200EE8C06 /* MessageConentAudioView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8F1558C28124D5200EE8C06 /* MessageConentAudioView.m */; }; E8F1559028125E2D00EE8C06 /* MessageAudioCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E8F1558F28125E2D00EE8C06 /* MessageAudioCenter.m */; }; E8F1559328129EBA00EE8C06 /* ContentSecretaryModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8F1559228129EBA00EE8C06 /* ContentSecretaryModel.m */; }; + E8F65C1F286998C9009BB5B9 /* XPMineShareViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8F65C1E286998C9009BB5B9 /* XPMineShareViewController.m */; }; + E8F65C222869A36F009BB5B9 /* ContentShareMonentsModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8F65C212869A36F009BB5B9 /* ContentShareMonentsModel.m */; }; E8F9168427EC913C00F10D8F /* XPHomeLittleGameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8F9168327EC913C00F10D8F /* XPHomeLittleGameViewController.m */; }; E8F9168727EC927C00F10D8F /* XPHomeLittleGamePesenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E8F9168627EC927C00F10D8F /* XPHomeLittleGamePesenter.m */; }; E8F9168B27EC940E00F10D8F /* XPHomeLittleGameTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8F9168A27EC940E00F10D8F /* XPHomeLittleGameTableViewCell.m */; }; @@ -2873,6 +2875,10 @@ E8F1558F28125E2D00EE8C06 /* MessageAudioCenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageAudioCenter.m; sourceTree = ""; }; E8F1559128129EBA00EE8C06 /* ContentSecretaryModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentSecretaryModel.h; sourceTree = ""; }; E8F1559228129EBA00EE8C06 /* ContentSecretaryModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ContentSecretaryModel.m; sourceTree = ""; }; + E8F65C1D286998C9009BB5B9 /* XPMineShareViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineShareViewController.h; sourceTree = ""; }; + E8F65C1E286998C9009BB5B9 /* XPMineShareViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineShareViewController.m; sourceTree = ""; }; + E8F65C202869A36F009BB5B9 /* ContentShareMonentsModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentShareMonentsModel.h; sourceTree = ""; }; + E8F65C212869A36F009BB5B9 /* ContentShareMonentsModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ContentShareMonentsModel.m; sourceTree = ""; }; E8F9168227EC913C00F10D8F /* XPHomeLittleGameViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomeLittleGameViewController.h; sourceTree = ""; }; E8F9168327EC913C00F10D8F /* XPHomeLittleGameViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPHomeLittleGameViewController.m; sourceTree = ""; }; E8F9168527EC927C00F10D8F /* XPHomeLittleGamePesenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPHomeLittleGamePesenter.h; sourceTree = ""; }; @@ -5307,6 +5313,8 @@ E86507E7281A8212006951B0 /* ContentTweetModel.m */, E86E79CE28A4E0B2006DAF48 /* ContentRistAlertModel.h */, E86E79CF28A4E0B2006DAF48 /* ContentRistAlertModel.m */, + E8F65C202869A36F009BB5B9 /* ContentShareMonentsModel.h */, + E8F65C212869A36F009BB5B9 /* ContentShareMonentsModel.m */, ); path = SessionContent; sourceTree = ""; @@ -6075,6 +6083,8 @@ E896EFA12771AE9400AD2CC1 /* XPMineFriendViewController.m */, E84CBCDF28436D3C00D43221 /* XPMineContactViewController.h */, E84CBCE028436D3C00D43221 /* XPMineContactViewController.m */, + E8F65C1D286998C9009BB5B9 /* XPMineShareViewController.h */, + E8F65C1E286998C9009BB5B9 /* XPMineShareViewController.m */, E84CBCE2284372D800D43221 /* XPRoomHalfMessageView.h */, E84CBCE3284372D800D43221 /* XPRoomHalfMessageView.m */, E8DAC5AA2858305A00012CFD /* XPRoomMessageBubbleView.h */, @@ -7844,6 +7854,7 @@ E8751E6628A6465A0056EF44 /* XPSailingRankSubView.m in Sources */, E86B911E2810351A0007DEE7 /* MessageToolMenuCollectionViewCell.m in Sources */, 9B2EA7C32804052E00ED17BF /* AnchorPKMicroView.m in Sources */, + E8F65C1F286998C9009BB5B9 /* XPMineShareViewController.m in Sources */, 181D7F1B2726CE2A00B7C059 /* StageView.m in Sources */, 18EE3FF12750D2AD00A452BF /* NIMTimeUtils.m in Sources */, E8ACEFEF27C8C45100F66D1A /* XPHomeHapppyRoomTableViewCell.m in Sources */, @@ -8226,6 +8237,7 @@ E8DEC99E2764A5B60078CB70 /* XPRoomMoreMenuViewController.m in Sources */, E82325F2274E2DE6003A3332 /* XPUserCardViewController.m in Sources */, E8E859D228264C2300EE4857 /* HTTPServer.m in Sources */, + E8F65C222869A36F009BB5B9 /* ContentShareMonentsModel.m in Sources */, E8C167182806A03800ECB15C /* XPSuperAdminSetPresenter.m in Sources */, 9B6E856E281AABAB0041A321 /* XPRoomRecommendModel.m in Sources */, E801274B27E327DA00BAC3F2 /* XPRoomPKTypeTableViewCell.m in Sources */, diff --git a/xplan-ios/Base/UI/ShareView/Model/XPShareInfoModel.h b/xplan-ios/Base/UI/ShareView/Model/XPShareInfoModel.h index efa5819f..16e5df16 100644 --- a/xplan-ios/Base/UI/ShareView/Model/XPShareInfoModel.h +++ b/xplan-ios/Base/UI/ShareView/Model/XPShareInfoModel.h @@ -34,6 +34,13 @@ typedef NS_ENUM(NSUInteger, ShareType) { @property (nonatomic,assign) NSInteger shareType; ///分享房间的uid @property (nonatomic,assign) NSInteger roomUid; +#pragma mark - 动态分享 +///被分享动态的那个人 +@property (nonatomic,copy) NSString *uid; +///动态分享 +@property (nonatomic,copy) NSString *dynamicId; +///话题id +@property (nonatomic,copy) NSString *worldId; @end diff --git a/xplan-ios/Base/UI/ShareView/XPShareView.m b/xplan-ios/Base/UI/ShareView/XPShareView.m index db147015..c54f8e91 100644 --- a/xplan-ios/Base/UI/ShareView/XPShareView.m +++ b/xplan-ios/Base/UI/ShareView/XPShareView.m @@ -14,8 +14,11 @@ ///Tool #import "XPMacro.h" #import "ThemeColor.h" +#import "XCCurrentVCStackManager.h" +#import "TTPopup.h" ///View #import "XPShareItemCell.h" +#import "XPMineShareViewController.h" @interface XPShareView() ///取消 @@ -110,13 +113,25 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ XPShareItemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPShareItemCell class]) forIndexPath:indexPath]; XPShareItem * item = [self.items objectAtIndex:indexPath.item]; - item.disable = [self isInstallClient:[self getSharePlatformType:item.type]]; + if (item.type == XPShareItemTagAppFriends) { + item.disable = YES; + } else { + item.disable = [self isInstallClient:[self getSharePlatformType:item.type]]; + } cell.shareItem = item; return cell; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ [collectionView deselectItemAtIndexPath:indexPath animated:YES]; XPShareItem * item = [self.items objectAtIndex:indexPath.item]; + if (item.type == XPShareItemTagAppFriends) { + [TTPopup dismiss]; + XPMineShareViewController * shareVC = [[XPMineShareViewController alloc] init]; + shareVC.shareType = MineShareType_Monents; + shareVC.shareInfo = self.shareInfo; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:shareVC animated:YES]; + return; + } self.shareInfo.shareType = item.type; NSMutableDictionary *shareParams = [NSMutableDictionary dictionary]; NSString * title = [self.shareInfo shareTitle].length > 0 ? self.shareInfo.shareTitle : @""; diff --git a/xplan-ios/Global/XPEnum.h b/xplan-ios/Global/XPEnum.h index 5f022ea5..72cd2772 100644 --- a/xplan-ios/Global/XPEnum.h +++ b/xplan-ios/Global/XPEnum.h @@ -73,5 +73,13 @@ typedef NS_ENUM(NSInteger, RoomPKResultType) { RoomPKResultType_Red = 2, //红方胜 }; +typedef NS_ENUM(NSInteger, ContactUseingType) { + ///默认 + ContactUseingType_Normal = 0, + ///在房间内 + ContactUseingType_In_Room = 1, + ///分享 + ContactUseingType_Share = 2, +}; #endif /* XPEnum_h */ diff --git a/xplan-ios/Global/XPHtmlUrl.h b/xplan-ios/Global/XPHtmlUrl.h index ab19221e..f44f1acf 100644 --- a/xplan-ios/Global/XPHtmlUrl.h +++ b/xplan-ios/Global/XPHtmlUrl.h @@ -77,7 +77,9 @@ typedef NS_ENUM(NSUInteger, URLType) { ///活动地址 kSailingActivityURL, ///网络整治乱象 - kNetworkRenovateURL + kNetworkRenovateURL, + ///动态分享 + kMonentsShareURL, }; NSString * const URLWithType(URLType type); diff --git a/xplan-ios/Global/XPHtmlUrl.m b/xplan-ios/Global/XPHtmlUrl.m index 28cb36a1..052b95f2 100644 --- a/xplan-ios/Global/XPHtmlUrl.m +++ b/xplan-ios/Global/XPHtmlUrl.m @@ -50,7 +50,8 @@ NSString * const URLWithType(URLType type) { @(kSailingActivityURL) : @"activity/act-sail/more.html", ///航海活动地址 @(kSailingPlayDescdURL) : @"activity/act-sail/play_explain.html", ///航海玩法规则 @(kSailingRecordURL) : @"activity/act-sail/win_record.html", ///航海中奖记录 - @(kNetworkRenovateURL) : @"activity/activemodel/index.html?code=ZBGG"///网络整治乱象 + @(kNetworkRenovateURL) : @"activity/activemodel/index.html?code=ZBGG",///网络整治乱象 + @(kMonentsShareURL) : @"modules/world/share-page/index.html",///分享动态 }; NSString * url = [dic objectForKey:@(type)]; diff --git a/xplan-ios/Main/Message/Model/SessionContent/ContentShareMonentsModel.h b/xplan-ios/Main/Message/Model/SessionContent/ContentShareMonentsModel.h new file mode 100644 index 00000000..2df8e6b0 --- /dev/null +++ b/xplan-ios/Main/Message/Model/SessionContent/ContentShareMonentsModel.h @@ -0,0 +1,27 @@ +// +// ContentShareMonentsModel.h +// xplan-ios +// +// Created by 冯硕 on 2022/6/27. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface ContentShareMonentsModel : NSObject +///动态内容 +@property (nonatomic,copy) NSString *content; +///动态id +@property (nonatomic,copy) NSString *dynamicId; +///头像 +@property (nonatomic,copy) NSString *avatar; +///标题 +@property (nonatomic,copy) NSString *title; +///跳转类型 +@property (nonatomic,assign) NSInteger routerType; +///跳转的id +@property (nonatomic,copy) NSString *routerValue; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Message/Model/SessionContent/ContentShareMonentsModel.m b/xplan-ios/Main/Message/Model/SessionContent/ContentShareMonentsModel.m new file mode 100644 index 00000000..597b217d --- /dev/null +++ b/xplan-ios/Main/Message/Model/SessionContent/ContentShareMonentsModel.m @@ -0,0 +1,12 @@ +// +// ContentShareMonentsModel.m +// xplan-ios +// +// Created by 冯硕 on 2022/6/27. +// + +#import "ContentShareMonentsModel.h" + +@implementation ContentShareMonentsModel + +@end diff --git a/xplan-ios/Main/Mine/Model/Friend/FansInfoModel.h b/xplan-ios/Main/Mine/Model/Friend/FansInfoModel.h index 39750053..5fb9a5ee 100644 --- a/xplan-ios/Main/Mine/Model/Friend/FansInfoModel.h +++ b/xplan-ios/Main/Mine/Model/Friend/FansInfoModel.h @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN ///贵族信息 @property (nonatomic, strong) UserVipInfoVo *userVipInfoVO; ///是否在房间中 本地字段 -@property (nonatomic,assign) BOOL isInRoom; +@property (nonatomic,assign) ContactUseingType useingType; @end diff --git a/xplan-ios/Main/Mine/View/Cell/Friend/XPMineAttentionTableViewCell.m b/xplan-ios/Main/Mine/View/Cell/Friend/XPMineAttentionTableViewCell.m index 8b11571c..3447db1b 100644 --- a/xplan-ios/Main/Mine/View/Cell/Friend/XPMineAttentionTableViewCell.m +++ b/xplan-ios/Main/Mine/View/Cell/Friend/XPMineAttentionTableViewCell.m @@ -113,7 +113,7 @@ self.avatarImageView.imageUrl = _fansInfo.avatar; self.nickLabel.text = _fansInfo.nick; self.signLabel.text = _fansInfo.userDesc && _fansInfo.userDesc.length > 0? _fansInfo.userDesc : @"这个人很懒还没有签名"; - if (!_fansInfo.isInRoom) { + if (_fansInfo.useingType != ContactUseingType_In_Room && _fansInfo.useingType != ContactUseingType_Share) { self.experImageView.hidden = NO; self.charmImageView.hidden = NO; self.nobleImageView.hidden = NO; diff --git a/xplan-ios/Main/Mine/View/Cell/Friend/XPMineFansTableViewCell.m b/xplan-ios/Main/Mine/View/Cell/Friend/XPMineFansTableViewCell.m index 88c77b74..c295052e 100644 --- a/xplan-ios/Main/Mine/View/Cell/Friend/XPMineFansTableViewCell.m +++ b/xplan-ios/Main/Mine/View/Cell/Friend/XPMineFansTableViewCell.m @@ -115,7 +115,7 @@ self.nickLabel.text = _fansInfo.nick; self.signLabel.text = _fansInfo.userDesc && _fansInfo.userDesc.length > 0? _fansInfo.userDesc : @"这个人很懒还没有签名"; - if (!_fansInfo.isInRoom) { + if (_fansInfo.useingType != ContactUseingType_In_Room && _fansInfo.useingType != ContactUseingType_Share) { self.experImageView.hidden = NO; self.charmImageView.hidden = NO; self.nobleImageView.hidden = NO; @@ -135,7 +135,7 @@ BOOL isMyFriend = [[NIMSDK sharedSDK].userManager isMyFriend:_fansInfo.uid]; self.attentionButton.enabled = !isMyFriend; - self.attentionButton.hidden = _fansInfo.isInRoom; + self.attentionButton.hidden = NO; UIImage* image = self.experImageView.image; if (image) { CGFloat scale = image.size.width / image.size.height; diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.h b/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.h index 8ea5a22c..6030c5c2 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.h +++ b/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.h @@ -7,11 +7,20 @@ #import "MvpViewController.h" #import +#import "XPEnum.h" NS_ASSUME_NONNULL_BEGIN +@class XPMineAttentionViewController, FansInfoModel; +@protocol XPMineAttentionViewControllerDelegate + +- (void)xPMineAttentionViewController:(XPMineAttentionViewController *)viewController didSelectItem:(FansInfoModel *)userInfo; + +@end @interface XPMineAttentionViewController : MvpViewController -//是否在房间内 -@property (nonatomic,assign) BOOL isInRoom; +///类型 +@property (nonatomic,assign) ContactUseingType type; +///代理 +@property (nonatomic,weak) id delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.m b/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.m index 8af648ce..9e0c120f 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.m +++ b/xplan-ios/Main/Mine/View/Friend/XPMineAttentionViewController.m @@ -43,7 +43,7 @@ @implementation XPMineAttentionViewController - (BOOL)isHiddenNavBar { - return self.isInRoom ? YES : NO; + return self.type == ContactUseingType_In_Room ? YES : NO; } - (XPMineAttentionPresenter *)createPresenter { @@ -132,7 +132,7 @@ } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return self.datasource.count > 0 ? 65 : self.isInRoom ? (KScreenHeight - kNavigationHeight) : (KScreenHeight - 200 - kNavigationHeight); + return self.datasource.count > 0 ? 65 : self.type == ContactUseingType_In_Room ? (KScreenHeight - kNavigationHeight) : (KScreenHeight - 200 - kNavigationHeight); } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -143,7 +143,7 @@ } cell.delegate = self; FansInfoModel * fansInfo = [self.datasource objectAtIndex:indexPath.row]; - fansInfo.isInRoom = self.isInRoom; + fansInfo.useingType = self.type; cell.fansInfo = fansInfo; return cell; } @@ -159,15 +159,17 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (self.datasource.count > 0) { - if (self.isInRoom) { - FansInfoModel * fansInfoModel = [self.datasource objectAtIndex:indexPath.row]; + FansInfoModel * fansInfoModel = [self.datasource objectAtIndex:indexPath.row]; + if (self.type == ContactUseingType_In_Room) { SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:[NIMSession session:fansInfoModel.uid type:NIMSessionTypeP2P]]; sessionVC.openType = SessionListOpenTypeRoom; [self.navigationController pushViewController:sessionVC animated:YES]; + } else if(self.type == ContactUseingType_Share){ + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineAttentionViewController:didSelectItem:)]) { + [self.delegate xPMineAttentionViewController:self didSelectItem:fansInfoModel]; + } } else { XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init]; - FansInfoModel * fansInfoModel = [self.datasource objectAtIndex:indexPath.row]; - fansInfoModel.isInRoom = self.isInRoom; userInfoVC.uid = fansInfoModel.uid.integerValue; [self.navigationController pushViewController:userInfoVC animated:YES]; } diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineContactViewController.m b/xplan-ios/Main/Mine/View/Friend/XPMineContactViewController.m index 6db54504..d1fda5cd 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineContactViewController.m +++ b/xplan-ios/Main/Mine/View/Friend/XPMineContactViewController.m @@ -146,7 +146,7 @@ - (XPMineAttentionViewController *)attentionVC { if (!_attentionVC) { _attentionVC = [[XPMineAttentionViewController alloc] init]; - _attentionVC.isInRoom = YES; + _attentionVC.type = ContactUseingType_In_Room; } return _attentionVC; } @@ -154,7 +154,7 @@ - (XPMineFriendViewController *)friendVC { if (!_friendVC) { _friendVC = [[XPMineFriendViewController alloc] init]; - _friendVC.isInRoom = YES; + _friendVC.type = ContactUseingType_In_Room; } return _friendVC; } @@ -162,7 +162,7 @@ - (XPMineFansViewController *)fansVC { if (!_fansVC) { _fansVC = [[XPMineFansViewController alloc] init]; - _fansVC.isInRoom = YES; + _fansVC.type = ContactUseingType_In_Room; } return _fansVC; } diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.h b/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.h index 89e87a32..5d1a4b9d 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.h +++ b/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.h @@ -7,11 +7,21 @@ #import "MvpViewController.h" #import +#import "XPEnum.h" NS_ASSUME_NONNULL_BEGIN +@class XPMineFansViewController, FansInfoModel; +@protocol XPMineFansViewControllerDelegate + +- (void)xPMineFansViewController:(XPMineFansViewController *)view didSelectItem:(FansInfoModel *)userInfo; + +@end @interface XPMineFansViewController : MvpViewController -///是否在房间内 -@property (nonatomic,assign) BOOL isInRoom; +///类型 +@property (nonatomic,assign) ContactUseingType type; +///代理 +@property (nonatomic,weak) id delegate; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.m b/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.m index 4bd0fd44..5dc98853 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.m +++ b/xplan-ios/Main/Mine/View/Friend/XPMineFansViewController.m @@ -38,7 +38,7 @@ @implementation XPMineFansViewController - (BOOL)isHiddenNavBar { - return self.isInRoom ? YES : NO; + return self.type == ContactUseingType_In_Room ? YES : NO; } - (XPMineFansPresenter *)createPresenter { @@ -142,7 +142,7 @@ } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return self.datasource.count > 0 ? 65 : self.isInRoom ? (KScreenHeight - kNavigationHeight) : (KScreenHeight - 200 - kNavigationHeight); + return self.datasource.count > 0 ? 65 : self.type == ContactUseingType_In_Room ? (KScreenHeight - kNavigationHeight) : (KScreenHeight - 200 - kNavigationHeight); } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { @@ -153,7 +153,7 @@ } cell.delegate = self; FansInfoModel * fansInfo = [self.datasource objectAtIndex:indexPath.row]; - fansInfo.isInRoom = self.isInRoom; + fansInfo.useingType = self.type; cell.fansInfo = fansInfo; return cell; } @@ -169,14 +169,17 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (self.datasource.count > 0) { - if (self.isInRoom) { - FansInfoModel * fansInfoModel = [self.datasource objectAtIndex:indexPath.row]; + FansInfoModel * fansInfoModel = [self.datasource objectAtIndex:indexPath.row]; + if (self.type == ContactUseingType_In_Room) { SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:[NIMSession session:fansInfoModel.uid type:NIMSessionTypeP2P]]; sessionVC.openType = SessionListOpenTypeRoom; [self.navigationController pushViewController:sessionVC animated:YES]; + } else if(self.type == ContactUseingType_Share) { + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineFansViewController:didSelectItem:)]) { + [self.delegate xPMineFansViewController:self didSelectItem:fansInfoModel]; + } } else { XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init]; - FansInfoModel * fansInfoModel = [self.datasource objectAtIndex:indexPath.row]; userInfoVC.uid = fansInfoModel.uid.integerValue; [self.navigationController pushViewController:userInfoVC animated:YES]; } diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.h b/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.h index 7c2a876c..b6d6a0f1 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.h +++ b/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.h @@ -7,11 +7,19 @@ #import "MvpViewController.h" #import +#import "XPEnum.h" NS_ASSUME_NONNULL_BEGIN +@class XPMineFriendViewController, UserInfoModel; +@protocol XPMineFriendViewControllerDelegate +- (void)xPMineFriendViewController:(XPMineFriendViewController *)viewController didSelectItem:(UserInfoModel *)userInfo; + +@end @interface XPMineFriendViewController : MvpViewController -//是否在房间内 -@property (nonatomic,assign) BOOL isInRoom; +///类型 +@property (nonatomic,assign) ContactUseingType type; +///代理 +@property (nonatomic,weak) id delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.m b/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.m index 8de1fe62..4f7cf251 100644 --- a/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.m +++ b/xplan-ios/Main/Mine/View/Friend/XPMineFriendViewController.m @@ -41,7 +41,7 @@ } - (BOOL)isHiddenNavBar { - return self.isInRoom ? YES : NO; + return self.type == ContactUseingType_In_Room ? YES : NO; } - (void)viewDidLoad { @@ -74,7 +74,7 @@ } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { - return self.datasource.count > 0 ? 65 : self.isInRoom ? (KScreenHeight - kNavigationHeight) : (KScreenHeight - 200 - kNavigationHeight); + return self.datasource.count > 0 ? 65 : self.type == ContactUseingType_In_Room ? (KScreenHeight - kNavigationHeight) : (KScreenHeight - 200 - kNavigationHeight); } @@ -100,9 +100,15 @@ [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (self.datasource.count > 0) { UserInfoModel * userInfo = [self.datasource objectAtIndex:indexPath.row]; - SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:[NIMSession session:[NSString stringWithFormat:@"%ld", userInfo.uid] type:NIMSessionTypeP2P]]; - sessionVC.openType = SessionListOpenTypeRoom; - [self.navigationController pushViewController:sessionVC animated:YES]; + if (self.type == ContactUseingType_Share) { + if (self.delegate && [self.delegate respondsToSelector:@selector(xPMineFriendViewController:didSelectItem:)]) { + [self.delegate xPMineFriendViewController:self didSelectItem:userInfo]; + } + } else { + SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:[NIMSession session:[NSString stringWithFormat:@"%ld", userInfo.uid] type:NIMSessionTypeP2P]]; + sessionVC.openType = SessionListOpenTypeRoom; + [self.navigationController pushViewController:sessionVC animated:YES]; + } } } diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineShareViewController.h b/xplan-ios/Main/Mine/View/Friend/XPMineShareViewController.h new file mode 100644 index 00000000..476a7b0c --- /dev/null +++ b/xplan-ios/Main/Mine/View/Friend/XPMineShareViewController.h @@ -0,0 +1,24 @@ +// +// XPMineShareViewController.h +// xplan-ios +// +// Created by 冯硕 on 2022/6/27. +// + +#import "BaseViewController.h" + +NS_ASSUME_NONNULL_BEGIN +@class XPShareInfoModel; + +typedef NS_ENUM(NSInteger, MineShareType) { + ///分享动态 + MineShareType_Monents = 1, +}; + +@interface XPMineShareViewController : BaseViewController +@property (nonatomic,strong) XPShareInfoModel *shareInfo; +///分享的类型 +@property (nonatomic,assign) MineShareType shareType; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Mine/View/Friend/XPMineShareViewController.m b/xplan-ios/Main/Mine/View/Friend/XPMineShareViewController.m new file mode 100644 index 00000000..0b9eddb4 --- /dev/null +++ b/xplan-ios/Main/Mine/View/Friend/XPMineShareViewController.m @@ -0,0 +1,224 @@ +// +// XPMineShareViewController.m +// xplan-ios +// +// Created by 冯硕 on 2022/6/27. +// + +#import "XPMineShareViewController.h" +///Third +#import +#import +#import +#import +///Tool +#import "ThemeColor.h" +#import "XPMacro.h" +#import "TTPopup.h" +///Model +#import "XPShareInfoModel.h" +#import "FansInfoModel.h" +#import "UserInfoModel.h" +#import "AttachMentModel.h" +#import "ContentShareMonentsModel.h" +///View +#import "SessionViewController.h" +#import "SessionListViewController.h" +#import "XPMineFriendViewController.h" +#import "XPMineAttentionViewController.h" +#import "XPMineFansViewController.h" +@interface XPMineShareViewController () +///标题 +@property (nonatomic,strong) NSArray *titles; +///滑块 +@property (nonatomic,strong) JXCategoryTitleView *titleView; +@property (nonatomic, strong) JXCategoryListContainerView *listContainerView; +///好友 +@property (nonatomic,strong) XPMineFriendViewController *friendVC; +///关注 +@property (nonatomic,strong) XPMineAttentionViewController *attentionVC; +///粉丝 +@property (nonatomic,strong) XPMineFansViewController *fansVC; +///回话的id +@property (nonatomic,copy) NSString *sessionId; +@end + +@implementation XPMineShareViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [self initSubViews]; + [self initSubViewConstraints]; +} + +#pragma mark - Private Method +- (void)initSubViews { + self.title = @"选择好友"; + [self.view addSubview:self.titleView]; + [self.view addSubview:self.listContainerView]; +} + +- (void)initSubViewConstraints { + [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.mas_equalTo(self.view); + make.height.mas_equalTo(50); + }]; + + [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.bottom.mas_equalTo(self.view); + make.top.mas_equalTo(self.titleView.mas_bottom); + }]; +} + +- (void)sendCustomMessage:(AttachmentModel *)attachment { + NIMMessage *message = [[NIMMessage alloc]init]; + NIMCustomObject *object = [[NIMCustomObject alloc] init]; + object.attachment = attachment; + message.messageObject = object; + NIMSessionType sessionType = NIMSessionTypeP2P; + //构造会话 + NIMSession *session = [NIMSession session:self.sessionId type:sessionType]; + [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil]; +} + +- (void)shareToUser:(NSString *)nick { + NSString * title; + AttachmentModel * attachment = [[AttachmentModel alloc] init]; + switch (self.shareType) { + case MineShareType_Monents: + { + title = [NSString stringWithFormat:@"确认分享给%@吗?", nick]; + attachment.first = CustomMessageType_Monents; + attachment.second = Custom_Message_Sub_Monents_Share; + ContentShareMonentsModel * shareInfo = [[ContentShareMonentsModel alloc] init]; + shareInfo.avatar = self.shareInfo.shareImageUrl; + shareInfo.title = self.shareInfo.shareTitle; + shareInfo.content = self.shareInfo.shareContent; + shareInfo.routerValue = self.shareInfo.dynamicId; + shareInfo.routerType = 50; + attachment.data = shareInfo.model2dictionary; + } + + break; + + default: + break; + } + if (title.length > 0) { + [TTPopup alertWithMessage:title confirmHandler:^{ + [self sendCustomMessage:attachment]; + } cancelHandler:^{ + + }]; + } +} + +#pragma mark - JXCategoryListContainerViewDelegate +- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView { + return self.titles.count; +} + +// 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例 +- (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index { + if (index == 0) { + return self.friendVC; + } else if(index == 1) { + return self.fansVC; + } else { + return self.attentionVC; + } +} + +#pragma mark - XPMineAttentionViewControllerDelegate +///点击了关注的某个人 +- (void)xPMineAttentionViewController:(XPMineAttentionViewController *)viewController didSelectItem:(FansInfoModel *)userInfo { + self.sessionId = userInfo.uid; + [self shareToUser:userInfo.nick]; +} + +#pragma mark - XPMineFansViewControllerDelegate +///点击了粉丝 +- (void)xPMineFansViewController:(XPMineFansViewController *)view didSelectItem:(FansInfoModel *)userInfo { + self.sessionId = userInfo.uid; + [self shareToUser:userInfo.nick]; +} + +#pragma mark - XPMineFriendViewControllerDelegate +///点击了好友 +- (void)xPMineFriendViewController:(XPMineFriendViewController *)viewController didSelectItem:(UserInfoModel *)userInfo { + self.sessionId = [NSString stringWithFormat:@"%ld", userInfo.uid]; + [self shareToUser:userInfo.nick]; +} + +#pragma mark - Getters And Setters + +- (JXCategoryListContainerView *)listContainerView { + if (!_listContainerView) { + _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; + _listContainerView.listCellBackgroundColor = [UIColor clearColor]; + } + return _listContainerView; +} + +- (NSArray *)titles { + if (!_titles) { + _titles = @[@"好友",@"粉丝", @"关注"]; + } + return _titles; +} + +- (JXCategoryTitleView *)titleView { + if (!_titleView) { + _titleView = [[JXCategoryTitleView alloc] initWithFrame:CGRectZero]; + _titleView.backgroundColor =[UIColor clearColor]; + _titleView.titleColor = UIColorFromRGB(0x444444); + _titleView.titleSelectedColor = [ThemeColor mainTextColor]; + _titleView.titleFont = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold]; + _titleView.titleSelectedFont = [UIFont systemFontOfSize:18 weight:UIFontWeightHeavy]; + _titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter; + _titleView.contentScrollViewClickTransitionAnimationEnabled = NO; + _titleView.averageCellSpacingEnabled = NO; + _titleView.defaultSelectedIndex = 0; + _titleView.titles = self.titles; + _titleView.delegate = self; + _titleView.cellSpacing = 0; + _titleView.cellWidth = (CGFloat)KScreenWidth/ 3.0; + _titleView.listContainer = self.listContainerView; + + JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init]; + lineView.indicatorColor = [ThemeColor appMainColor]; + lineView.indicatorWidth = 8.f; + lineView.indicatorHeight = 4.f; + lineView.indicatorCornerRadius = 2.f; + _titleView.indicators = @[lineView]; + } + return _titleView; +} + +- (XPMineAttentionViewController *)attentionVC { + if (!_attentionVC) { + _attentionVC = [[XPMineAttentionViewController alloc] init]; + _attentionVC.type = ContactUseingType_Share; + _attentionVC.delegate = self; + } + return _attentionVC; +} + +- (XPMineFriendViewController *)friendVC { + if (!_friendVC) { + _friendVC = [[XPMineFriendViewController alloc] init]; + _friendVC.type = ContactUseingType_Share; + _friendVC.delegate = self; + } + return _friendVC; +} + +- (XPMineFansViewController *)fansVC { + if (!_fansVC) { + _fansVC = [[XPMineFansViewController alloc] init]; + _fansVC.type = ContactUseingType_Share; + _fansVC.delegate = self; + } + return _fansVC; +} +@end diff --git a/xplan-ios/Main/Monents/Model/MonentsInfoModel.h b/xplan-ios/Main/Monents/Model/MonentsInfoModel.h index 7463cacb..b5dd651f 100644 --- a/xplan-ios/Main/Monents/Model/MonentsInfoModel.h +++ b/xplan-ios/Main/Monents/Model/MonentsInfoModel.h @@ -37,7 +37,7 @@ typedef NS_ENUM(NSInteger, MonentsContentType) { ///喜欢的次数 @property (nonatomic,copy) NSString *likeCount; ///我是否已经点赞 -@property (nonatomic, assign) BOOL like; +@property (nonatomic, assign) BOOL isLike; ///评论的次数 @property (nonatomic,copy) NSString *commentCount; //发布时间 diff --git a/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.m b/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.m index 14b89f68..958dcbc3 100644 --- a/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.m +++ b/xplan-ios/Main/Monents/View/Cell/XPMonentsTableViewCell.m @@ -13,6 +13,7 @@ #import "ThemeColor.h" #import "NetImageView.h" #import "XPMonentsLayoutConfig.h" +#import "SDPhotoBrowser.h" ///Model #import "MonentsInfoModel.h" ///View @@ -22,7 +23,7 @@ #import "XPMoentsTopicView.h" #import "XPMonentsContentView.h" #import "XPMonentsLayoutConfig.h" -@interface XPMonentsTableViewCell () +@interface XPMonentsTableViewCell () ///显示颜色的 有的时候stackView 不能显示颜色 @property (nonatomic,strong) UIView * backView; ///容器 @@ -98,6 +99,28 @@ } } +#pragma mark - SDPhotoBrowserDelegate +- (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index { + MonentsPicInfoModel *picinfo = [self.monentsInfo.dynamicResList objectAtIndex:index]; + return [NSURL URLWithString:picinfo.resUrl]; +} + +- (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index { + return [UIImageConstant defalutBannerPlaceholder]; +} + +#pragma mark - XPMonentsPhotoViewDelegate +- (void)xPMonentsPhotoView:(XPMonentsPhotoView *)view didClickImage:(NSInteger)index { + NSInteger count = self.monentsInfo.dynamicResList.count; + SDPhotoBrowser *browser = [[SDPhotoBrowser alloc]init]; + browser.sourceImagesContainerView = self; + browser.delegate = self; + browser.imageCount = count; + browser.currentImageIndex = index; + browser.isMe = NO; + [browser show]; +} + #pragma mark - Getters And Setters - (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo { _monentsInfo = monentsInfo; @@ -145,6 +168,7 @@ - (XPMonentsPhotoView *)photoView { if (!_photoView) { _photoView = [[XPMonentsPhotoView alloc] init]; + _photoView.delegate = self; } return _photoView; } diff --git a/xplan-ios/Main/Monents/View/SubViews/XPMonentsPhotoView.h b/xplan-ios/Main/Monents/View/SubViews/XPMonentsPhotoView.h index 96065782..3b52e854 100644 --- a/xplan-ios/Main/Monents/View/SubViews/XPMonentsPhotoView.h +++ b/xplan-ios/Main/Monents/View/SubViews/XPMonentsPhotoView.h @@ -8,10 +8,18 @@ #import NS_ASSUME_NONNULL_BEGIN -@class MonentsPicInfoModel; +@class MonentsPicInfoModel, XPMonentsPhotoView; +@protocol XPMonentsPhotoViewDelegate + +- (void)xPMonentsPhotoView:(XPMonentsPhotoView *)view didClickImage:(NSInteger)index; + +@end + @interface XPMonentsPhotoView : UIView ///发布的内容 @property (nonatomic,copy) NSArray *dynamicResList; +///代理 +@property (nonatomic,weak) id delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Monents/View/SubViews/XPMonentsPhotoView.m b/xplan-ios/Main/Monents/View/SubViews/XPMonentsPhotoView.m index 80129113..507b4ec7 100644 --- a/xplan-ios/Main/Monents/View/SubViews/XPMonentsPhotoView.m +++ b/xplan-ios/Main/Monents/View/SubViews/XPMonentsPhotoView.m @@ -67,6 +67,15 @@ }]; } +#pragma mark - Event Response +- (void)tapImageView:(UITapGestureRecognizer *)tap { + NetImageView * imageView = (NetImageView *)tap.view; + if (imageView.imageUrl.length > 0 && self.delegate && [self.delegate respondsToSelector:@selector(xPMonentsPhotoView:didClickImage:)]) { + [self.delegate xPMonentsPhotoView:self didClickImage:imageView.tag - 1001]; + } +} + + #pragma mark - Getters And Setters - (void)setDynamicResList:(NSArray *)dynamicResList { _dynamicResList = dynamicResList; @@ -136,6 +145,10 @@ _firstImageView.layer.masksToBounds = YES; _firstImageView.layer.cornerRadius = 12; _firstImageView.contentMode = UIViewContentModeScaleAspectFill; + _firstImageView.tag = 1000 + 1; + _firstImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_firstImageView addGestureRecognizer:tap]; } return _firstImageView; } @@ -149,6 +162,10 @@ _secondImageView.layer.masksToBounds = YES; _secondImageView.layer.cornerRadius = 12; _secondImageView.contentMode = UIViewContentModeScaleAspectFill; + _secondImageView.tag = 1000 + 2; + _secondImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_secondImageView addGestureRecognizer:tap]; } return _secondImageView; } @@ -162,6 +179,10 @@ _thirdImageView.layer.masksToBounds = YES; _thirdImageView.layer.cornerRadius = 12; _thirdImageView.contentMode = UIViewContentModeScaleAspectFill; + _thirdImageView.tag = 1000 + 3; + _thirdImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_thirdImageView addGestureRecognizer:tap]; } return _thirdImageView; } @@ -176,6 +197,11 @@ _fourthImageView.layer.masksToBounds = YES; _fourthImageView.layer.cornerRadius = 12; _fourthImageView.contentMode = UIViewContentModeScaleAspectFill; + _fourthImageView.tag = 1000 + 4; + _fourthImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_fourthImageView addGestureRecognizer:tap]; + } return _fourthImageView; } @@ -189,6 +215,10 @@ _fifthImageView.layer.masksToBounds = YES; _fifthImageView.layer.cornerRadius = 12; _fifthImageView.contentMode = UIViewContentModeScaleAspectFill; + _fifthImageView.tag = 1000 + 5; + _fifthImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_fifthImageView addGestureRecognizer:tap]; } return _fifthImageView; } @@ -203,6 +233,10 @@ _sixthImageView.layer.masksToBounds = YES; _sixthImageView.layer.cornerRadius = 12; _sixthImageView.contentMode = UIViewContentModeScaleAspectFill; + _sixthImageView.tag = 1000 + 6; + _sixthImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_sixthImageView addGestureRecognizer:tap]; } return _sixthImageView; } @@ -217,6 +251,10 @@ _sevenImageView.layer.masksToBounds = YES; _sevenImageView.layer.cornerRadius = 12; _sevenImageView.contentMode = UIViewContentModeScaleAspectFill; + _sevenImageView.tag = 1000 + 7; + _sevenImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_sevenImageView addGestureRecognizer:tap]; } return _sevenImageView; } @@ -231,6 +269,10 @@ _eighthImageView.layer.masksToBounds = YES; _eighthImageView.layer.cornerRadius = 12; _eighthImageView.contentMode = UIViewContentModeScaleAspectFill; + _eighthImageView.tag = 1000 + 8; + _eighthImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_eighthImageView addGestureRecognizer:tap]; } return _eighthImageView; } @@ -245,6 +287,10 @@ _ninthImageView.layer.masksToBounds = YES; _ninthImageView.layer.cornerRadius = 12; _ninthImageView.contentMode = UIViewContentModeScaleAspectFill; + _ninthImageView.tag = 1000 + 9; + _ninthImageView.userInteractionEnabled = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapImageView:)]; + [_ninthImageView addGestureRecognizer:tap]; } return _ninthImageView; } diff --git a/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.m b/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.m index 7c48157b..ad7d0293 100644 --- a/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.m +++ b/xplan-ios/Main/Monents/View/SubViews/XPMonentsTooBarView.m @@ -15,6 +15,10 @@ #import "XPShareView.h" #import "XCHUDTool.h" #import "XPMacro.h" +#import "ApiHost.h" +#import "XPHtmlUrl.h" +#import "AccountInfoStorage.h" +#import "Api+Monents.h" ///Model #import "MonentsInfoModel.h" ///View @@ -143,7 +147,7 @@ } - (void)shareButtonAction:(UIButton *)sender { - XPShareItem *friend = [XPShareItem itemWitTag:XPShareItemTagMoments title:@"好友" imageName:@"share_wechat_circle_normal" disableImageName:@"share_wechat_circle_disable"]; + XPShareItem *friend = [XPShareItem itemWitTag:XPShareItemTagAppFriends title:@"好友" imageName:@"share_friend" disableImageName:@"share_friend"]; XPShareItem *cycle = [XPShareItem itemWitTag:XPShareItemTagMoments title:@"朋友圈" imageName:@"share_wechat_circle_normal" disableImageName:@"share_wechat_circle_disable"]; XPShareItem *wechat = [XPShareItem itemWitTag:XPShareItemTagWeChat title:@"微信好友" imageName:@"share_wechat_normal" disableImageName:@"share_wechat_disable"]; XPShareItem *qq = [XPShareItem itemWitTag:XPShareItemTagQQ title:@"QQ好友" imageName:@"share_qq_normal" disableImageName:@"share_qq_disable"]; @@ -152,6 +156,19 @@ CGFloat margin = 15; CGSize itemSize = CGSizeMake((KScreenWidth-2*margin)/4, 65); XPShareInfoModel * shareInfo = [[XPShareInfoModel alloc] init]; + NSString * title= self.monentsInfo.nick; + if (self.monentsInfo.nick.length > 6) { + title = [title substringToIndex:6]; + } + shareInfo.shareTitle = [NSString stringWithFormat:@"%@发布了一条动态", title]; + shareInfo.shareContent = self.monentsInfo.content; + shareInfo.shareImageUrl = self.monentsInfo.avatar; + NSString * uid = [AccountInfoStorage instance].getUid; + NSString *urlStr = [NSString stringWithFormat:@"%@/%@?uid=%@&dynamicId=%@&worldId=%ld",API_HOST_URL, URLWithType(kMonentsShareURL), uid, self.monentsInfo.dynamicId, self.monentsInfo.worldId]; + shareInfo.shareUrl = urlStr; + shareInfo.dynamicId = self.monentsInfo.dynamicId; + shareInfo.uid = self.monentsInfo.uid; + shareInfo.worldId = [NSString stringWithFormat:@"%ld", self.monentsInfo.worldId]; XPShareView *shareView = [[XPShareView alloc] initWithItems:items itemSize:itemSize shareInfo:shareInfo]; shareView.delegate = self; [TTPopup popupView:shareView style:TTPopupStyleActionSheet]; @@ -164,6 +181,9 @@ } - (void)shareView:(XPShareView *)shareView didSuccess:(XPShareInfoModel *)shareInfo{ + [Api userShareMonents:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + + } dynamicId:shareInfo.dynamicId uid:shareInfo.uid worldId:shareInfo.worldId shareUid:[AccountInfoStorage instance].getUid]; [TTPopup dismiss]; } @@ -175,7 +195,7 @@ - (void)setMonentsInfo:(MonentsInfoModel *)monentsInfo { _monentsInfo = monentsInfo; if (_monentsInfo) { - self.likeButton.selected = _monentsInfo.like; + self.likeButton.selected = _monentsInfo.isLike; self.likeLabel.text = _monentsInfo.likeCount.length > 0 ? _monentsInfo.likeCount : @"0"; self.commentLabel.text = _monentsInfo.commentCount.length > 0 ? _monentsInfo.commentCount : @"0"; } diff --git a/xplan-ios/Main/Monents/View/XPMonentsAttentionViewController.m b/xplan-ios/Main/Monents/View/XPMonentsAttentionViewController.m index c9fa465b..c799dbcd 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsAttentionViewController.m +++ b/xplan-ios/Main/Monents/View/XPMonentsAttentionViewController.m @@ -22,7 +22,7 @@ #import "XPMonentsTableViewCell.h" #import "XPMonentsEmptyTableViewCell.h" -@interface XPMonentsAttentionViewController () +@interface XPMonentsAttentionViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; ///数据源 @@ -114,12 +114,18 @@ if (self.datasource.count > 0) { XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; MonentsInfoModel * monentsInfo = [self.datasource objectAtIndex:indexPath.row]; + cell.delegate = self; cell.monentsInfo = monentsInfo; return cell; } XPMonentsEmptyTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsEmptyTableViewCell class])]; return cell; } +#pragma mark - XPMonentsTableViewCellDelegate +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; +} + #pragma mark -JXCategoryListContainerViewDelegate - (UIView *)listView { return self.view; @@ -157,6 +163,20 @@ } } +- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { + [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj.dynamicId isEqualToString:dynamicId]) { + if (status) { + obj.isLike += 1; + } else { + obj.isLike -= 1; + } + *stop = YES; + } + }]; + [self.tableView reloadData]; +} + #pragma mark - Getters And Setters - (UITableView *)tableView { if (!_tableView) { diff --git a/xplan-ios/Main/Monents/View/XPMonentsDetailViewController.m b/xplan-ios/Main/Monents/View/XPMonentsDetailViewController.m index 4d4760c8..eae8d76a 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsDetailViewController.m +++ b/xplan-ios/Main/Monents/View/XPMonentsDetailViewController.m @@ -23,7 +23,7 @@ #import "XPMonentDetailPresenter.h" #import "XPMonentsDetailProtocol.h" -@interface XPMonentsDetailViewController () +@interface XPMonentsDetailViewController () ///列表 @property (nonatomic,strong) UITableView *tableView; ///数据源 @@ -147,6 +147,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section ==0) { XPMonentsTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMonentsTableViewCell class])]; + cell.delegate = self; cell.monentsInfo = self.monentsInfo; return cell; } else { @@ -167,6 +168,11 @@ [self.presenter getMonentsCommentReplyList:self.monentsInfo.dynamicId commentId:commentInfo.commentId timestamp:commentInfo.replyInfo.nextTimestamp]; } +#pragma mark - XPMonentsTableViewCellDelegate +- (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; +} + #pragma mark - XPMonentsDetailProtocol - (void)getMonentsDetailSuccess:(MonentsInfoModel *)commentInfo { self.monentsInfo = commentInfo; @@ -209,6 +215,21 @@ } } +- (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { + if ([self.monentsInfo.dynamicId isEqualToString:dynamicId]) { + NSInteger count = self.monentsInfo.likeCount.integerValue; + self.monentsInfo.isLike = status; + if (status) { + count += 1; + } else { + count -= 1; + } + self.monentsInfo.likeCount = [NSString stringWithFormat:@"%ld", count]; + [self.tableView reloadData]; + } +} + + #pragma mark - Getters And Setters - (UITableView *)tableView { if (!_tableView) { diff --git a/xplan-ios/Main/Monents/View/XPMonentsLatestViewController.m b/xplan-ios/Main/Monents/View/XPMonentsLatestViewController.m index 92900389..21d7da1c 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsLatestViewController.m +++ b/xplan-ios/Main/Monents/View/XPMonentsLatestViewController.m @@ -134,7 +134,7 @@ } #pragma mark - XPMonentsTableViewCellDelegate - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { - [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.like likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; } #pragma mark -JXCategoryListContainerViewDelegate @@ -177,11 +177,14 @@ - (void)likeMonentsSuccess:(NSString *)dynamicId status:(BOOL)status { [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj.dynamicId isEqualToString:dynamicId]) { + NSInteger count = obj.likeCount.integerValue; + obj.isLike = status; if (status) { - obj.like += 1; + count += 1; } else { - obj.like -= 1; + count -= 1; } + obj.likeCount = [NSString stringWithFormat:@"%ld", count]; *stop = YES; } }]; diff --git a/xplan-ios/Main/Monents/View/XPMonentsRecommendViewController.m b/xplan-ios/Main/Monents/View/XPMonentsRecommendViewController.m index c67b6702..9f47b92e 100644 --- a/xplan-ios/Main/Monents/View/XPMonentsRecommendViewController.m +++ b/xplan-ios/Main/Monents/View/XPMonentsRecommendViewController.m @@ -137,7 +137,7 @@ } #pragma mark - XPMonentsTableViewCellDelegate - (void)xPMonentsTableViewCell:(XPMonentsTableViewCell *)view didClickLike:(MonentsInfoModel *)monentsInfo { - [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.like likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; + [self.presenter likeMonent:monentsInfo.dynamicId status:!monentsInfo.isLike likedUid:monentsInfo.uid worldId:[NSString stringWithFormat:@"%ld", monentsInfo.worldId]]; } #pragma mark -JXCategoryListContainerViewDelegate @@ -184,9 +184,9 @@ [self.datasource enumerateObjectsUsingBlock:^(MonentsInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj.dynamicId isEqualToString:dynamicId]) { if (status) { - obj.like += 1; + obj.isLike += 1; } else { - obj.like -= 1; + obj.isLike -= 1; } *stop = YES; }