






#import "UpperDictationViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+SigmaPlay.h"
#import "NSString+WakePrepTap.h"

@interface UpperDictationViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *draftBadKinWayControl;
@property (nonatomic, strong) UIView * manualVisionSpeakingCreateMeter;
@property (nonatomic, strong) UIView * guestClampedWeeklyExpandRet;

@property (nonatomic, strong) UIScrollView * lowFillDustView;

@end

@implementation UpperDictationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.workOuncesButton.hidden = YES;
    self.agePreferButton.hidden = YES;
    
    UISegmentedControl *mixFailView = [[UISegmentedControl alloc] initWithItems:@[HerLaunched.pinCarOuterMan.hertzBankCapturedBeaconFlipSolutions,HerLaunched.pinCarOuterMan.wonLengthMicroDisablesWayPrior]];
    mixFailView.layer.masksToBounds = YES; 
    mixFailView.layer.cornerRadius = 2;    
    [mixFailView setTitleTextAttributes:@{NSForegroundColorAttributeName:[HerLaunched ironGuideColor]} forState:UIControlStateSelected];
    [mixFailView setTitleTextAttributes:@{NSForegroundColorAttributeName:[HerLaunched ironGuideColor]} forState:UIControlStateNormal];
    [self.view addSubview:mixFailView];
    [mixFailView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(HerLaunched.brownFairKin.rangeScalar);
    }];
    [mixFailView addTarget:self action:@selector(rotateLimited:) forControlEvents:UIControlEventValueChanged];
    self.draftBadKinWayControl = mixFailView;
    
    _lowFillDustView = [[UIScrollView alloc]init];
    _lowFillDustView.pagingEnabled = YES;
    _lowFillDustView.delegate = self;
    [self.view addSubview:_lowFillDustView];
    [_lowFillDustView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(HerLaunched.brownFairKin.yearEarAlien);
        make.right.equalTo(self.view).offset(-HerLaunched.brownFairKin.yearEarAlien);
        make.top.equalTo(self.view).offset(HerLaunched.brownFairKin.noncePanOpen);
        make.bottom.equalTo(self.view).offset(-HerLaunched.brownFairKin.fetchedAlpha);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.lowFillDustView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.lowFillDustView);
        make.height.equalTo(_lowFillDustView);
    }];
    
    UIView * localGeneral = [self keyOperandView:[HerLaunched rainCaptionYetLoudPrototype]];
    [containerView addSubview:localGeneral];
    [localGeneral mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.lowFillDustView);
    }];
    self.manualVisionSpeakingCreateMeter = localGeneral;
    
    UIView * decomposeRet = [self keyOperandView:[HerLaunched textureHasStationReachableRadians]];
    [containerView addSubview:decomposeRet];
    [decomposeRet mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(localGeneral.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.lowFillDustView);
    }];
    self.guestClampedWeeklyExpandRet = decomposeRet;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(decomposeRet.mas_right);
    }];
    
    if (![self.artworkBand boolValue]) {
        UIButton *execYouButton = [HerLaunched sortSaySpeakersOrnamentsKitColor:HerLaunched.pinCarOuterMan.flushStarPut];
        [execYouButton setBackgroundImage:[UIImage deepTopBedKnowColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [execYouButton addTarget:self action:@selector(squashCatSubjectStormForbidWarn:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:execYouButton];
        [execYouButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-HerLaunched.brownFairKin.workSwahili);
            make.centerX.equalTo(self.view).multipliedBy(.65);
            make.height.mas_equalTo(HerLaunched.brownFairKin.textIllQueue);
        }];
    }
    
    UIButton *upscaleButton =  [HerLaunched sortSaySpeakersOrnamentsKitColor:HerLaunched.pinCarOuterMan.liveSlight];
    [upscaleButton addTarget:self action:@selector(primeFullCivilRunSixLog:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:upscaleButton];
    [upscaleButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-HerLaunched.brownFairKin.workSwahili);
        make.centerX.equalTo(self.view).multipliedBy(![self.artworkBand boolValue]?1.35:1);
        make.height.mas_equalTo(HerLaunched.brownFairKin.textIllQueue);
    }];
    
    mixFailView.selectedSegmentIndex = 0;
    [self rotateLimited:mixFailView];
}

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

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

- (void)dependingCreditsBitMethodMarginText:(NSInteger)type {
    NSString *objectBlue = nil;
    UIView *contentView = nil;
    objectBlue = type == 0 ? [HerLaunched rainCaptionYetLoudPrototype]:[HerLaunched textureHasStationReachableRadians];
    contentView = type == 0 ? self.manualVisionSpeakingCreateMeter:self.guestClampedWeeklyExpandRet;
    
    if (objectBlue.largerMinCup) {
        return;
    }
    
    if ([[objectBlue pathExtension] containsString:HerLaunched.brownFairKin.chromaAccountGregorianLostPronoun]) {
        UITextView *wetView = (UITextView *)contentView;
        if (wetView.text.length > 0) {
            return;
        }

        
        [PasteArrowView greenLoseMoreView:contentView];

        
        NSURL *url = [NSURL URLWithString:objectBlue];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [PasteArrowView twitterPreservesRecoveredCreatingRotorView:contentView];
                
                if (error || data.length == 0) {
                    
                    wetView.text = HerLaunched.pinCarOuterMan.providerRoundOccurredScopeCoverageHow;
                    return;
                }
                
                
                NSString *proxiesItalic = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                wetView.text = proxiesItalic ?: HerLaunched.pinCarOuterMan.cellSinChatterRotationRearWrittenMillion;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *cousin = (WKWebView *)contentView;
        if (!cousin.isLoading && cousin.estimatedProgress == 1) {
            [PasteArrowView twitterPreservesRecoveredCreatingRotorView:contentView];
            return;
        }
        [PasteArrowView greenLoseMoreView:contentView];
        NSString *silentWon =  [objectBlue.spotlightCoercionFrameSongAlongPager stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:silentWon];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [cousin loadRequest:request];
    }
}

- (void)squashCatSubjectStormForbidWarn:(id)sender {
    [self circularBracketBoxFlagPersonalAction:nil];
    if (self.thinFormSearchPrefixedHormone) {
        self.thinFormSearchPrefixedHormone(NO);
    }
}

- (void)primeFullCivilRunSixLog:(id)sender {
    [self circularBracketBoxFlagPersonalAction:nil];
    if (self.thinFormSearchPrefixedHormone) {
        self.thinFormSearchPrefixedHormone(YES);
    }
}

- (UIView *)keyOperandView:(NSString *)string {
    UIView *smallestBox = nil;
    if ([[string pathExtension] containsString:HerLaunched.brownFairKin.chromaAccountGregorianLostPronoun]) {
        UITextView * midDutch = [UITextView new];
        midDutch.editable = NO;
        midDutch.backgroundColor = UIColor.whiteColor;
        midDutch.textColor = UIColor.grayColor;
        smallestBox = midDutch;
    }else {
        WKWebView *fillBridged = [[WKWebView alloc] initWithFrame:CGRectZero];
        fillBridged.backgroundColor = UIColor.clearColor;
        fillBridged.scrollView.backgroundColor = UIColor.lightGrayColor;
        fillBridged.opaque = YES;
        fillBridged.scrollView.bounces =NO;
        fillBridged.scrollView.showsVerticalScrollIndicator = NO;
        fillBridged.scrollView.showsHorizontalScrollIndicator = NO;
        fillBridged.navigationDelegate = self;
        smallestBox = fillBridged;
    }
    return smallestBox;
}

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

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

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

@end
