//
//  NoteTVC.swift
//  MyTatvaCare
//
//  Created by Nirav Ramani on 07/05/25.
//

import UIKit

class NoteTVC: UITableViewCell {
    
    @IBOutlet weak var labelTitle: UILabel!
    @IBOutlet weak var labelDesc: UILabel!
    @IBOutlet weak var imageViewLeft: UIImageView!
    @IBOutlet weak var heightConstraint: NSLayoutConstraint!
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        labelTitle.text = "Important Note"
        labelTitle.font = FontManager.font(ofSize: 20, weight: .medium)
        labelTitle.textColor = CustomColor.shared.primaryBlack
    }
    
    func setImportantNote(isFromSuccessConnection: Bool) {
        var first = ""
        var second = ""
        
        if isFromSuccessConnection {
            imageViewLeft.image = loadImage(named: "do_not_throw_sensor")
             first = "Don’t throw away the sensor case.\n"
             second = "This might be used in case of any troubleshooting"
        } else {
            imageViewLeft.image = loadImage(named: "do_not_place_inside")
             first = "Don't place your transmitter back in the charging pod.\n"
             second = "Doing this will break connection with the app"
        }
        
        let paragraphStyle = NSMutableParagraphStyle()
        paragraphStyle.lineSpacing = 4

        let attributedString = NSMutableAttributedString(string: first, attributes: [
            .paragraphStyle: paragraphStyle,
            .font: FontManager.font(ofSize: 14, weight: .semibold),
            .foregroundColor: CustomColor.shared.primaryBlack
        ])

        let secondAttributes: [NSAttributedString.Key: Any] = [
            .paragraphStyle: paragraphStyle,
            .foregroundColor: CustomColor.shared.primaryBlack,
            .font:  FontManager.font(ofSize: 14, weight: .regular)
        ]

        let secondPart = NSAttributedString(string: second, attributes: secondAttributes)
        attributedString.append(secondPart)
        labelDesc.attributedText = attributedString
    }
    
    
    func setImportantNote() {
        imageViewLeft.image = loadImage(named: "do_not_place_inside")
        let first = "Don't place your transmitter back in the charging pod.\n"
        let second = "Don’t unlock your sensor before putting it the sensor on your skin"
       
        let paragraphStyle = NSMutableParagraphStyle()
        paragraphStyle.lineSpacing = 4

        let attributedString = NSMutableAttributedString(string: first, attributes: [
            .paragraphStyle: paragraphStyle,
            .font: FontManager.font(ofSize: 14, weight: .semibold),
            .foregroundColor: CustomColor.shared.primaryBlack
        ])

        let secondAttributes: [NSAttributedString.Key: Any] = [
            .paragraphStyle: paragraphStyle,
            .foregroundColor: CustomColor.shared.primaryBlack,
            .font:  FontManager.font(ofSize: 14, weight: .regular)
        ]

        let secondPart = NSAttributedString(string: second, attributes: secondAttributes)
        attributedString.append(secondPart)
        labelDesc.attributedText = attributedString
    }
}
