//
//  TooltipView.m
//  ChatAgentApp
//
//  Created by zhangyafei on 2024/11/5.
//
#import "BaiduAgentApi.h"
#import "BaseViewController.h"
#import <Foundation/Foundation.h>


//@implementation TooltipView
//
//- (instancetype)initWithText:(NSString *)text {
//    self = [super initWithFrame:CGRectZero];
//    if (self) {
//        self.backgroundColor = [UIColor blackColor];
//        self.layer.cornerRadius = 5.0;
//
//        _textLabel = [[UILabel alloc] init];
//        _textLabel.text = text;
//        _textLabel.textColor = [UIColor whiteColor];
//        _textLabel.font = [UIFont systemFontOfSize:14];
//        _textLabel.numberOfLines = 0;
//        [self addSubview:_textLabel];
//
//        // 自动尺寸调整
//        [self.textLabel sizeToFit];
//        CGRect frame = self.textLabel.frame;
//        self.frame = CGRectMake(0, 0, frame.size.width + 20, frame.size.height + 10);
//        self.textLabel.center = CGPointMake(self.bounds.size.width / 2, self.bounds.size.height / 2);
//    }
//    return self;
//}
//
//@end

@interface BaseViewController ()

@end
@implementation BaseViewController

@end

@implementation BaseViewController (Alert)

- (void)alertTitle:(NSString *)title andMessage:(NSString *)message andCancleBlock:(void (^ __nullable)(UIAlertAction *action))handler {
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:handler];
    [alertController addAction:okAction];
    
    [self presentViewController:alertController animated:YES completion:nil];
}

- (void)alertTitle:(NSString *)title andMessage:(NSString *)message andOK:(NSString*)ok andCancle:(NSString*)cancle andBlock:(void (^)(UIAlertAction *action))OK {
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *okAction = [UIAlertAction actionWithTitle:ok style:UIAlertActionStyleDestructive handler:OK];
    [alertController addAction:okAction];
    
    UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:cancle style:UIAlertActionStyleDefault handler:nil];
    [alertController addAction:cancleAction];
    
    [self presentViewController:alertController animated:YES completion:nil];
}

- (void)alertTitle:(NSString *)title andMessage:(NSString *)message andOK:(NSString*)ok andCancle:(NSString*)cancle andBlock:(void (^)(UIAlertAction *action))OK andCancleBlock:(void (^)(UIAlertAction *action))cancleBlock {
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *okAction = [UIAlertAction actionWithTitle:ok style:UIAlertActionStyleDestructive handler:OK];
    [alertController addAction:okAction];
    
    UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:cancle style:UIAlertActionStyleDefault handler:cancleBlock];
    [alertController addAction:cancleAction];
    
    [self presentViewController:alertController animated:YES completion:nil];
}

@end

