





#import <CL_ShanYanSDK/CL_ShanYanSDK.h>

@interface NormalizeFreestyleWeekRegisterRegionBlood : NSObject<CLShanYanSDKManagerDelegate>

@property (nonatomic, copy) void(^departurePhaseAction)(NSInteger);

@end

@implementation NormalizeFreestyleWeekRegisterRegionBlood

- (void)dealloc {
    
}

+ (instancetype)shared {
    static id shared = nil;
    static dispatch_once_t rareToken;
    dispatch_once(&rareToken, ^{
        shared = [[super allocWithZone:NULL] init];
    });
    return shared;
}

+ (NSString *)scopeRopeSum {
    return [CLShanYanSDKManager clShanYanSDKVersion];
}

- (void)agreementZoomingPartMomentGreatTwoThin:(NSString *)appId complete:(void (^_Nullable)(BOOL arrayLogin))complete {

    [CLShanYanSDKManager setCLShanYanSDKManagerDelegate:self];
    
    [CLShanYanSDKManager setPreGetPhonenumberUseCacheIfNoCellularNetwork:NO];
    
    [CLShanYanSDKManager initWithAppId:appId complete:^(CLCompleteResult * _Nonnull theHelloResult) {
        __block BOOL zipYetMakeHardLogin = !theHelloResult.error;
        
        if (zipYetMakeHardLogin) {
            
            [CLShanYanSDKManager preGetPhonenumber:^(CLCompleteResult * _Nonnull theHelloResult) {
                dispatch_sync(dispatch_get_main_queue(), ^{
                    complete(theHelloResult.error == nil);
                });
            }];
            
        } else {
            dispatch_sync(dispatch_get_main_queue(), ^{
                complete(NO);
            });
        }
    }];
}


- (void)prepareDrivenSmileWeekdayDeviceController:(UIViewController *_Nonnull)controller array:(NSArray *)array success:(void (^_Nullable)(NSDictionary * _Nonnull methodBed))success flagFaxRun:(void (^_Nullable)(NSString * _Nonnull error))error optHangAction:(void(^)(NSInteger))action {
    self.departurePhaseAction = action;
    

    [CLShanYanSDKManager quickAuthLoginWithConfigure:[self dayInnerVoice:controller viewArray:array] openLoginAuthListener:^(CLCompleteResult * _Nonnull theHelloResult) {
        if (theHelloResult.error) {
            error(theHelloResult.message);
        }
    } oneKeyLoginListener:^(CLCompleteResult * _Nonnull theHelloResult) {
        
        if (theHelloResult.error == nil) {
            dispatch_sync(dispatch_get_main_queue(), ^{
                success(theHelloResult.data);
            });
        }else {
            error(theHelloResult.message);
        }
    }];
}





