//
//  TSAIPhotoGeneratoBaserVC+Image.swift
//  KittensTravelNotes
//
//  Created by 100Years on 2025/7/7.
//

extension TSAIPhotoGeneratoBaserVC {
    
    
    func setUpPhotoSomeView(){
        contentView.addSubview(locationLabel)
        
        let bgView = UIView()
        contentView.addSubview(bgView)
        
        let bgImageView = UIImageView.createImageView(image: .generateResultDecoration0)
        bgView.addSubview(bgImageView)
        bgView.addSubview(networkImageView)
        let frontImageView = UIImageView.createImageView(image: .generateResultDecoration1)
        bgView.addSubview(frontImageView)
        
        locationLabel.snp.makeConstraints { make in
            make.top.equalTo(47+k_Height_StatusBar)
            make.leading.equalTo(16)
            make.trailing.equalTo(-16)
        }
        
        bgView.snp.makeConstraints { make in
            make.top.equalTo(100+k_Height_StatusBar)
            make.centerX.equalToSuperview()
            make.width.equalTo(343*kDesignScale)
            make.height.equalTo(462*kDesignScale)
        }
        
        bgImageView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        networkImageView.contentMode = .scaleAspectFill
        networkImageView.layer.borderColor = UIColor.white.cgColor
        networkImageView.layer.borderWidth = 5
        networkImageView.cornerRadius = 8
        networkImageView.isUserInteractionEnabled = true
        networkImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickNetworkImageView)))
        networkImageView.snp.makeConstraints { make in
            make.center.equalToSuperview()
            make.width.equalTo(260*kDesignScale)
            make.height.equalTo(346*kDesignScale)
        }
        
        frontImageView.snp.makeConstraints { make in
            make.trailing.equalTo(-4*kDesignScale)
            make.bottom.equalTo(9*kDesignScale)
            make.width.equalTo(104*kDesignScale)
            make.height.equalTo(107*kDesignScale)
        }
    }
    
    
    func updateNetWorkImageView(){
        guard let infoModel = infoModel else { return }
        locationLabel.text = infoModel.request.inputText
        networkImageView.setAsyncImage(urlString: infoModel.response.resultUrl)
    }
    
    @objc func clickNetworkImageView(){
        guard let infoModel = infoModel else { return }
        kPresentModalVC(target: self, modelVC: TSImageBrowseVC(dataModelArray: [infoModel], currentIndex: 0,saveBlock: { [weak self]  in
            guard let self = self else { return }
            isSavePhotoMark = true
        }))
    }
}
