首页bug修改

This commit is contained in:
澜声世纪 2025-12-25 10:14:38 +08:00
parent 5fdccdad66
commit f9f5b83e20
9 changed files with 206 additions and 125 deletions

View File

@ -89,6 +89,7 @@
85606A9F2EEBE95A005D989D /* NRDashedLineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85606A9E2EEBE95A005D989D /* NRDashedLineView.swift */; };
85859E5C2EF3FC5F0020D282 /* NotificationService.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 85859E552EF3FC5F0020D282 /* NotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
85859E662EF3FC6E0020D282 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85859E632EF3FC6E0020D282 /* NotificationService.swift */; };
85859E682EFCD1D80020D282 /* NRHomeMustReadTodayTransformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85859E672EFCD1D80020D282 /* NRHomeMustReadTodayTransformer.swift */; };
85CF941D2EEBFEA6006467E3 /* NRCoinsPackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85CF941C2EEBFEA6006467E3 /* NRCoinsPackModel.swift */; };
85CF941F2EEBFECF006467E3 /* NRCoinsPackReceiveModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85CF941E2EEBFECF006467E3 /* NRCoinsPackReceiveModel.swift */; };
85CF94212EEC050D006467E3 /* NRCoinsPackBuyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85CF94202EEC050D006467E3 /* NRCoinsPackBuyView.swift */; };
@ -588,6 +589,7 @@
85859E552EF3FC5F0020D282 /* NotificationService.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationService.appex; sourceTree = BUILT_PRODUCTS_DIR; };
85859E622EF3FC6E0020D282 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
85859E632EF3FC6E0020D282 /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
85859E672EFCD1D80020D282 /* NRHomeMustReadTodayTransformer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NRHomeMustReadTodayTransformer.swift; sourceTree = "<group>"; };
85CF941C2EEBFEA6006467E3 /* NRCoinsPackModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NRCoinsPackModel.swift; sourceTree = "<group>"; };
85CF941E2EEBFECF006467E3 /* NRCoinsPackReceiveModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NRCoinsPackReceiveModel.swift; sourceTree = "<group>"; };
85CF94202EEC050D006467E3 /* NRCoinsPackBuyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NRCoinsPackBuyView.swift; sourceTree = "<group>"; };
@ -1359,6 +1361,7 @@
0398109E2ED069890006E317 /* M */ = {
isa = PBXGroup;
children = (
85859E672EFCD1D80020D282 /* NRHomeMustReadTodayTransformer.swift */,
039810BB2ED43C8E0006E317 /* NRReadWhatViewTransformer.swift */,
F34990B82EDEB1620039E939 /* NRHomeNovelModuleItem.swift */,
);
@ -2529,6 +2532,7 @@
85CF94472EF001AD006467E3 /* NRMyUnlocksViewController.swift in Sources */,
F3B8596B2EE91C9F0095A9CC /* NRStoreCoinsCell.swift in Sources */,
F3B859712EE94A1B0095A9CC /* NRFeedbackViewController.swift in Sources */,
85859E682EFCD1D80020D282 /* NRHomeMustReadTodayTransformer.swift in Sources */,
85CF94392EEFE35A006467E3 /* NRLoginManager+Facebook.swift in Sources */,
F34348C72ED6CCBC00AA7E70 /* NRExploreNovelContentListViewController.swift in Sources */,
039810B82ED431780006E317 /* NRHomeNovelReadWhatView.swift in Sources */,

View File

@ -5,8 +5,8 @@
// Created by on 2025/11/26.
//
import UIKit
import SnapKit
import UIKit
class NRExploreNovelContentListViewController: NRViewController {
@ -17,9 +17,13 @@ class NRExploreNovelContentListViewController: NRViewController {
lazy var dataArr: [NRNovelModel] = []
lazy var collectionViewLayout: UICollectionViewCompositionalLayout = {
let item = NSCollectionLayoutItem(layoutSize: .init(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1)))
let item = NSCollectionLayoutItem(
layoutSize: .init(
widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1)))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: .init(widthDimension: .fractionalWidth(1), heightDimension: .absolute(60)), subitems: [item])
let group = NSCollectionLayoutGroup.horizontal(
layoutSize: .init(widthDimension: .fractionalWidth(1), heightDimension: .absolute(60)),
subitems: [item])
let section = NSCollectionLayoutSection(group: group)
section.interGroupSpacing = 8
@ -27,17 +31,20 @@ class NRExploreNovelContentListViewController: NRViewController {
let configuration = UICollectionViewCompositionalLayoutConfiguration()
let layout = UICollectionViewCompositionalLayout(section: section, configuration: configuration)
let layout = UICollectionViewCompositionalLayout(
section: section, configuration: configuration)
return layout
}()
lazy var collectionView: NRCollectionView = {
let collectionView = NRCollectionView(frame: .zero, collectionViewLayout: collectionViewLayout)
let collectionView = NRCollectionView(
frame: .zero, collectionViewLayout: collectionViewLayout)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.contentInset = .init(top: 0, left: 0, bottom: 10, right: 0)
collectionView.register(NRExploreNovelContentListCell.self, forCellWithReuseIdentifier: "cell")
collectionView.register(
NRExploreNovelContentListCell.self, forCellWithReuseIdentifier: "cell")
return collectionView
}()
@ -50,7 +57,9 @@ class NRExploreNovelContentListViewController: NRViewController {
self.backgroundImageView.isHidden = true
self.view.backgroundColor = .clear
NotificationCenter.default.addObserver(self, selector: #selector(networkStatusDidChangeNotification), name: NRNetworkReachableManager.networkStatusDidChangeNotification, object: nil)
NotificationCenter.default.addObserver(
self, selector: #selector(networkStatusDidChangeNotification),
name: NRNetworkReachableManager.networkStatusDidChangeNotification, object: nil)
nr_setupUI()
@ -59,9 +68,10 @@ class NRExploreNovelContentListViewController: NRViewController {
}
}
@objc private func networkStatusDidChangeNotification() {
guard NRNetworkReachableManager.manager.isReachable == true, self.dataArr.isEmpty else { return }
guard NRNetworkReachableManager.manager.isReachable == true, self.dataArr.isEmpty else {
return
}
Task {
await requestDataArr()
}
@ -83,17 +93,25 @@ extension NRExploreNovelContentListViewController {
}
//MARK: UICollectionViewDelegate UICollectionViewDataSource
extension NRExploreNovelContentListViewController: UICollectionViewDelegate, UICollectionViewDataSource {
extension NRExploreNovelContentListViewController: UICollectionViewDelegate,
UICollectionViewDataSource
{
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! NRExploreNovelContentListCell
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath)
-> UICollectionViewCell
{
let cell =
collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
as! NRExploreNovelContentListCell
cell.menuItem = self.menuItem
cell.row = indexPath.row
cell.model = dataArr[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int)
-> Int
{
return dataArr.count
}
@ -110,7 +128,10 @@ extension NRExploreNovelContentListViewController {
private func requestDataArr() async {
guard let type = self.menuItem?.type else { return }
guard let list = await NRHomeAPI.requestRankingCollection(type: type.rawValue, days: self.contentType.rawValue) else { return }
guard
let list = await NRHomeAPI.requestRankingCollection(
type: type.rawValue, days: self.contentType.rawValue)
else { return }
self.dataArr = list

View File

@ -0,0 +1,47 @@
//
// NRHomeMustReadTodayTransformer.swift
// ReaderHive
//
// Created by on 2025/11/24.
//
import FSPagerView
import UIKit
class NRHomeMustReadTodayTransformer: FSPagerViewTransformer {
nonisolated override init(type: FSPagerViewTransformerType) {
super.init(type: type)
}
nonisolated override func applyTransform(to attributes: FSPagerViewLayoutAttributes) {
MainActor.assumeIsolated {
guard let pagerView = self.pagerView else { return }
let itemWidth = pagerView.itemSize.width
let pagerWidth = pagerView.frame.width
// 16
let leftMargin: CGFloat = 16
// FSPagerView item
// item pagerView.width / 2
// item 16 (16 + itemWidth / 2)
let targetCenter = leftMargin + itemWidth / 2
let currentCenter = pagerWidth / 2
let offset = currentCenter - targetCenter
// item offset
attributes.transform = CGAffineTransform(translationX: -offset, y: 0)
}
}
nonisolated override func proposedInteritemSpacing() -> CGFloat {
guard let pagerView = self.pagerView else {
return 0
}
return MainActor.assumeIsolated {
return pagerView.interitemSpacing
}
}
}

View File

@ -5,10 +5,11 @@
// Created by on 2025/11/24.
//
import UIKit
import FSPagerView
import SnapKit
import UIKit
class NRHomeNovelMustReadTodayCell: UICollectionViewCell {
class NRHomeNovelMustReadTodayCell: FSPagerViewCell {
var model: NRNovelModel? {
didSet {
@ -72,7 +73,9 @@ class NRHomeNovelMustReadTodayCell: UICollectionViewCell {
lazy var readNowBgView: UIView = {
let view = NRGradientView()
view.colors = [UIColor.F_3912_F.cgColor, UIColor.FF_4_A_4_A.cgColor, UIColor.FA_9_B_1_F.cgColor]
view.colors = [
UIColor.F_3912_F.cgColor, UIColor.FF_4_A_4_A.cgColor, UIColor.FA_9_B_1_F.cgColor,
]
view.startPoint = .init(x: 0, y: 0.5)
view.endPoint = .init(x: 1, y: 0.5)
view.layer.cornerRadius = 8

View File

@ -5,36 +5,36 @@
// Created by on 2025/11/24.
//
import UIKit
import FSPagerView
import SnapKit
import UIKit
import YYCategories
class NRHomeNovelMustReadTodayView: NRHomeNovelHeaderContentView {
var dataArr: [NRNovelModel] = [] {
didSet {
self.collectionView.reloadData()
self.pagerView.reloadData()
}
}
lazy var collectionViewLayout: UICollectionViewFlowLayout = {
let layout = UICollectionViewFlowLayout()
layout.scrollDirection = .horizontal
layout.itemSize = .init(width: 316, height: 174)
layout.minimumLineSpacing = 16
return layout
}()
lazy var collectionView: NRCollectionView = {
let collectionView = NRCollectionView(frame: .zero, collectionViewLayout: collectionViewLayout)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.showsHorizontalScrollIndicator = false
collectionView.contentInset = .init(top: 0, left: 16, bottom: 0, right: 16)
collectionView.register(NRHomeNovelMustReadTodayCell.self, forCellWithReuseIdentifier: "cell")
return collectionView
lazy var pagerView: FSPagerView = {
let pagerView = FSPagerView()
pagerView.delegate = self
pagerView.dataSource = self
//
pagerView.isInfinite = true
//
pagerView.automaticSlidingInterval = 5.0
// item
pagerView.interitemSpacing = 16
// item
pagerView.itemSize = CGSize(width: 316, height: 174)
// Transformer
pagerView.transformer = NRHomeMustReadTodayTransformer(type: .linear)
// Cell
pagerView.register(NRHomeNovelMustReadTodayCell.self, forCellWithReuseIdentifier: "cell")
return pagerView
}()
override init(frame: CGRect) {
@ -53,34 +53,40 @@ class NRHomeNovelMustReadTodayView: NRHomeNovelHeaderContentView {
extension NRHomeNovelMustReadTodayView {
private func nr_setupUI() {
contentView.addSubview(collectionView)
contentView.addSubview(pagerView)
collectionView.snp.makeConstraints { make in
pagerView.snp.makeConstraints { make in
make.left.right.top.equalToSuperview()
make.bottom.equalToSuperview()
make.height.equalTo(self.collectionViewLayout.itemSize.height)
make.height.equalTo(174)
}
}
}
//MARK: UICollectionViewDelegate UICollectionViewDataSource
extension NRHomeNovelMustReadTodayView: UICollectionViewDelegate, UICollectionViewDataSource {
// MARK: - FSPagerViewDataSource, FSPagerViewDelegate
extension NRHomeNovelMustReadTodayView: FSPagerViewDataSource, FSPagerViewDelegate {
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! NRHomeNovelMustReadTodayCell
cell.model = self.dataArr[indexPath.row]
return cell
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
func numberOfItems(in pagerView: FSPagerView) -> Int {
return self.dataArr.count
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
func pagerView(_ pagerView: FSPagerView, cellForItemAt index: Int) -> FSPagerViewCell {
let cell =
pagerView.dequeueReusableCell(withReuseIdentifier: "cell", at: index)
as! NRHomeNovelMustReadTodayCell
cell.model = self.dataArr[index]
return cell
}
func pagerView(_ pagerView: FSPagerView, didSelectItemAt index: Int) {
pagerView.deselectItem(at: index, animated: true)
let vc = NRNovelDetailViewController()
vc.novelId = dataArr[indexPath.row].id ?? ""
vc.novelId = dataArr[index].id ?? ""
self.viewController?.navigationController?.pushViewController(vc, animated: true)
}
// UICollectionViewContentInset FSPagerView itemSize transformer
// transform
}

View File

@ -33,7 +33,7 @@ class NRReadChapterCatalogModel: NSObject, SmartCodable {
func parserEmpty() {
let chapterModel = NRReadChapterModel()
if self.is_lock == true {
chapterModel.parserEmpty("Not unlocked yet".localized)
chapterModel.parserEmpty("Chapter Locked".localized)
} else {
chapterModel.parserEmpty("Loading".localized)
}

View File

@ -73,7 +73,7 @@ class NRReadChapterModel: NSObject, SmartCodable {
///
func parserEmpty(_ text: String) {
fullContent = NSMutableAttributedString(string: "\n\n\n\n\n" + text, attributes: NRNovelReadSetManager.manager.attributes(isTitle: true))
fullContent = NSMutableAttributedString(string: "\n\n\n\n\n" + text, attributes: NRNovelReadSetManager.manager.attributes(isTitle: false))
let pageModel = NRReadPageModel()
pageModel.content = fullContent

View File

@ -201,10 +201,10 @@ extension NRNovelReadViewModel {
self.vc?.loadData()
}
view.didDismissHandle = { [weak self] in
guard let self = self else { return }
self.showVipRetainAlert(catalogModel)
}
// view.didDismissHandle = { [weak self] in
// guard let self = self else { return }
// self.showVipRetainAlert(catalogModel)
// }
view.present(in: nil)
self.popView = view

View File

@ -76,7 +76,7 @@
"alert_title_01" = "Recommend this book?";
"alert_detail_01" = "Help us share this story with others.";
"Yes, Recommend" = "Yes, Recommend";
"Not unlocked yet" = "Not unlocked yet";
"Chapter Locked" = "Chapter Locked";
"No data" = "No data";
"Coins" = "Coins";
"Bonus" = "Bonus";