//
//  QuoteDetailController.m
//  AIIM
//
//  Created by qitewei on 2025/5/29.
//

#import "QuoteDetailController.h"

@interface QuoteDetailController ()
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIView *contentView;
@property (nonatomic, strong) UILabel *quoteContentLabel;
@end

@implementation QuoteDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configUI];
    [self configConstraints];
    [self populateData];
}

- (void)configUI{
//    self.view.backgroundColor = UIColor.whiteColor;
    
    UIImageView * bgImageView = [[UIImageView alloc] initWithImage:kImageMake(@"loginBG")];
    [self.view addSubview:bgImageView];
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    
    [self setNavigationTitle:self.quotedSenderName];
    [self setNavigationBarTransparent:YES];
    [self setNavigationBarBackgroundColor:UIColor.clearColor];
    [self setNavigationTitleColor:UIColor.whiteColor font:SYSBFONT(18)];
    [self addBarButtonWithImage:kImageMake(@"fanhui") position:BarButtonItemPositionLeft action:@selector(backToChat)];
    self.view.backgroundColor = UIColor.blackColor;
    
//    [self setNavigationTitle:self.quotedSenderName];
//    // 设置导航栏背景色
//    [self setNavigationBarBackgroundColor:UIColor.clearColor];
//    
//    // 设置标题颜色和字体
//    [self setNavigationTitleColor:[UIColor whiteColor] font:[UIFont boldSystemFontOfSize:16]];
//    
//    // 设置返回按钮
//    [self setBackButtonTitle:@"fanhui"];
//    [self setBackButtonColor:[UIColor whiteColor]];
    
    _scrollView = [[UIScrollView alloc] init];
    [self.view addSubview:_scrollView];
    
    // 内容视图
    _contentView = [[UIView alloc] init];
    [_scrollView addSubview:_contentView];
    
    _quoteContentLabel = [[UILabel alloc] init];
    _quoteContentLabel.textColor = UIColor.whiteColor;
    _quoteContentLabel.numberOfLines = 0;
    _quoteContentLabel.font = SYSMFONT(24);
    [_contentView addSubview:_quoteContentLabel];
    
//    [self.view jk_addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) {
//        [self dismissViewControllerAnimated:YES completion:nil];
//    }];
}

#pragma mark private
- (void)backToChat{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)configConstraints{
    [_scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    [_contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(_scrollView);
        make.width.equalTo(_scrollView);
    }];
    
    [_quoteContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_contentView.mas_top).offset(112);
        make.left.equalTo(_contentView).offset(12);
        make.right.equalTo(_contentView).offset(-12);
        make.bottom.equalTo(_contentView).offset(-12);
    }];
}

- (void)populateData{
    NSString *quoteText;
    if (self.quotedSenderName) {
        quoteText = [NSString stringWithFormat:@"%@: %@", self.quotedSenderName, self.quotedContent];
    }else{
        quoteText = self.quotedContent;
    }
    _quoteContentLabel.text = quoteText;
}

@end
