






#import "AppleLegalTextViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+Teaspoons.h"
#import "NSString+BandAndPing.h"

@interface AppleLegalTextViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *logOptTooBlendControl;
@property (nonatomic, strong) UIView * trapCompileResonantCompoundArm;
@property (nonatomic, strong) UIView * rebusUnwindingFixRatioCreated;

@property (nonatomic, strong) UIScrollView * sixEasyBusyView;

@end

@implementation AppleLegalTextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.arrayChestButton.hidden = YES;
    self.surgeMaskButton.hidden = YES;
    
    UISegmentedControl *catalogView = [[UISegmentedControl alloc] initWithItems:@[SaveWayTaps.hueOldAreaMole.backwardsEventualStiffnessExtendOptionalBody,SaveWayTaps.hueOldAreaMole.oldestMoireCleanupSuddenPredictedTag]];
    catalogView.layer.masksToBounds = YES; 
    catalogView.layer.cornerRadius = 2;    
    [catalogView setTitleTextAttributes:@{NSForegroundColorAttributeName:[SaveWayTaps divideRunColor]} forState:UIControlStateSelected];
    [catalogView setTitleTextAttributes:@{NSForegroundColorAttributeName:[SaveWayTaps divideRunColor]} forState:UIControlStateNormal];
    [self.view addSubview:catalogView];
    [catalogView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(SaveWayTaps.offerHitEasy.dryHelpMake);
    }];
    [catalogView addTarget:self action:@selector(suffixMounted:) forControlEvents:UIControlEventValueChanged];
    self.logOptTooBlendControl = catalogView;
    
    _sixEasyBusyView = [[UIScrollView alloc]init];
    _sixEasyBusyView.pagingEnabled = YES;
    _sixEasyBusyView.delegate = self;
    [self.view addSubview:_sixEasyBusyView];
    [_sixEasyBusyView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(SaveWayTaps.offerHitEasy.labelBookKey);
        make.right.equalTo(self.view).offset(-SaveWayTaps.offerHitEasy.labelBookKey);
        make.top.equalTo(self.view).offset(SaveWayTaps.offerHitEasy.halfLargeDue);
        make.bottom.equalTo(self.view).offset(-SaveWayTaps.offerHitEasy.periodScheme);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.sixEasyBusyView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.sixEasyBusyView);
        make.height.equalTo(_sixEasyBusyView);
    }];
    
    UIView * hardInferBed = [self theMustDidView:[SaveWayTaps friendsCathedralAtomBuddhistDisplays]];
    [containerView addSubview:hardInferBed];
    [hardInferBed mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.sixEasyBusyView);
    }];
    self.trapCompileResonantCompoundArm = hardInferBed;
    
    UIView * emailTintMan = [self theMustDidView:[SaveWayTaps detachDimensionCutoffCenteringParagraph]];
    [containerView addSubview:emailTintMan];
    [emailTintMan mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(hardInferBed.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.sixEasyBusyView);
    }];
    self.rebusUnwindingFixRatioCreated = emailTintMan;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(emailTintMan.mas_right);
    }];
    
    if (![self.mindFastTab boolValue]) {
        UIButton *stayManButton = [SaveWayTaps bringArrangerNanogramsScaleOutColor:SaveWayTaps.hueOldAreaMole.accessoryBar];
        [stayManButton setBackgroundImage:[UIImage penTheAlphaUseColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [stayManButton addTarget:self action:@selector(midDeepLowSubTagsIndex:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:stayManButton];
        
        [stayManButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-SaveWayTaps.offerHitEasy.envelopeTen);
            make.left.equalTo(self.view).offset(SaveWayTaps.offerHitEasy.labelBookKey);
            make.right.equalTo(self.view.mas_centerX).offset(-SaveWayTaps.offerHitEasy.tagsBitMind);
            make.height.mas_equalTo(SaveWayTaps.offerHitEasy.identityWill);
        }];
    }

    UIButton *wayBeenButton =  [SaveWayTaps bringArrangerNanogramsScaleOutColor:SaveWayTaps.hueOldAreaMole.caseNapZip];
    [wayBeenButton addTarget:self action:@selector(roleFactPublisherDisallowTurnGaelic:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:wayBeenButton];
    BOOL styleButton = ![self.mindFastTab boolValue];
    [wayBeenButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-SaveWayTaps.offerHitEasy.envelopeTen);
        make.right.equalTo(self.view).offset(-SaveWayTaps.offerHitEasy.labelBookKey);
        
        if (styleButton) {
            make.left.equalTo(self.view.mas_centerX).offset(SaveWayTaps.offerHitEasy.tagsBitMind);
        } else {
            make.left.equalTo(self.view).offset(SaveWayTaps.offerHitEasy.labelBookKey);
        }
        make.height.mas_equalTo(SaveWayTaps.offerHitEasy.identityWill);
    }];
    
    catalogView.selectedSegmentIndex = 0;
    [self suffixMounted:catalogView];
}

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

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

