//
//  SpeakPracticeBackView.swift
//  SpeakEasyLearnEnglish
//
//  Created by edy on 2025/7/23.
//

import UIKit

class SpeakPracticeBackView: UIView {

    
    @IBOutlet weak var SpeakPracticeBackFavorites: UIButton!
    @IBOutlet weak var SpeakPracticeBackWord: UILabel!
    @IBOutlet weak var SpeakPracticeBackWord1: UILabel!
    
    @IBOutlet weak var SpeakPracticeBackDesc: UILabel!
    @IBOutlet weak var SpeakPracticeBackUnlock: UIButton!
    
    class func xib() -> SpeakPracticeBackView {
        let nib = UINib(nibName: "SpeakPracticeBackView", bundle: nil).instantiate(withOwner: nil).first as! SpeakPracticeBackView
        return nib
    }

    @IBAction func SpeakPracticeUnlockTaps(_ sender: Any) {
        let iap = SpeakEleIAPViewCtr()
        iap.state = .other
        let vc = self.responderCtr()
        vc?.navigationController?.AnimationState = .present
        vc?.navigationController?.pushViewController(iap, animated: true)
    }
    
    @IBAction func SpeakWordTaps(_ sender: Any) {
        if SpeakPracticeBackWord.text?.count ?? 0 > 0 {
            SpeakSpeechSynthesizer.share.speakText(SpeakPracticeBackWord.text ?? "")
        }
    }
    
    @IBAction func FavoritesTaps(_ sender: UIButton) {
        SpeakPracticeBackFavorites.isSelected = !sender.isSelected
        if let call = callblack {
            call(sender.isSelected)
        }
    }
    
    deinit {
        callblack = nil
    }
}
