//
//  SLRoleCreatSucView.m
//  SLAiELTS
//
//  Created by Gusont on 2023/3/1.
//

#import "SLRoleCreatSucView.h"

@interface SLRoleCreatSucView ()

@property (nonatomic, strong) UIWindow *rootWindow;

@end

@implementation SLRoleCreatSucView

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        [self addContentView];
    }
    return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addContentView];
    }
    return self;
}

- (void)addContentView {
    [[NSBundle mainBundle] loadNibNamed:@"SLRoleCreatSucView" owner:self options:nil];
    self.contentView.frame = self.bounds;
    [self addSubview:self.contentView];
    self.contentView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.55];
}

- (void)alertShow
{
    UIWindow* window = nil;
    if (@available(iOS 13.0, *)) {
        for (UIWindowScene* windowScene in [UIApplication sharedApplication].connectedScenes)
        {
            if (windowScene.activationState == UISceneActivationStateForegroundActive)
            {
                window = windowScene.windows.firstObject;
                break;
            }
        }
    }else {
        window = [[UIApplication sharedApplication].delegate window];
    }
    [window addSubview:self];
}

- (IBAction)okBtnClick:(id)sender {
    if (self.sucBlock) {
        self.sucBlock();
        [self removeFromSuperview];
    }
}

@end
