diff --git a/BeeReel.xcodeproj/project.pbxproj b/BeeReel.xcodeproj/project.pbxproj index 057bc9a..7fe2690 100644 --- a/BeeReel.xcodeproj/project.pbxproj +++ b/BeeReel.xcodeproj/project.pbxproj @@ -152,6 +152,9 @@ BFC676B92E1385FC006659E5 /* BRPopularPicksSmallCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFC676B82E1385FC006659E5 /* BRPopularPicksSmallCell.swift */; }; BFC676BC2E138ABB006659E5 /* BRNewReleasesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFC676BB2E138ABB006659E5 /* BRNewReleasesViewController.swift */; }; BFC676BE2E13A8EB006659E5 /* UIScrollView+BRRefresh.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFC676BD2E13A8DD006659E5 /* UIScrollView+BRRefresh.swift */; }; + F39855202E32166300E2D28D /* BRFavoritesPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F398551F2E32166300E2D28D /* BRFavoritesPageViewController.swift */; }; + F39855222E32227D00E2D28D /* BRPlayHistorysViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F39855212E32227D00E2D28D /* BRPlayHistorysViewController.swift */; }; + F39855242E3222BE00E2D28D /* BRPlayHistorysCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F39855232E3222BE00E2D28D /* BRPlayHistorysCell.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -315,6 +318,9 @@ BFC676BD2E13A8DD006659E5 /* UIScrollView+BRRefresh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIScrollView+BRRefresh.swift"; sourceTree = ""; }; C8F11086BA392585E9563BA7 /* Pods-ShortBox.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ShortBox.release.xcconfig"; path = "Target Support Files/Pods-ShortBox/Pods-ShortBox.release.xcconfig"; sourceTree = ""; }; F06627B1DEE86552C2A87AEC /* Pods-BeeReel.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BeeReel.debug.xcconfig"; path = "Target Support Files/Pods-BeeReel/Pods-BeeReel.debug.xcconfig"; sourceTree = ""; }; + F398551F2E32166300E2D28D /* BRFavoritesPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRFavoritesPageViewController.swift; sourceTree = ""; }; + F39855212E32227D00E2D28D /* BRPlayHistorysViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRPlayHistorysViewController.swift; sourceTree = ""; }; + F39855232E3222BE00E2D28D /* BRPlayHistorysCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BRPlayHistorysCell.swift; sourceTree = ""; }; F70FA1F4169364C4C53534CE /* Pods-BeeReel.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BeeReel.release.xcconfig"; path = "Target Support Files/Pods-BeeReel/Pods-BeeReel.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -363,7 +369,9 @@ BF02B8062E2F613600172177 /* Controller */ = { isa = PBXGroup; children = ( + F398551F2E32166300E2D28D /* BRFavoritesPageViewController.swift */, BF02B8072E2F616E00172177 /* BRFavoritesViewController.swift */, + F39855212E32227D00E2D28D /* BRPlayHistorysViewController.swift */, ); path = Controller; sourceTree = ""; @@ -371,8 +379,9 @@ BF02B80B2E2F63C600172177 /* View */ = { isa = PBXGroup; children = ( - BF02B80C2E2F63ED00172177 /* BRFavoritesCell.swift */, BF02B80E2E2F6EEA00172177 /* BRFavoritesHeaderView.swift */, + BF02B80C2E2F63ED00172177 /* BRFavoritesCell.swift */, + F39855232E3222BE00E2D28D /* BRPlayHistorysCell.swift */, ); path = View; sourceTree = ""; @@ -1147,6 +1156,7 @@ BF3338F72E16176900B10F76 /* BRDetailPlayerCell.swift in Sources */, BF3338EA2E152B8100B10F76 /* BRPlayerCache.swift in Sources */, BF3A56832E30C561009E5CF9 /* BRSearchResultView.swift in Sources */, + F39855242E3222BE00E2D28D /* BRPlayHistorysCell.swift in Sources */, BFC676952E126BBF006659E5 /* BRSpotlightNewCell.swift in Sources */, BF692B402E0A8FA100A5C2DA /* UIColor+BRAdd.swift in Sources */, BF692B102E0A7B4300A5C2DA /* BRUserDefaultsKey.swift in Sources */, @@ -1180,6 +1190,7 @@ BF3338FD2E1626B000B10F76 /* BRPlayerControlProtocol.swift in Sources */, BF692B582E0AAA6F00A5C2DA /* UIScreen+BRAdd.swift in Sources */, BF692B1F2E0A804600A5C2DA /* BRLocalizedManager.swift in Sources */, + F39855222E32227D00E2D28D /* BRPlayHistorysViewController.swift in Sources */, BF02B7E92E2E29E900172177 /* BREpisodeSelectorCell.swift in Sources */, BF02B83B2E30BB4C00172177 /* BRHotSearchView.swift in Sources */, BF02B8332E308E4300172177 /* BRSearchRecordTagCell.swift in Sources */, @@ -1198,6 +1209,7 @@ BF02B8022E2F39FE00172177 /* BRCategorieShortViewController.swift in Sources */, BF3338FB2E161CF900B10F76 /* NSNumber+BRAdd.swift in Sources */, BF692B222E0A820D00A5C2DA /* String+BRAdd.swift in Sources */, + F39855202E32166300E2D28D /* BRFavoritesPageViewController.swift in Sources */, BF02B80F2E2F6EEA00172177 /* BRFavoritesHeaderView.swift in Sources */, BF692B632E0B9D4800A5C2DA /* BRTabBarItem.swift in Sources */, BFC6768B2E123690006659E5 /* BRVideoRevolutionManager.swift in Sources */, @@ -1268,6 +1280,7 @@ GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = BeeReel/Sources/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = BeeReel; + INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIMainStoryboardFile = ""; @@ -1303,6 +1316,7 @@ GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = BeeReel/Sources/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = BeeReel; + INFOPLIST_KEY_ITSAppUsesNonExemptEncryption = NO; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UIMainStoryboardFile = ""; diff --git a/BeeReel/Base/Controller/BRTabBarController.swift b/BeeReel/Base/Controller/BRTabBarController.swift index 77ae065..15fa39c 100644 --- a/BeeReel/Base/Controller/BRTabBarController.swift +++ b/BeeReel/Base/Controller/BRTabBarController.swift @@ -72,7 +72,7 @@ extension BRTabBarController { private func br_setup() { let nav1 = createNavigationController(viewController: BRHomeViewController(), title: "首页".localized, image: UIImage(named: "tabbar_icon_01"), selectedImage: UIImage(named: "tabbar_icon_01_selected")) let nav2 = createNavigationController(viewController: BRExploreViewController(), title: "推荐".localized, image: UIImage(named: "tabbar_icon_02"), selectedImage: UIImage(named: "tabbar_icon_02_selected")) - let nav3 = createNavigationController(viewController: BRFavoritesViewController(), title: "首页".localized, image: UIImage(named: "tabbar_icon_03"), selectedImage: UIImage(named: "tabbar_icon_03_selected")) + let nav3 = createNavigationController(viewController: BRFavoritesPageViewController(), title: "首页".localized, image: UIImage(named: "tabbar_icon_03"), selectedImage: UIImage(named: "tabbar_icon_03_selected")) let nav4 = createNavigationController(viewController: BRMineViewController(), title: "首页".localized, image: UIImage(named: "tabbar_icon_04"), selectedImage: UIImage(named: "tabbar_icon_04_selected")) viewControllers = [nav1, nav2, nav3, nav4] diff --git a/BeeReel/Class/Favorites/Controller/BRFavoritesPageViewController.swift b/BeeReel/Class/Favorites/Controller/BRFavoritesPageViewController.swift new file mode 100644 index 0000000..5f6c96a --- /dev/null +++ b/BeeReel/Class/Favorites/Controller/BRFavoritesPageViewController.swift @@ -0,0 +1,81 @@ +// +// BRFavoritesPageViewController.swift +// BeeReel +// +// Created by 长沙鸿瑶 on 2025/7/24. +// + +import UIKit +import WMZPageController + +class BRFavoritesPageViewController: BRViewController { + + private lazy var vcArr: [BRViewController] = { + let arr = [ + BRFavoritesViewController(), + BRPlayHistorysViewController(), + ] + return arr + }() + + private lazy var pageParam: WMZPageParam = { + let param = WMZPageParam() + param.wTitleArr = [ + [WMZPageBTNKey.keyImage : "Favorites 1", WMZPageBTNKey.keySelectImage : "Favorites", WMZPageBTNKey.keyTitleWidth : UIImage(named: "Favorites")?.size.width ?? 0], + [WMZPageBTNKey.keyImage : "history 1", WMZPageBTNKey.keySelectImage : "history", WMZPageBTNKey.keyTitleWidth : UIImage(named: "history")?.size.width ?? 0], + ] + param.wViewController = { [weak self] index in + return self?.vcArr[index] + } + + //顶部可下拉 + param.wBounces = false + + param.wMenuHeight = 25 + param.wMenuTitleOffset = 20 + param.wMenuInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15) + param.wMenuBgColor = .clear + param.wBgColor = .clear + + + param.wCustomNaviBarY = { _ in + return UIScreen.statusBarHeight + 18 + } + param.wCustomTabbarY = { _ in + return 0 + } + + return param + }() + + private lazy var pageView: WMZPageView = { + let view = WMZPageView(frame: self.view.bounds, autoFix: true, param: pageParam, parentReponder: self) + view.backgroundColor = .clear + view.downSc?.backgroundColor = .clear + return view + }() + + override func viewDidLoad() { + super.viewDidLoad() + self.navigationController?.isNavigationBarHidden = true + + br_setupUI() + } + + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + self.navigationController?.setNavigationBarHidden(true, animated: true) + } + +} + +extension BRFavoritesPageViewController { + + private func br_setupUI() { + view.addSubview(pageView) + + + } + +} diff --git a/BeeReel/Class/Favorites/Controller/BRFavoritesViewController.swift b/BeeReel/Class/Favorites/Controller/BRFavoritesViewController.swift index 569103d..1b8c49c 100644 --- a/BeeReel/Class/Favorites/Controller/BRFavoritesViewController.swift +++ b/BeeReel/Class/Favorites/Controller/BRFavoritesViewController.swift @@ -12,23 +12,6 @@ class BRFavoritesViewController: BRViewController { private lazy var listArr: [BRShortModel] = [] private lazy var page = 1 - ///播放历史 - private var playHistoryModel: BRShortModel? { - didSet { - if let _ = playHistoryModel { - self.collectionViewLayout.headerReferenceSize = .init(width: UIScreen.width, height: 180) - } else { - self.collectionViewLayout.headerReferenceSize = .zero - } - - collectionView.reloadData() - } - } - - private lazy var titleImageView: UIImageView = { - let imageView = UIImageView(image: UIImage(named: "title_icon_01")) - return imageView - }() private lazy var collectionViewLayout: UICollectionViewFlowLayout = { let width = floor((UIScreen.width - 30 - 22) / 3) @@ -79,23 +62,10 @@ class BRFavoritesViewController: BRViewController { requestDataList(page: 1, completer: nil) - requestPlayHistorys() } - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - self.navigationController?.setNavigationBarHidden(true, animated: true) - } - - override func viewDidAppear(_ animated: Bool) { - if self.hasViewDidAppear { - requestPlayHistorys() - } - super.viewDidAppear(animated) - } override func handleHeaderRefresh(_ completer: (() -> Void)?) { - self.requestPlayHistorys() self.requestDataList(page: 1) { [weak self] in self?.collectionView.br_endHeaderRefreshing() } @@ -108,7 +78,7 @@ class BRFavoritesViewController: BRViewController { } private func updateEmptyStatus() { - if listArr.isEmpty, self.playHistoryModel == nil { + if listArr.isEmpty { self.collectionView.ly_showEmpty() } else { self.collectionView.ly_hideEmpty() @@ -120,18 +90,12 @@ class BRFavoritesViewController: BRViewController { extension BRFavoritesViewController { private func br_setupUI() { - view.addSubview(titleImageView) view.addSubview(collectionView) view.addSubview(addFavoritesButton) - titleImageView.snp.makeConstraints { make in - make.left.equalToSuperview().offset(15) - make.top.equalToSuperview().offset(UIScreen.statusBarHeight + 20) - } - collectionView.snp.makeConstraints { make in make.left.right.equalToSuperview() - make.top.equalToSuperview().offset(UIScreen.statusBarHeight + 60) + make.top.equalToSuperview().offset(18) make.bottom.equalTo(addFavoritesButton.snp.top).offset(-10) } @@ -157,18 +121,21 @@ extension BRFavoritesViewController { extension BRFavoritesViewController: UICollectionViewDelegate, UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! BRFavoritesCell - cell.model = self.listArr[indexPath.row] + cell.model = self.listArr[indexPath.row + 1] return cell } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return self.listArr.count + if self.listArr.count == 0 { + return 0 + } + return self.listArr.count - 1 } func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { if kind == UICollectionView.elementKindSectionHeader { let view = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "headerView", for: indexPath) as! BRFavoritesHeaderView - view.model = self.playHistoryModel + view.model = self.listArr.first return view } else { return UICollectionReusableView() @@ -176,7 +143,7 @@ extension BRFavoritesViewController: UICollectionViewDelegate, UICollectionViewD } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let model = self.listArr[indexPath.row] + let model = self.listArr[indexPath.row + 1] let vc = BRVideoDetailViewController() vc.shortPlayId = model.short_play_id self.navigationController?.pushViewController(vc, animated: true) @@ -198,23 +165,22 @@ extension BRFavoritesViewController { $0.is_collect = true } self.listArr += list + + if self.listArr.count > 0 { + self.collectionViewLayout.headerReferenceSize = .init(width: UIScreen.width, height: 180) + } else { + self.collectionViewLayout.headerReferenceSize = .zero + } + self.page = page self.collectionView.reloadData() } + self.updateEmptyStatus() completer?() } } - private func requestPlayHistorys() { - BRVideoAPI.requestPlayHistorys(page: 1, pageSize: 1) { [weak self] listModel in - guard let self = self else { return } - guard let list = listModel?.list else { return } - self.playHistoryModel = list.first - self.updateEmptyStatus() - } - } - } diff --git a/BeeReel/Class/Favorites/Controller/BRPlayHistorysViewController.swift b/BeeReel/Class/Favorites/Controller/BRPlayHistorysViewController.swift new file mode 100644 index 0000000..c8c7898 --- /dev/null +++ b/BeeReel/Class/Favorites/Controller/BRPlayHistorysViewController.swift @@ -0,0 +1,126 @@ +// +// BRPlayHistorysViewController.swift +// BeeReel +// +// Created by 长沙鸿瑶 on 2025/7/24. +// + +import UIKit + +class BRPlayHistorysViewController: BRViewController { + + private lazy var listArr: [BRShortModel] = [] + private lazy var page = 1 + + private lazy var collectionViewLayout: UICollectionViewFlowLayout = { + let width = floor((UIScreen.width - 30 - 22) / 3) + let height = 144 / 108 * width + + let layout = UICollectionViewFlowLayout() + layout.minimumLineSpacing = 11 + layout.minimumInteritemSpacing = 11 + layout.sectionInset = .init(top: 0, left: 15, bottom: 0, right: 15) + layout.itemSize = .init(width: width, height: height) + return layout + }() + + private lazy var collectionView: BRCollectionView = { + let collectionView = BRCollectionView(frame: .zero, collectionViewLayout: collectionViewLayout) + collectionView.delegate = self + collectionView.dataSource = self + collectionView.ly_emptyView = BREmpty.br_normalEmptyView() + collectionView.contentInset = .init(top: 0, left: 0, bottom: UIScreen.customTabBarHeight + 10, right: 0) + collectionView.br_addRefreshHeader { [weak self] in + self?.handleHeaderRefresh(nil) + } + collectionView.br_addRefreshBackFooter(insetBottom: 0) { [weak self] in + self?.handleFooterRefresh(nil) + } + collectionView.register(BRPlayHistorysCell.self, forCellWithReuseIdentifier: "cell") + return collectionView + }() + + override func viewDidLoad() { + super.viewDidLoad() + requestDataList(page: 1, completer: nil) + + view.addSubview(collectionView) + + collectionView.snp.makeConstraints { make in + make.top.equalToSuperview().offset(18) + make.left.right.bottom.equalToSuperview() + } + + } + + override func viewDidAppear(_ animated: Bool) { + if self.hasViewDidAppear { + requestDataList(page: 1, completer: nil) + } + super.viewDidAppear(animated) + } + + override func handleHeaderRefresh(_ completer: (() -> Void)?) { + self.requestDataList(page: 1) { [weak self] in + self?.collectionView.br_endHeaderRefreshing() + } + } + + override func handleFooterRefresh(_ completer: (() -> Void)?) { + self.requestDataList(page: self.page + 1) { [weak self] in + self?.collectionView.br_endFooterRefreshing() + } + } + + +} + + +// MARK: - UICollectionViewDelegate & UICollectionViewDataSource +extension BRPlayHistorysViewController: UICollectionViewDelegate, UICollectionViewDataSource { + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! BRPlayHistorysCell + cell.model = self.listArr[indexPath.row] + return cell + } + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return self.listArr.count + } + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + let model = self.listArr[indexPath.row] + let vc = BRVideoDetailViewController() + vc.shortPlayId = model.short_play_id + self.navigationController?.pushViewController(vc, animated: true) + } + +} + +extension BRPlayHistorysViewController { + + private func requestDataList(page: Int, completer: (() -> Void)?) { + + BRVideoAPI.requestPlayHistorys(page: page) { [weak self] listModel in + guard let self = self else { return } + if let list = listModel?.list { + if page == 1 { + self.listArr.removeAll() + } + list.forEach { + $0.is_collect = true + } + self.listArr += list + self.page = page + self.collectionView.reloadData() + } + completer?() + } + + } + + + +} + diff --git a/BeeReel/Class/Favorites/View/BRFavoritesCell.swift b/BeeReel/Class/Favorites/View/BRFavoritesCell.swift index a50338f..d02b734 100644 --- a/BeeReel/Class/Favorites/View/BRFavoritesCell.swift +++ b/BeeReel/Class/Favorites/View/BRFavoritesCell.swift @@ -13,17 +13,17 @@ class BRFavoritesCell: BRCollectionViewCell { didSet { coverView.br_setImage(url: model?.image_url) - let epString = NSMutableAttributedString() - - let epStr1 = NSMutableAttributedString(string: "EP.##".localizedReplace(text: model?.current_episode ?? "")) - epStr1.yy_color = .colorE3FC37() - epString.append(epStr1) - - let epStr2 = NSMutableAttributedString(string: "/" + "EP.##".localizedReplace(text: "\(model?.episode_total ?? 0)")) - epStr2.yy_color = .colorD3D3D3() - epString.append(epStr2) - - epLabel.attributedText = epString +// let epString = NSMutableAttributedString() +// +// let epStr1 = NSMutableAttributedString(string: "EP.##".localizedReplace(text: model?.current_episode ?? "")) +// epStr1.yy_color = .colorE3FC37() +// epString.append(epStr1) +// +// let epStr2 = NSMutableAttributedString(string: "/" + "EP.##".localizedReplace(text: "\(model?.episode_total ?? 0)")) +// epStr2.yy_color = .colorD3D3D3() +// epString.append(epStr2) +// +// epLabel.attributedText = epString favoriteButton.isSelected = model?.is_collect ?? false } @@ -34,17 +34,17 @@ class BRFavoritesCell: BRCollectionViewCell { return imageView }() - private lazy var bottomView: UIView = { - let view = UIView() - view.br_addEffectView(style: .light) - return view - }() - - private lazy var epLabel: UILabel = { - let label = UILabel() - label.font = .fontRegular(ofSize: 12) - return label - }() +// private lazy var bottomView: UIView = { +// let view = UIView() +// view.br_addEffectView(style: .light) +// return view +// }() +// +// private lazy var epLabel: UILabel = { +// let label = UILabel() +// label.font = .fontRegular(ofSize: 12) +// return label +// }() private lazy var favoriteButton: UIButton = { let button = UIButton(type: .custom) @@ -99,23 +99,23 @@ extension BRFavoritesCell { private func br_setupUI() { contentView.addSubview(coverView) - contentView.addSubview(bottomView) - bottomView.addSubview(epLabel) +// contentView.addSubview(bottomView) +// bottomView.addSubview(epLabel) contentView.addSubview(favoriteButton) coverView.snp.makeConstraints { make in make.edges.equalToSuperview() } - bottomView.snp.makeConstraints { make in - make.left.right.bottom.equalToSuperview() - make.height.equalTo(28) - } - - epLabel.snp.makeConstraints { make in - make.left.equalToSuperview().offset(6) - make.centerY.equalToSuperview() - } +// bottomView.snp.makeConstraints { make in +// make.left.right.bottom.equalToSuperview() +// make.height.equalTo(28) +// } +// +// epLabel.snp.makeConstraints { make in +// make.left.equalToSuperview().offset(6) +// make.centerY.equalToSuperview() +// } favoriteButton.snp.makeConstraints { make in make.top.equalToSuperview().offset(5) diff --git a/BeeReel/Class/Favorites/View/BRFavoritesHeaderView.swift b/BeeReel/Class/Favorites/View/BRFavoritesHeaderView.swift index ef2b119..4cee43c 100644 --- a/BeeReel/Class/Favorites/View/BRFavoritesHeaderView.swift +++ b/BeeReel/Class/Favorites/View/BRFavoritesHeaderView.swift @@ -34,6 +34,8 @@ class BRFavoritesHeaderView: UICollectionReusableView { private lazy var bgView: UIImageView = { let view = UIImageView(image: UIImage(named: "history_bg_image")) view.isUserInteractionEnabled = true + let tap = UITapGestureRecognizer(target: self, action: #selector(handlePlayButton)) + view.addGestureRecognizer(tap) return view }() @@ -47,11 +49,11 @@ class BRFavoritesHeaderView: UICollectionReusableView { private lazy var playButton: UIButton = { let button = UIButton(type: .custom) + button.isUserInteractionEnabled = false button.layer.cornerRadius = 10 button.layer.masksToBounds = true button.backgroundColor = .colorE3FC37() button.setImage(UIImage(named: "play_icon_06"), for: .normal) - button.addTarget(self, action: #selector(handlePlayButton), for: .touchUpInside) return button }() diff --git a/BeeReel/Class/Favorites/View/BRPlayHistorysCell.swift b/BeeReel/Class/Favorites/View/BRPlayHistorysCell.swift new file mode 100644 index 0000000..08f2d4a --- /dev/null +++ b/BeeReel/Class/Favorites/View/BRPlayHistorysCell.swift @@ -0,0 +1,126 @@ +// +// BRPlayHistorysCell.swift +// BeeReel +// +// Created by 长沙鸿瑶 on 2025/7/24. +// + +import UIKit + +class BRPlayHistorysCell: BRCollectionViewCell { + + var model: BRShortModel? { + didSet { + coverView.br_setImage(url: model?.image_url) + + let epString = NSMutableAttributedString() + + let epStr1 = NSMutableAttributedString(string: "EP.##".localizedReplace(text: model?.current_episode ?? "")) + epStr1.yy_color = .colorE3FC37() + epString.append(epStr1) + + let epStr2 = NSMutableAttributedString(string: "/" + "EP.##".localizedReplace(text: "\(model?.episode_total ?? 0)")) + epStr2.yy_color = .colorD3D3D3() + epString.append(epStr2) + + epLabel.attributedText = epString + + favoriteButton.isSelected = model?.is_collect ?? false + } + } + + private lazy var coverView: BRImageView = { + let imageView = BRImageView() + return imageView + }() + + private lazy var bottomView: UIView = { + let view = UIView() + view.br_addEffectView(style: .light) + return view + }() + + private lazy var epLabel: UILabel = { + let label = UILabel() + label.font = .fontRegular(ofSize: 12) + return label + }() + + private lazy var favoriteButton: UIButton = { + let button = UIButton(type: .custom) + button.setImage(UIImage(named: "favorite_icon_04"), for: .normal) + button.setImage(UIImage(named: "favorite_icon_04_selected"), for: .selected) + button.setImage(UIImage(named: "favorite_icon_04_selected"), for: [.selected, .highlighted]) + button.addTarget(self, action: #selector(handleFavoriteButton), for: .touchUpInside) + return button + }() + + deinit { + NotificationCenter.default.removeObserver(self) + } + + override init(frame: CGRect) { + super.init(frame: frame) + NotificationCenter.default.addObserver(self, selector: #selector(updateShortFavoriteStateNotification), name: BRVideoAPI.updateShortFavoriteStateNotification, object: nil) + self.contentView.layer.cornerRadius = 8 + self.contentView.layer.masksToBounds = true + + br_setupUI() + } + + @MainActor required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + @objc private func handleFavoriteButton() { + guard let shortPlayId = self.model?.short_play_id else { return } + let isFavorite = !(self.model?.is_collect ?? false) + + BRVideoAPI.requestFavorite(isFavorite: isFavorite, shortPlayId: shortPlayId, videoId: model?.short_play_video_id) { + + } + + } + + @objc private func updateShortFavoriteStateNotification(sender: Notification) { + guard let userInfo = sender.userInfo else { return } + guard let shortPlayId = userInfo["id"] as? String else { return } + guard let state = userInfo["state"] as? Bool else { return } + guard shortPlayId == self.model?.short_play_id else { return } + + self.model?.is_collect = state; + + favoriteButton.isSelected = self.model?.is_collect ?? false + } + +} + +extension BRPlayHistorysCell { + + private func br_setupUI() { + contentView.addSubview(coverView) + contentView.addSubview(bottomView) + bottomView.addSubview(epLabel) + contentView.addSubview(favoriteButton) + + coverView.snp.makeConstraints { make in + make.edges.equalToSuperview() + } + + bottomView.snp.makeConstraints { make in + make.left.right.bottom.equalToSuperview() + make.height.equalTo(28) + } + + epLabel.snp.makeConstraints { make in + make.left.equalToSuperview().offset(6) + make.centerY.equalToSuperview() + } + + favoriteButton.snp.makeConstraints { make in + make.top.equalToSuperview().offset(5) + make.right.equalToSuperview().offset(-5) + } + } + +} diff --git a/BeeReel/Class/Home/View/Spotlight/BRSpotlightHotCell.swift b/BeeReel/Class/Home/View/Spotlight/BRSpotlightHotCell.swift index ebdfe18..b319990 100644 --- a/BeeReel/Class/Home/View/Spotlight/BRSpotlightHotCell.swift +++ b/BeeReel/Class/Home/View/Spotlight/BRSpotlightHotCell.swift @@ -15,7 +15,7 @@ class BRSpotlightHotCell: BRCollectionViewCell { titleLabel.text = model?.name categoryLabel.text = model?.category?.first - favoriteButton.isSelected = self.model?.is_collect ?? false +// favoriteButton.isSelected = self.model?.is_collect ?? false hotView.setNeedsUpdateConfiguration() } @@ -68,23 +68,23 @@ class BRSpotlightHotCell: BRCollectionViewCell { return button }() - private lazy var favoriteButton: UIButton = { - let button = UIButton(type: .custom) - button.setImage(UIImage(named: "favorite_icon_01"), for: .normal) - button.setImage(UIImage(named: "favorite_icon_01_selected"), for: .selected) - button.setImage(UIImage(named: "favorite_icon_01_selected"), for: [.selected, .highlighted]) - button.addTarget(self, action: #selector(handleFavoriteButton), for: .touchUpInside) - return button - }() +// private lazy var favoriteButton: UIButton = { +// let button = UIButton(type: .custom) +// button.setImage(UIImage(named: "favorite_icon_01"), for: .normal) +// button.setImage(UIImage(named: "favorite_icon_01_selected"), for: .selected) +// button.setImage(UIImage(named: "favorite_icon_01_selected"), for: [.selected, .highlighted]) +// button.addTarget(self, action: #selector(handleFavoriteButton), for: .touchUpInside) +// return button +// }() - deinit { - NotificationCenter.default.removeObserver(self) - } +// deinit { +// NotificationCenter.default.removeObserver(self) +// } override init(frame: CGRect) { super.init(frame: frame) - NotificationCenter.default.addObserver(self, selector: #selector(updateShortFavoriteStateNotification), name: BRVideoAPI.updateShortFavoriteStateNotification, object: nil) +// NotificationCenter.default.addObserver(self, selector: #selector(updateShortFavoriteStateNotification), name: BRVideoAPI.updateShortFavoriteStateNotification, object: nil) contentView.backgroundColor = .colorFFFFFF() contentView.layer.cornerRadius = 10 @@ -98,27 +98,27 @@ class BRSpotlightHotCell: BRCollectionViewCell { } - @objc private func handleFavoriteButton() { - guard let shortPlayId = self.model?.short_play_id else { return } - - let isFavorite = !(self.model?.is_collect ?? false) - let videoId = self.model?.short_play_video_id - - BRVideoAPI.requestFavorite(isFavorite: isFavorite, shortPlayId: shortPlayId, videoId: videoId) { - - } - } +// @objc private func handleFavoriteButton() { +// guard let shortPlayId = self.model?.short_play_id else { return } +// +// let isFavorite = !(self.model?.is_collect ?? false) +// let videoId = self.model?.short_play_video_id +// +// BRVideoAPI.requestFavorite(isFavorite: isFavorite, shortPlayId: shortPlayId, videoId: videoId) { +// +// } +// } - @objc private func updateShortFavoriteStateNotification(sender: Notification) { - guard let userInfo = sender.userInfo else { return } - guard let shortPlayId = userInfo["id"] as? String else { return } - guard let state = userInfo["state"] as? Bool else { return } - guard shortPlayId == self.model?.short_play_id else { return } - - self.model?.is_collect = state; - - favoriteButton.isSelected = self.model?.is_collect ?? false - } +// @objc private func updateShortFavoriteStateNotification(sender: Notification) { +// guard let userInfo = sender.userInfo else { return } +// guard let shortPlayId = userInfo["id"] as? String else { return } +// guard let state = userInfo["state"] as? Bool else { return } +// guard shortPlayId == self.model?.short_play_id else { return } +// +// self.model?.is_collect = state; +// +// favoriteButton.isSelected = self.model?.is_collect ?? false +// } } @@ -126,7 +126,7 @@ extension BRSpotlightHotCell { private func br_setupUI() { contentView.addSubview(coverImageView) - contentView.addSubview(favoriteButton) +// contentView.addSubview(favoriteButton) contentView.addSubview(titleLabel) contentView.addSubview(playIconImageView) contentView.addSubview(categoryLabel) @@ -137,10 +137,10 @@ extension BRSpotlightHotCell { make.height.equalTo(160) } - favoriteButton.snp.makeConstraints { make in - make.top.equalToSuperview().offset(4) - make.right.equalToSuperview().offset(-4) - } +// favoriteButton.snp.makeConstraints { make in +// make.top.equalToSuperview().offset(4) +// make.right.equalToSuperview().offset(-4) +// } titleLabel.snp.makeConstraints { make in make.left.equalToSuperview().offset(7) diff --git a/BeeReel/Sources/Assets.xcassets/icon/title_icon_01.imageset/Contents.json b/BeeReel/Sources/Assets.xcassets/icon/Favorites 1.imageset/Contents.json similarity index 100% rename from BeeReel/Sources/Assets.xcassets/icon/title_icon_01.imageset/Contents.json rename to BeeReel/Sources/Assets.xcassets/icon/Favorites 1.imageset/Contents.json diff --git a/BeeReel/Sources/Assets.xcassets/icon/Favorites 1.imageset/Favorites@2x.png b/BeeReel/Sources/Assets.xcassets/icon/Favorites 1.imageset/Favorites@2x.png new file mode 100644 index 0000000..6627104 Binary files /dev/null and b/BeeReel/Sources/Assets.xcassets/icon/Favorites 1.imageset/Favorites@2x.png differ diff --git a/BeeReel/Sources/Assets.xcassets/icon/Favorites 1.imageset/Favorites@3x.png b/BeeReel/Sources/Assets.xcassets/icon/Favorites 1.imageset/Favorites@3x.png new file mode 100644 index 0000000..eb7ae92 Binary files /dev/null and b/BeeReel/Sources/Assets.xcassets/icon/Favorites 1.imageset/Favorites@3x.png differ diff --git a/BeeReel/Sources/Assets.xcassets/icon/Favorites.imageset/Contents.json b/BeeReel/Sources/Assets.xcassets/icon/Favorites.imageset/Contents.json new file mode 100644 index 0000000..dd0db90 --- /dev/null +++ b/BeeReel/Sources/Assets.xcassets/icon/Favorites.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Favorites@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Favorites@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/BeeReel/Sources/Assets.xcassets/icon/title_icon_01.imageset/Favorites@2x.png b/BeeReel/Sources/Assets.xcassets/icon/Favorites.imageset/Favorites@2x.png similarity index 100% rename from BeeReel/Sources/Assets.xcassets/icon/title_icon_01.imageset/Favorites@2x.png rename to BeeReel/Sources/Assets.xcassets/icon/Favorites.imageset/Favorites@2x.png diff --git a/BeeReel/Sources/Assets.xcassets/icon/title_icon_01.imageset/Favorites@3x.png b/BeeReel/Sources/Assets.xcassets/icon/Favorites.imageset/Favorites@3x.png similarity index 100% rename from BeeReel/Sources/Assets.xcassets/icon/title_icon_01.imageset/Favorites@3x.png rename to BeeReel/Sources/Assets.xcassets/icon/Favorites.imageset/Favorites@3x.png diff --git a/BeeReel/Sources/Assets.xcassets/icon/history 1.imageset/Contents.json b/BeeReel/Sources/Assets.xcassets/icon/history 1.imageset/Contents.json new file mode 100644 index 0000000..a9c623f --- /dev/null +++ b/BeeReel/Sources/Assets.xcassets/icon/history 1.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "history@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "history@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/BeeReel/Sources/Assets.xcassets/icon/history 1.imageset/history@2x.png b/BeeReel/Sources/Assets.xcassets/icon/history 1.imageset/history@2x.png new file mode 100644 index 0000000..bdad5a1 Binary files /dev/null and b/BeeReel/Sources/Assets.xcassets/icon/history 1.imageset/history@2x.png differ diff --git a/BeeReel/Sources/Assets.xcassets/icon/history 1.imageset/history@3x.png b/BeeReel/Sources/Assets.xcassets/icon/history 1.imageset/history@3x.png new file mode 100644 index 0000000..fdab34c Binary files /dev/null and b/BeeReel/Sources/Assets.xcassets/icon/history 1.imageset/history@3x.png differ diff --git a/BeeReel/Sources/Assets.xcassets/icon/history.imageset/Contents.json b/BeeReel/Sources/Assets.xcassets/icon/history.imageset/Contents.json new file mode 100644 index 0000000..a9c623f --- /dev/null +++ b/BeeReel/Sources/Assets.xcassets/icon/history.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "history@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "history@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/BeeReel/Sources/Assets.xcassets/icon/history.imageset/history@2x.png b/BeeReel/Sources/Assets.xcassets/icon/history.imageset/history@2x.png new file mode 100644 index 0000000..2c93e84 Binary files /dev/null and b/BeeReel/Sources/Assets.xcassets/icon/history.imageset/history@2x.png differ diff --git a/BeeReel/Sources/Assets.xcassets/icon/history.imageset/history@3x.png b/BeeReel/Sources/Assets.xcassets/icon/history.imageset/history@3x.png new file mode 100644 index 0000000..cd9e02e Binary files /dev/null and b/BeeReel/Sources/Assets.xcassets/icon/history.imageset/history@3x.png differ