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

#import "CNLiveListManager.h"
#import "CNCategoryGetChannelModel.h"
#import "CNLiveClassifySegmentController.h"

@interface CNLiveListManager()
{
    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;
}

+(CNCategoryBaseViewController *)CNCategoryBaseViewController
{
    return [[CNLiveClassifySegmentController alloc] init];
}

-(UIViewController *)model:(CNCategoryGetChannelModel *)model black:(BOOL)black bgImage:(NSString *)bgImage bgColor:(nonnull NSString *)bgColor bgImageH5:(nonnull NSString *)bgImageH5
{
    NSDictionary * paramDic = nil;
    if ([model.pageType isEqualToString:@"4"] || [model.pageType isEqualToString:@"5"]){
         paramDic= @{
             @"title": model.showName?model.showName:@"",
            @"bgColor": bgColor?bgColor:@"",
            @"isBlack":@(black),
             @"backgroundImg": bgImage?bgImage:@"",
             @"channelId":model.channelId?model.channelId:@"",
             @"channelName":model.id?model.id:@"",
             @"pageId":model.pageId?model.pageId:@""
            
        };
    }else{
         paramDic= @{
            @"title": model.showName?model.showName:@"",
            @"bgColor": bgColor?bgColor:@"",
            @"isBlack":@(black),
            @"thirdUrl":model.thirdUrl?model.thirdUrl:@"",
            @"backgroundImgH5":bgImageH5?bgImageH5:@""
        };
    }
   UIViewController *subVC = [CNLiveClassifyJumpBridge ListViewWithPageType:model.pageType.integerValue param:paramDic];
    return subVC;
}
- (void)requestWebViewForScrollView:(nonnull UIScrollView *)scrollView isBeginDragging:(BOOL)isBeginDragging
{
    if (isBeginDragging) {
        beginoffsetY = scrollView.offsetY;
    }else
    {
        if (scrollView.offsetY - beginoffsetY>5) {
            !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(YES);
        }else if (scrollView.offsetY - beginoffsetY<0) {
            !self.scrollViewDidScrollBlock ?: self.scrollViewDidScrollBlock(NO);
        }
    }
}

@end