






#import "ChromaticWidthViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+OrderReal.h"
#import "NSString+OddPlayback.h"

@interface ChromaticWidthViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *smileAreaBezelControl;
@property (nonatomic, strong) UIView * editGaelicTremorBeatMagnesium;
@property (nonatomic, strong) UIView * obtainStrategyExerciseArtsTerabytes;

@property (nonatomic, strong) UIScrollView * outcomeRootView;

@end

@implementation ChromaticWidthViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.dueLexiconButton.hidden = YES;
    self.whileSkinButton.hidden = YES;
    
    UISegmentedControl *noteAddView = [[UISegmentedControl alloc] initWithItems:@[DueIcyFetch.catBaseSinFill.kinSceneCanNearZoomNine,DueIcyFetch.catBaseSinFill.indicesSliderScriptsLifetimeKeyRenewing]];
    noteAddView.layer.masksToBounds = YES; 
    noteAddView.layer.cornerRadius = 2;    
    [noteAddView setTitleTextAttributes:@{NSForegroundColorAttributeName:[DueIcyFetch outPostalColor]} forState:UIControlStateSelected];
    [noteAddView setTitleTextAttributes:@{NSForegroundColorAttributeName:[DueIcyFetch outPostalColor]} forState:UIControlStateNormal];
    [self.view addSubview:noteAddView];
    [noteAddView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(DueIcyFetch.itsPosterIcy.fadeFoodEye);
    }];
    [noteAddView addTarget:self action:@selector(fireRaceIdiom:) forControlEvents:UIControlEventValueChanged];
    self.smileAreaBezelControl = noteAddView;
    
    _outcomeRootView = [[UIScrollView alloc]init];
    _outcomeRootView.pagingEnabled = YES;
    _outcomeRootView.delegate = self;
    [self.view addSubview:_outcomeRootView];
    [_outcomeRootView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(DueIcyFetch.itsPosterIcy.designSpaCar);
        make.right.equalTo(self.view).offset(-DueIcyFetch.itsPosterIcy.designSpaCar);
        make.top.equalTo(self.view).offset(DueIcyFetch.itsPosterIcy.pingMouseSum);
        make.bottom.equalTo(self.view).offset(-DueIcyFetch.itsPosterIcy.bedHowSupply);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.outcomeRootView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.outcomeRootView);
        make.height.equalTo(_outcomeRootView);
    }];
    
    UIView * areFoundHard = [self checkedBusView:[DueIcyFetch keepIncomingResourcesInternalSpherical]];
    [containerView addSubview:areFoundHard];
    [areFoundHard mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.outcomeRootView);
    }];
    self.editGaelicTremorBeatMagnesium = areFoundHard;
    
    UIView * itsMaskStair = [self checkedBusView:[DueIcyFetch streetLuminanceRedClockHebrew]];
    [containerView addSubview:itsMaskStair];
    [itsMaskStair mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(areFoundHard.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.outcomeRootView);
    }];
    self.obtainStrategyExerciseArtsTerabytes = itsMaskStair;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(itsMaskStair.mas_right);
    }];
    
    if (![self.weeklySpeed boolValue]) {
        UIButton *sexPartButton = [DueIcyFetch expertNetBitsSplatHeaderColor:DueIcyFetch.catBaseSinFill.bitChangeIcy];
        [sexPartButton setBackgroundImage:[UIImage pinRatioTheMenColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [sexPartButton addTarget:self action:@selector(originsIgnoringMoveOffInhalerExpose:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:sexPartButton];
        [sexPartButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-DueIcyFetch.itsPosterIcy.thirdWasPop);
            make.centerX.equalTo(self.view).multipliedBy(.65);
            make.height.mas_equalTo(DueIcyFetch.itsPosterIcy.appearTooKit);
        }];
    }
    
    UIButton *originsButton =  [DueIcyFetch expertNetBitsSplatHeaderColor:DueIcyFetch.catBaseSinFill.planRadial];
    [originsButton addTarget:self action:@selector(hasStreamAchievedSocketExpensiveRemembers:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:originsButton];
    [originsButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-DueIcyFetch.itsPosterIcy.thirdWasPop);
        make.centerX.equalTo(self.view).multipliedBy(![self.weeklySpeed boolValue]?1.35:1);
        make.height.mas_equalTo(DueIcyFetch.itsPosterIcy.appearTooKit);
    }];
    
    noteAddView.selectedSegmentIndex = 0;
    [self fireRaceIdiom:noteAddView];
}

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

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

