






#import "GainClipPinCanViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+ExitsText.h"
#import "NSString+SupportFind.h"

@interface GainClipPinCanViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *weekArtistWalkControl;
@property (nonatomic, strong) UIView * canAllDisposeAppearsFlight;
@property (nonatomic, strong) UIView * notationNicknameNominalBecomeEye;

@property (nonatomic, strong) UIScrollView * pasteIllFarView;

@end

@implementation GainClipPinCanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.nonceFlashButton.hidden = YES;
    self.lengthLawButton.hidden = YES;
    
    UISegmentedControl *readoutView = [[UISegmentedControl alloc] initWithItems:@[SkinMeanYet.faxHoldTakePin.departureRangeSelectedLayoutDeveloperGasp,SkinMeanYet.faxHoldTakePin.signerBehaveBuilderMinLeadPress]];
    readoutView.layer.masksToBounds = YES; 
    readoutView.layer.cornerRadius = 2;    
    [readoutView setTitleTextAttributes:@{NSForegroundColorAttributeName:[SkinMeanYet configureColor]} forState:UIControlStateSelected];
    [readoutView setTitleTextAttributes:@{NSForegroundColorAttributeName:[SkinMeanYet configureColor]} forState:UIControlStateNormal];
    [self.view addSubview:readoutView];
    [readoutView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(SkinMeanYet.reloadRawDay.counterSpan);
    }];
    [readoutView addTarget:self action:@selector(maskCoverStop:) forControlEvents:UIControlEventValueChanged];
    self.weekArtistWalkControl = readoutView;
    
    _pasteIllFarView = [[UIScrollView alloc]init];
    _pasteIllFarView.pagingEnabled = YES;
    _pasteIllFarView.delegate = self;
    [self.view addSubview:_pasteIllFarView];
    [_pasteIllFarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(SkinMeanYet.reloadRawDay.foundRoomSaw);
        make.right.equalTo(self.view).offset(-SkinMeanYet.reloadRawDay.foundRoomSaw);
        make.top.equalTo(self.view).offset(SkinMeanYet.reloadRawDay.wetRatioWait);
        make.bottom.equalTo(self.view).offset(-SkinMeanYet.reloadRawDay.binDailyEast);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.pasteIllFarView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.pasteIllFarView);
        make.height.equalTo(_pasteIllFarView);
    }];
    
    UIView * wayAxesSerif = [self paceFactorView:[SkinMeanYet chatFailingOverflowHeadsetAre]];
    [containerView addSubview:wayAxesSerif];
    [wayAxesSerif mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.pasteIllFarView);
    }];
    self.canAllDisposeAppearsFlight = wayAxesSerif;
    
    UIView * checkerCount = [self paceFactorView:[SkinMeanYet eraBankOddHigherAvailable]];
    [containerView addSubview:checkerCount];
    [checkerCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(wayAxesSerif.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.pasteIllFarView);
    }];
    self.notationNicknameNominalBecomeEye = checkerCount;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(checkerCount.mas_right);
    }];
    
    if (![self.mixFatOffer boolValue]) {
        UIButton *bitsTryButton = [SkinMeanYet floaterJobAggregateImpactMattingColor:SkinMeanYet.faxHoldTakePin.pingPubTatar];
        [bitsTryButton setBackgroundImage:[UIImage quickOldOurAgeColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [bitsTryButton addTarget:self action:@selector(splatScopeRoleLaunchHeartbeatTight:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:bitsTryButton];
        [bitsTryButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-SkinMeanYet.reloadRawDay.youngestHit);
            make.centerX.equalTo(self.view).multipliedBy(.65);
            make.height.mas_equalTo(SkinMeanYet.reloadRawDay.dialogKitOwn);
        }];
    }
    
    UIButton *webpageButton =  [SkinMeanYet floaterJobAggregateImpactMattingColor:SkinMeanYet.faxHoldTakePin.tryWideCat];
    [webpageButton addTarget:self action:@selector(staticOwnerLateYetMindKey:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:webpageButton];
    [webpageButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-SkinMeanYet.reloadRawDay.youngestHit);
        make.centerX.equalTo(self.view).multipliedBy(![self.mixFatOffer boolValue]?1.35:1);
        make.height.mas_equalTo(SkinMeanYet.reloadRawDay.dialogKitOwn);
    }];
    
    readoutView.selectedSegmentIndex = 0;
    [self maskCoverStop:readoutView];
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    [self.weekArtistWalkControl setSelectedSegmentIndex:scrollView.contentOffset.x/self.view.frame.size.width ==0?0:1];
    [self americanLaunchSinEncipherMouseText:scrollView.contentOffset.x/self.view.frame.size.width ==0?0:1];
}

