fix
无故事王国
2024-06-18 c1862d736587c9a5c10a368dabaeb72be2df4bcb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
//
//  HomeStudyCompleteVC.swift
//  DolphinEnglishLearnStudent
//
//  Created by 无故事王国 on 2024/5/24.
//
 
import UIKit
 
let StudyCompleteNextLession_Noti = Notification.Name.init("StudyCompleteNextLession_Noti")
 
class HomeStudyCompleteVC: BaseVC {
                @IBOutlet weak var label_coin: UILabel!
                @IBOutlet weak var label_correctNum: UILabel!
                @IBOutlet weak var label_totalNum: UILabel!
                @IBOutlet weak var label_errorNum: UILabel!
                @IBOutlet weak var label_ratioNum: UILabel!
                @IBOutlet weak var btn_next: UIButton!
                @IBOutlet weak var stackView: UIStackView!
                @IBOutlet weak var btn_back: UIButton!
                
                private var correctNum:Int = 0
                private var errorNum:Int = 0
                private var totalCoin:Int = 0
                private var listenType:ListenType!
 
                required init(correctNum:Int,errorNum:Int,totalCoin:Int,listenType:ListenType){
                                super.init(nibName: nil, bundle: nil)
                                self.correctNum = correctNum
                                self.errorNum = errorNum
                                self.totalCoin = totalCoin
                                self.listenType = listenType
                }
                
                required init?(coder: NSCoder) {
                                fatalError("init(coder:) has not been implemented")
                }
                
    override func viewDidLoad() {
        super.viewDidLoad()
 
                                yy_popBlock = {[weak self] () in
                                                self?.backAction()
                                }
 
                                label_coin.text = "恭喜你,已完成全部答题!获得\(totalCoin)积分!"
                                label_correctNum.text = "\(correctNum)次"
                                label_errorNum.text = "\(errorNum)次"
                                label_totalNum.text = "\(correctNum + errorNum)次"
                                label_ratioNum.text = String(format: "正确率:%.0lf%%", Double(correctNum) / Double(correctNum + errorNum) * 100)
 
                                btn_next.isHidden = listenType.rawValue >= 5
 
                                stackView.isHidden = listenType == .story2
                                label_ratioNum.isHidden = listenType == .story2
 
                                NotificationCenter.default.post(name: Refresh_ListenSchedule_Noti, object: nil)
    }
 
                override func setUI() {
                                super.setUI()
                }
 
                @IBAction func backHomeAction(_ sender: UIButton) {
                                backAction()
                }
 
                @IBAction func nextAction(_ sender: UIButton) {
 
 
                                var toVC:UIViewController?
                                for subv in self.navigationController?.viewControllers ?? []{
                                                if subv is HomeListenVC{
                                                                toVC = subv;break
                                                }
                                }
 
                                if toVC == nil{
                                                self.navigationController?.popToRootViewController(animated: true)
                                }else{
                                                self.navigationController?.popToViewController(toVC!, animated: true)
                                                let nextType = ListenType(rawValue: listenType.rawValue + 1)
                                                NotificationCenter.default.post(name: StudyCompleteNextLession_Noti, object: nextType)
                                }
                }
 
                private func backAction(){
                                for vc in navigationController?.viewControllers ?? []{
                                                if vc.isKind(of: HomeListenMenuVC.self){
                                                                navigationController?.popToViewController(vc, animated: true);break
                                                }
 
                                                if vc.isKind(of: HomeListenVC.self){
                                                                navigationController?.popToViewController(vc, animated: true);break
                                                }
                                }
                }
}