- (void)consoleDiscardDistortedAcquireFaxText:(NSInteger)type {
    NSString *loudAnyPut = nil;
    UIView *contentView = nil;
    loudAnyPut = type == 0 ? [DueIcyFetch keepIncomingResourcesInternalSpherical]:[DueIcyFetch streetLuminanceRedClockHebrew];
    contentView = type == 0 ? self.editGaelicTremorBeatMagnesium:self.obtainStrategyExerciseArtsTerabytes;
    
    if (loudAnyPut.icyAreDigest) {
        return;
    }
    
    if ([[loudAnyPut pathExtension] containsString:DueIcyFetch.itsPosterIcy.drainBookmarksGopherRollbackFloor]) {
        UITextView *anyView = (UITextView *)contentView;
        if (anyView.text.length > 0) {
            return;
        }

        
        [BinaryBankView cookiesStrideView:contentView];

        
        NSURL *url = [NSURL URLWithString:loudAnyPut];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [BinaryBankView candidateReviewEnsureLowAdjustView:contentView];
                
                if (error || data.length == 0) {
                    
                    anyView.text = DueIcyFetch.catBaseSinFill.clipReadOrnamentsRefreshFilmSeven;
                    return;
                }
                
                
                NSString *threeDidMagic = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                anyView.text = threeDidMagic ?: DueIcyFetch.catBaseSinFill.rotatingEyeGivenMillionPasswordsOneArt;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *arcade = (WKWebView *)contentView;
        if (!arcade.isLoading && arcade.estimatedProgress == 1) {
            [BinaryBankView candidateReviewEnsureLowAdjustView:contentView];
            return;
        }
        [BinaryBankView cookiesStrideView:contentView];
        NSString *disparity =  [loudAnyPut.localizedStillExchangeDetachingArtReleased stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:disparity];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [arcade loadRequest:request];
    }
}

- (void)originsIgnoringMoveOffInhalerExpose:(id)sender {
    [self shiftFinnishSumPenLiftAction:nil];
    if (self.cleanQueueThermalViabilitySlashes) {
        self.cleanQueueThermalViabilitySlashes(NO);
    }
}

- (void)hasStreamAchievedSocketExpensiveRemembers:(id)sender {
    [self shiftFinnishSumPenLiftAction:nil];
    if (self.cleanQueueThermalViabilitySlashes) {
        self.cleanQueueThermalViabilitySlashes(YES);
    }
}

- (UIView *)checkedBusView:(NSString *)string {
    UIView *movementBig = nil;
    if ([[string pathExtension] containsString:DueIcyFetch.itsPosterIcy.drainBookmarksGopherRollbackFloor]) {
        UITextView * halfPrep = [UITextView new];
        halfPrep.editable = NO;
        halfPrep.backgroundColor = UIColor.whiteColor;
        halfPrep.textColor = UIColor.grayColor;
        movementBig = halfPrep;
    }else {
        WKWebView *whoEraPause = [[WKWebView alloc] initWithFrame:CGRectZero];
        whoEraPause.backgroundColor = UIColor.clearColor;
        whoEraPause.scrollView.backgroundColor = UIColor.lightGrayColor;
        whoEraPause.opaque = YES;
        whoEraPause.scrollView.bounces =NO;
        whoEraPause.scrollView.showsVerticalScrollIndicator = NO;
        whoEraPause.scrollView.showsHorizontalScrollIndicator = NO;
        whoEraPause.navigationDelegate = self;
        movementBig = whoEraPause;
    }
    return movementBig;
}

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

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

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

@end
