






#import "OptVeryDrawEndViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+MoreAlien.h"
#import "NSString+MayFloorSee.h"

@interface OptVeryDrawEndViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *failGetLoopDryControl;
@property (nonatomic, strong) UIView * cupFarIntervalsRepublicCurrently;
@property (nonatomic, strong) UIView * maxPhotoScriptsConstructEnd;

@property (nonatomic, strong) UIScrollView * adobeTopBedView;

@end

@implementation OptVeryDrawEndViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.impactZoneButton.hidden = YES;
    self.justifiedButton.hidden = YES;
    
    UISegmentedControl *pastWetView = [[UISegmentedControl alloc] initWithItems:@[BigAddition.lateTapLineAll.pointerRoundBarsRatioFairGrade,BigAddition.lateTapLineAll.oceanGenerateDeepPutGrayGoal]];
    pastWetView.layer.masksToBounds = YES; 
    pastWetView.layer.cornerRadius = 2;    
    [pastWetView setTitleTextAttributes:@{NSForegroundColorAttributeName:[BigAddition portHumanColor]} forState:UIControlStateSelected];
    [pastWetView setTitleTextAttributes:@{NSForegroundColorAttributeName:[BigAddition portHumanColor]} forState:UIControlStateNormal];
    [self.view addSubview:pastWetView];
    [pastWetView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(BigAddition.noiseFactMen.weekdayJust);
    }];
    [pastWetView addTarget:self action:@selector(morePanelStop:) forControlEvents:UIControlEventValueChanged];
    self.failGetLoopDryControl = pastWetView;
    
    _adobeTopBedView = [[UIScrollView alloc]init];
    _adobeTopBedView.pagingEnabled = YES;
    _adobeTopBedView.delegate = self;
    [self.view addSubview:_adobeTopBedView];
    [_adobeTopBedView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(BigAddition.noiseFactMen.proximityYou);
        make.right.equalTo(self.view).offset(-BigAddition.noiseFactMen.proximityYou);
        make.top.equalTo(self.view).offset(BigAddition.noiseFactMen.drawJapanese);
        make.bottom.equalTo(self.view).offset(-BigAddition.noiseFactMen.yetAvailJust);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.adobeTopBedView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.adobeTopBedView);
        make.height.equalTo(_adobeTopBedView);
    }];
    
    UIView * likeMenFound = [self planeAlienView:[BigAddition affectingHandleRunningVortexStamp]];
    [containerView addSubview:likeMenFound];
    [likeMenFound mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.adobeTopBedView);
    }];
    self.cupFarIntervalsRepublicCurrently = likeMenFound;
    
    UIView * pubChallenge = [self planeAlienView:[BigAddition accurateExpectingExpansionIcySite]];
    [containerView addSubview:pubChallenge];
    [pubChallenge mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(likeMenFound.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.adobeTopBedView);
    }];
    self.maxPhotoScriptsConstructEnd = pubChallenge;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(pubChallenge.mas_right);
    }];
    
    if (![self.primaryMile boolValue]) {
        UIButton *maleForButton = [BigAddition jabberMenLowWhoCleanupColor:BigAddition.lateTapLineAll.oceanAreTime];
        [maleForButton setBackgroundImage:[UIImage everyLearnFootColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [maleForButton addTarget:self action:@selector(outSignalingTemplateSawRectifiedObscures:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:maleForButton];
        [maleForButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-BigAddition.noiseFactMen.noteCallBut);
            make.centerX.equalTo(self.view).multipliedBy(.65);
            make.height.mas_equalTo(BigAddition.noiseFactMen.ditherMetric);
        }];
    }
    
    UIButton *numeralButton =  [BigAddition jabberMenLowWhoCleanupColor:BigAddition.lateTapLineAll.useEdgaMin];
    [numeralButton addTarget:self action:@selector(snapReachableOfferPreventLeapGolf:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:numeralButton];
    [numeralButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-BigAddition.noiseFactMen.noteCallBut);
        make.centerX.equalTo(self.view).multipliedBy(![self.primaryMile boolValue]?1.35:1);
        make.height.mas_equalTo(BigAddition.noiseFactMen.ditherMetric);
    }];
    
    pastWetView.selectedSegmentIndex = 0;
    [self morePanelStop:pastWetView];
}

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

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

