






#import "RedOneMillBestViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+SeeSupply.h"
#import "NSString+HisFillLess.h"

@interface RedOneMillBestViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *holdModalSugarControl;
@property (nonatomic, strong) UIView * discoverySyntaxPutBusMusical;
@property (nonatomic, strong) UIView * salientPauseEmailAuditedPeople;

@property (nonatomic, strong) UIScrollView * nowHandlingView;

@end

@implementation RedOneMillBestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.voiceClockButton.hidden = YES;
    self.bevelTapsButton.hidden = YES;
    
    UISegmentedControl *strokedView = [[UISegmentedControl alloc] initWithItems:@[BestSharpen.hangFillerPick.sixteenIndirectLettishVisibleFarsiNone,BestSharpen.hangFillerPick.sinhaleseObjectHierarchyAttachVitalityProgram]];
    strokedView.layer.masksToBounds = YES; 
    strokedView.layer.cornerRadius = 2;    
    [strokedView setTitleTextAttributes:@{NSForegroundColorAttributeName:[BestSharpen sawExportColor]} forState:UIControlStateSelected];
    [strokedView setTitleTextAttributes:@{NSForegroundColorAttributeName:[BestSharpen sawExportColor]} forState:UIControlStateNormal];
    [self.view addSubview:strokedView];
    [strokedView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(BestSharpen.didNapCoptic.surgeSpaSaw);
    }];
    [strokedView addTarget:self action:@selector(scatteredFile:) forControlEvents:UIControlEventValueChanged];
    self.holdModalSugarControl = strokedView;
    
    _nowHandlingView = [[UIScrollView alloc]init];
    _nowHandlingView.pagingEnabled = YES;
    _nowHandlingView.delegate = self;
    [self.view addSubview:_nowHandlingView];
    [_nowHandlingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(BestSharpen.didNapCoptic.modifyInland);
        make.right.equalTo(self.view).offset(-BestSharpen.didNapCoptic.modifyInland);
        make.top.equalTo(self.view).offset(BestSharpen.didNapCoptic.spaEmptySafe);
        make.bottom.equalTo(self.view).offset(-BestSharpen.didNapCoptic.wasTagLaunch);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.nowHandlingView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.nowHandlingView);
        make.height.equalTo(_nowHandlingView);
    }];
    
    UIView * oneWireFatal = [self consoleFitView:[BestSharpen dietaryPhaseFatPermittedRestart]];
    [containerView addSubview:oneWireFatal];
    [oneWireFatal mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.nowHandlingView);
    }];
    self.discoverySyntaxPutBusMusical = oneWireFatal;
    
    UIView * needTraining = [self consoleFitView:[BestSharpen nicknameNegotiateSpecifierAccessedTexture]];
    [containerView addSubview:needTraining];
    [needTraining mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(oneWireFatal.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.nowHandlingView);
    }];
    self.salientPauseEmailAuditedPeople = needTraining;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(needTraining.mas_right);
    }];
    
    if (![self.tenHitError boolValue]) {
        UIButton *callHitButton = [BestSharpen idiomBikeNineRebusEmailColor:BestSharpen.hangFillerPick.croatianBeat];
        [callHitButton setBackgroundImage:[UIImage fatArmDrumSlowColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [callHitButton addTarget:self action:@selector(tapAbortOptionalElderMediaPicker:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:callHitButton];
        
        [callHitButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-BestSharpen.didNapCoptic.hoursDomain);
            make.left.equalTo(self.view).offset(BestSharpen.didNapCoptic.modifyInland);
            make.right.equalTo(self.view.mas_centerX).offset(-BestSharpen.didNapCoptic.eggPanGuide);
            make.height.mas_equalTo(BestSharpen.didNapCoptic.monthOffTrad);
        }];
    }

    UIButton *illWillButton =  [BestSharpen idiomBikeNineRebusEmailColor:BestSharpen.hangFillerPick.creditRows];
    [illWillButton addTarget:self action:@selector(slovakOffsetsTopPagerContactsDrag:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:illWillButton];
    BOOL legalButton = ![self.tenHitError boolValue];
    [illWillButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-BestSharpen.didNapCoptic.hoursDomain);
        make.right.equalTo(self.view).offset(-BestSharpen.didNapCoptic.modifyInland);
        
        if (legalButton) {
            make.left.equalTo(self.view.mas_centerX).offset(BestSharpen.didNapCoptic.eggPanGuide);
        } else {
            make.left.equalTo(self.view).offset(BestSharpen.didNapCoptic.modifyInland);
        }
        make.height.mas_equalTo(BestSharpen.didNapCoptic.monthOffTrad);
    }];
    
    strokedView.selectedSegmentIndex = 0;
    [self scatteredFile:strokedView];
}

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

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

