happy birthdays sora (tomorrow 😭)

Also reader fixed
This commit is contained in:
cranci1 2025-07-13 17:08:02 +02:00
parent c722ec9b29
commit c1e3ee3ea3
11 changed files with 147 additions and 69 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

View file

@ -1,34 +1,24 @@
{ {
"images" : [ "images" : [
{ {
"filename" : "lightmode.png", "filename" : "6hdvom4xz8gc2sut.png",
"idiom" : "universal", "idiom" : "universal",
"platform" : "ios", "platform" : "ios",
"size" : "1024x1024" "size" : "1024x1024"
}, },
{ {
"appearances" : [ "filename" : "6hdvom4xz8gc2sut 1.png",
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "darkmode.png",
"idiom" : "universal", "idiom" : "universal",
"platform" : "ios", "platform" : "ios",
"size" : "1024x1024" "size" : "1024x1024",
"unassigned" : true
}, },
{ {
"appearances" : [ "filename" : "6hdvom4xz8gc2sut 2.png",
{
"appearance" : "luminosity",
"value" : "tinted"
}
],
"filename" : "tinting.png",
"idiom" : "universal", "idiom" : "universal",
"platform" : "ios", "platform" : "ios",
"size" : "1024x1024" "size" : "1024x1024",
"unassigned" : true
} }
], ],
"info" : { "info" : {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

View file

@ -5,13 +5,14 @@
// Created by paul on 26/06/25. // Created by paul on 26/06/25.
// //
import SwiftUI import UIKit
import NukeUI import NukeUI
import SwiftUI
struct AllReadingView: View { struct AllReadingView: View {
@Environment(\.dismiss) private var dismiss @Environment(\.dismiss) private var dismiss
@State private var continueReadingItems: [ContinueReadingItem] = [] @State private var continueReadingItems: [ContinueReadingItem] = []
@State private var isRefreshing: Bool = false @State private var isRefreshing: Bool = false
@State private var sortOption: SortOption = .dateAdded @State private var sortOption: SortOption = .dateAdded
@ -204,10 +205,10 @@ struct AllReadingView: View {
} else { } else {
ForEach(filteredAndSortedItems) { item in ForEach(filteredAndSortedItems) { item in
FullWidthContinueReadingCell( FullWidthContinueReadingCell(
item: item, item: item,
markAsRead: { markAsRead: {
markContinueReadingItemAsRead(item: item) markContinueReadingItemAsRead(item: item)
}, },
removeItem: { removeItem: {
removeContinueReadingItem(item: item) removeContinueReadingItem(item: item)
}, },
@ -335,18 +336,12 @@ struct FullWidthContinueReadingCell: View {
} }
} }
} else { } else {
NavigationLink(destination: ReaderView( Button(action: {
moduleId: item.moduleId, presentReaderView()
chapterHref: item.href, }) {
chapterTitle: item.chapterTitle,
mediaTitle: item.mediaTitle,
chapterNumber: item.chapterNumber
)) {
cellContent cellContent
} }
.simultaneousGesture(TapGesture().onEnded { .buttonStyle(PlainButtonStyle())
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
})
} }
} }
.contextMenu { .contextMenu {
@ -445,4 +440,38 @@ struct FullWidthContinueReadingCell: View {
} }
.frame(height: 157.03) .frame(height: 157.03)
} }
}
private func presentReaderView() {
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootVC = windowScene.windows.first?.rootViewController {
let topVC = findTopViewController.findViewController(rootVC)
if topVC is UIHostingController<ReaderView> {
Logger.shared.log("ReaderView is already presented, skipping presentation", type: "Debug")
return
}
}
let readerView = ReaderView(
moduleId: item.moduleId,
chapterHref: item.href,
chapterTitle: item.chapterTitle,
chapters: [],
mediaTitle: item.mediaTitle,
chapterNumber: item.chapterNumber
)
let hostingController = UIHostingController(rootView: readerView)
hostingController.modalPresentationStyle = .overFullScreen
hostingController.modalTransitionStyle = .crossDissolve
hostingController.isModalInPresentation = true
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootVC = windowScene.windows.first?.rootViewController {
findTopViewController.findViewController(rootVC).present(hostingController, animated: true)
}
}
}

View file

@ -5,8 +5,9 @@
// Created by paul on 26/06/25. // Created by paul on 26/06/25.
// //
import SwiftUI import UIKit
import NukeUI import NukeUI
import SwiftUI
struct ContinueReadingSection: View { struct ContinueReadingSection: View {
@Binding var items: [ContinueReadingItem] @Binding var items: [ContinueReadingItem]
@ -67,14 +68,9 @@ struct ContinueReadingCell: View {
} }
var body: some View { var body: some View {
NavigationLink(destination: ReaderView( Button(action: {
moduleId: item.moduleId, presentReaderView()
chapterHref: item.href, }) {
chapterTitle: item.chapterTitle,
chapters: [],
mediaTitle: item.mediaTitle,
chapterNumber: item.chapterNumber
)) {
ZStack { ZStack {
LazyImage(url: imageURL) { state in LazyImage(url: imageURL) { state in
if let image = state.imageContainer?.image { if let image = state.imageContainer?.image {
@ -178,4 +174,38 @@ struct ContinueReadingCell: View {
print("Progress: \(item.progress)") print("Progress: \(item.progress)")
} }
} }
private func presentReaderView() {
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootVC = windowScene.windows.first?.rootViewController {
let topVC = findTopViewController.findViewController(rootVC)
if topVC is UIHostingController<ReaderView> {
Logger.shared.log("ReaderView is already presented, skipping presentation", type: "Debug")
return
}
}
let readerView = ReaderView(
moduleId: item.moduleId,
chapterHref: item.href,
chapterTitle: item.chapterTitle,
chapters: [],
mediaTitle: item.mediaTitle,
chapterNumber: item.chapterNumber
)
let hostingController = UIHostingController(rootView: readerView)
hostingController.modalPresentationStyle = .overFullScreen
hostingController.modalTransitionStyle = .crossDissolve
hostingController.isModalInPresentation = true
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootVC = windowScene.windows.first?.rootViewController {
findTopViewController.findViewController(rootVC).present(hostingController, animated: true)
}
}
} }

View file

@ -728,8 +728,8 @@ struct MediaInfoView: View {
if let href = chapter["href"] as? String, if let href = chapter["href"] as? String,
let number = chapter["number"] as? Int, let number = chapter["number"] as? Int,
let title = chapter["title"] as? String { let title = chapter["title"] as? String {
NavigationLink( Button(action: {
destination: ReaderView( presentReaderView(
moduleId: module.id, moduleId: module.id,
chapterHref: href, chapterHref: href,
chapterTitle: title, chapterTitle: title,
@ -737,12 +737,7 @@ struct MediaInfoView: View {
mediaTitle: self.title, mediaTitle: self.title,
chapterNumber: number chapterNumber: number
) )
.onAppear { }) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
ChapterNavigator.shared.currentChapter = nil
}
}
) {
ChapterCell( ChapterCell(
chapterNumber: String(number), chapterNumber: String(number),
chapterTitle: title, chapterTitle: title,
@ -751,17 +746,7 @@ struct MediaInfoView: View {
href: href href: href
) )
} }
.simultaneousGesture(TapGesture().onEnded { .buttonStyle(PlainButtonStyle())
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
ChapterNavigator.shared.currentChapter = (
moduleId: module.id,
href: href,
title: title,
chapters: chapters,
mediaTitle: self.title,
chapterNumber: number
)
})
.contextMenu { .contextMenu {
Button(action: { Button(action: {
markChapterAsRead(href: href, number: number) markChapterAsRead(href: href, number: number)
@ -1295,10 +1280,10 @@ struct MediaInfoView: View {
let number = chapterToRead["number"] as? Int { let number = chapterToRead["number"] as? Int {
UserDefaults.standard.set(true, forKey: "navigatingToReaderView") UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
ChapterNavigator.shared.currentChapter = ( presentReaderView(
moduleId: module.id, moduleId: module.id,
href: href, chapterHref: href,
title: title, chapterTitle: title,
chapters: chapters, chapters: chapters,
mediaTitle: self.title, mediaTitle: self.title,
chapterNumber: number chapterNumber: number
@ -1438,6 +1423,40 @@ struct MediaInfoView: View {
} }
private func presentReaderView(moduleId: UUID, chapterHref: String, chapterTitle: String, chapters: [[String: Any]], mediaTitle: String, chapterNumber: Int) {
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootVC = windowScene.windows.first?.rootViewController {
let topVC = findTopViewController.findViewController(rootVC)
if topVC is UIHostingController<ReaderView> {
Logger.shared.log("ReaderView is already presented, skipping presentation", type: "Debug")
return
}
}
let readerView = ReaderView(
moduleId: moduleId,
chapterHref: chapterHref,
chapterTitle: chapterTitle,
chapters: chapters,
mediaTitle: mediaTitle,
chapterNumber: chapterNumber
)
let hostingController = UIHostingController(rootView: readerView)
hostingController.modalPresentationStyle = .overFullScreen
hostingController.modalTransitionStyle = .crossDissolve
hostingController.isModalInPresentation = true
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootVC = windowScene.windows.first?.rootViewController {
findTopViewController.findViewController(rootVC).present(hostingController, animated: true)
}
}
private func openSafariViewController(with urlString: String) { private func openSafariViewController(with urlString: String) {
guard let url = URL(string: urlString), UIApplication.shared.canOpenURL(url) else { guard let url = URL(string: urlString), UIApplication.shared.canOpenURL(url) else {
Logger.shared.log("Unable to open the webpage", type: "Error") Logger.shared.log("Unable to open the webpage", type: "Error")

View file

@ -123,8 +123,6 @@ struct ReaderView: View {
} }
} }
var body: some View { var body: some View {
ZStack(alignment: .bottom) { ZStack(alignment: .bottom) {
currentTheme.background.ignoresSafeArea() currentTheme.background.ignoresSafeArea()
@ -267,10 +265,10 @@ struct ReaderView: View {
chapterNumber: next.chapterNumber chapterNumber: next.chapterNumber
) )
let hostingController = UIHostingController(rootView: nextReader) let hostingController = UIHostingController(rootView: nextReader)
hostingController.modalPresentationStyle = .fullScreen hostingController.modalPresentationStyle = .overFullScreen
hostingController.modalTransitionStyle = .crossDissolve hostingController.modalTransitionStyle = .crossDissolve
hostingController.isModalInPresentation = true
findTopViewController.findViewController(rootVC).present(hostingController, animated: true) findTopViewController.findViewController(rootVC).present(hostingController, animated: true)
} }
@ -430,7 +428,7 @@ struct ReaderView: View {
ZStack(alignment: .top) { ZStack(alignment: .top) {
HStack { HStack {
Button(action: { Button(action: {
dismiss() dismissReaderView()
}) { }) {
Image(systemName: "chevron.left") Image(systemName: "chevron.left")
.font(.system(size: 16, weight: .bold)) .font(.system(size: 16, weight: .bold))
@ -794,6 +792,18 @@ struct ReaderView: View {
.circularGradientOutline() .circularGradientOutline()
} }
private func dismissReaderView() {
dismiss()
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootVC = windowScene.windows.first?.rootViewController {
let topVC = findTopViewController.findViewController(rootVC)
if topVC is UIHostingController<ReaderView> {
topVC.dismiss(animated: true)
}
}
}
private func goToNextChapter() { private func goToNextChapter() {
guard let currentIndex = chapters.firstIndex(where: { $0["href"] as? String == chapterHref }), guard let currentIndex = chapters.firstIndex(where: { $0["href"] as? String == chapterHref }),
currentIndex + 1 < chapters.count else { currentIndex + 1 < chapters.count else {