增加换肤功能
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// TUIGroupObjectFactory_Minimalist.h
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/3/20.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/TUICore.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* TUIGroupService currently provides a service:
|
||||
* Create group member selector
|
||||
*
|
||||
* You can call the service through the [TUICore createObject:..] method. The different service parameters are as follows:
|
||||
* > Create group information interface:
|
||||
* serviceName: TUICore_TUIGroupObjectFactory_Minimalist
|
||||
* method: TUICore_TUIGroupObjectFactory_GetGroupInfoVC_Minimalist
|
||||
* param: @{
|
||||
* TUICore_TUIGroupObjectFactory_GetGroupInfoVC_GroupID; @"groupID"
|
||||
* };
|
||||
* > Create group member selector:
|
||||
* serviceName: TUICore_TUIGroupObjectFactory_Minimalist
|
||||
* method: TUICore_TUIGroupObjectFactory_GetSelectGroupMemberViewControllerMethod
|
||||
* param: @{
|
||||
* TUICore_TUIGroupObjectFactory_GetSelectGroupMemberViewControllerMethod_GroupIDKey : @"groupID",
|
||||
* TUICore_TUIGroupObjectFactory_GetSelectGroupMemberViewControllerMethod_NameKey : @"name",
|
||||
* TUICore_TUIGroupObjectFactory_GetSelectGroupMemberViewControllerMethod_OptionalStyleKey : style
|
||||
* };
|
||||
*/
|
||||
@interface TUIGroupObjectFactory_Minimalist : NSObject
|
||||
+ (TUIGroupObjectFactory_Minimalist *)shareInstance;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// TUIGroupObjectFactory_Minimalist.m
|
||||
// TUIGroup
|
||||
//
|
||||
// Created by wyl on 2023/3/20.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TUIGroupObjectFactory_Minimalist.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/NSDictionary+TUISafe.h>
|
||||
#import <TUICore/TUIGlobalization.h>
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
#import "TUIGroupInfoController_Minimalist.h"
|
||||
#import "TUIGroupRequestViewController_Minimalist.h"
|
||||
#import "TUISelectGroupMemberViewController_Minimalist.h"
|
||||
|
||||
@interface TUIGroupObjectFactory_Minimalist () <TUIObjectProtocol>
|
||||
@end
|
||||
|
||||
@implementation TUIGroupObjectFactory_Minimalist
|
||||
+ (void)load {
|
||||
[TUICore registerObjectFactory:TUICore_TUIGroupObjectFactory_Minimalist objectFactory:[TUIGroupObjectFactory_Minimalist shareInstance]];
|
||||
}
|
||||
+ (TUIGroupObjectFactory_Minimalist *)shareInstance {
|
||||
static dispatch_once_t onceToken;
|
||||
static TUIGroupObjectFactory_Minimalist *g_sharedInstance = nil;
|
||||
dispatch_once(&onceToken, ^{
|
||||
g_sharedInstance = [[TUIGroupObjectFactory_Minimalist alloc] init];
|
||||
});
|
||||
return g_sharedInstance;
|
||||
}
|
||||
|
||||
#pragma mark - TUIObjectProtocol
|
||||
- (id)onCreateObject:(NSString *)method param:(nullable NSDictionary *)param {
|
||||
id returnObject = nil;
|
||||
|
||||
if ([method isEqualToString:TUICore_TUIGroupObjectFactory_GetGroupRequestViewControllerMethod]) {
|
||||
returnObject =
|
||||
[self createGroupRequestViewController:[param tui_objectForKey:TUICore_TUIGroupObjectFactory_GetGroupRequestViewControllerMethod_GroupInfoKey
|
||||
asClass:V2TIMGroupInfo.class]];
|
||||
|
||||
} else if ([method isEqualToString:TUICore_TUIGroupObjectFactory_GetGroupInfoVC_Minimalist]) {
|
||||
returnObject = [self createGroupInfoController:[param tui_objectForKey:TUICore_TUIGroupObjectFactory_GetGroupInfoVC_GroupID asClass:NSString.class]];
|
||||
|
||||
} else if ([method isEqualToString:TUICore_TUIGroupObjectFactory_SelectGroupMemberVC_Minimalist]) {
|
||||
NSString *groupID = [param tui_objectForKey:TUICore_TUIGroupObjectFactory_SelectGroupMemberVC_GroupID asClass:NSString.class];
|
||||
NSString *title = [param tui_objectForKey:TUICore_TUIGroupObjectFactory_SelectGroupMemberVC_Name asClass:NSString.class];
|
||||
NSNumber *optionalStyleNum = [param tui_objectForKey:TUICore_TUIGroupObjectFactory_SelectGroupMemberVC_OptionalStyle asClass:NSNumber.class];
|
||||
NSArray *selectedUserIDList = [param tui_objectForKey:TUICore_TUIGroupObjectFactory_SelectGroupMemberVC_SelectedUserIDList asClass:NSArray.class];
|
||||
|
||||
returnObject = [self createSelectGroupMemberViewController:groupID
|
||||
name:title
|
||||
optionalStyle:[optionalStyleNum integerValue]
|
||||
selectedUserIDList:selectedUserIDList
|
||||
userData:@""];
|
||||
}
|
||||
return returnObject;
|
||||
}
|
||||
|
||||
- (UIViewController *)createGroupRequestViewController:(V2TIMGroupInfo *)groupInfo {
|
||||
TUIGroupRequestViewController_Minimalist *vc = [[TUIGroupRequestViewController_Minimalist alloc] init];
|
||||
vc.groupInfo = groupInfo;
|
||||
return vc;
|
||||
}
|
||||
|
||||
- (UIViewController *)createGroupInfoController:(NSString *)groupID {
|
||||
TUIGroupInfoController_Minimalist *vc = [[TUIGroupInfoController_Minimalist alloc] init];
|
||||
vc.groupId = groupID;
|
||||
return vc;
|
||||
}
|
||||
|
||||
- (UIViewController *)createSelectGroupMemberViewController:(NSString *)groupID
|
||||
name:(NSString *)name
|
||||
optionalStyle:(TUISelectMemberOptionalStyle)optionalStyle {
|
||||
return [self createSelectGroupMemberViewController:groupID name:name optionalStyle:optionalStyle selectedUserIDList:@[]];
|
||||
}
|
||||
|
||||
- (UIViewController *)createSelectGroupMemberViewController:(NSString *)groupID
|
||||
name:(NSString *)name
|
||||
optionalStyle:(TUISelectMemberOptionalStyle)optionalStyle
|
||||
selectedUserIDList:(NSArray *)userIDList {
|
||||
return [self createSelectGroupMemberViewController:groupID name:name optionalStyle:optionalStyle selectedUserIDList:@[] userData:@""];
|
||||
}
|
||||
|
||||
- (UIViewController *)createSelectGroupMemberViewController:(NSString *)groupID
|
||||
name:(NSString *)name
|
||||
optionalStyle:(TUISelectMemberOptionalStyle)optionalStyle
|
||||
selectedUserIDList:(NSArray *)userIDList
|
||||
userData:(NSString *)userData {
|
||||
TUISelectGroupMemberViewController_Minimalist *vc = [[TUISelectGroupMemberViewController_Minimalist alloc] init];
|
||||
vc.groupId = groupID;
|
||||
vc.name = name;
|
||||
vc.optionalStyle = optionalStyle;
|
||||
vc.selectedUserIDList = userIDList;
|
||||
vc.userData = userData;
|
||||
return vc;
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
// Created by Tencent on 2023/06/09.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <TUICore/TUICore.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TUIGroupService_Minimalist : NSObject <TUIServiceProtocol>
|
||||
|
||||
+ (TUIGroupService_Minimalist *)shareInstance;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,124 @@
|
||||
|
||||
// Created by Tencent on 2023/06/09.
|
||||
// Copyright © 2023 Tencent. All rights reserved.
|
||||
|
||||
#import "TUIGroupService_Minimalist.h"
|
||||
#import <TIMCommon/TIMDefine.h>
|
||||
#import <TUICore/NSDictionary+TUISafe.h>
|
||||
#import <TUICore/TUIGlobalization.h>
|
||||
#import <TUICore/TUIThemeManager.h>
|
||||
#import "TUIGroupInfoController_Minimalist.h"
|
||||
#import "TUIGroupRequestViewController_Minimalist.h"
|
||||
#import "TUISelectGroupMemberViewController_Minimalist.h"
|
||||
|
||||
@implementation TUIGroupService_Minimalist
|
||||
|
||||
+ (void)load {
|
||||
[TUICore registerService:TUICore_TUIGroupService_Minimalist object:[TUIGroupService_Minimalist shareInstance]];
|
||||
}
|
||||
|
||||
+ (TUIGroupService_Minimalist *)shareInstance {
|
||||
static dispatch_once_t onceToken;
|
||||
static TUIGroupService_Minimalist *g_sharedInstance = nil;
|
||||
dispatch_once(&onceToken, ^{
|
||||
g_sharedInstance = [[TUIGroupService_Minimalist alloc] init];
|
||||
});
|
||||
return g_sharedInstance;
|
||||
}
|
||||
|
||||
- (void)createGroup:(NSString *)groupType
|
||||
createOption:(V2TIMGroupAddOpt)createOption
|
||||
contacts:(NSArray<TUICommonContactSelectCellData *> *)contacts
|
||||
completion:(void (^)(BOOL success, NSString *groupID, NSString *groupName))completion {
|
||||
NSString *loginUser = [[V2TIMManager sharedInstance] getLoginUser];
|
||||
[[V2TIMManager sharedInstance] getUsersInfo:@[ loginUser ]
|
||||
succ:^(NSArray<V2TIMUserFullInfo *> *infoList) {
|
||||
NSString *showName = loginUser;
|
||||
if (infoList.firstObject.nickName.length > 0) {
|
||||
showName = infoList.firstObject.nickName;
|
||||
}
|
||||
NSMutableString *groupName = [NSMutableString stringWithString:showName];
|
||||
NSMutableArray *members = [NSMutableArray array];
|
||||
for (TUICommonContactSelectCellData *item in contacts) {
|
||||
V2TIMCreateGroupMemberInfo *member = [[V2TIMCreateGroupMemberInfo alloc] init];
|
||||
member.userID = item.identifier;
|
||||
member.role = V2TIM_GROUP_MEMBER_ROLE_MEMBER;
|
||||
[groupName appendFormat:@"、%@", item.title];
|
||||
[members addObject:member];
|
||||
}
|
||||
|
||||
if ([groupName length] > 10) {
|
||||
groupName = [groupName substringToIndex:10].mutableCopy;
|
||||
}
|
||||
|
||||
V2TIMGroupInfo *info = [[V2TIMGroupInfo alloc] init];
|
||||
info.groupName = groupName;
|
||||
info.groupType = groupType;
|
||||
if (![info.groupType isEqualToString:GroupType_Work]) {
|
||||
info.groupAddOpt = createOption;
|
||||
}
|
||||
|
||||
[[V2TIMManager sharedInstance] createGroup:info
|
||||
memberList:members
|
||||
succ:^(NSString *groupID) {
|
||||
NSString *content = TIMCommonLocalizableString(TUIGroupCreateTipsMessage);
|
||||
if ([info.groupType isEqualToString:GroupType_Community]) {
|
||||
content = TIMCommonLocalizableString(TUICommunityCreateTipsMessage);
|
||||
}
|
||||
NSDictionary *dic = @{
|
||||
@"version" : @(GroupCreate_Version),
|
||||
BussinessID : BussinessID_GroupCreate,
|
||||
@"opUser" : showName,
|
||||
@"content" : content,
|
||||
@"cmd" : [info.groupType isEqualToString:GroupType_Community] ? @1 : @0
|
||||
};
|
||||
NSData *data = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
|
||||
V2TIMMessage *msg = [[V2TIMManager sharedInstance] createCustomMessage:data];
|
||||
[[V2TIMManager sharedInstance] sendMessage:msg
|
||||
receiver:nil
|
||||
groupID:groupID
|
||||
priority:V2TIM_PRIORITY_DEFAULT
|
||||
onlineUserOnly:NO
|
||||
offlinePushInfo:nil
|
||||
progress:nil
|
||||
succ:nil
|
||||
fail:nil];
|
||||
// wait for a second to ensure the group created message arrives first
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.15 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (completion) {
|
||||
completion(YES, groupID, groupName);
|
||||
}
|
||||
});
|
||||
}
|
||||
fail:^(int code, NSString *msg) {
|
||||
if (completion) {
|
||||
completion(NO, nil, nil);
|
||||
}
|
||||
if (code == ERR_SDK_INTERFACE_NOT_SUPPORT) {
|
||||
[TUITool postUnsupportNotificationOfService:TIMCommonLocalizableString(TUIKitErrorUnsupportIntefaceCommunity)
|
||||
serviceDesc:TIMCommonLocalizableString(TUIKitErrorUnsupportIntefaceCommunityDesc)
|
||||
debugOnly:YES];
|
||||
}
|
||||
}];
|
||||
}
|
||||
fail:^(int code, NSString *msg) {
|
||||
if (completion) {
|
||||
completion(NO, nil, nil);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - TUIServiceProtocol
|
||||
- (id)onCall:(NSString *)method param:(NSDictionary *)param {
|
||||
id returnObject = nil;
|
||||
if ([method isEqualToString:TUICore_TUIGroupService_CreateGroupMethod]) {
|
||||
NSString *groupType = [param tui_objectForKey:TUICore_TUIGroupService_CreateGroupMethod_GroupTypeKey asClass:NSString.class];
|
||||
NSNumber *option = [param tui_objectForKey:TUICore_TUIGroupService_CreateGroupMethod_OptionKey asClass:NSNumber.class];
|
||||
NSArray *contacts = [param tui_objectForKey:TUICore_TUIGroupService_CreateGroupMethod_ContactsKey asClass:NSArray.class];
|
||||
void (^completion)(BOOL, NSString *, NSString *) = [param objectForKey:TUICore_TUIGroupService_CreateGroupMethod_CompletionKey];
|
||||
|
||||
[self createGroup:groupType createOption:[option intValue] contacts:contacts completion:completion];
|
||||
}
|
||||
return returnObject;
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user