






#import "UniformDesktopViewController.h"
#import <WebKit/WebKit.h>
#import <WebKit/WKFoundation.h>
#import "NSString+EasyStorm.h"
#import "NSString+StairTooIcy.h"

@interface UniformDesktopViewController ()<UIScrollViewDelegate,WKNavigationDelegate>

@property (nonatomic, strong) UISegmentedControl *fatalRoleHoursControl;
@property (nonatomic, strong) UIView * presenceLingerThreadsOutBelow;
@property (nonatomic, strong) UIView * syntaxMapCentersIdenticalRoman;

@property (nonatomic, strong) UIScrollView * artworkTypeView;

@end

@implementation UniformDesktopViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.blobLogKinButton.hidden = YES;
    self.vowelMostButton.hidden = YES;
    
    UISegmentedControl *optBoldView = [[UISegmentedControl alloc] initWithItems:@[FixMaterial.dryMicroCapTag.exceededBondCoercionSheOperationChannels,FixMaterial.dryMicroCapTag.adoptConsumerLearnedSpanEnumerateKilometer]];
    optBoldView.layer.masksToBounds = YES; 
    optBoldView.layer.cornerRadius = 2;    
    [optBoldView setTitleTextAttributes:@{NSForegroundColorAttributeName:[FixMaterial beforeArtColor]} forState:UIControlStateSelected];
    [optBoldView setTitleTextAttributes:@{NSForegroundColorAttributeName:[FixMaterial beforeArtColor]} forState:UIControlStateNormal];
    [self.view addSubview:optBoldView];
    [optBoldView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.mas_equalTo(FixMaterial.capsLoopsAge.eventNetCar);
    }];
    [optBoldView addTarget:self action:@selector(layeringChild:) forControlEvents:UIControlEventValueChanged];
    self.fatalRoleHoursControl = optBoldView;
    
    _artworkTypeView = [[UIScrollView alloc]init];
    _artworkTypeView.pagingEnabled = YES;
    _artworkTypeView.delegate = self;
    [self.view addSubview:_artworkTypeView];
    [_artworkTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(FixMaterial.capsLoopsAge.twoFunStream);
        make.right.equalTo(self.view).offset(-FixMaterial.capsLoopsAge.twoFunStream);
        make.top.equalTo(self.view).offset(FixMaterial.capsLoopsAge.oddSpokenYou);
        make.bottom.equalTo(self.view).offset(-FixMaterial.capsLoopsAge.askLocalized);
    }];
    
    UIView *containerView = [UIView new];
    containerView.backgroundColor = UIColor.whiteColor;
    [self.artworkTypeView addSubview:containerView];
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.artworkTypeView);
        make.height.equalTo(_artworkTypeView);
    }];
    
    UIView * leaveSegment = [self bloodPlaneView:[FixMaterial useMiterThresholdFoundSpectral]];
    [containerView addSubview:leaveSegment];
    [leaveSegment mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.bottom.equalTo(containerView);
        make.width.mas_equalTo(self.artworkTypeView);
    }];
    self.presenceLingerThreadsOutBelow = leaveSegment;
    
    UIView * curlUnionMin = [self bloodPlaneView:[FixMaterial optimizeOneDifferentPacketsSeparated]];
    [containerView addSubview:curlUnionMin];
    [curlUnionMin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(leaveSegment.mas_right);
        make.bottom.top.equalTo(containerView);
        make.width.mas_equalTo(self.artworkTypeView);
    }];
    self.syntaxMapCentersIdenticalRoman = curlUnionMin;
    
    [containerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(curlUnionMin.mas_right);
    }];
    
    if (![self.sexDeclined boolValue]) {
        UIButton *fitNoteButton = [FixMaterial rangeSeeHectaresImproperLowercaseColor:FixMaterial.dryMicroCapTag.rankObscures];
        [fitNoteButton setBackgroundImage:[UIImage narrativeLinerColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateNormal];
        [fitNoteButton addTarget:self action:@selector(teamTruncatesFireTipTagEach:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.view addSubview:fitNoteButton];
        [fitNoteButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.view).offset(-FixMaterial.capsLoopsAge.headsetView);
            make.centerX.equalTo(self.view).multipliedBy(.65);
            make.height.mas_equalTo(FixMaterial.capsLoopsAge.subgroupCall);
        }];
    }
    
    UIButton *handSpaButton =  [FixMaterial rangeSeeHectaresImproperLowercaseColor:FixMaterial.dryMicroCapTag.lookTagger];
    [handSpaButton addTarget:self action:@selector(maleRunningRelatedBlockNearbyAccording:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:handSpaButton];
    [handSpaButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view).offset(-FixMaterial.capsLoopsAge.headsetView);
        make.centerX.equalTo(self.view).multipliedBy(![self.sexDeclined boolValue]?1.35:1);
        make.height.mas_equalTo(FixMaterial.capsLoopsAge.subgroupCall);
    }];
    
    optBoldView.selectedSegmentIndex = 0;
    [self layeringChild:optBoldView];
}

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

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

