Music_Player3/MusicPlayer/MP/MPPositive/Views/Player/MPPositive_PlayerCoverView.swift
2024-05-11 09:48:37 +08:00

143 lines
5.8 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// MPPositive_PlayerCoverView.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/5/8.
//
import UIKit
//BView(View)
class MPPositive_PlayerCoverView: UIView {
///
lazy var coverImageView:UIImageView = {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFill
imageView.layer.masksToBounds = true
imageView.layer.cornerRadius = 16*width
return imageView
}()
///
lazy var titleLabel:UILabel = createLabel(font: .systemFont(ofSize: 22*width, weight: .regular), textColor: .init(hex: "#FFFFFF", alpha: 0.85), textAlignment: .left)
///
lazy var subtitleLabel:UILabel = createLabel(font: .systemFont(ofSize: 12*width, weight: .regular), textColor: .init(hex: "#EEEEEE", alpha: 0.6), textAlignment: .left)
///
lazy var collectionSongBtn:UIButton = {
let btn = UIButton()
btn.setBackgroundImage(UIImage(named: "List_UnCollection'logo"), for: .normal)
btn.setBackgroundImage(UIImage(named: "List_Collectioned'logo"), for: .selected)
btn.addTarget(self, action: #selector(collectionSwitchClick(_ :)), for: .touchUpInside)
return btn
}()
///
lazy var loadBtn:UIButton = {
let btn:UIButton = .init()
btn.setBackgroundImage(UIImage(named: "Song_Unload'logo"), for: .normal)
btn.setBackgroundImage(UIImage(named: "Song_Loaded'logo"), for: .selected)
btn.addTarget(self, action: #selector(loadActionClick(_ :)), for: .touchUpInside)
return btn
}()
///View
lazy var sliderView:MPPositive_PlayerSilder = {
let sliderView:MPPositive_PlayerSilder = .init(frame: .init(x: 0, y: 0, width: 335*width, height: 6*width))
sliderView.addTarget(self, action: #selector(seekProgressClick(_:forEvent:)), for: .valueChanged)
sliderView.addTarget(self, action: #selector(seekProgressClick(_:forEvent:)), for: .touchDown)
sliderView.addTarget(self, action: #selector(seekProgressClick(_:forEvent:)), for: .touchUpInside)
return sliderView
}()
///Label
lazy var durationLabel:UILabel = createLabel("00:00" ,font: .systemFont(ofSize: 12*width, weight: .medium), textColor: .init(hex: "#FFFFFF", alpha: 0.85), textAlignment: .left)
///Label
lazy var maxTimesLabel:UILabel = createLabel("00:00" ,font: .systemFont(ofSize: 12*width, weight: .medium), textColor: .init(hex: "#FFFFFF", alpha: 0.6), textAlignment: .right)
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .clear
configure()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
//
private func configure() {
//
addSubview(coverImageView)
coverImageView.snp.makeConstraints { make in
make.width.equalTo(335*width)
make.height.equalTo(330*width)
make.centerX.equalToSuperview()
make.top.equalToSuperview().offset(12*width)
}
//
addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.left.equalTo(coverImageView.snp.left)
make.top.equalTo(coverImageView.snp.bottom).offset(36*width)
make.right.equalTo(coverImageView.snp.right).offset(-100*width)
}
addSubview(subtitleLabel)
subtitleLabel.snp.makeConstraints { make in
make.left.right.equalTo(titleLabel)
make.top.equalTo(titleLabel.snp.bottom).offset(6*width)
}
//
addSubview(loadBtn)
loadBtn.snp.makeConstraints { make in
make.right.equalTo(coverImageView.snp.right).offset(-12*width)
make.top.equalTo(coverImageView.snp.bottom).offset(47*width)
make.width.height.equalTo(24*width)
}
addSubview(collectionSongBtn)
collectionSongBtn.snp.makeConstraints { make in
make.right.equalTo(loadBtn.snp.left).offset(-20*width)
make.centerY.equalTo(loadBtn.snp.centerY)
make.width.height.equalTo(24*width)
}
//label
addSubview(sliderView)
sliderView.snp.makeConstraints { make in
make.top.equalTo(subtitleLabel.snp.bottom).offset(25*width)
make.centerX.equalToSuperview()
make.width.equalTo(335*width)
make.height.equalTo(6*width)
}
addSubview(durationLabel)
durationLabel.snp.makeConstraints { make in
make.left.equalTo(sliderView.snp.left)
make.top.equalTo(sliderView.snp.bottom).offset(5*width)
}
addSubview(maxTimesLabel)
maxTimesLabel.snp.makeConstraints { make in
make.right.equalTo(sliderView.snp.right)
make.top.equalTo(sliderView.snp.bottom).offset(5*width)
}
}
//
@objc private func seekProgressClick(_ sender: UISlider, forEvent event: UIEvent) {
//touchEvent
let touchEvent = event.allTouches?.first
//
switch touchEvent?.phase {
case .began://
//
MP_PlayerManager.shared.setEditPorgressStatu()
case .moved://
break
case .ended://
let value = sender.value
//
MP_PlayerManager.shared.setEditProgressEnd(value)
default:
break
}
}
//
@objc private func collectionSwitchClick(_ sender:UIButton) {
}
//
@objc private func loadActionClick(_ sender:UIButton) {
}
}