diff --git a/MoviaBox/Class/Home/Controller/SPHomeViewController.swift b/MoviaBox/Class/Home/Controller/SPHomeViewController.swift index 2536e41..afcf74d 100644 --- a/MoviaBox/Class/Home/Controller/SPHomeViewController.swift +++ b/MoviaBox/Class/Home/Controller/SPHomeViewController.swift @@ -80,6 +80,12 @@ class SPHomeViewController: SPHomeChildController { private var headerView: SPHomeHeaderView? + private lazy var playHistoricalView: SPHomePlayHistoricalView = { + let view = SPHomePlayHistoricalView() + view.isHidden = true + return view + }() + override func viewDidLoad() { super.viewDidLoad() @@ -144,6 +150,7 @@ extension SPHomeViewController { view.addSubview(allButton) view.addSubview(rewardButton) view.addSubview(self.collectionView) + view.addSubview(playHistoricalView) // logoImageView.snp.makeConstraints { make in // make.left.equalToSuperview().offset(16) @@ -174,6 +181,12 @@ extension SPHomeViewController { // make.top.equalToSuperview().offset(kSPStatusbarHeight + 66) make.top.equalTo(searchButton.snp.bottom).offset(34) } + + playHistoricalView.snp.makeConstraints { make in + make.left.equalToSuperview().offset(16) + make.centerX.equalToSuperview() + make.bottom.equalToSuperview().offset(-4) + } } } @@ -329,6 +342,11 @@ extension SPHomeViewController { self.viewModel.playHistoryArr = list self.layout.headerReferenceSize = CGSize(width: kSPScreenWidth, height: SPHomeHeaderView.contentHeight(viewModel: self.viewModel)) self.collectionView.reloadData() + + if let model = listModel?.list?.first { + self.playHistoricalView.model = model + self.playHistoricalView.isHidden = false + } } self.updateEmptyState() completer?() @@ -354,4 +372,6 @@ extension SPHomeViewController { } } + + } diff --git a/MoviaBox/Class/Home/View/SPHomePlayHistoricalView.swift b/MoviaBox/Class/Home/View/SPHomePlayHistoricalView.swift new file mode 100644 index 0000000..038e3df --- /dev/null +++ b/MoviaBox/Class/Home/View/SPHomePlayHistoricalView.swift @@ -0,0 +1,138 @@ +// +// SPHomePlayHistoricalView.swift +// MoviaBox +// +// Created by 长沙佳儿 on 2025/6/17. +// + +import UIKit + +class SPHomePlayHistoricalView: UIView { + + var model: SPShortModel? { + didSet { + coverImageView.sp_setImage(url: model?.image_url) + titleLabel.text = model?.name + subtitleLabel.text = "movia_watched_episode".localizedReplace(text: model?.current_episode ?? "") + } + } + + private lazy var bgView: UIView = { + let view = UIImageView(image: UIImage(named: "home_historical_bg_image_")) + view.isUserInteractionEnabled = true +// view.addEffectView(style: .dark) +// view.addRadius(topLeft: 0, topRight: 24, bottomLeft: 0, bottomRight: 24) + let tap = UITapGestureRecognizer(target: self, action: #selector(handlePlayButton)) + view.addGestureRecognizer(tap) + return view + }() + + private lazy var coverImageView: SPImageView = { + let imageView = SPImageView() + imageView.layer.cornerRadius = 4 + imageView.layer.masksToBounds = true + return imageView + }() + + private lazy var closeButton: UIButton = { + let button = UIButton(type: .custom) + button.setImage(UIImage(named: "close_icon_03"), for: .normal) + button.addTarget(self, action: #selector(handleCloseButton), for: .touchUpInside) + return button + }() + + private lazy var playButton: UIButton = { + let button = UIButton(type: .custom) + button.isUserInteractionEnabled = false + button.setImage(UIImage(named: "play_icon_05"), for: .normal) + button.addTarget(self, action: #selector(handlePlayButton), for: .touchUpInside) + return button + }() + + private lazy var titleLabel: UILabel = { + let label = UILabel() + label.font = .fontMedium(ofSize: 12) + label.textColor = .colorFFFFFF() + return label + }() + + private lazy var subtitleLabel: UILabel = { + let label = UILabel() + label.font = .fontRegular(ofSize: 12) + label.textColor = .colorFFFFFF(alpha: 0.3) + return label + }() + + override init(frame: CGRect) { + super.init(frame: frame) + + sp_setupUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + @objc private func handleCloseButton() { + self.isHidden = true + } + + @objc private func handlePlayButton() { + guard let shortPlayId = model?.short_play_id else { return } + + let vc = SPPlayerDetailViewController() + vc.shortPlayId = shortPlayId + SPAPPTool.topViewController()?.navigationController?.pushViewController(vc, animated: true) + } + +} + +extension SPHomePlayHistoricalView { + + private func sp_setupUI() { + addSubview(bgView) + addSubview(coverImageView) + bgView.addSubview(closeButton) + bgView.addSubview(playButton) + bgView.addSubview(titleLabel) + bgView.addSubview(subtitleLabel) + + + bgView.snp.makeConstraints { make in + make.left.right.bottom.equalToSuperview() +// make.height.equalTo(48) + } + + coverImageView.snp.makeConstraints { make in + make.left.bottom.top.equalToSuperview() + make.height.equalTo(58) + make.width.equalTo(44) + } + + closeButton.snp.makeConstraints { make in + make.centerY.equalToSuperview() + make.right.equalToSuperview().offset(-4) + make.width.equalTo(32) + make.height.equalTo(40) + } + + playButton.snp.makeConstraints { make in + make.centerY.equalToSuperview() + make.right.equalToSuperview().offset(-38) + } + + titleLabel.snp.makeConstraints { make in + make.left.equalToSuperview().offset(52) + make.top.equalToSuperview().offset(7) + make.right.lessThanOrEqualToSuperview().offset(-100) + } + + subtitleLabel.snp.makeConstraints { make in + make.left.equalTo(titleLabel) + make.bottom.equalToSuperview().offset(-7) + make.right.lessThanOrEqualToSuperview().offset(-100) + } + + } + +} diff --git a/MoviaBox/Class/Rewards/Controller/SPRewardsViewController.swift b/MoviaBox/Class/Rewards/Controller/SPRewardsViewController.swift index 41d484d..57d82d2 100644 --- a/MoviaBox/Class/Rewards/Controller/SPRewardsViewController.swift +++ b/MoviaBox/Class/Rewards/Controller/SPRewardsViewController.swift @@ -28,6 +28,12 @@ class SPRewardsViewController: SPCampaignWebViewController { self.webView.backgroundColor = .clear self.webView.scrollView.backgroundColor = .clear + + self.webView.snp.remakeConstraints { make in + make.left.right.bottom.equalToSuperview() + make.top.equalToSuperview().offset(kSPNavBarHeight) + } + setEmptyView() diff --git a/MoviaBox/Libs/SPLocalizedManager/SPLocalizedManager.swift b/MoviaBox/Libs/SPLocalizedManager/SPLocalizedManager.swift index 52fc4e4..1f8925b 100644 --- a/MoviaBox/Libs/SPLocalizedManager/SPLocalizedManager.swift +++ b/MoviaBox/Libs/SPLocalizedManager/SPLocalizedManager.swift @@ -124,7 +124,14 @@ extension SPLocalizedManager { } extension String { + var localized: String { - return SPLocalizedManager.shared.localizedString(forKey: self) + var text = SPLocalizedManager.shared.localizedString(forKey: self) + text = text.replacingOccurrences(of: "
", with: "\n") + return text + } + + func localizedReplace(text: String) -> String { + return self.localized.replacingOccurrences(of: "##", with: text) } } diff --git a/MoviaBox/Source/Assets.xcassets/icon/close_icon_03.imageset/Contents.json b/MoviaBox/Source/Assets.xcassets/icon/close_icon_03.imageset/Contents.json new file mode 100644 index 0000000..5c4d3b1 --- /dev/null +++ b/MoviaBox/Source/Assets.xcassets/icon/close_icon_03.imageset/Contents.json @@ -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 + } +} diff --git a/MoviaBox/Source/Assets.xcassets/icon/close_icon_03.imageset/Frame@2x.png b/MoviaBox/Source/Assets.xcassets/icon/close_icon_03.imageset/Frame@2x.png new file mode 100644 index 0000000..6ba86d1 Binary files /dev/null and b/MoviaBox/Source/Assets.xcassets/icon/close_icon_03.imageset/Frame@2x.png differ diff --git a/MoviaBox/Source/Assets.xcassets/icon/close_icon_03.imageset/Frame@3x.png b/MoviaBox/Source/Assets.xcassets/icon/close_icon_03.imageset/Frame@3x.png new file mode 100644 index 0000000..0446a1e Binary files /dev/null and b/MoviaBox/Source/Assets.xcassets/icon/close_icon_03.imageset/Frame@3x.png differ diff --git a/MoviaBox/Source/Assets.xcassets/icon/play_icon_05.imageset/Contents.json b/MoviaBox/Source/Assets.xcassets/icon/play_icon_05.imageset/Contents.json new file mode 100644 index 0000000..6bc782a --- /dev/null +++ b/MoviaBox/Source/Assets.xcassets/icon/play_icon_05.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Frame 1912056685@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Frame 1912056685@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/MoviaBox/Source/Assets.xcassets/icon/play_icon_05.imageset/Frame 1912056685@2x.png b/MoviaBox/Source/Assets.xcassets/icon/play_icon_05.imageset/Frame 1912056685@2x.png new file mode 100644 index 0000000..6563608 Binary files /dev/null and b/MoviaBox/Source/Assets.xcassets/icon/play_icon_05.imageset/Frame 1912056685@2x.png differ diff --git a/MoviaBox/Source/Assets.xcassets/icon/play_icon_05.imageset/Frame 1912056685@3x.png b/MoviaBox/Source/Assets.xcassets/icon/play_icon_05.imageset/Frame 1912056685@3x.png new file mode 100644 index 0000000..93fb0e5 Binary files /dev/null and b/MoviaBox/Source/Assets.xcassets/icon/play_icon_05.imageset/Frame 1912056685@3x.png differ diff --git a/MoviaBox/Source/Assets.xcassets/image/home_historical_bg_image_.imageset/Contents.json b/MoviaBox/Source/Assets.xcassets/image/home_historical_bg_image_.imageset/Contents.json new file mode 100644 index 0000000..04e6e87 --- /dev/null +++ b/MoviaBox/Source/Assets.xcassets/image/home_historical_bg_image_.imageset/Contents.json @@ -0,0 +1,44 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "背景切图@2x.png", + "idiom" : "universal", + "resizing" : { + "cap-insets" : { + "left" : 88, + "right" : 72 + }, + "center" : { + "mode" : "tile", + "width" : 1 + }, + "mode" : "3-part-horizontal" + }, + "scale" : "2x" + }, + { + "filename" : "背景切图@3x.png", + "idiom" : "universal", + "resizing" : { + "cap-insets" : { + "left" : 108, + "right" : 110 + }, + "center" : { + "mode" : "tile", + "width" : 1 + }, + "mode" : "3-part-horizontal" + }, + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/MoviaBox/Source/Assets.xcassets/image/home_historical_bg_image_.imageset/背景切图@2x.png b/MoviaBox/Source/Assets.xcassets/image/home_historical_bg_image_.imageset/背景切图@2x.png new file mode 100644 index 0000000..3e65952 Binary files /dev/null and b/MoviaBox/Source/Assets.xcassets/image/home_historical_bg_image_.imageset/背景切图@2x.png differ diff --git a/MoviaBox/Source/Assets.xcassets/image/home_historical_bg_image_.imageset/背景切图@3x.png b/MoviaBox/Source/Assets.xcassets/image/home_historical_bg_image_.imageset/背景切图@3x.png new file mode 100644 index 0000000..7224bce Binary files /dev/null and b/MoviaBox/Source/Assets.xcassets/image/home_historical_bg_image_.imageset/背景切图@3x.png differ diff --git a/MoviaBox/Source/en.lproj/Localizable.strings b/MoviaBox/Source/en.lproj/Localizable.strings index 7e1b950..46585ff 100644 --- a/MoviaBox/Source/en.lproj/Localizable.strings +++ b/MoviaBox/Source/en.lproj/Localizable.strings @@ -114,6 +114,7 @@ "Y_complex" = "years"; "movia_vip_membership" = "VIP Membership"; "movia_library" = "Library"; +"movia_watched_episode" = "Watched EP##"; "movia_vip_alert_text_01" = "Short Drama VIP Exclusive";