首页历史记录,bug修复
This commit is contained in:
parent
cd6b6f7dcf
commit
3fb1d9c61d
@ -250,4 +250,8 @@ extension UIColor {
|
||||
return UIColor(rgb: 0xE0E0E0, alpha: alpha)
|
||||
}
|
||||
|
||||
static func colorDBDBDB(alpha: CGFloat = 1) -> UIColor {
|
||||
return UIColor(rgb: 0xDBDBDB, alpha: alpha)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,15 @@ class VPExploreViewController: VPVideoPlayerViewController {
|
||||
|
||||
var pagination: VPListPaginationModel?
|
||||
|
||||
private lazy var emptyView: VPEmptyView = {
|
||||
let view = VPEmptyView.createNoNetworkEmptyView { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.requestDataArr(page: 1)
|
||||
}
|
||||
view.isHidden = false
|
||||
return view
|
||||
}()
|
||||
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
@ -22,13 +31,15 @@ class VPExploreViewController: VPVideoPlayerViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(loginStateDidChangeNotification), name: VPLoginManager.loginStateDidChangeNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(reachabilityDidChangeNotification), name: VPNetworkReachabilityManager.reachabilityDidChangeNotification, object: nil)
|
||||
self.collectionView.vp_onRefrsh = true
|
||||
self.collectionView.vp_refreshDelegate = self
|
||||
self.delegate = self
|
||||
self.dataSource = self
|
||||
|
||||
|
||||
requestDataArr(page: 1)
|
||||
|
||||
vp_setupUI()
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
@ -39,9 +50,30 @@ class VPExploreViewController: VPVideoPlayerViewController {
|
||||
@objc private func loginStateDidChangeNotification() {
|
||||
requestDataArr(page: 1)
|
||||
}
|
||||
|
||||
@objc private func reachabilityDidChangeNotification() {
|
||||
if VPNetworkReachabilityManager.manager.isReachable == true, self.getDataCount() == 0 {
|
||||
requestDataArr(page: 1)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension VPExploreViewController {
|
||||
|
||||
private func vp_setupUI() {
|
||||
|
||||
view.addSubview(emptyView)
|
||||
|
||||
emptyView.snp.makeConstraints { make in
|
||||
make.left.equalToSuperview()
|
||||
make.centerX.equalToSuperview()
|
||||
make.centerY.equalToSuperview().offset(-100)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//MARK: -------------- VPPlayerListViewControllerDelegate --------------
|
||||
extension VPExploreViewController: VPPlayerListViewControllerDelegate {
|
||||
func vp_playerViewControllerLoadMoreData(playerViewController: VPVideoPlayerViewController) {
|
||||
@ -95,6 +127,8 @@ extension VPExploreViewController {
|
||||
|
||||
VPVideoAPI.requestRecommandsVideo(page: page) { [weak self] listModel in
|
||||
guard let self = self else { return }
|
||||
self.emptyView.isHidden = true
|
||||
self.collectionView.isHidden = false
|
||||
if let listModel = listModel, let list = listModel.list {
|
||||
if page == 1 {
|
||||
self.setDataArr(dataArr: list) { [weak self] in
|
||||
@ -105,6 +139,13 @@ extension VPExploreViewController {
|
||||
self.addDataArr(dataArr: list)
|
||||
}
|
||||
self.pagination = listModel.pagination
|
||||
|
||||
}
|
||||
else {
|
||||
if VPNetworkReachabilityManager.manager.isReachable != true, self.getDataCount() == 0 {
|
||||
self.emptyView.isHidden = false
|
||||
self.collectionView.isHidden = true
|
||||
}
|
||||
}
|
||||
completer?()
|
||||
}
|
||||
|
@ -127,11 +127,7 @@ class VPHomePageViewController: VPViewController {
|
||||
}()
|
||||
|
||||
private lazy var emptyView: VPEmptyView = {
|
||||
let view = VPEmptyView()
|
||||
view.image = UIImage(named: "empty_image_03")
|
||||
view.title = "veloria_no_network".localized
|
||||
view.des = "veloria_no_network_string".localized
|
||||
view.clickButtonBlock = { [weak self] in
|
||||
let view = VPEmptyView.createNoNetworkEmptyView { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.vp_setup()
|
||||
}
|
||||
@ -140,6 +136,7 @@ class VPHomePageViewController: VPViewController {
|
||||
|
||||
private lazy var playHistoricalView: VPHomePlayHistoricalView = {
|
||||
let view = VPHomePlayHistoricalView()
|
||||
view.isHidden = true
|
||||
return view
|
||||
}()
|
||||
|
||||
@ -157,6 +154,11 @@ class VPHomePageViewController: VPViewController {
|
||||
self.navigationController?.setNavigationBarHidden(true, animated: true)
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
self.requestPlayHistorical()
|
||||
}
|
||||
|
||||
override func handleHeaderRefresh(_ completer: (() -> Void)?) {
|
||||
if let vc = self.pageView.upSc.currentVC as? VPViewController {
|
||||
vc.handleHeaderRefresh { [weak self] in
|
||||
@ -204,12 +206,7 @@ class VPHomePageViewController: VPViewController {
|
||||
extension VPHomePageViewController {
|
||||
@objc private func reachabilityDidChangeNotification() {
|
||||
if VPNetworkReachabilityManager.manager.isReachable == true {
|
||||
if self.viewModel.oldModuleList == nil {
|
||||
requestHomeData()
|
||||
}
|
||||
requestCategories()
|
||||
|
||||
vp_setupUI()
|
||||
vp_setup()
|
||||
}
|
||||
|
||||
}
|
||||
@ -217,9 +214,12 @@ extension VPHomePageViewController {
|
||||
|
||||
extension VPHomePageViewController {
|
||||
private func vp_setup() {
|
||||
requestHomeData()
|
||||
if self.viewModel.oldModuleList == nil {
|
||||
requestHomeData()
|
||||
}
|
||||
requestCategories()
|
||||
setupPageView()
|
||||
requestPlayHistorical()
|
||||
vp_setupUI()
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ extension VPHomePageViewController {
|
||||
|
||||
playHistoricalView.snp.makeConstraints { make in
|
||||
make.centerX.equalToSuperview()
|
||||
make.right.equalToSuperview().offset(15)
|
||||
make.right.equalToSuperview().offset(-15)
|
||||
make.bottom.equalToSuperview().offset(-(UIScreen.customTabBarHeight + 10))
|
||||
}
|
||||
}
|
||||
@ -320,4 +320,16 @@ extension VPHomePageViewController {
|
||||
}
|
||||
}
|
||||
|
||||
private func requestPlayHistorical() {
|
||||
|
||||
VPVideoAPI.requestPlayHistoryList(page: 1, pageSize: 1) { [weak self] listModel in
|
||||
guard let self = self else { return }
|
||||
if let model = listModel?.list?.first {
|
||||
self.playHistoricalView.model = model
|
||||
self.playHistoricalView.isHidden = false
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,15 @@ import UIKit
|
||||
|
||||
class VPHomePlayHistoricalView: UIView {
|
||||
|
||||
var model: VPShortModel? {
|
||||
didSet {
|
||||
coverImageView.vp_setImage(url: model?.image_url)
|
||||
titleLabel.text = model?.name
|
||||
|
||||
subtitleLabel.text = "veloria_last_play_episode".localizedReplace(text: model?.current_episode ?? "")
|
||||
}
|
||||
}
|
||||
|
||||
private lazy var bgView: UIView = {
|
||||
let view = UIView()
|
||||
view.layer.cornerRadius = 10
|
||||
@ -17,6 +26,41 @@ class VPHomePlayHistoricalView: UIView {
|
||||
return view
|
||||
}()
|
||||
|
||||
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 coverImageView: VPImageView = {
|
||||
let imageView = VPImageView()
|
||||
imageView.layer.cornerRadius = 8
|
||||
imageView.layer.masksToBounds = true
|
||||
return imageView
|
||||
}()
|
||||
|
||||
private lazy var titleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .fontMedium(ofSize: 13)
|
||||
label.textColor = .colorFFFFFF()
|
||||
return label
|
||||
}()
|
||||
|
||||
private lazy var subtitleLabel: UILabel = {
|
||||
let label = UILabel()
|
||||
label.font = .fontRegular(ofSize: 12)
|
||||
label.textColor = .colorDBDBDB()
|
||||
return label
|
||||
}()
|
||||
|
||||
private lazy var playButton: UIButton = {
|
||||
let button = UIButton(type: .custom)
|
||||
button.setImage(UIImage(named: "play_icon_02"), for: .normal)
|
||||
button.addTarget(self, action: #selector(handlePlayButton), for: .touchUpInside)
|
||||
return button
|
||||
}()
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
@ -28,6 +72,17 @@ class VPHomePlayHistoricalView: UIView {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@objc private func handleCloseButton() {
|
||||
self.isHidden = true
|
||||
}
|
||||
|
||||
@objc private func handlePlayButton() {
|
||||
guard let id = model?.short_play_id else { return }
|
||||
|
||||
let vc = VPDetailPlayerViewController()
|
||||
vc.shortPlayId = id
|
||||
VPAppTool.topViewController?.navigationController?.pushViewController(vc, animated: true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -35,12 +90,47 @@ extension VPHomePlayHistoricalView {
|
||||
|
||||
private func vp_setupUI() {
|
||||
addSubview(bgView)
|
||||
addSubview(coverImageView)
|
||||
bgView.addSubview(closeButton)
|
||||
bgView.addSubview(titleLabel)
|
||||
bgView.addSubview(subtitleLabel)
|
||||
bgView.addSubview(playButton)
|
||||
|
||||
|
||||
bgView.snp.makeConstraints { make in
|
||||
make.left.right.bottom.equalToSuperview()
|
||||
make.top.equalToSuperview().offset(12)
|
||||
make.height.equalTo(56)
|
||||
}
|
||||
|
||||
coverImageView.snp.makeConstraints { make in
|
||||
make.top.bottom.equalToSuperview()
|
||||
make.left.equalToSuperview().offset(32)
|
||||
make.width.equalTo(52)
|
||||
}
|
||||
|
||||
closeButton.snp.makeConstraints { make in
|
||||
make.centerY.equalToSuperview()
|
||||
make.left.equalToSuperview().offset(8)
|
||||
}
|
||||
|
||||
titleLabel.snp.makeConstraints { make in
|
||||
make.left.equalToSuperview().offset(91)
|
||||
make.top.equalToSuperview().offset(12)
|
||||
make.right.lessThanOrEqualToSuperview().offset(-50)
|
||||
}
|
||||
|
||||
subtitleLabel.snp.makeConstraints { make in
|
||||
make.left.equalTo(titleLabel)
|
||||
make.bottom.equalToSuperview().offset(-11)
|
||||
make.right.lessThanOrEqualToSuperview().offset(-50)
|
||||
}
|
||||
|
||||
playButton.snp.makeConstraints { make in
|
||||
make.centerY.equalToSuperview()
|
||||
make.right.equalToSuperview().offset(-11)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -126,10 +126,23 @@ class VPMyListViewController: VPViewController {
|
||||
return button
|
||||
}()
|
||||
|
||||
private lazy var emptyView: VPEmptyView = {
|
||||
let view = VPEmptyView.createNoNetworkEmptyView { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.vp_setupUI()
|
||||
}
|
||||
view.isHidden = false
|
||||
return view
|
||||
}()
|
||||
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(reachabilityDidChangeNotification), name: VPNetworkReachabilityManager.reachabilityDidChangeNotification, object: nil)
|
||||
|
||||
vp_setupUI()
|
||||
// pageView.selectMenu(with: 1)
|
||||
}
|
||||
@ -155,7 +168,10 @@ class VPMyListViewController: VPViewController {
|
||||
self?.pageView.selectMenu(with: 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@objc private func reachabilityDidChangeNotification() {
|
||||
vp_setupUI()
|
||||
}
|
||||
}
|
||||
|
||||
extension VPMyListViewController {
|
||||
@ -175,6 +191,19 @@ extension VPMyListViewController {
|
||||
|
||||
extension VPMyListViewController {
|
||||
private func vp_setupUI() {
|
||||
|
||||
guard VPNetworkReachabilityManager.manager.isReachable == true, pageView.superview == nil else {
|
||||
if emptyView.superview == nil {
|
||||
view.addSubview(emptyView)
|
||||
emptyView.snp.makeConstraints { make in
|
||||
make.left.equalToSuperview()
|
||||
make.centerX.equalToSuperview()
|
||||
make.centerY.equalToSuperview().offset(-100)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
view.addSubview(pageView)
|
||||
view.addSubview(editorButton)
|
||||
view.addSubview(cancelEditButton)
|
||||
|
@ -281,6 +281,19 @@ extension VPEpisodeView: UICollectionViewDelegate, UICollectionViewDataSource {
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||
guard indexPath.row != currentIndex else { return }
|
||||
|
||||
var lastIndex = indexPath.row - 1
|
||||
var lastIsLock = false
|
||||
if lastIndex > 0 && lastIndex < self.dataArr.count {
|
||||
let lastModel = self.dataArr[lastIndex]
|
||||
lastIsLock = lastModel.is_lock ?? false
|
||||
}
|
||||
|
||||
if lastIsLock {
|
||||
VPToast.show(text: "veloria_jump_unlock_error".localized)
|
||||
return
|
||||
}
|
||||
|
||||
self.didSelectedIndex?(indexPath.row)
|
||||
self.dismiss(animated: true) {
|
||||
|
||||
|
@ -9,17 +9,43 @@ import UIKit
|
||||
import EmptyDataSet_Swift
|
||||
|
||||
extension UIScrollView {
|
||||
func vp_addNormalEmpty(image: UIImage? = UIImage(named: "empty_image_01"), title: String? = "veloria_no_data".localized, des: String? = "veloria_no_data_add".localized) {
|
||||
func vp_addNormalEmpty(image: UIImage? = UIImage(named: "empty_image_01"), title: String? = "veloria_no_data".localized, des: String? = "veloria_no_data_add".localized, buttonHandle: (() -> Void)? = nil) {
|
||||
|
||||
let emptyView = VPEmptyView()
|
||||
emptyView.image = image
|
||||
emptyView.title = title
|
||||
emptyView.des = des
|
||||
if let handle = buttonHandle {
|
||||
emptyView.clickButtonBlock = handle
|
||||
}
|
||||
|
||||
self.emptyDataSetView { view in
|
||||
view.customView(emptyView)
|
||||
.verticalOffset(-130)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func vp_addNoNetworkEmpty(buttonHandle: (() -> Void)? = nil) {
|
||||
|
||||
let emptyView = VPEmptyView.createNoNetworkEmptyView(buttonHandle: buttonHandle)
|
||||
|
||||
self.emptyDataSetView { view in
|
||||
view.customView(emptyView)
|
||||
.verticalOffset(-130)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension VPEmptyView {
|
||||
|
||||
static func createNoNetworkEmptyView(buttonHandle: (() -> Void)?) -> VPEmptyView {
|
||||
let view = VPEmptyView()
|
||||
view.image = UIImage(named: "empty_image_03")
|
||||
view.title = "veloria_no_network".localized
|
||||
view.des = "veloria_no_network_string".localized
|
||||
view.clickButtonBlock = buttonHandle
|
||||
return view
|
||||
}
|
||||
|
||||
}
|
||||
|
BIN
Veloria/Source/Assets.xcassets/icon/close_icon_03.imageset/Close.png
vendored
Normal file
BIN
Veloria/Source/Assets.xcassets/icon/close_icon_03.imageset/Close.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 780 B |
BIN
Veloria/Source/Assets.xcassets/icon/close_icon_03.imageset/Close@3x.png
vendored
Normal file
BIN
Veloria/Source/Assets.xcassets/icon/close_icon_03.imageset/Close@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
22
Veloria/Source/Assets.xcassets/icon/close_icon_03.imageset/Contents.json
vendored
Normal file
22
Veloria/Source/Assets.xcassets/icon/close_icon_03.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Close.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Close@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
Veloria/Source/Assets.xcassets/icon/play_icon_02.imageset/Component 41@2x.png
vendored
Normal file
BIN
Veloria/Source/Assets.xcassets/icon/play_icon_02.imageset/Component 41@2x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
BIN
Veloria/Source/Assets.xcassets/icon/play_icon_02.imageset/Component 41@3x.png
vendored
Normal file
BIN
Veloria/Source/Assets.xcassets/icon/play_icon_02.imageset/Component 41@3x.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
22
Veloria/Source/Assets.xcassets/icon/play_icon_02.imageset/Contents.json
vendored
Normal file
22
Veloria/Source/Assets.xcassets/icon/play_icon_02.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Component 41@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Component 41@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
@ -93,6 +93,7 @@
|
||||
"veloria_quarter" = "1 quarter";
|
||||
"veloria_year" = "1 year";
|
||||
"veloria_days_count_text" = "## days";
|
||||
"veloria_last_play_episode" = "Last time Episode ##";
|
||||
|
||||
|
||||
"veloria_bonus_count_text" = "+## Bonus";
|
||||
|
Loading…
x
Reference in New Issue
Block a user