Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions KMReader.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
"CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "KMReader/KMReader-macOS.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 502;
CURRENT_PROJECT_VERSION = 503;
DEVELOPMENT_TEAM = M777UHWZA4;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -500,7 +500,7 @@
"CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = "KMReader/KMReader-macOS.entitlements";
CODE_SIGN_IDENTITY = "Apple Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 502;
CURRENT_PROJECT_VERSION = 503;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=appletvos*]" = M777UHWZA4;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = M777UHWZA4;
Expand Down Expand Up @@ -560,7 +560,7 @@
CODE_SIGN_ENTITLEMENTS = KMReaderWidgets/KMReaderWidgets.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 502;
CURRENT_PROJECT_VERSION = 503;
DEVELOPMENT_TEAM = M777UHWZA4;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = KMReaderWidgets/Info.plist;
Expand Down Expand Up @@ -594,7 +594,7 @@
CODE_SIGN_IDENTITY = "Apple Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 502;
CURRENT_PROJECT_VERSION = 503;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = M777UHWZA4;
GENERATE_INFOPLIST_FILE = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
enum ReaderLoadingProgress {
static let complete = 1.0

static func displayValue(for progress: Double) -> Double {
let normalized = min(max(progress, 0), 1)
guard normalized > 0, normalized < 1 else { return normalized }
Expand Down
8 changes: 4 additions & 4 deletions KMReader/Features/Reader/ViewModels/ReaderViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ class ReaderViewModel {
let status = await OfflineManager.shared.getDownloadStatus(bookId: book.id)
if case .downloaded = status {
if updatesLoadingState {
clearLoadingProgress()
updateLoadingProgress(ReaderLoadingProgress.complete)
updateLoadingDetail(String(localized: "Using downloaded book files"))
}
return
Expand All @@ -853,7 +853,7 @@ class ReaderViewModel {
info: downloadInfo
)
case .downloaded:
clearLoadingProgress()
updateLoadingProgress(ReaderLoadingProgress.complete)
updateLoadingDetail(String(localized: "Using downloaded book files"))
return
}
Expand All @@ -867,7 +867,7 @@ class ReaderViewModel {
switch currentStatus {
case .downloaded:
if updatesLoadingState {
clearLoadingProgress()
updateLoadingProgress(ReaderLoadingProgress.complete)
updateLoadingDetail(String(localized: "Using downloaded book files"))
}
return
Expand All @@ -882,7 +882,7 @@ class ReaderViewModel {
let progress = DownloadProgressTracker.shared.progress[book.id]
{
if progress >= 1 {
clearLoadingProgress()
updateLoadingProgress(ReaderLoadingProgress.complete)
let status = offlinePostDownloadStatus(for: downloadInfo.kind)
updateLoadingTitle(status.title)
updateLoadingDetail(status.detail)
Expand Down
16 changes: 11 additions & 5 deletions KMReader/Features/Reader/Views/Epub/EpubReaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -690,12 +690,18 @@
}

private var loadingProgress: Double? {
guard viewModel.loadingStage == .downloading else { return nil }
if let expectedBytes = viewModel.downloadBytesExpected, expectedBytes > 0 {
return viewModel.downloadProgress
}
switch viewModel.loadingStage {
case .downloading:
if let expectedBytes = viewModel.downloadBytesExpected, expectedBytes > 0 {
return viewModel.downloadProgress
}

return viewModel.downloadProgress > 0 ? viewModel.downloadProgress : nil
return viewModel.downloadProgress > 0 ? viewModel.downloadProgress : nil
case .finalizingOfflineDownload, .preparingOfflineResources, .preparingReader, .paginating:
return ReaderLoadingProgress.complete
case .fetchingMetadata, .idle:
return nil
}
}

private var loadingDetail: String {
Expand Down
16 changes: 11 additions & 5 deletions KMReader/Features/Reader/Views/Pdf/PdfReaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,18 @@
}

private var loadingProgress: Double? {
guard viewModel.loadingStage == .downloading else { return nil }
if let expectedBytes = viewModel.downloadBytesExpected, expectedBytes > 0 {
return viewModel.downloadProgress
}
switch viewModel.loadingStage {
case .downloading:
if let expectedBytes = viewModel.downloadBytesExpected, expectedBytes > 0 {
return viewModel.downloadProgress
}

return viewModel.downloadProgress > 0 ? viewModel.downloadProgress : nil
return viewModel.downloadProgress > 0 ? viewModel.downloadProgress : nil
case .finalizingOfflineDownload, .preparingReader:
return ReaderLoadingProgress.complete
case .fetchingMetadata, .idle:
return nil
}
}

private var loadingDetail: String {
Expand Down