1.0.18 feat:房间设置增加修改房间头像的选项

This commit is contained in:
eggmanQQQ
2024-10-21 18:38:57 +08:00
parent 01743623f2
commit 602789ab5c
3 changed files with 119 additions and 125 deletions

View File

@@ -20,6 +20,8 @@ typedef NS_ENUM(NSInteger, RoomSettingItemType) {
RoomSettingItemType_Class,
///房间标签
RoomSettingItemType_Tag,
///房间头像
RoomSettingItemType_Avatar,
///管理员
RoomSettingItemType_Manager_List,
///黑名单

View File

@@ -47,7 +47,12 @@
classItem.title = YMLocalizedString(@"XPRoomSettingPresenter2");
classItem.subTitle = roomInfo.sortName;
classItem.type = RoomSettingItemType_Class;
XPRoomSettingItemModel *avatarItem = [[XPRoomSettingItemModel alloc] init];
avatarItem.title = YMLocalizedString(@"RoomSetting_1.0.17_0");
avatarItem.subTitle = roomInfo.roomTag;
avatarItem.type = RoomSettingItemType_Avatar;
XPRoomSettingItemModel *tagItem = [[XPRoomSettingItemModel alloc] init];
tagItem.title = YMLocalizedString(@"XPRoomSettingPresenter3");
tagItem.subTitle = roomInfo.roomTag;
@@ -80,14 +85,12 @@
leaveItem.title = YMLocalizedString(@"XPRoomSettingPresenter9");
leaveItem.switchState = roomInfo.leaveMode;
leaveItem.type = RoomSettingItemType_Leave_Model;
XPRoomSettingItemModel * giftValueItem = [[XPRoomSettingItemModel alloc] init];
giftValueItem.title = roomInfo.showGiftValue ? YMLocalizedString(@"XPMoreMenuPresenter27") : YMLocalizedString(@"XPMoreMenuPresenter3");
giftValueItem.switchState = roomInfo.showGiftValue;
giftValueItem.type = RoomSettingItemType_Gift_Value_Model;
NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
NSString * uid = [AccountInfoStorage instance].getUid;
///
@@ -98,129 +101,61 @@
NSArray * array;
if (error == nil) {
NIMChatroomMember * member = members.firstObject;
//
BOOL isCreatorOrSuperAdmin = (member.type == NIMChatroomMemberTypeCreator || isSuperAdmin);
//
BOOL isPermitRoom = (roomInfo.isPermitRoom == PermitRoomType_License);
//
BOOL hasRoomPwd = (roomInfo.roomPwd.length > 0);
//
NSMutableArray *firstSection = [@[titleItem, lockItem] mutableCopy];
if (hasRoomPwd) {
[firstSection addObject:pwdItem];
}
NSMutableArray *secondSection = [@[tagItem] mutableCopy];
NSMutableArray *thirdSection = [@[blackItem, giftEffectItem, messageScreedItem] mutableCopy];
if (isCreatorOrSuperAdmin) {
// avatarItem
[secondSection insertObject:avatarItem atIndex:0];
[thirdSection insertObject:managerItem atIndex:0];
}
if (roomInfo.type == RoomType_Anchor) {
if (member.type == NIMChatroomMemberTypeCreator || isSuperAdmin) {
if (roomInfo.isPermitRoom == PermitRoomType_License) {
if (roomInfo.roomPwd.length > 0) {
array = @[
@[titleItem, lockItem, pwdItem],
@[classItem, tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem]
];
} else {
array = @[
@[titleItem, lockItem],
@[classItem, tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem]
];
}
} else {
if (roomInfo.roomPwd.length > 0) {
array = @[
@[titleItem, lockItem, pwdItem],
@[classItem, tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem]
];
} else {
array = @[
@[titleItem, lockItem],
@[classItem, tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem]
];
}
}
if (isCreatorOrSuperAdmin) {
// -
array = @[firstSection, secondSection, thirdSection];
} else {
if (roomInfo.roomPwd.length > 0) {
array = @[
@[titleItem, lockItem, pwdItem],
@[tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem]
];
} else {
array = @[
@[titleItem, lockItem],
@[tagItem],
@[blackItem, giftEffectItem]
];
}
// -
array = @[firstSection, secondSection, thirdSection];
}
} else {
//
if (member.type == NIMChatroomMemberTypeCreator) {
if (roomInfo.isPermitRoom == PermitRoomType_License) {
if (roomInfo.roomPwd.length > 0) {
array = @[
@[titleItem, lockItem,pwdItem],
@[tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem, arrangeMicItem, leaveItem]
];
} else {
array = @[
@[titleItem, lockItem],
@[tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem, arrangeMicItem, leaveItem]
];
}
} else {
if (roomInfo.type == RoomType_MiniGame) {
if (roomInfo.roomPwd.length > 0) {
array = @[
@[titleItem, lockItem, pwdItem],
@[tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem]
];
}else {
array = @[
@[titleItem, lockItem],
@[tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem]
];
}
} else {
if (roomInfo.roomPwd.length > 0) {
array = @[
@[titleItem, lockItem, pwdItem],
@[tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem, arrangeMicItem]
];
}else {
array = @[
@[titleItem, lockItem],
@[tagItem],
@[managerItem, blackItem, giftEffectItem, messageScreedItem, arrangeMicItem]
];
}
}
}
}else if(isSuperAdmin) {
if (roomInfo.roomPwd.length > 0) {
array = @[
@[titleItem, lockItem,pwdItem],
@[tagItem],
@[managerItem,blackItem, giftEffectItem, messageScreedItem, arrangeMicItem]
];
} else {
array = @[
@[titleItem, lockItem],
@[tagItem],
@[managerItem,blackItem, giftEffectItem, messageScreedItem, arrangeMicItem]
];
}
} else if(member.type == NIMChatroomMemberTypeManager) {
if (roomInfo.roomPwd.length > 0) {
array = @[
@[titleItem, lockItem,pwdItem],
@[tagItem],
@[blackItem, giftEffectItem, messageScreedItem, arrangeMicItem]
];
} else {
array = @[
@[titleItem, lockItem],
@[tagItem],
@[blackItem, giftEffectItem, messageScreedItem, arrangeMicItem]
];
}
}
//
[thirdSection addObjectsFromArray:@[arrangeMicItem, leaveItem]];
} else if (isSuperAdmin) {
//
[thirdSection addObject:arrangeMicItem];
} else if (member.type == NIMChatroomMemberTypeManager) {
//
[thirdSection addObject:arrangeMicItem];
}
if (roomInfo.type == RoomType_MiniGame) {
//
array = @[firstSection, secondSection, thirdSection];
} else {
//
array = @[firstSection, secondSection, thirdSection];
}
}
NSMutableArray *list = [[NSMutableArray alloc]initWithArray:array];
if(member.type == NIMChatroomMemberTypeManager || member.type == NIMChatroomMemberTypeCreator || isSuperAdmin){
NSMutableArray *subList = [[NSMutableArray alloc]initWithArray:[list xpSafeObjectAtIndex:2]?:@[]];
@@ -242,8 +177,6 @@
}];
}
///
/// @param roomUid uid
- (void)getRoomInfo:(NSString *)roomUid {

View File

@@ -36,7 +36,7 @@
#import "XPRoomRoleViewController.h"
#import "MSRoomSetingBackdropVC.h"
@interface XPRoomSettingViewController ()<UITableViewDelegate, UITableViewDataSource, XPRoomSettingProtocol, XPRoomSettingTableViewCellDelegate, XPRoomSettingInputViewDelegate>
@interface XPRoomSettingViewController ()<UITableViewDelegate, UITableViewDataSource, XPRoomSettingProtocol, XPRoomSettingTableViewCellDelegate, XPRoomSettingInputViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate>
///
@property (nonatomic,strong) RoomInfoModel *roomInfo;
///
@@ -229,6 +229,28 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index
[self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:tag classifyId:roomClassifyId hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:itemModel.type mgId:mgId backPic:self.roomInfo.backPic];
};
[TTPopup popupView:view style:TTPopupStyleAlert];
}
break;
case RoomSettingItemType_Avatar: {
@kWeakify(self);
[YYUtility checkAssetsLibrayAvailable:^{
@kStrongify(self);
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.modalPresentationCapturesStatusBarAppearance = YES;
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.allowsEditing = YES;
// [self presentViewController:[self photoPickerWillDisplayGIF: NO]
// animated:YES
// completion:nil];
} denied:^{
@kStrongify(self);
[self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController7") content:YMLocalizedString(@"XPMineUserInfoEditViewController8")];
} restriction:^{
@kStrongify(self);
[self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController9") content:YMLocalizedString(@"XPMineUserInfoEditViewController10")];
}];
}
break;
case RoomSettingItemType_Title:
@@ -282,6 +304,22 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index
}
}
- (void)showNotPhoto:(NSString *)title content:(NSString *)content {
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = title;
config.message = content;
[TTPopup alertWithConfig:config confirmHandler:^{
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
}];
}
} cancelHandler:^{
}];
}
#pragma mark - XPRoomSettingInputViewDelegate
- (void)xPRoomSettingInputView:(XPRoomSettingInputView *)view didClickConfirm:(NSString *)text type:(RoomSettingInputType)type {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
@@ -426,6 +464,27 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index
}
}
#pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *selectedPhoto = [info objectForKey:UIImagePickerControllerEditedImage];
if (selectedPhoto) {
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum(selectedPhoto, nil, nil, nil);
}
// TODO: API
// [self showLoading];
// [self.presenter uploadAvatar:selectedPhoto];
}
[picker dismissViewControllerAnimated:YES completion:^{}];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[picker dismissViewControllerAnimated:YES completion:^{
}];
}
#pragma mark - XPRoomSettingProtocol
-(void)closeRoomGiftValueSuccessWithItemModel:(XPRoomSettingItemModel *)itemModel{