






#import "ZoomEldestTradViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+Violation.h"
#import "NSString+LeakyMapIll.h"

@interface ZoomEldestTradViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *oneSawOutPlaceControl;
@property (nonatomic, strong) UIView * pinStorageInitiatedExtrasDecipher;
@property (nonatomic, strong) UIView * clearLenientCovariantAllDetail;

@property (nonatomic, strong) UIScrollView * liveHostingView;

@end

@implementation ZoomEldestTradViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.crossClampButton.hidden = YES;
    self.areShadowButton.hidden = YES;
    
    UISegmentedControl *rowEachView = [[UISegmentedControl alloc] initWithItems:@[ButPhonetic.snowTabWhoDrum.offBorderedSlashedNetHyphensSign,ButPhonetic.snowTabWhoDrum.zoneDietaryFlightRunIndirectSurge]];
    rowEachView.layer.masksToBounds = YES; 
    rowEachView.layer.cornerRadius = 2;    
    [rowEachView setTitleTextAttributes:@{NSForegroundColorAttributeName:[ButPhonetic sonLegacyColor]} forState:UIControlStateSelected];
    [rowEachView setTitleTextAttributes:@{NSForegroundColorAttributeName:[ButPhonetic sonLegacyColor]} forState:UIControlStateNormal];
    [self.view addSubview:rowEachView];
    [rowEachView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(ButPhonetic.ditheredFast.hairHundred);
    }];
    [rowEachView addTarget:self action:@selector(tintTypeFocus:) forControlEvents:UIControlEventValueChanged];
    self.oneSawOutPlaceControl = rowEachView;
    
    _liveHostingView = [[UIScrollView alloc]init];
    _liveHostingView.pagingEnabled = YES;
    _liveHostingView.delegate = self;
    [self.view addSubview:_liveHostingView];
    [_liveHostingView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(ButPhonetic.ditheredFast.proteinEarly);
        make.right.equalTo(self.view).offset(-ButPhonetic.ditheredFast.proteinEarly);
        make.top.equalTo(self.view).offset(ButPhonetic.ditheredFast.darkerSawAir);
        make.bottom.equalTo(self.view).offset(-ButPhonetic.ditheredFast.literalEntry);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.liveHostingView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.liveHostingView);
        make.height.equalTo(_liveHostingView);
    }];
    
    UIView * escapeBusBar = [self ageLawNextView:[ButPhonetic pullTryAffectingParentalYet]];
    [containerView addSubview:escapeBusBar];
    [escapeBusBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.liveHostingView);
    }];
    self.pinStorageInitiatedExtrasDecipher = escapeBusBar;
    
    UIView * femaleGender = [self ageLawNextView:[ButPhonetic capturesBusCancelMotionLog]];
    [containerView addSubview:femaleGender];
    [femaleGender mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(escapeBusBar.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.liveHostingView);
    }];
    self.clearLenientCovariantAllDetail = femaleGender;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(femaleGender.mas_right);
    }];
    
    if (![self.tiedDecibel boolValue]) {
        UIButton *yetHoldButton = [ButPhonetic maximumYearsVoiceEscapePrecisionColor:ButPhonetic.snowTabWhoDrum.yardKilogram];
        [yetHoldButton setBackgroundImage:[UIImage alertCostBoundColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [yetHoldButton addTarget:self action:@selector(crossRollWorldPinkCapturedDry:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:yetHoldButton];
        [yetHoldButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-ButPhonetic.ditheredFast.localPacket);
            make.centerX.equalTo(self.view).multipliedBy(.65);
            make.height.mas_equalTo(ButPhonetic.ditheredFast.carBeginWrap);
        }];
    }
    
    UIButton *theIconButton =  [ButPhonetic maximumYearsVoiceEscapePrecisionColor:ButPhonetic.snowTabWhoDrum.reloadHead];
    [theIconButton addTarget:self action:@selector(smallKirghizMuteCauseCreditEngineer:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:theIconButton];
    [theIconButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-ButPhonetic.ditheredFast.localPacket);
        make.centerX.equalTo(self.view).multipliedBy(![self.tiedDecibel boolValue]?1.35:1);
        make.height.mas_equalTo(ButPhonetic.ditheredFast.carBeginWrap);
    }];
    
    rowEachView.selectedSegmentIndex = 0;
    [self tintTypeFocus:rowEachView];
}

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

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

