diff --git a/Podfile.lock b/Podfile.lock index 8bf84631..5babd586 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -205,4 +205,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 8120dbc8eb506e124ccb97e8ce2ecf2420ac8b5f -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.0 diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index a4820399..2285eeea 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -425,6 +425,8 @@ E8A6C29B27CF53BF00AC7442 /* XPHomeLikePresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A6C29A27CF53BF00AC7442 /* XPHomeLikePresenter.m */; }; E8A6C29F27CF5FE500AC7442 /* HomeLiveRoomModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A6C29E27CF5FE500AC7442 /* HomeLiveRoomModel.m */; }; E8A6C2A227CF856E00AC7442 /* HomeCollectRoomModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A6C2A127CF856E00AC7442 /* HomeCollectRoomModel.m */; }; + E8AA6EEF27DF1E6B009B4C2B /* XPRoomTopicViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8AA6EEE27DF1E6B009B4C2B /* XPRoomTopicViewController.m */; }; + E8AA6EF227DF1E97009B4C2B /* XPRoomTopicPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E8AA6EF127DF1E97009B4C2B /* XPRoomTopicPresenter.m */; }; E8AC721026F43955007D6E91 /* UIImageConstant.m in Sources */ = {isa = PBXBuildFile; fileRef = E8AC720F26F43955007D6E91 /* UIImageConstant.m */; }; E8AC721326F46ADD007D6E91 /* XPMineSettingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8AC721226F46ADD007D6E91 /* XPMineSettingViewController.m */; }; E8AC721626F46B06007D6E91 /* XPMineSettingTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8AC721526F46B06007D6E91 /* XPMineSettingTableViewCell.m */; }; @@ -1383,6 +1385,11 @@ E8A6C29E27CF5FE500AC7442 /* HomeLiveRoomModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeLiveRoomModel.m; sourceTree = ""; }; E8A6C2A027CF856E00AC7442 /* HomeCollectRoomModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeCollectRoomModel.h; sourceTree = ""; }; E8A6C2A127CF856E00AC7442 /* HomeCollectRoomModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeCollectRoomModel.m; sourceTree = ""; }; + E8AA6EED27DF1E6B009B4C2B /* XPRoomTopicViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomTopicViewController.h; sourceTree = ""; }; + E8AA6EEE27DF1E6B009B4C2B /* XPRoomTopicViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomTopicViewController.m; sourceTree = ""; }; + E8AA6EF027DF1E97009B4C2B /* XPRoomTopicPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomTopicPresenter.h; sourceTree = ""; }; + E8AA6EF127DF1E97009B4C2B /* XPRoomTopicPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomTopicPresenter.m; sourceTree = ""; }; + E8AA6EF327DF1EB6009B4C2B /* XPRoomTopicProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomTopicProtocol.h; sourceTree = ""; }; E8AC720E26F43955007D6E91 /* UIImageConstant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIImageConstant.h; sourceTree = ""; }; E8AC720F26F43955007D6E91 /* UIImageConstant.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIImageConstant.m; sourceTree = ""; }; E8AC721126F46ADD007D6E91 /* XPMineSettingViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineSettingViewController.h; sourceTree = ""; }; @@ -3186,6 +3193,7 @@ children = ( E8412FAD2779CB2D006E1101 /* XPRoomSettingProtocol.h */, E87AE7FD277AAC5A0037823A /* XPRoomTagProtocol.h */, + E8AA6EF327DF1EB6009B4C2B /* XPRoomTopicProtocol.h */, ); path = Protocol; sourceTree = ""; @@ -3197,6 +3205,8 @@ E8412FAF2779CB4D006E1101 /* XPRoomSettingPresenter.m */, E87AE7FA277AAC450037823A /* XPRoomTagPresenter.h */, E87AE7FB277AAC450037823A /* XPRoomTagPresenter.m */, + E8AA6EF027DF1E97009B4C2B /* XPRoomTopicPresenter.h */, + E8AA6EF127DF1E97009B4C2B /* XPRoomTopicPresenter.m */, ); path = Presenter; sourceTree = ""; @@ -3217,6 +3227,8 @@ E84BF7DF277C869A00EF8877 /* XPRoomOnLineViewController.m */, E87E91532796B6DE00A7B3F2 /* XPRoomInviteUserViewController.h */, E87E91542796B6DE00A7B3F2 /* XPRoomInviteUserViewController.m */, + E8AA6EED27DF1E6B009B4C2B /* XPRoomTopicViewController.h */, + E8AA6EEE27DF1E6B009B4C2B /* XPRoomTopicViewController.m */, ); path = View; sourceTree = ""; @@ -4790,6 +4802,7 @@ E8788950273A699900BF1D57 /* ThemeColor+SendGift.m in Sources */, E81C279D26EEEC620031E639 /* XPConstant.m in Sources */, 9B92A36D2798179B00AD168F /* XPSkillCardTypeCollectionViewCell.m in Sources */, + E8AA6EF227DF1E97009B4C2B /* XPRoomTopicPresenter.m in Sources */, 187EEEFE26E8A82C002833B2 /* NSObject+AutoCoding.m in Sources */, E884C36F2743AAC800E1EBED /* AttachmentModel.m in Sources */, E8AC721926F46E0B007D6E91 /* XPMineSettingItemModel.m in Sources */, @@ -5002,6 +5015,7 @@ E8E5E18E27C3331E00F457D8 /* XPHomeRecommendViewController.m in Sources */, 9B73CD05279A9A6A006AF255 /* XPSkillCardSaveModel.m in Sources */, E8E7DAE82744F5EF00C631CC /* XPGiftStorage.m in Sources */, + E8AA6EEF27DF1E6B009B4C2B /* XPRoomTopicViewController.m in Sources */, E87AE7FC277AAC450037823A /* XPRoomTagPresenter.m in Sources */, E878894C273A607C00BF1D57 /* XPGiftUserCollectionViewCell.m in Sources */, 181D7F212727D9DB00B7C059 /* SocialStageView.m in Sources */, diff --git a/xplan-ios/Assets.xcassets/Room/Position/room_postion_topic_edit.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/Position/room_postion_topic_edit.imageset/Contents.json new file mode 100644 index 00000000..7fb4bc78 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/Position/room_postion_topic_edit.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "room_postion_topic_edit@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "room_postion_topic_edit@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/Position/room_postion_topic_edit.imageset/room_postion_topic_edit@2x.png b/xplan-ios/Assets.xcassets/Room/Position/room_postion_topic_edit.imageset/room_postion_topic_edit@2x.png new file mode 100644 index 00000000..176d2344 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/Position/room_postion_topic_edit.imageset/room_postion_topic_edit@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/Position/room_postion_topic_edit.imageset/room_postion_topic_edit@3x.png b/xplan-ios/Assets.xcassets/Room/Position/room_postion_topic_edit.imageset/room_postion_topic_edit@3x.png new file mode 100644 index 00000000..d01d82f1 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/Position/room_postion_topic_edit.imageset/room_postion_topic_edit@3x.png differ diff --git a/xplan-ios/Main/Room/Model/RoomInfoModel.h b/xplan-ios/Main/Room/Model/RoomInfoModel.h index fc0cbecb..4c9da429 100644 --- a/xplan-ios/Main/Room/Model/RoomInfoModel.h +++ b/xplan-ios/Main/Room/Model/RoomInfoModel.h @@ -103,6 +103,8 @@ typedef NS_ENUM(NSInteger, RoomDatingStateChangeType) { @property (nonatomic , assign) BOOL leaveMode; @property (nonatomic, copy) NSString *backPic; @property (nonatomic , assign) RoomModeType roomModeType;//房间模式 +///房间介绍 +@property (nonatomic, copy) NSString *introduction; ///糖果树的配置 @property (nonatomic,strong) CandyTreeSwitchModel *boxSwitchVo; /// 是否已经收藏 diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m index aa3e6323..3e7504c4 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -31,6 +31,7 @@ #import "XPAnchorAudienceUpMicView.h" #import "XPRoomAnchorInfoCardView.h" #import "AnchorGiftValueView.h" +#import "XPRoomTopicViewController.h" @interface XPRoomFunctionContainerView () ///host 代理 @property (nonatomic,weak) iddelegate; @@ -42,6 +43,12 @@ @property (nonatomic, strong) dispatch_source_t followAnchorTimer; ///个播房房主魅力值 @property (nonatomic, strong) AnchorGiftValueView *anchorGiftValueView; +///话题的容器 +@property (nonatomic,strong) UIStackView *topicStackView; +///话题 +@property (nonatomic,strong) UILabel *topicLabel; +///编辑 +@property (nonatomic,strong) UIButton *editButton; @end @@ -67,6 +74,9 @@ - (void)initSubViews { [self addSubview:self.contributionButton]; [self addSubview:self.anchorGiftValueView]; + [self addSubview:self.topicStackView]; + [self.topicStackView addArrangedSubview:self.topicLabel]; + [self.topicStackView addArrangedSubview:self.editButton]; } - (void)initSubViewConstraints { @@ -81,6 +91,12 @@ make.centerY.mas_equalTo(self.contributionButton); make.height.mas_equalTo(26); }]; + + [self.topicStackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerX.mas_equalTo(self); + make.height.mas_equalTo(15); + make.top.mas_equalTo(58 + 5 + 6 + 12 + 3 + kNavigationHeight); + }]; } #pragma mark - RoomGuestDelegate @@ -134,6 +150,7 @@ make.top.mas_equalTo(statusbarHeight+57); }]; } + [self updateRoomTopic]; } - (void)onRoomEntered { @@ -150,6 +167,7 @@ } uid:uid isLikeUid:roomUid]; } } + [self updateRoomTopic]; } - (void)onMicroGiftValueUpdate:(NSDictionary *)data { @@ -219,6 +237,72 @@ } } +#pragma mark - 房间话题 +- (void)updateRoomTopicViewConstraint { + RoomInfoModel * roomInfo = self.delegate.getRoomInfo; + CGFloat offsetY = kNavigationHeight; + if (roomInfo.datingState == RoomDatingStateChangeType_Open) { + offsetY += ((58 + 5) * kScreenScale + 6 + 12 + 3); + } else if (roomInfo.type == RoomType_Anchor) { + offsetY += (120 + 5 + 6 + 20 + 3); + } else if(roomInfo.hadChangeRoomType) { + offsetY += (58 + 5 + 6 + 12 + 3 ); + } else { + return; + } + + [self.topicStackView mas_updateConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(offsetY); + }]; +} + +- (void)updateRoomTopic { + [self updateRoomTopicViewConstraint]; + NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; + request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.roomId]; + request.userIds = @[[AccountInfoStorage instance].getUid]; + [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { + if (error== nil) { + NIMChatroomMember* member = members.firstObject; + if (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager) { + self.editButton.hidden = NO; + } else { + self.editButton.hidden = YES; + } + } + }]; + self.topicLabel.text = self.delegate.getRoomInfo.roomDesc.length > 0 ? self.delegate.getRoomInfo.roomDesc : @"暂未设置话题"; +} + +- (void)topicGestureRecognizer:(UITapGestureRecognizer *)tap { + NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; + request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.roomId]; + request.userIds = @[[AccountInfoStorage instance].getUid]; + [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { + if (error== nil) { + NIMChatroomMember* member = members.firstObject; + RoomInfoModel * roomInfo= self.delegate.getRoomInfo; + if (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager) { + XPRoomTopicViewController * editTopicVC = [[XPRoomTopicViewController alloc] init]; + editTopicVC.roomInfo = roomInfo; + [self.delegate.getCurrentNav pushViewController:editTopicVC animated:YES]; + } else { + NSString * title = roomInfo.roomDesc.length > 0 ? roomInfo.roomDesc : @"暂未设置话题"; + TTAlertConfig * config = [[TTAlertConfig alloc] init]; + config.title = title; + config.message = roomInfo.introduction.length > 0 ? roomInfo.introduction : @"暂未设置房间话题"; + config.actionStyle = TTAlertActionCancelStyle; + config.cancelButtonConfig.title = @"关闭"; + [TTPopup alertWithConfig:config confirmHandler:^{ + + } cancelHandler:^{ + + }]; + } + } + }]; +} + #pragma mark - 个播模式弹窗关注主播 - (void)setFollowAnchorTimer { if (self.followAnchorTimer != nil) { @@ -345,4 +429,36 @@ return _anchorGiftValueView; } +- (UIStackView *)topicStackView { + if (!_topicStackView) { + _topicStackView = [[UIStackView alloc] init]; + _topicStackView.axis = UILayoutConstraintAxisHorizontal; + _topicStackView.distribution = UIStackViewDistributionFill; + _topicStackView.alignment = UIStackViewAlignmentFill; + _topicStackView.spacing = 3; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(topicGestureRecognizer:)]; + [_topicStackView addGestureRecognizer:tap]; + } + return _topicStackView; +} + +- (UILabel *)topicLabel { + if (!_topicLabel) { + _topicLabel = [[UILabel alloc] init]; + _topicLabel.font = [UIFont systemFontOfSize:12]; + _topicLabel.textColor = [UIColor whiteColor]; + } + return _topicLabel; +} + +- (UIButton *)editButton { + if (!_editButton) { + _editButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_editButton setImage:[UIImage imageNamed:@"room_postion_topic_edit"] forState:UIControlStateNormal]; + [_editButton setImage:[UIImage imageNamed:@"room_postion_topic_edit"] forState:UIControlStateSelected]; + _editButton.hidden = YES; + } + return _editButton; +} + @end diff --git a/xplan-ios/Main/Room/View/Setting/Presenter/XPRoomSettingPresenter.m b/xplan-ios/Main/Room/View/Setting/Presenter/XPRoomSettingPresenter.m index 95096f8d..930fdd53 100644 --- a/xplan-ios/Main/Room/View/Setting/Presenter/XPRoomSettingPresenter.m +++ b/xplan-ios/Main/Room/View/Setting/Presenter/XPRoomSettingPresenter.m @@ -158,7 +158,7 @@ ]; } } - } else if(member.type == NIMTeamInviteModeManager) { + } else if(member.type == NIMChatroomMemberTypeManager) { if (roomInfo.roomPwd.length > 0) { array = @[ @[titleItem, lockItem,pwdItem], @@ -259,8 +259,7 @@ } if (roomPwd.length > 0) { - NSString *pwdDes = [DESEncrypt encryptUseDES:roomPwd key:KeyWithType(KeyType_PasswordEncode)]; - [params setObject:pwdDes forKey:@"roomPwd"]; + [params setObject:roomPwd forKey:@"roomPwd"]; } else{ [params setObject:@"" forKey:@"roomPwd"]; } diff --git a/xplan-ios/Main/Room/View/Setting/Presenter/XPRoomTopicPresenter.h b/xplan-ios/Main/Room/View/Setting/Presenter/XPRoomTopicPresenter.h new file mode 100644 index 00000000..e70fd36f --- /dev/null +++ b/xplan-ios/Main/Room/View/Setting/Presenter/XPRoomTopicPresenter.h @@ -0,0 +1,17 @@ +// +// XPRoomTopicPresenter.h +// xplan-ios +// +// Created by 冯硕 on 2022/3/14. +// + +#import "BaseMvpPresenter.h" + +NS_ASSUME_NONNULL_BEGIN +@class RoomInfoModel; +@interface XPRoomTopicPresenter : BaseMvpPresenter +///更新房间信息 +- (void)roomTopicUpdate:(NSString *)roomDesc introduction:(NSString *)introduction roomInfo:(RoomInfoModel *)roomInfo; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/Setting/Presenter/XPRoomTopicPresenter.m b/xplan-ios/Main/Room/View/Setting/Presenter/XPRoomTopicPresenter.m new file mode 100644 index 00000000..00f7f1e8 --- /dev/null +++ b/xplan-ios/Main/Room/View/Setting/Presenter/XPRoomTopicPresenter.m @@ -0,0 +1,48 @@ +// +// XPRoomTopicPresenter.m +// xplan-ios +// +// Created by 冯硕 on 2022/3/14. +// + +#import "XPRoomTopicPresenter.h" +#import "XPConstant.h" +#import "DESEncrypt.h" +#import "AccountInfoStorage.h" +#import "Api+RoomSetting.h" +#import "XPRoomTopicProtocol.h" +#import "RoomInfoModel.h" + +@implementation XPRoomTopicPresenter + +///更新房间信息 +- (void)roomTopicUpdate:(NSString *)roomDesc introduction:(NSString *)introduction roomInfo:(RoomInfoModel *)roomInfo { + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * ticket = [AccountInfoStorage instance].getTicket; + NSMutableDictionary * params = [NSMutableDictionary dictionary]; + [params setObject:ticket forKey:@"ticket"]; + [params setObject:uid forKey:@"uid"]; + [params setObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"]; + if (roomInfo.title.length > 0) { + [params setObject:roomInfo.title forKey:@"title"]; + } + + if (roomInfo.roomPwd.length > 0) { + [params setObject:roomInfo.roomPwd forKey:@"roomPwd"]; + } + + if (roomInfo.tagId > 0) { + [params setObject:[NSString stringWithFormat:@"%ld", roomInfo.tagId] forKey:@"tagId"]; + } + + [params setValue:roomDesc forKey:@"roomDesc"]; + if (introduction.length > 0) { + [params setValue:introduction forKey:@"introduction"]; + } + [params setObject:@(roomInfo.hasAnimationEffect) forKey:@"hasAnimationEffect"]; + [Api ownerUpdateRoomInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] updateRoomTopicSuccess]; + } showLoading:YES] params:params]; +} + +@end diff --git a/xplan-ios/Main/Room/View/Setting/Protocol/XPRoomTopicProtocol.h b/xplan-ios/Main/Room/View/Setting/Protocol/XPRoomTopicProtocol.h new file mode 100644 index 00000000..cfcfa9ca --- /dev/null +++ b/xplan-ios/Main/Room/View/Setting/Protocol/XPRoomTopicProtocol.h @@ -0,0 +1,19 @@ +// +// XPRoomTopicProtocol.h +// xplan-ios +// +// Created by 冯硕 on 2022/3/14. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol XPRoomTopicProtocol + +///更新房间话题成功 +- (void)updateRoomTopicSuccess; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/Setting/View/XPRoomSettingViewController.m b/xplan-ios/Main/Room/View/Setting/View/XPRoomSettingViewController.m index 3f9b159a..6fdf5f5d 100644 --- a/xplan-ios/Main/Room/View/Setting/View/XPRoomSettingViewController.m +++ b/xplan-ios/Main/Room/View/Setting/View/XPRoomSettingViewController.m @@ -198,8 +198,7 @@ XPRoomSettingItemModel * itemModel = [[self.datasource objectAtIndex:indexPath.s @kWeakify(self); roomTagVC.completion = ^(NSString * _Nonnull tag) { @kStrongify(self) - NSString * roomPwd = [DESEncrypt decryptUseDES:self.roomInfo.roomPwd key:KeyWithType(KeyType_PasswordEncode)]; - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:roomPwd tagId:tag hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId itemType:itemModel.type]; + [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:tag hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId itemType:itemModel.type]; }; [self.navigationController presentViewController:roomTagVC animated:YES completion:nil]; } @@ -254,10 +253,10 @@ XPRoomSettingItemModel * itemModel = [[self.datasource objectAtIndex:indexPath.s NSString * roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId]; NSString * roomTag = [NSString stringWithFormat:@"%ld", self.roomInfo.tagId]; if (type == RoomSettingInputType_Pwd) { - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:text tagId:roomTag hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId itemType:RoomSettingItemType_Pwd]; + NSString *pwdDes = [DESEncrypt encryptUseDES:text key:KeyWithType(KeyType_PasswordEncode)]; + [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:pwdDes tagId:roomTag hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId itemType:RoomSettingItemType_Pwd]; } else if(type == RoomSettingInputType_Title) { - NSString * roomPwd = [DESEncrypt decryptUseDES:self.roomInfo.roomPwd key:KeyWithType(KeyType_PasswordEncode)]; - [self.presenter updateRoomInfo:text roomPwd:roomPwd tagId:roomTag hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId itemType:RoomSettingItemType_Title]; + [self.presenter updateRoomInfo:text roomPwd:self.roomInfo.roomPwd tagId:roomTag hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId itemType:RoomSettingItemType_Title]; } } @@ -325,8 +324,7 @@ XPRoomSettingItemModel * itemModel = [[self.datasource objectAtIndex:indexPath.s case RoomSettingItemType_Gift_Effect: { if (isOn) { - NSString * roomPwd = [DESEncrypt decryptUseDES:self.roomInfo.roomPwd key:KeyWithType(KeyType_PasswordEncode)]; - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:roomPwd tagId:roomTag hasAnimationEffect:YES roomUid:roomUid roomId:roomId itemType:itemModel.type]; + [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:roomTag hasAnimationEffect:YES roomUid:roomUid roomId:roomId itemType:itemModel.type]; return; } TTAlertConfig *config = [[TTAlertConfig alloc] init]; @@ -335,8 +333,7 @@ XPRoomSettingItemModel * itemModel = [[self.datasource objectAtIndex:indexPath.s config.shouldDismissOnBackgroundTouch = NO; [TTPopup alertWithConfig:config confirmHandler:^{ - NSString * roomPwd = [DESEncrypt decryptUseDES:self.roomInfo.roomPwd key:KeyWithType(KeyType_PasswordEncode)]; - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:roomPwd tagId:roomTag hasAnimationEffect:NO roomUid:roomUid roomId:roomId itemType:itemModel.type]; + [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:roomTag hasAnimationEffect:NO roomUid:roomUid roomId:roomId itemType:itemModel.type]; } cancelHandler:^{ }]; diff --git a/xplan-ios/Main/Room/View/Setting/View/XPRoomTopicViewController.h b/xplan-ios/Main/Room/View/Setting/View/XPRoomTopicViewController.h new file mode 100644 index 00000000..47c83c99 --- /dev/null +++ b/xplan-ios/Main/Room/View/Setting/View/XPRoomTopicViewController.h @@ -0,0 +1,17 @@ +// +// XPRoomTopicViewController.h +// xplan-ios +// +// Created by 冯硕 on 2022/3/14. +// + +#import "MvpViewController.h" + +NS_ASSUME_NONNULL_BEGIN +@class RoomInfoModel; +@interface XPRoomTopicViewController : MvpViewController +///房间信息 +@property (nonatomic,strong) RoomInfoModel *roomInfo; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/Setting/View/XPRoomTopicViewController.m b/xplan-ios/Main/Room/View/Setting/View/XPRoomTopicViewController.m new file mode 100644 index 00000000..f24e6c76 --- /dev/null +++ b/xplan-ios/Main/Room/View/Setting/View/XPRoomTopicViewController.m @@ -0,0 +1,241 @@ +// +// XPRoomTopicViewController.m +// xplan-ios +// +// Created by 冯硕 on 2022/3/14. +// + +#import "XPRoomTopicViewController.h" +///Third +#import +///Tool +#import "ThemeColor.h" +#import "UIImage+Utils.h" +#import "XPMacro.h" +///Model +#import "RoomInfoModel.h" +///P +#import "XPRoomTopicPresenter.h" +#import "XPRoomTopicProtocol.h" + +@interface XPRoomTopicViewController () +///显示标题 +@property (nonatomic,strong) UITextField *textField; +///标题显示多少个 +@property (nonatomic,strong) UILabel *titleNumberLabel; +///显示内容 +@property (nonatomic,strong) UITextView *contentTextView; +///内容显示多少个 +@property (nonatomic,strong) UILabel *contentLabel; +///确认 +@property (nonatomic,strong) UIButton *confirmButton; +///容器 +@property (nonatomic,strong) UIView * contentView; +///占位的 +@property (nonatomic,strong) UILabel *placeLabel; +@end + +@implementation XPRoomTopicViewController + +- (XPRoomTopicPresenter *)createPresenter { + return [[XPRoomTopicPresenter alloc] init]; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + [self initSubViews]; + [self initSubViewConstraints]; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + [self.view endEditing:YES]; +} + +#pragma mark - Private Method +- (void)initSubViews { + self.title = @"房间公告"; + [self.view addSubview:self.textField]; + [self.view addSubview:self.titleNumberLabel]; + [self.view addSubview:self.contentView]; + [self.view addSubview:self.contentLabel]; + [self.view addSubview:self.confirmButton]; + + [self.contentView addSubview:self.contentTextView]; + [self.contentView addSubview:self.placeLabel]; +} + +- (void)initSubViewConstraints { + [self.textField mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.view).inset(15); + make.height.mas_equalTo(44); + make.top.mas_equalTo(self.view).offset(15); + }]; + + [self.titleNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(self.view).offset(-15); + make.top.mas_equalTo(self.textField.mas_bottom).offset(5); + }]; + + [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.view).inset(15); + make.top.mas_equalTo(self.titleNumberLabel.mas_bottom).offset(15); + make.height.mas_equalTo(210); + }]; + + [self.contentTextView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self.contentView).inset(5); + }]; + + [self.placeLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.top.mas_equalTo(self.contentTextView); + }]; + + [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(self.contentView);; + make.top.mas_equalTo(self.contentView.mas_bottom).offset(15); + }]; + + [self.confirmButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.view).inset(47); + make.height.mas_equalTo(44); + make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight - 20); + }]; +} + +#pragma mark - UITextViewDelegate +- (void)textViewDidChange:(UITextView *)textView { + if (textView.text.length > 0) { + self.placeLabel.hidden = YES; + } else { + self.placeLabel.hidden = NO; + } + if (textView.text.length > 300) { + textView.text = [textView.text substringToIndex:300]; + } + self.contentLabel.text = [NSString stringWithFormat:@"%ld/300", (300 - textView.text.length)]; +} + +- (void)textViewDidBeginEditing:(UITextView *)textView { + self.placeLabel.hidden = YES; +} + +#pragma mark - XPRoomTopicProtocol +- (void)updateRoomTopicSuccess { + [self.navigationController popViewControllerAnimated:YES]; +} + +#pragma mark - Event Response +- (void)confirmButtonAction:(UIButton *)sender { + if (self.textField.text.length <= 0) { + [self showErrorToast:@"主题不能为空"]; + return; + } + [self.presenter roomTopicUpdate:self.textField.text introduction:self.contentTextView.text roomInfo:self.roomInfo]; +} + +- (void)textFiledDidChange:(UITextField *)textField { + if (textField.text.length > 15) { + textField.text = [textField.text substringToIndex:15]; + } + self.titleNumberLabel.text = [NSString stringWithFormat:@"%ld/15", (15 - textField.text.length)]; +} + + +#pragma mark - Getters And Setters +- (void)setRoomInfo:(RoomInfoModel *)roomInfo { + _roomInfo = roomInfo; + if (_roomInfo) { + self.textField.text = _roomInfo.roomDesc; + self.contentTextView.text = _roomInfo.introduction; + self.titleNumberLabel.text = [NSString stringWithFormat:@"%ld/15", _roomInfo.roomDesc.length]; + self.contentLabel.text = [NSString stringWithFormat:@"%ld/300", _roomInfo.introduction.length]; + self.placeLabel.hidden = _roomInfo.introduction.length > 0; + } +} + +- (UITextField *)textField { + if (!_textField) { + _textField = [[UITextField alloc] init]; + _textField.layer.cornerRadius = 8; + _textField.layer.masksToBounds = YES; + _textField.backgroundColor = [ThemeColor appCellBackgroundColor]; + _textField.font = [UIFont systemFontOfSize:13]; + _textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请设置公告标题" attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:13], NSForegroundColorAttributeName : [ThemeColor textThirdColor]}]; + _textField.tintColor = [ThemeColor appMainColor]; + UIView *searchIconView = [[UIView alloc] init]; + searchIconView.frame = CGRectMake(0, 0, 7, 10); + _textField.leftView = searchIconView; + _textField.leftViewMode = UITextFieldViewModeAlways; + [_textField addTarget:self action:@selector(textFiledDidChange:) forControlEvents:UIControlEventEditingChanged]; + } + return _textField; +} + +- (UILabel *)titleNumberLabel { + if (!_titleNumberLabel) { + _titleNumberLabel = [[UILabel alloc] init]; + _titleNumberLabel.textColor = [ThemeColor mainTextColor]; + _titleNumberLabel.font = [UIFont systemFontOfSize:10]; + _titleNumberLabel.text = @"0/15"; + } + return _titleNumberLabel; +} + +- (UITextView *)contentTextView { + if (!_contentTextView) { + _contentTextView = [[UITextView alloc] init]; + _contentTextView.backgroundColor = [UIColor clearColor]; + _contentTextView.font = [UIFont systemFontOfSize:13]; + _contentTextView.tintColor = [UIColor clearColor]; + _contentTextView.textColor = [ThemeColor mainTextColor]; + _contentTextView.tintColor = [ThemeColor appMainColor]; + _contentTextView.delegate = self; + } + return _contentTextView; +} + +- (UILabel *)contentLabel { + if (!_contentLabel) { + _contentLabel = [[UILabel alloc] init]; + _contentLabel.font = [UIFont systemFontOfSize:10]; + _contentLabel.textColor = [ThemeColor mainTextColor]; + _contentLabel.text = @"0/300"; + } + return _contentLabel; +} + +- (UIView *)contentView { + if (!_contentView) { + _contentView = [[UIView alloc] init]; + _contentView.backgroundColor = [ThemeColor appCellBackgroundColor]; + _contentView.layer.masksToBounds = YES; + _contentView.layer.cornerRadius = 8; + } + return _contentView; +} + +- (UILabel *)placeLabel { + if (!_placeLabel) { + _placeLabel = [[UILabel alloc] init]; + _placeLabel.text = @"请输入公告内容"; + _placeLabel.font = [UIFont systemFontOfSize:13]; + _placeLabel.textColor = [ThemeColor secondTextColor]; + } + return _placeLabel; +} + +- (UIButton *)confirmButton { + if (!_confirmButton) { + _confirmButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_confirmButton setTitle:@"确定" forState:UIControlStateNormal]; + [_confirmButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + _confirmButton.titleLabel.font = [UIFont systemFontOfSize:15]; + [_confirmButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal]; + _confirmButton.layer.masksToBounds = YES; + _confirmButton.layer.cornerRadius = 22; + [_confirmButton addTarget:self action:@selector(confirmButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _confirmButton; +} + +@end diff --git a/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m b/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m index 90aa0ef5..72fab1ec 100644 --- a/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m +++ b/xplan-ios/Main/Room/View/StageView/MicroView/MicroView.m @@ -350,6 +350,8 @@ - (void)configUser:(UserInfoModel *)userInfo { self.userInfo = userInfo; self.nickLabel.text = @"号麦位"; + self.postionLabel.hidden = NO; + self.nickLabel.hidden = NO; if (userInfo) { self.avatarImageView.imageUrl = userInfo.avatar; if (userInfo.gender == GenderType_Male) { @@ -371,6 +373,10 @@ self.nickLabel.textColor = [ThemeColor positionNickColor]; self.avatarImageView.image = nil; [self.postionLabel setBackgroundColor:[ThemeColor positionNormalNickBackColor]]; + if (self.microModel.microState.position == -1) { + self.postionLabel.hidden = YES; + self.nickLabel.hidden = YES; + } } NSString * headWearUrl = userInfo.headwearEffect.length ? userInfo.headwearEffect : userInfo.headWearUrl.length ? userInfo.headWearUrl : userInfo.headwearPic; if (headWearUrl.length > 0 && !userInfo.vipMic) { diff --git a/xplan-ios/Main/Room/View/XPRoomViewController.m b/xplan-ios/Main/Room/View/XPRoomViewController.m index b241fe7f..03fd86be 100644 --- a/xplan-ios/Main/Room/View/XPRoomViewController.m +++ b/xplan-ios/Main/Room/View/XPRoomViewController.m @@ -338,6 +338,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; //虽然没退出房间 但是队列还是要拿的 [self.stageView onRoomEntered]; [self.messageContainerView onRoomMiniEntered]; + [self.functionView onRoomEntered]; } [[XPRoomMiniManager shareManager] configRoomInfo:nil]; } @@ -641,6 +642,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; [self.menuContainerView onRoomEntered]; [self changeStageViewOnRoomUpdate]; [self.backContainerView onRoomEntered]; + [self.functionView onRoomEntered]; [self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo]; [self.functionView onRoomEntered]; [self.messageContainerView onRoomEntered];