| | |
| | | import UIKit |
| | | |
| | | let StudyCompleteNextLession_Noti = Notification.Name.init("StudyCompleteNextLession_Noti") |
| | | let StudyCompleteCoinUpdate_Noti = Notification.Name.init("StudyCompleteCoinUpdate_Noti") |
| | | |
| | | class HomeStudyCompleteVC: BaseVC { |
| | | @IBOutlet weak var label_coin: UILabel! |
| | |
| | | label_correctNum.text = "\(viewModel.correctNum)次" |
| | | label_errorNum.text = "\(viewModel.errorNum)次" |
| | | label_totalNum.text = "\(viewModel.correctNum + viewModel.errorNum)次" |
| | | label_ratioNum.text = String(format: "正确率:%.0lf%%", Double(viewModel.correctNum) / Double(viewModel.correctNum + viewModel.errorNum) * 100) |
| | | |
| | | if viewModel.correctNum + viewModel.errorNum == 0{ |
| | | label_ratioNum.text = String(format: "正确率:0%%") |
| | | }else{ |
| | | label_ratioNum.text = String(format: "正确率:%.0lf%%", Double(viewModel.correctNum) / Double(viewModel.correctNum + viewModel.errorNum) * 100) |
| | | } |
| | | |
| | | if totalNum != nil && viewModel.listenType.value == .game2{ |
| | | label_title_totalNum.text = "总题目:" |
| | |
| | | label_errorNum.text = "\(viewModel.errorNum)" |
| | | } |
| | | |
| | | |
| | | btn_next.isHidden = viewModel.listenType.value == .lesson5 |
| | | |
| | | switch viewModel.listenType.value{ |
| | | case .lesson5,.game1,.game2,.story1,.story2:btn_next.isHidden = true |
| | | default:btn_next.isHidden = false |
| | | } |
| | | |
| | | stackView.isHidden = viewModel.listenType.value == .story2 |
| | | label_ratioNum.isHidden = viewModel.listenType.value == .story2 |
| | |
| | | super.setUI() |
| | | } |
| | | |
| | | override func setRx() { |
| | | NotificationCenter.default.rx.notification(StudyCompleteCoinUpdate_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] data in |
| | | guard let weakSelf = self else { return } |
| | | |
| | | if let coin = data.object as? Int{ |
| | | switch weakSelf.viewModel.listenType.value { |
| | | case .game2:weakSelf.label_coin.text = "恭喜您,已完成游戏!获得\(coin)积分!" |
| | | default:weakSelf.label_coin.text = "恭喜您,已完成全部答题!获得\(coin)积分!" |
| | | } |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | @IBAction func backHomeAction(_ sender: UIButton) { |
| | | backAction() |
| | | } |