Music_Player3/MusicPlayer/MP/ViewControllers/Base(基类-导航栏-标签栏-计时器-播放器)/BaseViewController.swift
Mr.zhou 96147c5e37 项目:Musicoo
版本:A面 1.0
构建:1.1
更新内容:对项目A面功能的实现,经测试确定各项功能无问题。
更新时间:2024年4月12日 11:20
上传状态:已上传App Connect
2024-04-12 11:19:58 +08:00

46 lines
1.7 KiB
Swift

//
// BaseViewController.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/3/27.
//
import UIKit
///
class BaseViewController: UIViewController {
///
var nullMusicAction:ActionBlock?
override func viewDidLoad() {
super.viewDidLoad()
//
view.backgroundColor = .init(hex: "#151718")
navigationController?.navigationBar.isTranslucent = true
tabBarController?.tabBar.isTranslucent = true
//
navigationController?.setNavigationBarHidden(true, animated: false)
}
//
@objc func fileMissAction(_ sender:Notification) {
DispatchQueue.main.async {
[weak self] in
//
let alert = UIAlertController(title: "Missing Files", message: "The current music file is missing and will remove remove the music from the catalog. If you want to continue using the music file, please re-import it!", preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .destructive) { [weak self] (_) in
guard let music = MPMediaCenterManager.shared.getMusic() else {
return
}
//
MusicModel.delete(music)
MPMediaCenterManager.shared.setMusic(nil)
//
guard self?.nullMusicAction != nil else {
return
}
self?.nullMusicAction!()
}
alert.addAction(okAction)
self?.present(alert, animated: true)
}
}
}