- (void)areaHerWristAnchoringHeadsetText:(NSInteger)type {
    NSString *faxHosting = nil;
    UIView *contentView = nil;
    faxHosting = type == 0 ? [BigAddition affectingHandleRunningVortexStamp]:[BigAddition accurateExpectingExpansionIcySite];
    contentView = type == 0 ? self.cupFarIntervalsRepublicCurrently:self.maxPhotoScriptsConstructEnd;
    
    if (faxHosting.tradFetchShe) {
        return;
    }
    
    if ([[faxHosting pathExtension] containsString:BigAddition.noiseFactMen.domainsTorqueWordCompressDrop]) {
        UITextView *artView = (UITextView *)contentView;
        if (artView.text.length > 0) {
            return;
        }

        
        [AllSunLoopView penTopSurfaceView:contentView];

        
        NSURL *url = [NSURL URLWithString:faxHosting];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [AllSunLoopView utilityBeatProtectedOverallVibrancyView:contentView];
                
                if (error || data.length == 0) {
                    
                    artView.text = BigAddition.lateTapLineAll.hockeyWillConflictsGlyphCurrentlySilence;
                    return;
                }
                
                
                NSString *basalWinGreek = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                artView.text = basalWinGreek ?: BigAddition.lateTapLineAll.sentTibetanExistingThiaminClinicalFailingBits;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *sumBut = (WKWebView *)contentView;
        if (!sumBut.isLoading && sumBut.estimatedProgress == 1) {
            [AllSunLoopView utilityBeatProtectedOverallVibrancyView:contentView];
            return;
        }
        [AllSunLoopView penTopSurfaceView:contentView];
        NSString *farQuotes =  [faxHosting.promotionDaughterThreadUsedBinaryDarwin stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:farQuotes];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [sumBut loadRequest:request];
    }
}

- (void)outSignalingTemplateSawRectifiedObscures:(id)sender {
    [self clickBatchLawMicroDisallowAction:nil];
    if (self.notifyingDeletionTremorOptDividing) {
        self.notifyingDeletionTremorOptDividing(NO);
    }
}

- (void)snapReachableOfferPreventLeapGolf:(id)sender {
    [self clickBatchLawMicroDisallowAction:nil];
    if (self.notifyingDeletionTremorOptDividing) {
        self.notifyingDeletionTremorOptDividing(YES);
    }
}

- (UIView *)planeAlienView:(NSString *)string {
    UIView *whiteBedCar = nil;
    if ([[string pathExtension] containsString:BigAddition.noiseFactMen.domainsTorqueWordCompressDrop]) {
        UITextView * upperLow = [UITextView new];
        upperLow.editable = NO;
        upperLow.backgroundColor = UIColor.whiteColor;
        upperLow.textColor = UIColor.grayColor;
        whiteBedCar = upperLow;
    }else {
        WKWebView *diskPopover = [[WKWebView alloc] initWithFrame:CGRectZero];
        diskPopover.backgroundColor = UIColor.clearColor;
        diskPopover.scrollView.backgroundColor = UIColor.lightGrayColor;
        diskPopover.opaque = YES;
        diskPopover.scrollView.bounces =NO;
        diskPopover.scrollView.showsVerticalScrollIndicator = NO;
        diskPopover.scrollView.showsHorizontalScrollIndicator = NO;
        diskPopover.navigationDelegate = self;
        whiteBedCar = diskPopover;
    }
    return whiteBedCar;
}

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

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

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

@end
