CNLiveListManager.m 2.14 KB
//
//  CNLiveListManager.m
//  CNLiveVideoClassifyKit
//
//  Created by CNLive on 2021/9/8.
//

#import "CNLiveListManager.h"
#import "CNCategoryGetChannelModel.h"
#import <CNLiveCWebViewModule/CNLiveCWebViewModule.h>
#import <CNLiveCWebViewModule/CNLiveSubWebViewController.h>
#import "CNLiveVideoClassifyProtocol.h"

@interface CNLiveListManager()
{
    BOOL _black;
    CNCategoryGetChannelModel *_model;
    CGFloat beginoffsetY;
}
@end

@implementation CNLiveListManager
+(instancetype)shareListManager
{
    static dispatch_once_t onceToken;
    static CNLiveListManager *manager = nil;
    dispatch_once(&onceToken, ^{
        manager = [[CNLiveListManager alloc] init];
    });
    return manager;
}


-(void)model:(CNCategoryGetChannelModel *)model black:(BOOL)black
{
    _model = model;
    _black = black;
}
- (void)requestWebViewForScrollView:(nonnull UIScrollView *)scrollView isBeginDragging:(BOOL)isBeginDragging
{
    if (isBeginDragging) {
        beginoffsetY = scrollView.offsetY;
    }else
    {
        if (scrollView.offsetY - beginoffsetY>2) {
            !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(YES);
        }else if (scrollView.offsetY - beginoffsetY<-2) {
            !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(NO);
        }
    }
}


#pragma mark - JXCategoryListContentViewDelegate

/**
 实现 <JXCategoryListContentViewDelegate> 协议方法,返回该视图控制器所拥有的「视图」
 */
- (UIView *)listView {
    if ([_model.pageType isEqualToString:@"4"] || [_model.pageType isEqualToString:@"5"]){
        Class class = NSClassFromString(@"CNLiveClassifyKitImpl");
//        [[BeeHive shareInstance] registerService:cnlivevid service:<#(__unsafe_unretained Class)#>];
    }
    NSDictionary * paramDic= @{
        @"title": _model.showName,
        @"intercept": @(YES),
        @"isBlack":@(_black)
        
    };
    CNLiveSubWebViewController *subVC = [CNLiveCWebViewModule showWebVCWithLunchForWebURL:_model.thirdUrl
                                ParamDict:paramDic ShowType:CNLiveWebViewLunchShowTypeHidden];
    [self.contentVC addChildViewController:subVC];
    return subVC.view;
}
@end