| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602 |
- // Created by Tencent on 2023/06/09.
- // Copyright © 2023 Tencent. All rights reserved.
- #import "TUIGroupInfoController.h"
- #import <TIMCommon/TIMDefine.h>
- #import <TUICore/TUICore.h>
- #import <TUICore/TUILogin.h>
- #import <TUICore/TUIThemeManager.h>
- #import <TIMCommon/TIMGroupInfo+TUIDataProvider.h>
- #import "TUIGroupInfoDataProvider.h"
- #import <TIMCommon/TUICommonGroupInfoCellData.h>
- #import "TUIGroupNoticeCell.h"
- #import "TUIGroupNoticeController.h"
- #define ADD_TAG @"-1"
- #define DEL_TAG @"-2"
- @interface TUIGroupInfoController () <TUIModifyViewDelegate,TUIProfileCardDelegate, TUIGroupInfoDataProviderDelegate>
- @property(nonatomic, strong) TUIGroupInfoDataProvider *dataProvider;
- @property(nonatomic, strong) TUINaviBarIndicatorView *titleView;
- @property(nonatomic, strong) UIViewController *showContactSelectVC;
- @end
- @implementation TUIGroupInfoController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setupViews];
- self.dataProvider = [[TUIGroupInfoDataProvider alloc] initWithGroupID:self.groupId];
- self.dataProvider.delegate = self;
- [self.dataProvider loadData];
- @weakify(self);
- [RACObserve(self.dataProvider, dataList) subscribeNext:^(id _Nullable x) {
- @strongify(self);
- [self.tableView reloadData];
- }];
- _titleView = [[TUINaviBarIndicatorView alloc] init];
- self.navigationItem.titleView = _titleView;
- self.navigationItem.title = @"";
- [_titleView setTitle:TIMCommonLocalizableString(ProfileDetails)];
- }
- - (void)setupViews {
- self.tableView.tableFooterView = [[UIView alloc] init];
- self.tableView.backgroundColor = TIMCommonDynamicColor(@"controller_bg_color", @"#F2F3F5");
- self.tableView.delaysContentTouches = NO;
- if (@available(iOS 15.0, *)) {
- self.tableView.sectionHeaderTopPadding = 0;
- }
- }
- - (void)updateData {
- [self.dataProvider loadData];
- }
- - (void)updateGroupInfo {
- [self.dataProvider updateGroupInfo];
- }
- #pragma mark - Table view data source
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return self.dataProvider.dataList.count;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- UIView *view = [[UIView alloc] init];
- view.backgroundColor = [UIColor clearColor];
- return view;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return 10;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- NSMutableArray *array = self.dataProvider.dataList[section];
- return array.count;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- NSMutableArray *array = self.dataProvider.dataList[indexPath.section];
- NSObject *data = array[indexPath.row];
- if ([data isKindOfClass:[TUIProfileCardCellData class]]) {
- return [(TUIProfileCardCellData *)data heightOfWidth:Screen_Width];
- } else if ([data isKindOfClass:[TUIGroupMembersCellData class]]) {
- return [(TUIGroupMembersCellData *)data heightOfWidth:Screen_Width];
- } else if ([data isKindOfClass:[TUIButtonCellData class]]) {
- return [(TUIButtonCellData *)data heightOfWidth:Screen_Width];
- } else if ([data isKindOfClass:[TUICommonSwitchCellData class]]) {
- return [(TUICommonSwitchCellData *)data heightOfWidth:Screen_Width];
- } else if ([data isKindOfClass:TUIGroupNoticeCellData.class]) {
- return 72.0;
- }
- return 44;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- NSMutableArray *array = self.dataProvider.dataList[indexPath.section];
- NSObject *data = array[indexPath.row];
- if ([data isKindOfClass:[TUIProfileCardCellData class]]) {
- TUIProfileCardCell *cell = [tableView dequeueReusableCellWithIdentifier:TGroupCommonCell_ReuseId];
- if (!cell) {
- cell = [[TUIProfileCardCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TGroupCommonCell_ReuseId];
- }
- cell.delegate = self;
- [cell fillWithData:(TUIProfileCardCellData *)data];
- return cell;
- } else if ([data isKindOfClass:[TUICommonTextCellData class]]) {
- TUICommonTextCell *cell = [tableView dequeueReusableCellWithIdentifier:TKeyValueCell_ReuseId];
- if (!cell) {
- cell = [[TUICommonTextCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TKeyValueCell_ReuseId];
- }
- [cell fillWithData:(TUICommonTextCellData *)data];
- return cell;
- } else if ([data isKindOfClass:[TUIGroupMembersCellData class]]) {
- TUICommonTableViewCell *cell = [[TUICommonTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TGroupMembersCell_ReuseId];
- NSDictionary *param = @{
- @"data": data ,
- @"pushVC": self.navigationController,
- @"groupID": self.groupId ? self.groupId : @"",
- @"membersData": self.dataProvider.membersData ,
- @"groupMembersCellData": self.dataProvider.groupMembersCellData,
- };
- [TUICore raiseExtension:TUICore_TUIChatExtension_GroupProfileMemberListExtension_ClassicExtensionID
- parentView:cell
- param:param];
- return cell;
- } else if ([data isKindOfClass:[TUICommonSwitchCellData class]]) {
- TUICommonSwitchCell *cell = [tableView dequeueReusableCellWithIdentifier:TSwitchCell_ReuseId];
- if (!cell) {
- cell = [[TUICommonSwitchCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TSwitchCell_ReuseId];
- }
- [cell fillWithData:(TUICommonSwitchCellData *)data];
- return cell;
- } else if ([data isKindOfClass:[TUIButtonCellData class]]) {
- TUIButtonCell *cell = [tableView dequeueReusableCellWithIdentifier:TButtonCell_ReuseId];
- if (!cell) {
- cell = [[TUIButtonCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TButtonCell_ReuseId];
- }
- [cell fillWithData:(TUIButtonCellData *)data];
- return cell;
- } else if ([data isKindOfClass:TUIGroupNoticeCellData.class]) {
- TUIGroupNoticeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TUIGroupNoticeCell"];
- if (cell == nil) {
- cell = [[TUIGroupNoticeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"TUIGroupNoticeCell"];
- }
- cell.cellData = data;
- return cell;
- }
- return nil;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- }
- - (void)leftBarButtonClick:(UIButton *)sender {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark TUIGroupInfoDataProviderDelegate
- - (void)groupProfileExtensionButtonClick:(TUICommonTextCell *)cell {
-
- TUIExtensionInfo *info = cell.data.tui_extValueObj;
- if (info == nil || ![info isKindOfClass:TUIExtensionInfo.class] || info.onClicked == nil) {
- return;
- }
- info.onClicked(@{});
- }
- - (void)didSelectMembers {
- NSMutableDictionary *param = [NSMutableDictionary dictionary];
- if (_groupId && _groupId.length >0) {
- param[@"groupID"] = _groupId;
- }
-
- if (self.dataProvider.groupInfo) {
- param[@"groupInfo"] = self.dataProvider.groupInfo;
- }
-
- UIViewController *vc = [TUICore createObject:TUICore_TUIContactObjectFactory
- key:TUICore_TUIContactObjectFactory_GetGroupMemberVCMethod
- param:param];
- if (vc && [vc isKindOfClass:UIViewController.class]) {
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- - (void)didSelectAddOption:(TUICommonTextCell *)cell {
- TUICommonTextCellData *data = cell.textData;
- BOOL isApprove = [data.key isEqualToString:TIMCommonLocalizableString(TUIKitGroupProfileInviteType)];
- __weak typeof(self) weakSelf = self;
- UIAlertController *ac = [UIAlertController
- alertControllerWithTitle:nil
- message:isApprove ? TIMCommonLocalizableString(TUIKitGroupProfileInviteType) : TIMCommonLocalizableString(TUIKitGroupProfileJoinType)
- preferredStyle:UIAlertControllerStyleActionSheet];
- NSArray *actionList = @[
- @{
- @(V2TIM_GROUP_ADD_FORBID) : isApprove ? TIMCommonLocalizableString(TUIKitGroupProfileInviteDisable)
- : TIMCommonLocalizableString(TUIKitGroupProfileJoinDisable)
- },
- @{@(V2TIM_GROUP_ADD_AUTH) : TIMCommonLocalizableString(TUIKitGroupProfileAdminApprove)},
- @{@(V2TIM_GROUP_ADD_ANY) : TIMCommonLocalizableString(TUIKitGroupProfileAutoApproval)}
- ];
- for (NSDictionary *map in actionList) {
- [ac tuitheme_addAction:[UIAlertAction actionWithTitle:map.allValues.firstObject
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction *_Nonnull action) {
- V2TIMGroupAddOpt opt = (V2TIMGroupAddOpt)[map.allKeys.firstObject intValue];
- if (isApprove) {
- [weakSelf.dataProvider setGroupApproveOpt:opt];
- } else {
- [weakSelf.dataProvider setGroupAddOpt:opt];
- }
- }]];
- }
- [ac tuitheme_addAction:[UIAlertAction actionWithTitle:TIMCommonLocalizableString(Cancel) style:UIAlertActionStyleCancel handler:nil]];
- [self presentViewController:ac animated:YES completion:nil];
- }
- - (void)didSelectGroupNick:(TUICommonTextCell *)cell {
- TUIModifyViewData *data = [[TUIModifyViewData alloc] init];
- data.title = TIMCommonLocalizableString(TUIKitGroupProfileEditAlias);
- data.content = self.dataProvider.selfInfo.nameCard;
- data.desc = TIMCommonLocalizableString(TUIKitGroupProfileEditAliasDesc);
- TUIModifyView *modify = [[TUIModifyView alloc] init];
- modify.tag = 2;
- modify.delegate = self;
- [modify setData:data];
- [modify showInWindow:self.view.window];
- }
- - (void)didSelectCommon {
- UIAlertController *ac = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
- __weak typeof(self) weakSelf = self;
- if ([self.dataProvider.groupInfo isPrivate] || [TUIGroupInfoDataProvider isMeOwner:self.dataProvider.groupInfo]) {
- [ac tuitheme_addAction:[UIAlertAction actionWithTitle:TIMCommonLocalizableString(TUIKitGroupProfileEditGroupName)
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction *_Nonnull action) {
- TUIModifyViewData *data = [[TUIModifyViewData alloc] init];
- data.title = TIMCommonLocalizableString(TUIKitGroupProfileEditGroupName);
- data.content = weakSelf.dataProvider.groupInfo.groupName;
- data.desc = TIMCommonLocalizableString(TUIKitGroupProfileEditGroupName);
- TUIModifyView *modify = [[TUIModifyView alloc] init];
- modify.tag = 0;
- modify.delegate = weakSelf;
- [modify setData:data];
- [modify showInWindow:weakSelf.view.window];
- }]];
- }
- if ([TUIGroupInfoDataProvider isMeOwner:self.dataProvider.groupInfo]) {
- [ac tuitheme_addAction:[UIAlertAction actionWithTitle:TIMCommonLocalizableString(TUIKitGroupProfileEditAnnouncement)
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction *_Nonnull action) {
- TUIModifyViewData *data = [[TUIModifyViewData alloc] init];
- data.title = TIMCommonLocalizableString(TUIKitGroupProfileEditAnnouncement);
- TUIModifyView *modify = [[TUIModifyView alloc] init];
- modify.tag = 1;
- modify.delegate = weakSelf;
- [modify setData:data];
- [modify showInWindow:weakSelf.view.window];
- }]];
- }
- if ([TUIGroupInfoDataProvider isMeOwner:self.dataProvider.groupInfo]) {
- @weakify(self);
- [ac tuitheme_addAction:[UIAlertAction actionWithTitle:TIMCommonLocalizableString(TUIKitGroupProfileEditAvatar)
- style:UIAlertActionStyleDefault
- handler:^(UIAlertAction *_Nonnull action) {
- @strongify(self);
- TUISelectAvatarController *vc = [[TUISelectAvatarController alloc] init];
- vc.selectAvatarType = TUISelectAvatarTypeGroupAvatar;
- vc.profilFaceURL = self.dataProvider.groupInfo.faceURL;
- [self.navigationController pushViewController:vc animated:YES];
- vc.selectCallBack = ^(NSString *_Nonnull urlStr) {
- if (urlStr.length > 0) {
- V2TIMGroupInfo *info = [[V2TIMGroupInfo alloc] init];
- info.groupID = self.groupId;
- info.faceURL = urlStr;
- [[V2TIMManager sharedInstance] setGroupInfo:info
- succ:^{
- [self updateGroupInfo];
- }
- fail:^(int code, NSString *msg) {
- [TUITool makeToastError:code msg:msg];
- }];
- }
- };
- }]];
- }
- [ac tuitheme_addAction:[UIAlertAction actionWithTitle:TIMCommonLocalizableString(Cancel) style:UIAlertActionStyleCancel handler:nil]];
- [self presentViewController:ac animated:YES completion:nil];
- }
- - (void)didSelectOnNotDisturb:(TUICommonSwitchCell *)cell {
- V2TIMReceiveMessageOpt opt;
- if (cell.switcher.on) {
- opt = V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE;
- } else {
- opt = V2TIM_RECEIVE_MESSAGE;
- }
- @weakify(self);
- [V2TIMManager.sharedInstance markConversation:@[ [NSString stringWithFormat:@"group_%@", self.groupId] ]
- markType:@(V2TIM_CONVERSATION_MARK_TYPE_FOLD)
- enableMark:NO
- succ:nil
- fail:nil];
- [self.dataProvider setGroupReceiveMessageOpt:opt
- Succ:^{
- @strongify(self);
- [self updateGroupInfo];
- }
- fail:^(int code, NSString *desc){
- }];
- }
- - (void)didSelectOnTop:(TUICommonSwitchCell *)cell {
- if (cell.switcher.on) {
- [[TUIConversationPin sharedInstance] addTopConversation:[NSString stringWithFormat:@"group_%@", _groupId]
- callback:^(BOOL success, NSString *_Nonnull errorMessage) {
- if (success) {
- return;
- }
- cell.switcher.on = !cell.switcher.isOn;
- [TUITool makeToast:errorMessage];
- }];
- } else {
- [[TUIConversationPin sharedInstance] removeTopConversation:[NSString stringWithFormat:@"group_%@", _groupId]
- callback:^(BOOL success, NSString *_Nonnull errorMessage) {
- if (success) {
- return;
- }
- cell.switcher.on = !cell.switcher.isOn;
- [TUITool makeToast:errorMessage];
- }];
- }
- }
- - (void)didDeleteGroup:(TUIButtonCell *)cell {
- UIAlertController *ac = [UIAlertController alertControllerWithTitle:nil
- message:TIMCommonLocalizableString(TUIKitGroupProfileDeleteGroupTips)
- preferredStyle:UIAlertControllerStyleActionSheet];
- @weakify(self);
- [ac tuitheme_addAction:[UIAlertAction
- actionWithTitle:TIMCommonLocalizableString(Confirm)
- style:UIAlertActionStyleDestructive
- handler:^(UIAlertAction *_Nonnull action) {
- @strongify(self);
- @weakify(self);
- if ([self.dataProvider.groupInfo canDismissGroup]) {
- [self.dataProvider
- dismissGroup:^{
- @strongify(self);
- @weakify(self);
- dispatch_async(dispatch_get_main_queue(), ^{
- @strongify(self);
- UIViewController *vc = [self findConversationListViewController];
- [[TUIConversationPin sharedInstance]
- removeTopConversation:[NSString stringWithFormat:@"group_%@", self.groupId]
- callback:nil];
- [V2TIMManager.sharedInstance markConversation:@[ [NSString stringWithFormat:@"group_%@", self.groupId] ]
- markType:@(V2TIM_CONVERSATION_MARK_TYPE_FOLD)
- enableMark:NO
- succ:^(NSArray<V2TIMConversationOperationResult *> *result) {
- [self.navigationController popToViewController:vc animated:YES];
- }
- fail:^(int code, NSString *desc) {
- [self.navigationController popToViewController:vc animated:YES];
- }];
- });
- }
- fail:^(int code, NSString *msg) {
- [TUITool makeToastError:code msg:msg];
- }];
- } else {
- [self.dataProvider
- quitGroup:^{
- @strongify(self);
- @weakify(self);
- dispatch_async(dispatch_get_main_queue(), ^{
- @strongify(self);
- UIViewController *vc = [self findConversationListViewController];
- [[TUIConversationPin sharedInstance]
- removeTopConversation:[NSString stringWithFormat:@"group_%@", self.groupId]
- callback:nil];
- [V2TIMManager.sharedInstance markConversation:@[ [NSString stringWithFormat:@"group_%@", self.groupId] ]
- markType:@(V2TIM_CONVERSATION_MARK_TYPE_FOLD)
- enableMark:NO
- succ:^(NSArray<V2TIMConversationOperationResult *> *result) {
- [self.navigationController popToViewController:vc animated:YES];
- }
- fail:^(int code, NSString *desc) {
- [self.navigationController popToViewController:vc animated:YES];
- }];
- });
- }
- fail:^(int code, NSString *msg) {
- [TUITool makeToastError:code msg:msg];
- }];
- }
- }]];
- [ac tuitheme_addAction:[UIAlertAction actionWithTitle:TIMCommonLocalizableString(Cancel) style:UIAlertActionStyleCancel handler:nil]];
- [self presentViewController:ac animated:YES completion:nil];
- }
- - (void)didReportGroup:(TUIButtonCell *)cell {
- NSURL *url = [NSURL URLWithString:@"https://cloud.tencent.com/act/event/report-platform"];
- [TUITool openLinkWithURL:url];
- }
- - (UIViewController *)findConversationListViewController {
- UIViewController *vc = self.navigationController.viewControllers[0];
- for (UIViewController *vc in self.navigationController.viewControllers) {
- if ([vc isKindOfClass:NSClassFromString(@"TUIFoldListViewController")]) {
- return vc;
- }
- }
- return vc;
- }
- - (void)didSelectOnFoldConversation:(TUICommonSwitchCell *)cell {
- BOOL enableMark = NO;
- if (cell.switcher.on) {
- enableMark = YES;
- }
- @weakify(self);
- [V2TIMManager.sharedInstance markConversation:@[ [NSString stringWithFormat:@"group_%@", self.groupId] ]
- markType:@(V2TIM_CONVERSATION_MARK_TYPE_FOLD)
- enableMark:enableMark
- succ : ^(NSArray<V2TIMConversationOperationResult *> *result) {
- cell.switchData.on = enableMark;
- [[TUIConversationPin sharedInstance] removeTopConversation:[NSString stringWithFormat:@"group_%@", self.groupId]
- callback:^(BOOL success, NSString *_Nonnull errorMessage) {
- @strongify(self);
- [self updateGroupInfo];
- }];
- } fail:nil];
- }
- - (void)didSelectOnChangeBackgroundImage:(TUICommonTextCell *)cell {
- @weakify(self);
- NSString *conversationID = [NSString stringWithFormat:@"group_%@", self.groupId];
- TUISelectAvatarController *vc = [[TUISelectAvatarController alloc] init];
- vc.selectAvatarType = TUISelectAvatarTypeConversationBackGroundCover;
- vc.profilFaceURL = [self getBackgroundImageUrlByConversationID:conversationID];
- [self.navigationController pushViewController:vc animated:YES];
- vc.selectCallBack = ^(NSString *_Nonnull urlStr) {
- @strongify(self);
- [self appendBackgroundImage:urlStr conversationID:conversationID];
- if (IS_NOT_EMPTY_NSSTRING(conversationID)) {
- [TUICore notifyEvent:TUICore_TUIContactNotify
- subKey:TUICore_TUIContactNotify_UpdateConversationBackgroundImageSubKey
- object:self
- param:@{TUICore_TUIContactNotify_UpdateConversationBackgroundImageSubKey_ConversationID : conversationID}];
- }
- };
- }
- - (NSString *)getBackgroundImageUrlByConversationID:(NSString *)targerConversationID {
- if (targerConversationID.length == 0) {
- return nil;
- }
- NSDictionary *dict = [NSUserDefaults.standardUserDefaults objectForKey:@"conversation_backgroundImage_map"];
- if (dict == nil) {
- dict = @{};
- }
- NSString *conversationID_UserID = [NSString stringWithFormat:@"%@_%@", targerConversationID, [TUILogin getUserID]];
- if (![dict isKindOfClass:NSDictionary.class] || ![dict.allKeys containsObject:conversationID_UserID]) {
- return nil;
- }
- return [dict objectForKey:conversationID_UserID];
- }
- - (void)appendBackgroundImage:(NSString *)imgUrl conversationID:(NSString *)conversationID {
- if (conversationID.length == 0) {
- return;
- }
- NSDictionary *dict = [NSUserDefaults.standardUserDefaults objectForKey:@"conversation_backgroundImage_map"];
- if (dict == nil) {
- dict = @{};
- }
- if (![dict isKindOfClass:NSDictionary.class]) {
- return;
- }
- NSString *conversationID_UserID = [NSString stringWithFormat:@"%@_%@", conversationID, [TUILogin getUserID]];
- NSMutableDictionary *originDataDict = [NSMutableDictionary dictionaryWithDictionary:dict];
- if (imgUrl.length == 0) {
- [originDataDict removeObjectForKey:conversationID_UserID];
- } else {
- [originDataDict setObject:imgUrl forKey:conversationID_UserID];
- }
- [NSUserDefaults.standardUserDefaults setObject:originDataDict forKey:@"conversation_backgroundImage_map"];
- [NSUserDefaults.standardUserDefaults synchronize];
- }
- - (void)didClearAllHistory:(TUIButtonCell *)cell {
- @weakify(self);
- UIAlertController *ac = [UIAlertController alertControllerWithTitle:nil
- message:TIMCommonLocalizableString(TUIKitClearAllChatHistoryTips)
- preferredStyle:UIAlertControllerStyleAlert];
- [ac tuitheme_addAction:[UIAlertAction actionWithTitle:TIMCommonLocalizableString(Confirm)
- style:UIAlertActionStyleDestructive
- handler:^(UIAlertAction *_Nonnull action) {
- @strongify(self);
- [self.dataProvider
- clearAllHistory:^{
- [TUICore notifyEvent:TUICore_TUIConversationNotify
- subKey:TUICore_TUIConversationNotify_ClearConversationUIHistorySubKey
- object:self
- param:nil];
- [TUITool makeToast:@"success"];
- }
- fail:^(int code, NSString *desc) {
- [TUITool makeToastError:code msg:desc];
- }];
- }]];
- [ac tuitheme_addAction:[UIAlertAction actionWithTitle:TIMCommonLocalizableString(Cancel) style:UIAlertActionStyleCancel handler:nil]];
- [self presentViewController:ac animated:YES completion:nil];
- }
- - (UINavigationController *)pushNavigationController {
- return self.navigationController;
- }
- - (void)didSelectGroupNotice {
- TUIGroupNoticeController *vc = [[TUIGroupNoticeController alloc] init];
- vc.groupID = self.groupId;
- __weak typeof(self) weakSelf = self;
- vc.onNoticeChanged = ^{
- [weakSelf updateGroupInfo];
- };
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark TUIProfileCardDelegate
- - (void)didTapOnAvatar:(TUIProfileCardCell *)cell {
- TUISelectAvatarController *vc = [[TUISelectAvatarController alloc] init];
- vc.selectAvatarType = TUISelectAvatarTypeGroupAvatar;
- vc.profilFaceURL = self.dataProvider.groupInfo.faceURL;
- [self.navigationController pushViewController:vc animated:YES];
- @weakify(self);
- vc.selectCallBack = ^(NSString *_Nonnull urlStr) {
- @strongify(self);
- if (urlStr.length > 0) {
- V2TIMGroupInfo *info = [[V2TIMGroupInfo alloc] init];
- info.groupID = self.groupId;
- info.faceURL = urlStr;
- [[V2TIMManager sharedInstance] setGroupInfo:info
- succ:^{
- [self updateGroupInfo];
- }
- fail:^(int code, NSString *msg) {
- [TUITool makeToastError:code msg:msg];
- }];
- }
- };
- }
- #pragma mark TUIModifyViewDelegate
- - (void)modifyView:(TUIModifyView *)modifyView didModiyContent:(NSString *)content {
- if (modifyView.tag == 0) {
- [self.dataProvider setGroupName:content];
- } else if (modifyView.tag == 1) {
- [self.dataProvider setGroupNotification:content];
- } else if (modifyView.tag == 2) {
- [self.dataProvider setGroupMemberNameCard:content];
- }
- }
- @end
- @interface IUGroupView : UIView
- @property(nonatomic, strong) UIView *view;
- @end
- @implementation IUGroupView
- - (instancetype)init {
- self = [super init];
- if (self) {
- self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
- [self addSubview:self.view];
- }
- return self;
- }
- @end
|