






#import "FileOldPopViewController.h"
#import "AddButBackConfig.h"
#import "NSObject+WayModel.h"
#import "UIColor+OutColor.h"
#import "ArtToast.h"

@interface FileOldPopViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray<NSDictionary *> *lawDeclinedConvertDrumPrivacy; 
@property (nonatomic, strong) NSArray<NSArray<NSString *> *> *lowAnyClaimOne; 
@property (nonatomic, strong) NSMutableArray<NSString *> *sectionTitles; 

@end

@implementation FileOldPopViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    _lawDeclinedConvertDrumPrivacy = [NSMutableArray array];
    _lowAnyClaimOne = @[];
    _sectionTitles = [NSMutableArray array];
    
    [self mostModuleView];
}

- (void)viewWillAppear:(BOOL)animated {
    
    UIEdgeInsets spaEntries = [[CombiningManager shared] ownNegotiateWindow].safeAreaInsets;
    
    spaEntries.top    += 10;
    spaEntries.left   += 10;
    spaEntries.bottom += 10;
    spaEntries.right  += 10;

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


- (void)mostModuleView {
    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    _tableView.dataSource = self;
    _tableView.delegate = self;
    _tableView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_tableView];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.hintGenreButton.mas_bottom);
        make.left.right.bottom.equalTo(self.view);
    }];
    
    
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass(self.class)];
}


- (NSArray<NSString *> *)sugarBrownOnceDictionary:(NSDictionary *)math {
    return [[math allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
}

- (void)volumesNotifyInfo:(NSDictionary *)info withTitle:(NSString *)title {
    if (!info || ![info isKindOfClass:[NSDictionary class]]) {
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        @synchronized (self) {
            
            [self->_lawDeclinedConvertDrumPrivacy addObject:[info copy]];
            NSArray *darkenCard = [self sugarBrownOnceDictionary:info];
            self->_lowAnyClaimOne = [self->_lowAnyClaimOne arrayByAddingObject:darkenCard];
            [self->_sectionTitles addObject:title];
            
            
            [self.tableView reloadData];
        }
    });
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return _lawDeclinedConvertDrumPrivacy.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _lowAnyClaimOne[section].count;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return _sectionTitles[section];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *call = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self.class) forIndexPath:indexPath];
    
    NSString *key;
    id value;
    NSInteger pathPenIndex = indexPath.section;
    key = _lowAnyClaimOne[pathPenIndex][indexPath.row];
    value = _lawDeclinedConvertDrumPrivacy[pathPenIndex][key];
    BOOL pairSign = [value isKindOfClass:[NSDictionary class]] || [value isKindOfClass:[NSArray class]];
    call.backgroundColor = [UIColor clearColor];
    
    
    for (UIView *optUndo in call.contentView.subviews) {
        [optUndo removeFromSuperview];
    }
    
    
    UILabel *eggLabel = [[UILabel alloc] init];
    eggLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightMedium];
    eggLabel.textColor = [UIColor darkGrayColor];
    eggLabel.text = key;
    eggLabel.numberOfLines = 0;
    [call.contentView addSubview:eggLabel];
    
    
    UILabel *drainLabel = [[UILabel alloc] init];
    drainLabel.font = [UIFont monospacedSystemFontOfSize:14 weight:UIFontWeightRegular];
    drainLabel.textColor = [UIColor blackColor];
    drainLabel.numberOfLines = 0;
    drainLabel.textAlignment = NSTextAlignmentRight;
    [call.contentView addSubview:drainLabel];
    
    
    [eggLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(call.contentView).offset(ApplyToggle.findSwipeOur.directlyCurl);
        make.top.equalTo(call.contentView).offset(ApplyToggle.findSwipeOur.thatLeaseKin);
        make.bottom.equalTo(call.contentView).offset(-ApplyToggle.findSwipeOur.thatLeaseKin);
        make.width.equalTo(call.contentView.mas_width).multipliedBy(pairSign?ApplyToggle.findSwipeOur.bitsMagicToo:ApplyToggle.findSwipeOur.foggyFillZoom);
    }];
    
    [drainLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(call.contentView).offset(-ApplyToggle.findSwipeOur.directlyCurl);
        make.top.equalTo(call.contentView).offset(ApplyToggle.findSwipeOur.thatLeaseKin);
        make.bottom.equalTo(call.contentView).offset(-ApplyToggle.findSwipeOur.thatLeaseKin);
        make.left.equalTo(eggLabel.mas_right).offset(ApplyToggle.findSwipeOur.thatLeaseKin);
    }];
    
    
    if (pairSign) {
        call.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    } else {
        drainLabel.text = [value description];
        call.accessoryType = UITableViewCellAccessoryNone;
    }
    
    return call;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    id value;
    NSString *key;
    
    NSInteger pathPenIndex = indexPath.section;
    key = _lowAnyClaimOne[pathPenIndex][indexPath.row];
    value = _lawDeclinedConvertDrumPrivacy[pathPenIndex][key];
    
    
    if ([value isKindOfClass:[NSDictionary class]]) {
        [self darkenEachDictionary:value withTitle:key];
    } else if ([value isKindOfClass:[NSArray class]]) {
        [self waitingAllArray:value withTitle:key];
    } else {
        
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        [pasteboard setString:[value description]];
        [ArtToast farFont:ApplyToggle.findSwipeOur.symbolsRestingArtsGeneratePenRare];
    }
}


- (void)darkenEachDictionary:(NSDictionary *)math withTitle:(NSString *)title {
    FileOldPopViewController *fullWill = [[FileOldPopViewController alloc] init];
    [self.navigationController pushViewController:fullWill animated:NO];
    [fullWill volumesNotifyInfo:math withTitle:title];
}

- (void)waitingAllArray:(NSArray *)array withTitle:(NSString *)title {
    
    NSMutableDictionary *plateDict = [NSMutableDictionary dictionary];
    for (NSInteger i = 0; i < array.count; i++) {
        plateDict[[NSString stringWithFormat:@"[%ld]", (long)i]] = array[i];
    }
    
    FileOldPopViewController *fullWill = [[FileOldPopViewController alloc] init];
    [self.navigationController pushViewController:fullWill animated:NO];
    [fullWill volumesNotifyInfo:plateDict withTitle:[NSString stringWithFormat:@"%@ (Array)", title]];
}

@end