- (void)fairPublisherPhoneEnteredPrepareText:(NSInteger)type {
    NSString *nodeAppend = nil;
    UIView *contentView = nil;
    nodeAppend = type == 0 ? [BestSharpen dietaryPhaseFatPermittedRestart]:[BestSharpen nicknameNegotiateSpecifierAccessedTexture];
    contentView = type == 0 ? self.discoverySyntaxPutBusMusical:self.salientPauseEmailAuditedPeople;
    
    if (nodeAppend.badUptimeSon) {
        return;
    }
    
    if ([[nodeAppend pathExtension] containsString:BestSharpen.didNapCoptic.revealedAnimatedCutGolfWill]) {
        UITextView *putView = (UITextView *)contentView;
        if (putView.text.length > 0) {
            return;
        }

        
        [CheckFloorView pullScopeSameView:contentView];

        
        NSURL *url = [NSURL URLWithString:nodeAppend];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [CheckFloorView alphaLeastRefreshedWillBuildView:contentView];
                
                if (error || data.length == 0) {
                    
                    putView.text = BestSharpen.hangFillerPick.phraseAdditiveOutsideOperatingRotorBiotin;
                    return;
                }
                
                
                NSString *fatAddFacePan = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                putView.text = fatAddFacePan ?: BestSharpen.hangFillerPick.monthProtectedLastDelayGuestFragmentFourth;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *lowKin = (WKWebView *)contentView;
        if (!lowKin.isLoading && lowKin.estimatedProgress == 1) {
            [CheckFloorView alphaLeastRefreshedWillBuildView:contentView];
            return;
        }
        [CheckFloorView pullScopeSameView:contentView];
        NSString *trapMusic =  [nodeAppend.fallbackCupMathMixPieceSigmoid stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:trapMusic];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [lowKin loadRequest:request];
    }
}

- (void)tapAbortOptionalElderMediaPicker:(id)sender {
    [self delayedChangeIcelandicCivilThumbnailAction:nil];
    if (self.ticketsArtDateDeferringBook) {
        self.ticketsArtDateDeferringBook(NO);
    }
}

- (void)slovakOffsetsTopPagerContactsDrag:(id)sender {
    [self delayedChangeIcelandicCivilThumbnailAction:nil];
    if (self.ticketsArtDateDeferringBook) {
        self.ticketsArtDateDeferringBook(YES);
    }
}

- (UIView *)consoleFitView:(NSString *)string {
    UIView *bendPackCat = nil;
    if ([[string pathExtension] containsString:BestSharpen.didNapCoptic.revealedAnimatedCutGolfWill]) {
        UITextView * ageStart = [UITextView new];
        ageStart.editable = NO;
        ageStart.backgroundColor = UIColor.whiteColor;
        ageStart.textColor = UIColor.grayColor;
        bendPackCat = ageStart;
    }else {
        WKWebView *beaconsBank = [[WKWebView alloc] initWithFrame:CGRectZero];
        beaconsBank.backgroundColor = UIColor.clearColor;
        beaconsBank.scrollView.backgroundColor = UIColor.lightGrayColor;
        beaconsBank.opaque = YES;
        beaconsBank.scrollView.bounces =NO;
        beaconsBank.scrollView.showsVerticalScrollIndicator = NO;
        beaconsBank.scrollView.showsHorizontalScrollIndicator = NO;
        beaconsBank.navigationDelegate = self;
        bendPackCat = beaconsBank;
    }
    return bendPackCat;
}

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

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

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

@end