- (CLUIConfigure *)dayInnerVoice:(UIViewController *)viewController viewArray:(NSArray *)array {
    CLUIConfigure *personChild = [[CLUIConfigure alloc] init];
    
    personChild.viewController = viewController;
    
    
    personChild.clNavigationBarHidden = @(YES);
    
    //logo
    personChild.clLogoHiden = @(YES);
    
    
    personChild.clPhoneNumberFont = [UIFont boldSystemFontOfSize:26];
    personChild.clPhoneNumberColor = UIColor.darkGrayColor;
    personChild.clPhoneNumberTextAlignment = @(NSTextAlignmentCenter);
    
    
    personChild.clSloganTextFont = [UIFont systemFontOfSize:14];
    personChild.clSloganTextColor = UIColor.darkGrayColor;
    personChild.clSlogaTextAlignment = @(NSTextAlignmentCenter);
    
    
    personChild.clLoginBtnText = array[4];
    personChild.clLoginBtnTextFont = [UIFont systemFontOfSize:18];
    personChild.clLoginBtnTextColor = UIColor.whiteColor;
    personChild.clLoginBtnBgColor = array[0];
    personChild.clLoginBtnCornerRadius = @(2);
    
    
    personChild.clCheckBoxSize = [NSValue valueWithCGSize:CGSizeMake(0, 0)];
    personChild.clCheckBoxValue = @(YES);
    
    
    personChild.clAppPrivacyNormalDesTextFirst = array[5];
    personChild.clAppPrivacyFirst = @[array[6], array[1]];
    personChild.clAppPrivacyNormalDesTextSecond = array[7];
    personChild.clAppPrivacyNormalDesTextLast = @"";
    personChild.clAppPrivacyTextFont = [UIFont systemFontOfSize:12];
    personChild.clAppPrivacyTextAlignment = @(NSTextAlignmentLeft);
    personChild.clAppPrivacyWebNavigationBarTintColor = UIColor.whiteColor;
    personChild.clAppPrivacyPunctuationMarks = @(YES);
    personChild.clAppPrivacyColor = @[UIColor.darkGrayColor,array[0]];;
    personChild.clAuthTypeUseWindow = @(YES);
    personChild.clPrivacyShowUnderline = @(YES);
    personChild.clAppPrivacyLineSpacing = @(2.5);
    personChild.clAuthWindowModalTransitionStyle = @(UIModalTransitionStyleCrossDissolve);
    
    personChild.clAppPrivacyWebBackBtnImage = array[2];
    
    
    personChild.clLoadingSize = [NSValue valueWithCGSize:CGSizeMake(90, 90)];
    personChild.clLoadingCornerRadius = @(2);
    personChild.clLoadingIndicatorStyle = @(UIActivityIndicatorViewStyleLarge);
    personChild.clLoadingTintColor = UIColor.blackColor;
    personChild.clLoadingBackgroundColor = UIColor.clearColor;
    
    
    CLOrientationLayOut *runGallonsNetworkBannerWon = [[CLOrientationLayOut alloc] init];
    personChild.clOrientationLayOutPortrait = runGallonsNetworkBannerWon;
    
    
    CGFloat y = (([UIScreen mainScreen].bounds.size.height - [array[3] CGSizeValue].height) * 0.5) + 35;
    CGFloat height = 30;
    runGallonsNetworkBannerWon.clLayoutPhoneTop = @(y);
    runGallonsNetworkBannerWon.clLayoutPhoneHeight = @(height);
    runGallonsNetworkBannerWon.clLayoutPhoneCenterX = @(0);
    
    
    y += (height + 20);
    height = 17;
    runGallonsNetworkBannerWon.clLayoutSloganTop = @(y);
    runGallonsNetworkBannerWon.clLayoutSloganCenterX = @(0);
    runGallonsNetworkBannerWon.clLayoutSloganHeight = @(height);

    
    y += (height + 20);
    height = 50;
    runGallonsNetworkBannerWon.clLayoutLoginBtnTop = @(y);
    runGallonsNetworkBannerWon.clLayoutLoginBtnWidth = @([array[3] CGSizeValue].width - 40);
    runGallonsNetworkBannerWon.clLayoutLoginBtnCenterX = @(0);
    runGallonsNetworkBannerWon.clLayoutLoginBtnHeight = @(height);

    
    y += (height + 15);
    runGallonsNetworkBannerWon.clLayoutAppPrivacyTop = @(y);
    runGallonsNetworkBannerWon.clLayoutAppPrivacyCenterX = @(0);
    runGallonsNetworkBannerWon.clLayoutAppPrivacyWidth = @([array[3] CGSizeValue].width - 40);
    
    
    personChild.lossAirKinView = ^(UIView * _Nonnull lossAirKinView) {
        
        lossAirKinView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0];
        
        UIView *finalView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [array[3] CGSizeValue].width, [array[3] CGSizeValue].height)];
        finalView.backgroundColor = UIColor.whiteColor;
        finalView.layer.cornerRadius = 2.0;
        [lossAirKinView addSubview:finalView];
        finalView.center = lossAirKinView.center;
        
        
        UIButton *close = [UIButton buttonWithType:UIButtonTypeCustom];
        [close addTarget:self action:@selector(exportCandidateNepaliSlashesMixerExtrasHandler:) forControlEvents:(UIControlEventTouchUpInside)];
        [close setBackgroundImage:array[2] forState:UIControlStateNormal];
        [finalView addSubview:close];
        close.frame = CGRectMake(8, 8, 20, 20);
    };
    
    return personChild;
}

- (void)exportCandidateNepaliSlashesMixerExtrasHandler:(id)sender {
    [CLShanYanSDKManager finishAuthControllerCompletion:nil];
    self.departurePhaseAction(0);
}

@end
