CNLiveCServiceManagerBridge.m 2.86 KB
//
//  CNLiveCServiceManagerBridge.m
//  CNLiveCServiceModule
//
//  Created by CNLive on 2021/12/2.
//

#import "CNLiveCServiceManagerBridge.h"
#import "CNLiveServicePresent.h"
#import "CNLiveServiceVC.h"

@implementation CNLiveCServiceManagerBridge
+ (instancetype)shareManager{
    static dispatch_once_t onceToken;
    static CNLiveCServiceManagerBridge *bridge = nil;
    dispatch_once(&onceToken, ^{
        bridge = [[CNLiveCServiceManagerBridge alloc] init];
    });
    return bridge;
}
- (instancetype)init
{
    self = [super init];
    if (self) {
        Class class = NSClassFromString(@"CNLiveCServiceModuleImpl");
        self.protocol = [class new];
    }
    return self;
}

+ (void)jumpServiceController:(NSString *)serviceId type:(NSString *)type to:(NSString *)to shopType:(NSString *)shopType controller:(UIViewController *)controller
{
    [CNLiveCServiceManagerBridge jumpServiceType:CNCServiceJumpTypeService service:serviceId type:type to:to shopType:shopType controller:controller];
}
+ (void)jumpServiceType:(CNCServiceJumpType)jumpType service:(NSString *)serviceId type:(NSString *)type to:(NSString *)to shopType:(NSString *)shopType controller:(UIViewController *)controller{
    NSDictionary *param = @{
        @"serviceId":serviceId,
        @"type":type,
        @"to":to,
        @"shopType":shopType,
    };
    [CNLiveCServiceManagerBridge jumpViewControllerType:jumpType param:param controller:controller];
}
+ (void)jumpGoodsViewController:(NSString *)goodsId controller:(UIViewController *)controller
{
    NSDictionary *param = @{
        @"goodsId":goodsId,
    };
    [CNLiveCServiceManagerBridge jumpViewControllerType:CNCServiceJumpTypeGoods param:param controller:controller];
}
+ (void)jumpGetPageOtherVC:(NSString *)contentId controller:(UIViewController *)controller{
    [QMUITips showLoadingInView:controller.view];
    [CNLiveServicePresent loadServiceInfoServiceId:contentId result:^(CNLiveSearchModel * _Nonnull model) {
        [QMUITips hideAllTips];
        [CNLiveCServiceManagerBridge jumpServiceController:model.id type:model.type to:model.to shopType:model.shopType controller:controller];
    } error:^{
        [QMUITips hideAllTips];
    }];
}
+ (void)jumpViewControllerType:(CNCServiceJumpType)type param:(NSDictionary *)param controller:(UIViewController *)controller{
    
    [[CNLiveCServiceManagerBridge shareManager].protocol jumpControllerType:type param:param controller:controller];
}

+ (UIViewController *)viewControllerFromView:(UIView *)view {
    for (UIView *next = [view superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
}
+ (CNLiveServiceVC *)serviceVC{
    CNLiveServiceVC *vc = [[CNLiveServiceVC alloc] init];
    return vc;
}
@end