- (void)hailMoveEllipsePullReplyText:(NSInteger)type {
    NSString *commonDrag = nil;
    UIView *contentView = nil;
    commonDrag = type == 0 ? [SaveWayTaps friendsCathedralAtomBuddhistDisplays]:[SaveWayTaps detachDimensionCutoffCenteringParagraph];
    contentView = type == 0 ? self.trapCompileResonantCompoundArm:self.rebusUnwindingFixRatioCreated;
    
    if (commonDrag.cameraBagPan) {
        return;
    }
    
    if ([[commonDrag pathExtension] containsString:SaveWayTaps.offerHitEasy.decipherVisitorEventualWasDominant]) {
        UITextView *bagView = (UITextView *)contentView;
        if (bagView.text.length > 0) {
            return;
        }

        
        [PoolSixLogView affinityFatalView:contentView];

        
        NSURL *url = [NSURL URLWithString:commonDrag];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [PoolSixLogView vowelIrishIndicesFullyWateryView:contentView];
                
                if (error || data.length == 0) {
                    
                    bagView.text = SaveWayTaps.hueOldAreaMole.heavyRedHexInterruptOffsetsDescended;
                    return;
                }
                
                
                NSString *soloDelayFlow = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                bagView.text = soloDelayFlow ?: SaveWayTaps.hueOldAreaMole.iterationOrderIdentitySonFunLongestDark;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *putShe = (WKWebView *)contentView;
        if (!putShe.isLoading && putShe.estimatedProgress == 1) {
            [PoolSixLogView vowelIrishIndicesFullyWateryView:contentView];
            return;
        }
        [PoolSixLogView affinityFatalView:contentView];
        NSString *axesLossy =  [commonDrag.kernelsTailExecutionUnboundDidFork stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:axesLossy];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [putShe loadRequest:request];
    }
}

- (void)midDeepLowSubTagsIndex:(id)sender {
    [self paletteExtendsDitheredFlightRingAction:nil];
    if (self.showingIndicatorLossDueThrough) {
        self.showingIndicatorLossDueThrough(NO);
    }
}

- (void)roleFactPublisherDisallowTurnGaelic:(id)sender {
    [self paletteExtendsDitheredFlightRingAction:nil];
    if (self.showingIndicatorLossDueThrough) {
        self.showingIndicatorLossDueThrough(YES);
    }
}

- (UIView *)theMustDidView:(NSString *)string {
    UIView *curveCanCup = nil;
    if ([[string pathExtension] containsString:SaveWayTaps.offerHitEasy.decipherVisitorEventualWasDominant]) {
        UITextView * elevated = [UITextView new];
        elevated.editable = NO;
        elevated.backgroundColor = UIColor.whiteColor;
        elevated.textColor = UIColor.grayColor;
        curveCanCup = elevated;
    }else {
        WKWebView *externMeter = [[WKWebView alloc] initWithFrame:CGRectZero];
        externMeter.backgroundColor = UIColor.clearColor;
        externMeter.scrollView.backgroundColor = UIColor.lightGrayColor;
        externMeter.opaque = YES;
        externMeter.scrollView.bounces =NO;
        externMeter.scrollView.showsVerticalScrollIndicator = NO;
        externMeter.scrollView.showsHorizontalScrollIndicator = NO;
        externMeter.navigationDelegate = self;
        curveCanCup = externMeter;
    }
    return curveCanCup;
}

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

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

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

@end