- (void)wrestlingKazakhUseRevertChestText:(NSInteger)type {
    NSString *unifiedHis = nil;
    UIView *contentView = nil;
    unifiedHis = type == 0 ? [ButPhonetic pullTryAffectingParentalYet]:[ButPhonetic capturesBusCancelMotionLog];
    contentView = type == 0 ? self.pinStorageInitiatedExtrasDecipher:self.clearLenientCovariantAllDetail;
    
    if (unifiedHis.sobBagFriend) {
        return;
    }
    
    if ([[unifiedHis pathExtension] containsString:ButPhonetic.ditheredFast.tooEngravedArbitraryLawWas]) {
        UITextView *canView = (UITextView *)contentView;
        if (canView.text.length > 0) {
            return;
        }

        
        [HallOldestView kitGreenDraftView:contentView];

        
        NSURL *url = [NSURL URLWithString:unifiedHis];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [HallOldestView urgentLayoutEscapesRotateSeparatedView:contentView];
                
                if (error || data.length == 0) {
                    
                    canView.text = ButPhonetic.snowTabWhoDrum.netInvertConfirmMixDimensionFour;
                    return;
                }
                
                
                NSString *brushSections = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                canView.text = brushSections ?: ButPhonetic.snowTabWhoDrum.preventsCutterTranslateSoftQuickTatarPager;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *manHis = (WKWebView *)contentView;
        if (!manHis.isLoading && manHis.estimatedProgress == 1) {
            [HallOldestView urgentLayoutEscapesRotateSeparatedView:contentView];
            return;
        }
        [HallOldestView kitGreenDraftView:contentView];
        NSString *drivenSay =  [unifiedHis.followerMidBeganMonitoredLocallyBus stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:drivenSay];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [manHis loadRequest:request];
    }
}

- (void)crossRollWorldPinkCapturedDry:(id)sender {
    [self rowTiedDrawPartRadiansAction:nil];
    if (self.repairAcquireGeneratesIncludesProcedure) {
        self.repairAcquireGeneratesIncludesProcedure(NO);
    }
}

- (void)smallKirghizMuteCauseCreditEngineer:(id)sender {
    [self rowTiedDrawPartRadiansAction:nil];
    if (self.repairAcquireGeneratesIncludesProcedure) {
        self.repairAcquireGeneratesIncludesProcedure(YES);
    }
}

- (UIView *)ageLawNextView:(NSString *)string {
    UIView *biotinPaste = nil;
    if ([[string pathExtension] containsString:ButPhonetic.ditheredFast.tooEngravedArbitraryLawWas]) {
        UITextView * retrieve = [UITextView new];
        retrieve.editable = NO;
        retrieve.backgroundColor = UIColor.whiteColor;
        retrieve.textColor = UIColor.grayColor;
        biotinPaste = retrieve;
    }else {
        WKWebView *putTempLoop = [[WKWebView alloc] initWithFrame:CGRectZero];
        putTempLoop.backgroundColor = UIColor.clearColor;
        putTempLoop.scrollView.backgroundColor = UIColor.lightGrayColor;
        putTempLoop.opaque = YES;
        putTempLoop.scrollView.bounces =NO;
        putTempLoop.scrollView.showsVerticalScrollIndicator = NO;
        putTempLoop.scrollView.showsHorizontalScrollIndicator = NO;
        putTempLoop.navigationDelegate = self;
        biotinPaste = putTempLoop;
    }
    return biotinPaste;
}

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

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

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

@end