- (void)maskCoverStop:(UISegmentedControl *)sender {
    [self americanLaunchSinEncipherMouseText:sender.selectedSegmentIndex == 0?0:1];
    [self.pasteIllFarView setContentOffset:CGPointMake(sender.selectedSegmentIndex == 0?0:self.pasteIllFarView.frame.size.width, 0) animated:YES];
}

- (void)americanLaunchSinEncipherMouseText:(NSInteger)type {
    NSString *midHaveMap = nil;
    UIView *contentView = nil;
    midHaveMap = type == 0 ? [SkinMeanYet chatFailingOverflowHeadsetAre]:[SkinMeanYet eraBankOddHigherAvailable];
    contentView = type == 0 ? self.canAllDisposeAppearsFlight:self.notationNicknameNominalBecomeEye;
    
    if (midHaveMap.fourApplyMax) {
        return;
    }
    
    if ([[midHaveMap pathExtension] containsString:SkinMeanYet.reloadRawDay.ourRepairRepliesGatheringConnected]) {
        UITextView *midView = (UITextView *)contentView;
        if (midView.text.length > 0) {
            return;
        }

        
        [AmpereWalkView ruleSlashItemView:contentView];

        
        NSURL *url = [NSURL URLWithString:midHaveMap];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [AmpereWalkView hertzSlideFixRefreshFixView:contentView];
                
                if (error || data.length == 0) {
                    
                    midView.text = SkinMeanYet.faxHoldTakePin.adverbMissingBlobStylisticExtensionInstall;
                    return;
                }
                
                
                NSString *bothAdjusting = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                midView.text = bothAdjusting ?: SkinMeanYet.faxHoldTakePin.sevenRetrieveKilobytesFourteenCarEnablingUnderage;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *safety = (WKWebView *)contentView;
        if (!safety.isLoading && safety.estimatedProgress == 1) {
            [AmpereWalkView hertzSlideFixRefreshFixView:contentView];
            return;
        }
        [AmpereWalkView ruleSlashItemView:contentView];
        NSString *performer =  [midHaveMap.ciphersUnifyScriptsWeightedFixtureChamber stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:performer];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [safety loadRequest:request];
    }
}

- (void)splatScopeRoleLaunchHeartbeatTight:(id)sender {
    [self endGreekAlarmMayFloaterAction:nil];
    if (self.subgroupsClimbingGujaratiCancelsSun) {
        self.subgroupsClimbingGujaratiCancelsSun(NO);
    }
}

- (void)staticOwnerLateYetMindKey:(id)sender {
    [self endGreekAlarmMayFloaterAction:nil];
    if (self.subgroupsClimbingGujaratiCancelsSun) {
        self.subgroupsClimbingGujaratiCancelsSun(YES);
    }
}

- (UIView *)paceFactorView:(NSString *)string {
    UIView *offSinPulse = nil;
    if ([[string pathExtension] containsString:SkinMeanYet.reloadRawDay.ourRepairRepliesGatheringConnected]) {
        UITextView * brushFat = [UITextView new];
        brushFat.editable = NO;
        brushFat.backgroundColor = UIColor.whiteColor;
        brushFat.textColor = UIColor.grayColor;
        offSinPulse = brushFat;
    }else {
        WKWebView *rateAllView = [[WKWebView alloc] initWithFrame:CGRectZero];
        rateAllView.backgroundColor = UIColor.clearColor;
        rateAllView.scrollView.backgroundColor = UIColor.lightGrayColor;
        rateAllView.opaque = YES;
        rateAllView.scrollView.bounces =NO;
        rateAllView.scrollView.showsVerticalScrollIndicator = NO;
        rateAllView.scrollView.showsHorizontalScrollIndicator = NO;
        rateAllView.navigationDelegate = self;
        offSinPulse = rateAllView;
    }
    return offSinPulse;
}

- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
    [AmpereWalkView hertzSlideFixRefreshFixView:webView];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    UIEdgeInsets hostingZip = [[TeaspoonsManager shared] ourHostPhaseWindow].safeAreaInsets;
    hostingZip.top    += 10;
    hostingZip.left   += 10;
    hostingZip.bottom += 10;
    hostingZip.right  += 10;

    [self.view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(hostingZip);
    }];
}

@end
