






#import "EarSoloPubHintViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+Anchoring.h"
#import "NSString+ResourceWas.h"

@interface EarSoloPubHintViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *triangleBrokenControl;
@property (nonatomic, strong) UIView * noteIterativeExternalNegativeKelvin;
@property (nonatomic, strong) UIView * reportedInsulinNeverNicknameEar;

@property (nonatomic, strong) UIScrollView * issuerGreenView;

@end

@implementation EarSoloPubHintViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.slashShapeButton.hidden = YES;
    self.sinScreenButton.hidden = YES;
    
    UISegmentedControl *hueGramView = [[UISegmentedControl alloc] initWithItems:@[BurstUpload.ejectPrimeHour.bondBreakPolarMercuryFocusedNordic,BurstUpload.ejectPrimeHour.cousinPanHasUnlearnFullyQuote]];
    hueGramView.layer.masksToBounds = YES; 
    hueGramView.layer.cornerRadius = 2;    
    [hueGramView setTitleTextAttributes:@{NSForegroundColorAttributeName:[BurstUpload manGlobalColor]} forState:UIControlStateSelected];
    [hueGramView setTitleTextAttributes:@{NSForegroundColorAttributeName:[BurstUpload manGlobalColor]} forState:UIControlStateNormal];
    [self.view addSubview:hueGramView];
    [hueGramView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(BurstUpload.styleOrigins.nowProposed);
    }];
    [hueGramView addTarget:self action:@selector(learnHueError:) forControlEvents:UIControlEventValueChanged];
    self.triangleBrokenControl = hueGramView;
    
    _issuerGreenView = [[UIScrollView alloc]init];
    _issuerGreenView.pagingEnabled = YES;
    _issuerGreenView.delegate = self;
    [self.view addSubview:_issuerGreenView];
    [_issuerGreenView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(BurstUpload.styleOrigins.personResize);
        make.right.equalTo(self.view).offset(-BurstUpload.styleOrigins.personResize);
        make.top.equalTo(self.view).offset(BurstUpload.styleOrigins.hungarianTry);
        make.bottom.equalTo(self.view).offset(-BurstUpload.styleOrigins.photoRenewal);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.issuerGreenView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.issuerGreenView);
        make.height.equalTo(_issuerGreenView);
    }];
    
    UIView * topCertModal = [self pingSquashView:[BurstUpload answerWasLeadNotifiedSummary]];
    [containerView addSubview:topCertModal];
    [topCertModal mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.issuerGreenView);
    }];
    self.noteIterativeExternalNegativeKelvin = topCertModal;
    
    UIView * sayHandleFit = [self pingSquashView:[BurstUpload tenInferMemoryAbortMajor]];
    [containerView addSubview:sayHandleFit];
    [sayHandleFit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(topCertModal.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.issuerGreenView);
    }];
    self.reportedInsulinNeverNicknameEar = sayHandleFit;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(sayHandleFit.mas_right);
    }];
    
    if (![self.notationFat boolValue]) {
        UIButton *faxDrumButton = [BurstUpload oneUpdatesSpatialSonGermanColor:BurstUpload.ejectPrimeHour.wideProduces];
        [faxDrumButton setBackgroundImage:[UIImage pinOwnRetInnerColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [faxDrumButton addTarget:self action:@selector(promisedToolSideHowAgeValidates:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:faxDrumButton];
        [faxDrumButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-BurstUpload.styleOrigins.jobNetEvery);
            make.centerX.equalTo(self.view).multipliedBy(.65);
            make.height.mas_equalTo(BurstUpload.styleOrigins.rowHumanFlip);
        }];
    }
    
    UIButton *programButton =  [BurstUpload oneUpdatesSpatialSonGermanColor:BurstUpload.ejectPrimeHour.binSpatial];
    [programButton addTarget:self action:@selector(bedDistinctProteinTightUnloadCapture:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:programButton];
    [programButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-BurstUpload.styleOrigins.jobNetEvery);
        make.centerX.equalTo(self.view).multipliedBy(![self.notationFat boolValue]?1.35:1);
        make.height.mas_equalTo(BurstUpload.styleOrigins.rowHumanFlip);
    }];
    
    hueGramView.selectedSegmentIndex = 0;
    [self learnHueError:hueGramView];
}

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

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

- (void)usesStrideLawDisparityWayText:(NSInteger)type {
    NSString *jobUseBeen = nil;
    UIView *contentView = nil;
    jobUseBeen = type == 0 ? [BurstUpload answerWasLeadNotifiedSummary]:[BurstUpload tenInferMemoryAbortMajor];
    contentView = type == 0 ? self.noteIterativeExternalNegativeKelvin:self.reportedInsulinNeverNicknameEar;
    
    if (jobUseBeen.stoodFairCar) {
        return;
    }
    
    if ([[jobUseBeen pathExtension] containsString:BurstUpload.styleOrigins.instantRelayAlignmentShuffleRecently]) {
        UITextView *herView = (UITextView *)contentView;
        if (herView.text.length > 0) {
            return;
        }

        
        [SiteHiddenView partBelowShowView:contentView];

        
        NSURL *url = [NSURL URLWithString:jobUseBeen];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [SiteHiddenView procedureAlignmentDecipherFitLinkageView:contentView];
                
                if (error || data.length == 0) {
                    
                    herView.text = BurstUpload.ejectPrimeHour.closureSegueCheckingOpenThreeVery;
                    return;
                }
                
                
                NSString *goalNearPoint = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                herView.text = goalNearPoint ?: BurstUpload.ejectPrimeHour.inferIndexingNearbyRequestLevelPrimeBrush;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *weekly = (WKWebView *)contentView;
        if (!weekly.isLoading && weekly.estimatedProgress == 1) {
            [SiteHiddenView procedureAlignmentDecipherFitLinkageView:contentView];
            return;
        }
        [SiteHiddenView partBelowShowView:contentView];
        NSString *suddenOff =  [jobUseBeen.patchSlideHundredsDefinesRepeatsVersion stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:suddenOff];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [weekly loadRequest:request];
    }
}

- (void)promisedToolSideHowAgeValidates:(id)sender {
    [self coverageSchedulerOpacityViolationSecondAction:nil];
    if (self.degradedBinHerDesktopEqually) {
        self.degradedBinHerDesktopEqually(NO);
    }
}

- (void)bedDistinctProteinTightUnloadCapture:(id)sender {
    [self coverageSchedulerOpacityViolationSecondAction:nil];
    if (self.degradedBinHerDesktopEqually) {
        self.degradedBinHerDesktopEqually(YES);
    }
}

- (UIView *)pingSquashView:(NSString *)string {
    UIView *officialFix = nil;
    if ([[string pathExtension] containsString:BurstUpload.styleOrigins.instantRelayAlignmentShuffleRecently]) {
        UITextView * forReset = [UITextView new];
        forReset.editable = NO;
        forReset.backgroundColor = UIColor.whiteColor;
        forReset.textColor = UIColor.grayColor;
        officialFix = forReset;
    }else {
        WKWebView *becomeNorth = [[WKWebView alloc] initWithFrame:CGRectZero];
        becomeNorth.backgroundColor = UIColor.clearColor;
        becomeNorth.scrollView.backgroundColor = UIColor.lightGrayColor;
        becomeNorth.opaque = YES;
        becomeNorth.scrollView.bounces =NO;
        becomeNorth.scrollView.showsVerticalScrollIndicator = NO;
        becomeNorth.scrollView.showsHorizontalScrollIndicator = NO;
        becomeNorth.navigationDelegate = self;
        officialFix = becomeNorth;
    }
    return officialFix;
}

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

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

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

@end
