我的列表开发

This commit is contained in:
2025-04-23 15:37:58 +08:00
parent 35544cfac0
commit 1a7eb496e1
30 changed files with 289 additions and 58 deletions

View File

@ -176,5 +176,9 @@ extension UIColor {
static func colorCCCCCC(alpha: CGFloat = 1) -> UIColor {
return color(hex: 0xCCCCCC, alpha: alpha)
}
static func color6D7A8F(alpha: CGFloat = 1) -> UIColor {
return color(hex: 0x6D7A8F, alpha: alpha)
}
}

View File

@ -143,6 +143,9 @@ extension SPAllShortViewController: UICollectionViewDelegate, UICollectionViewDa
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let model = dataArr[indexPath.row]
let vc = SPPlayerDetailViewController()
vc.shortPlayId = model.short_play_id
self.navigationController?.pushViewController(vc, animated: true)
}
}

View File

@ -17,14 +17,14 @@ class SPCollectListViewController: SPMyListChildViewController {
//MARK: UI
private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
let itemWidth = floor((kSPScreenWidth - 30 - 9 * 2) / 3)
let itemHeight = 146 / 109 * itemWidth + 36
let itemWidth = floor((kSPScreenWidth - 32 - 8 * 2) / 3)
let itemHeight = 145 / 109 * itemWidth + 36
let layout = UICollectionViewFlowLayout()
layout.itemSize = .init(width: itemWidth, height: itemHeight)
layout.minimumLineSpacing = 10
layout.minimumInteritemSpacing = 9
layout.sectionInset = .init(top: 0, left: 15, bottom: 0, right: 15)
layout.minimumLineSpacing = 18
layout.minimumInteritemSpacing = 8
layout.sectionInset = .init(top: 0, left: 16, bottom: 0, right: 16)
return layout
}()
@ -132,6 +132,11 @@ extension SPCollectListViewController: UICollectionViewDelegate, UICollectionVie
let cell = SPCollectListCell.dequeueReusableCell(collectionView: collectionView, indexPath: indexPath)
cell.sp_isEditing = self.sp_isEditing
cell.model = dataArr[indexPath.row]
cell.clickDeleteButton = { [weak self] cell in
guard let self = self else { return }
guard let indexPath = self.collectionView.indexPath(for: cell) else { return }
self.deleteShort(indexPath: indexPath)
}
return cell
}
@ -164,6 +169,19 @@ extension SPCollectListViewController: UICollectionViewDelegate, UICollectionVie
}
}
func deleteShort(indexPath: IndexPath) {
let model = self.dataArr[indexPath.row]
guard let id = model.short_play_id else { return }
SPVideoAPI.requestCollectShort(isCollect: false, shortPlayId: id, videoId: nil) { [weak self] in
guard let self = self else { return }
self.requestDataList(page: 1, completer: nil)
}
}
}
extension SPCollectListViewController {

View File

@ -11,7 +11,7 @@ class SPMyListChildViewController: SPViewController {
var sp_isEditing = false {
didSet {
deleteButton.isHidden = !sp_isEditing
// deleteButton.isHidden = !sp_isEditing
if sp_isEditing {
self.view.bringSubviewToFront(deleteButton)
}

View File

@ -10,7 +10,7 @@ import UIKit
class SPMyListViewController: SPViewController {
private lazy var titles = ["Follow List".localized, "Play List".localized]
private lazy var titles = ["Watch list".localized, "Recently viewed".localized]
private lazy var viewControllers: [SPMyListChildViewController] = {
let vc1 = SPCollectListViewController()
@ -50,18 +50,18 @@ class SPMyListViewController: SPViewController {
let pageView = JYPageController()
pageView.delegate = self
pageView.dataSource = self
pageView.config.indicatorWidth = 20
pageView.config.indicatorHeight = 4
pageView.config.indicatorCornerRadius = 2
pageView.config.indicatorColor = .colorFFFFFF(alpha: 0.9)
pageView.config.selectedTitleColor = .colorFFFFFF(alpha: 0.9)
// pageView.config.indicatorWidth = 20
pageView.config.indicatorHeight = 2
pageView.config.indicatorCornerRadius = 0
pageView.config.indicatorColor = .colorFF0000()
pageView.config.selectedTitleColor = .colorFFFFFF()
pageView.config.selectedTitleFont = 16
pageView.config.selectedTitleFontWeight = .medium
pageView.config.normalTitleColor = .color888888()
pageView.config.normalTitleFont = 15
pageView.config.normalTitleFontWeight = .regular
pageView.config.leftPadding = 15
pageView.config.itemsMargin = 40
pageView.config.normalTitleColor = .colorA8A5AA()
pageView.config.normalTitleFont = 16
pageView.config.normalTitleFontWeight = .medium
pageView.config.leftPadding = 16
pageView.config.itemsMargin = 22
return pageView
}()
@ -74,9 +74,10 @@ class SPMyListViewController: SPViewController {
private lazy var cancelButton: UIButton = {
let button = UIButton(type: .custom)
button.setTitle("Cancel".localized, for: .normal)
button.setTitleColor(.colorFFFFFF(alpha: 0.9), for: .normal)
button.titleLabel?.font = .fontRegular(ofSize: 15)
// button.setTitle("Cancel".localized, for: .normal)
button.setImage(UIImage(named: "cancel_icon_01"), for: .normal)
// button.setTitleColor(.colorFFFFFF(alpha: 0.9), for: .normal)
// button.titleLabel?.font = .fontRegular(ofSize: 15)
button.addTarget(self, action: #selector(handleCancelButton), for: .touchUpInside)
button.isHidden = true
return button
@ -98,6 +99,12 @@ class SPMyListViewController: SPViewController {
return button
}()
private lazy var lineView: UIView = {
let view = UIView()
view.backgroundColor = .color5A5C67()
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
@ -112,8 +119,10 @@ class SPMyListViewController: SPViewController {
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
if self.sp_isEditing {
self.sp_isEditing = false
}
}
@objc private func handleEditButton() {
self.sp_isEditing = true
@ -136,10 +145,18 @@ class SPMyListViewController: SPViewController {
extension SPMyListViewController {
private func _setupUI() {
addChild(pageView)
view.addSubview(lineView)
view.addSubview(pageView.view)
view.addSubview(editButton)
view.addSubview(cancelButton)
view.addSubview(allSelectedButton)
// view.addSubview(allSelectedButton)
lineView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.height.equalTo(1)
make.top.equalToSuperview().offset(kSPStatusbarHeight + 10 + 34)
}
pageView.view.snp.makeConstraints { make in
make.edges.equalToSuperview()
@ -153,14 +170,15 @@ extension SPMyListViewController {
}
cancelButton.snp.makeConstraints { make in
make.top.bottom.equalTo(editButton)
make.right.equalTo(editButton)
make.edges.equalTo(editButton)
// make.top.bottom.equalTo(editButton)
// make.right.equalTo(editButton)
}
allSelectedButton.snp.makeConstraints { make in
make.left.equalToSuperview().offset(15)
make.top.bottom.equalTo(editButton)
}
// allSelectedButton.snp.makeConstraints { make in
// make.left.equalToSuperview().offset(15)
// make.top.bottom.equalTo(editButton)
// }
}
}

View File

@ -16,14 +16,14 @@ class SPPlayHistoryViewController: SPMyListChildViewController {
//MARK: UI
private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
let itemWidth = floor((kSPScreenWidth - 30 - 9 * 2) / 3)
let itemHeight = 146 / 109 * itemWidth + 36
let itemWidth = kSPScreenWidth - 32
let itemHeight = 151.0
let layout = UICollectionViewFlowLayout()
layout.itemSize = .init(width: itemWidth, height: itemHeight)
layout.minimumLineSpacing = 10
layout.minimumLineSpacing = 18
layout.minimumInteritemSpacing = 9
layout.sectionInset = .init(top: 0, left: 15, bottom: 0, right: 15)
layout.sectionInset = .init(top: 0, left: 16, bottom: 0, right: 16)
return layout
}()
@ -39,7 +39,7 @@ class SPPlayHistoryViewController: SPMyListChildViewController {
collectionView.sp_addRefreshBackFooter { [weak self] in
self?.handleFooterRefresh(nil)
}
SPCollectListCell.registerCell(collectionView: collectionView)
SPPlayHistoryCell.registerCell(collectionView: collectionView)
return collectionView
}()
@ -130,8 +130,7 @@ extension SPPlayHistoryViewController {
extension SPPlayHistoryViewController: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = SPCollectListCell.dequeueReusableCell(collectionView: collectionView, indexPath: indexPath)
cell.sp_isEditing = self.sp_isEditing
let cell = SPPlayHistoryCell.dequeueReusableCell(collectionView: collectionView, indexPath: indexPath)
cell.model = dataArr[indexPath.row]
return cell
}

View File

@ -9,45 +9,59 @@ import UIKit
class SPCollectListCell: SPCollectionViewCell {
var clickDeleteButton: ((_ cell: SPCollectListCell) -> Void)?
var model: SPShortModel? {
didSet {
coverImageView.sp_setImage(url: model?.image_url)
titleLabel.text = model?.name
selectedButton.isSelected = model?.sp_isSelected ?? false
// selectedButton.isSelected = model?.sp_isSelected ?? false
}
}
var sp_isEditing: Bool = false {
didSet {
selectedButton.isHidden = !sp_isEditing
deleteButton.isHidden = !sp_isEditing
}
}
private lazy var coverImageView: SPImageView = {
let imageView = SPImageView()
imageView.layer.cornerRadius = 7
imageView.layer.cornerRadius = 6
imageView.layer.masksToBounds = true
imageView.layer.borderColor = UIColor.colorFFFFFF(alpha: 0.15).cgColor
imageView.layer.borderWidth = 1
imageView.isUserInteractionEnabled = true
return imageView
}()
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = .fontRegular(ofSize: 13)
label.textColor = .colorFFFFFF(alpha: 0.9)
label.font = .fontMedium(ofSize: 12)
label.textColor = .colorFFFFFF()
label.numberOfLines = 2
return label
}()
private lazy var selectedButton: UIButton = {
private lazy var deleteButton: UIButton = {
let button = UIButton(type: .custom)
button.isHidden = true
button.isUserInteractionEnabled = false
button.setImage(UIImage(named: "check_icon_01"), for: .normal)
button.setImage(UIImage(named: "check_icon_01_selected"), for: .selected)
// button.isUserInteractionEnabled = false
button.setImage(UIImage(named: "delete_icon_04"), for: .normal)
button.backgroundColor = .color000000(alpha: 0.68)
button.addTarget(self, action: #selector(handleDeleteButton), for: .touchUpInside)
return button
}()
// private lazy var selectedButton: UIButton = {
// let button = UIButton(type: .custom)
// button.isHidden = true
// button.isUserInteractionEnabled = false
// button.setImage(UIImage(named: "check_icon_01"), for: .normal)
// button.setImage(UIImage(named: "check_icon_01_selected"), for: .selected)
// return button
// }()
override init(frame: CGRect) {
super.init(frame: frame)
@ -59,6 +73,10 @@ class SPCollectListCell: SPCollectionViewCell {
fatalError("init(coder:) has not been implemented")
}
@objc private func handleDeleteButton() {
self.clickDeleteButton?(self)
}
}
extension SPCollectListCell {
@ -66,7 +84,7 @@ extension SPCollectListCell {
private func _setupUI() {
contentView.addSubview(coverImageView)
contentView.addSubview(titleLabel)
coverImageView.addSubview(selectedButton)
coverImageView.addSubview(deleteButton)
coverImageView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
@ -75,13 +93,12 @@ extension SPCollectListCell {
titleLabel.snp.makeConstraints { make in
make.left.equalToSuperview()
make.top.equalTo(coverImageView.snp.bottom).offset(5)
make.top.equalTo(coverImageView.snp.bottom).offset(8)
make.right.lessThanOrEqualToSuperview()
}
selectedButton.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-5)
make.top.equalToSuperview().offset(5)
deleteButton.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
}

View File

@ -0,0 +1,127 @@
//
// SPPlayHistoryCell.swift
// Thimra
//
// Created by Overseas on 2025/4/23.
//
import UIKit
class SPPlayHistoryCell: SPCollectionViewCell {
var model: SPShortModel? {
didSet {
coverImageView.sp_setImage(url: model?.image_url)
titleLabel.text = model?.name
let episode = String(format: "EP.%@".localized, model?.current_episode ?? "")
let totalEpisode = "/\(model?.episode_total ?? 0)"
let range = NSRange(location: episode.length(), length: totalEpisode.length())
let episodeString = NSMutableAttributedString(string: episode + totalEpisode)
episodeString.color = .colorEC3324()
episodeString.setColor(.color6D7A8F(), range: range)
episodeLabel.attributedText = episodeString
collectButton.isSelected = model?.is_collect ?? false
}
}
private lazy var coverImageView: SPImageView = {
let imageView = SPImageView()
imageView.layer.cornerRadius = 6
imageView.layer.masksToBounds = true
imageView.layer.borderColor = UIColor.colorFFFFFF(alpha: 0.15).cgColor
imageView.layer.borderWidth = 1
imageView.isUserInteractionEnabled = true
return imageView
}()
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.font = .fontMedium(ofSize: 16)
label.textColor = .colorFFFFFF()
label.numberOfLines = 2
return label
}()
private lazy var episodeLabel: UILabel = {
let label = UILabel()
label.font = .fontMedium(ofSize: 12)
return label
}()
private lazy var collectButton: UIButton = {
let button = UIButton(type: .custom)
button.setImage(UIImage(named: "collect_icon_02"), for: .normal)
button.setImage(UIImage(named: "collect_icon_02_selected"), for: .selected)
button.setImage(UIImage(named: "collect_icon_02_selected"), for: [.selected, .highlighted])
button.addTarget(self, action: #selector(handleCollectButton), for: .touchUpInside)
return button
}()
override init(frame: CGRect) {
super.init(frame: frame)
NotificationCenter.default.addObserver(self, selector: #selector(updateShortCollectStateNotification), name: SPVideoAPI.updateShortCollectStateNotification, object: nil)
_setupUI()
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc private func handleCollectButton() {
let isCollect = !(self.model?.is_collect ?? false)
guard let shortPlayId = self.model?.short_play_id else { return }
SPVideoAPI.requestCollectShort(isCollect: isCollect, shortPlayId: shortPlayId, videoId: nil) {
}
}
@objc private func updateShortCollectStateNotification(sender: Notification) {
guard let userInfo = sender.userInfo else { return }
guard let shortPlayId = userInfo["id"] as? String else { return }
guard let isCollect = userInfo["state"] as? Bool else { return }
guard shortPlayId == self.model?.short_play_id else { return }
self.model?.is_collect = isCollect
collectButton.isSelected = isCollect
}
}
extension SPPlayHistoryCell {
private func _setupUI() {
contentView.addSubview(coverImageView)
contentView.addSubview(titleLabel)
contentView.addSubview(episodeLabel)
contentView.addSubview(collectButton)
coverImageView.snp.makeConstraints { make in
make.left.top.bottom.equalToSuperview()
make.width.equalTo(109)
}
titleLabel.snp.makeConstraints { make in
make.left.equalTo(coverImageView.snp.right).offset(14)
make.top.equalToSuperview().offset(3)
make.right.lessThanOrEqualToSuperview().offset(-40)
}
episodeLabel.snp.makeConstraints { make in
make.left.equalTo(titleLabel)
make.top.equalTo(titleLabel.snp.bottom).offset(12)
}
collectButton.snp.makeConstraints { make in
make.right.equalToSuperview()
make.top.equalToSuperview().offset(3)
}
}
}

View File

@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "组件 67 2@2x.png",
"filename" : "Frame@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "组件 67 2@3x.png",
"filename" : "Frame@3x.png",
"idiom" : "universal",
"scale" : "3x"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "组件 67 9@2x.png",
"filename" : "Frame@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "组件 67 9@3x.png",
"filename" : "Frame@3x.png",
"idiom" : "universal",
"scale" : "3x"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 B

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "delet-选中@2x.png",
"filename" : "Frame@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "delet-选中@3x.png",
"filename" : "Frame@3x.png",
"idiom" : "universal",
"scale" : "3x"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Frame@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Frame@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

View File

@ -27,8 +27,8 @@
"Help Center" = "Help Center";
"About Us" = "About Us";
"My list" = "My list";
"Follow List" = "Follow List";
"Play List" = "Play List";
"Watch list" = "Watch list";
"Recently viewed" = "Recently viewed";
"Cancel" = "Cancel";
"Select All" = "Select All";
"Delet (%@)" = "Delet (%@)";
@ -43,5 +43,6 @@
"Full Episodes" = "Full Episodes";
"All" = "All";
"Shorts" = "Shorts";
"EP.%@" = "EP.%@";