- (void)primariesIconQuoteLeftoverOfficialText:(NSInteger)type {
    NSString *spaTwoBurn = nil;
    UIView *contentView = nil;
    spaTwoBurn = type == 0 ? [FixMaterial useMiterThresholdFoundSpectral]:[FixMaterial optimizeOneDifferentPacketsSeparated];
    contentView = type == 0 ? self.presenceLingerThreadsOutBelow:self.syntaxMapCentersIdenticalRoman;
    
    if (spaTwoBurn.thumbPending) {
        return;
    }
    
    if ([[spaTwoBurn pathExtension] containsString:FixMaterial.capsLoopsAge.oneDefinedRomanianStartingYiddish]) {
        UITextView *eggView = (UITextView *)contentView;
        if (eggView.text.length > 0) {
            return;
        }

        
        [FlattenPopView undefinedTreeView:contentView];

        
        NSURL *url = [NSURL URLWithString:spaTwoBurn];
        NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
                                                                 completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
            
            dispatch_async(dispatch_get_main_queue(), ^{
                
                [FlattenPopView hostingMomentResponseOlympusSmallerView:contentView];
                
                if (error || data.length == 0) {
                    
                    eggView.text = FixMaterial.dryMicroCapTag.zipSendClosurePrematureAbsentPrivilege;
                    return;
                }
                
                
                NSString *yetFixEntropy = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                eggView.text = yetFixEntropy ?: FixMaterial.dryMicroCapTag.caretFourFlashOrderProcessedHostWrapping;
            });
        }];
        
        [task resume];

    }else {
        WKWebView *didSaw = (WKWebView *)contentView;
        if (!didSaw.isLoading && didSaw.estimatedProgress == 1) {
            [FlattenPopView hostingMomentResponseOlympusSmallerView:contentView];
            return;
        }
        [FlattenPopView undefinedTreeView:contentView];
        NSString *tooSomali =  [spaTwoBurn.centerFoundDisplayAnimatingWayEnergy stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        NSURL *url = [NSURL URLWithString:tooSomali];
        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
        [didSaw loadRequest:request];
    }
}

- (void)teamTruncatesFireTipTagEach:(id)sender {
    [self topLeakyDissolveVisualSongAction:nil];
    if (self.smoothedArmShowingEmergencyLaunch) {
        self.smoothedArmShowingEmergencyLaunch(NO);
    }
}

- (void)maleRunningRelatedBlockNearbyAccording:(id)sender {
    [self topLeakyDissolveVisualSongAction:nil];
    if (self.smoothedArmShowingEmergencyLaunch) {
        self.smoothedArmShowingEmergencyLaunch(YES);
    }
}

- (UIView *)bloodPlaneView:(NSString *)string {
    UIView *pingRunPair = nil;
    if ([[string pathExtension] containsString:FixMaterial.capsLoopsAge.oneDefinedRomanianStartingYiddish]) {
        UITextView * handover = [UITextView new];
        handover.editable = NO;
        handover.backgroundColor = UIColor.whiteColor;
        handover.textColor = UIColor.grayColor;
        pingRunPair = handover;
    }else {
        WKWebView *putYoungest = [[WKWebView alloc] initWithFrame:CGRectZero];
        putYoungest.backgroundColor = UIColor.clearColor;
        putYoungest.scrollView.backgroundColor = UIColor.lightGrayColor;
        putYoungest.opaque = YES;
        putYoungest.scrollView.bounces =NO;
        putYoungest.scrollView.showsVerticalScrollIndicator = NO;
        putYoungest.scrollView.showsHorizontalScrollIndicator = NO;
        putYoungest.navigationDelegate = self;
        pingRunPair = putYoungest;
    }
    return pingRunPair;
}

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

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

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

@end
