//
|
// HomeVC.swift
|
// DolphinEnglishLearnStudent
|
//
|
// Created by 无故事王国 on 2024/5/22.
|
//
|
|
import UIKit
|
import SDWebImage
|
|
class HomeVC: BaseVC {
|
|
|
@IBOutlet weak var view_yearTwo: TapBtn!
|
@IBOutlet weak var view_yearThree: TapBtn!
|
@IBOutlet weak var view_yearFour: TapBtn!
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
|
Services.parentPage().subscribe(onNext: {data in
|
if let imgStr = data.data{
|
let promptlaunchScreen = UserDefaults.standard.object(forKey: "promptlaunchScreen") as? String
|
if promptlaunchScreen != imgStr || promptlaunchScreen == nil{
|
SDWebImageDownloader.shared.downloadImage(with: URL(string: imgStr)) { image, _, _, _ in
|
if let img = image{
|
LaunchImageHelper.changeAllLaunchImageToLandscape(img)
|
UserDefaults.standard.setValue(imgStr, forKey: "promptlaunchScreen")
|
UserDefaults.standard.synchronize()
|
}
|
}
|
}
|
}
|
}).disposed(by: disposeBag)
|
|
Services.promptVoice().subscribe(onNext: {data in
|
if let model = data.data{
|
let voice = UserDefaults.standard.object(forKey: "promptVoiceDate") as? String
|
if model.updateTime != voice || !VoicePlayer.hasPromoteVoice(){
|
VoicePlayer.share().donwloadPromoteVoice(successVoice: model.correct, failVoice: model.error,updateTime: model.updateTime)
|
}
|
}
|
}).disposed(by: disposeBag)
|
|
showLaunchImg()
|
|
NotificationCenter.default.rx.notification(UIApplication.didBecomeActiveNotification).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in
|
self?.showLaunchImg()
|
}).disposed(by: disposeBag)
|
}
|
|
private func showLaunchImg(){
|
let launchImg = UIImageView(image: UIImage(named: "launchscreen"))
|
sceneDelegate?.window?.addSubview(launchImg)
|
launchImg.snp.makeConstraints { make in
|
make.edges.equalToSuperview()
|
}
|
|
UIView.animate(withDuration: 0.6,delay: 2.5) {
|
launchImg.alpha = 0
|
} completion: { _ in
|
launchImg.removeFromSuperview()
|
}
|
|
}
|
|
override func viewDidLayoutSubviews() {
|
super.viewDidLayoutSubviews()
|
// view_yearTwo.jq_gradientColor(colorArr: [UIColor(hexString: "#F0F0F0")!.cgColor,UIColor(hexString: "#DDDDDD")!.cgColor], cornerRadius: 15, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: view_yearTwo.bounds,locations: [NSNumber(value: 0.35)])
|
//
|
// view_yearThree.jq_gradientColor(colorArr: [UIColor(hexString: "#F0F0F0")!.cgColor,UIColor(hexString: "#DDDDDD")!.cgColor], cornerRadius: 15, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: view_yearTwo.bounds,locations: [NSNumber(value: 0.35)])
|
//
|
// view_yearFour.jq_gradientColor(colorArr: [UIColor(hexString: "#F0F0F0")!.cgColor,UIColor(hexString: "#DDDDDD")!.cgColor], cornerRadius: 15, startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0, y: 1), bounds: view_yearTwo.bounds,locations: [NSNumber(value: 0.35)])
|
}
|
|
@IBAction func listenAction(_ sender: UIButton) {
|
|
Services.goodRecommend().subscribe(onNext: { data in
|
if (data.data?.count ?? 0) > 0{
|
AwardListView.show(items: data.data ?? []) { _ in
|
// not todo
|
}closeClouse: { () in
|
let listenMenuVC = HomeListenMenuVC()
|
listenMenuVC.title = "第一年学习周目选择"
|
self.push(vc: listenMenuVC)
|
}
|
}else{
|
let listenMenuVC = HomeListenMenuVC()
|
listenMenuVC.title = "第一年学习周目选择"
|
self.push(vc: listenMenuVC)
|
}
|
},onError: { error in
|
let listenMenuVC = HomeListenMenuVC()
|
listenMenuVC.title = "第一年学习周目选择"
|
self.push(vc: listenMenuVC)
|
}).disposed(by: disposeBag)
|
|
|
}
|
|
|
}
|