//
//  HWAddFolderViewController.m
//  双子星云手机
//
//  Created by 余衡武 on 2022/3/24.
//

#import "HWAddFolderViewController.h"

@interface HWAddFolderViewController ()

@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UITextField *textField;


@end

@implementation HWAddFolderViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self drawView];
}

- (void)drawView {
    
    self.bgView.layer.cornerRadius = 10;
    self.bgView.layer.masksToBounds = YES;
    
    NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"enter_folder_name",nil) attributes:
    @{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"FFFFFF" alpha:0.2],
                 NSFontAttributeName:[UIFont systemFontOfSize:14.f]}];
    self.textField.attributedPlaceholder = attrString;
    self.textField.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    [self.textField becomeFirstResponder];
}

- (IBAction)cancelBtnClick:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

- (IBAction)sureBtnClick:(UIButton *)sender {
    
    if (self.textField.text.length == 0) {
        [[iToast makeText:NSLocalizedString(@"enter_folder_name",nil)] show];
        return;
    }
    
    if ([_delegate respondsToSelector:@selector(addFolderWithName:)]) {
        [_delegate addFolderWithName:self.textField.text];
    }
    
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

@end
