Skip to content

Commit c1e3ee3

Browse files
committed
happy birthdays sora (tomorrow 😭)
Also reader fixed
1 parent c722ec9 commit c1e3ee3

File tree

11 files changed

+147
-69
lines changed

11 files changed

+147
-69
lines changed
161 KB
Loading
161 KB
Loading
161 KB
Loading

Sora/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,24 @@
11
{
22
"images" : [
33
{
4-
"filename" : "lightmode.png",
4+
"filename" : "6hdvom4xz8gc2sut.png",
55
"idiom" : "universal",
66
"platform" : "ios",
77
"size" : "1024x1024"
88
},
99
{
10-
"appearances" : [
11-
{
12-
"appearance" : "luminosity",
13-
"value" : "dark"
14-
}
15-
],
16-
"filename" : "darkmode.png",
10+
"filename" : "6hdvom4xz8gc2sut 1.png",
1711
"idiom" : "universal",
1812
"platform" : "ios",
19-
"size" : "1024x1024"
13+
"size" : "1024x1024",
14+
"unassigned" : true
2015
},
2116
{
22-
"appearances" : [
23-
{
24-
"appearance" : "luminosity",
25-
"value" : "tinted"
26-
}
27-
],
28-
"filename" : "tinting.png",
17+
"filename" : "6hdvom4xz8gc2sut 2.png",
2918
"idiom" : "universal",
3019
"platform" : "ios",
31-
"size" : "1024x1024"
20+
"size" : "1024x1024",
21+
"unassigned" : true
3222
}
3323
],
3424
"info" : {
-88 KB
Binary file not shown.
-88.5 KB
Binary file not shown.
-77.2 KB
Binary file not shown.

Sora/Views/LibraryView/AllReading.swift

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
// Created by paul on 26/06/25.
66
//
77

8-
import SwiftUI
8+
import UIKit
99
import NukeUI
10+
import SwiftUI
1011

1112
struct AllReadingView: View {
1213
@Environment(\.dismiss) private var dismiss
13-
14-
14+
15+
1516
@State private var continueReadingItems: [ContinueReadingItem] = []
1617
@State private var isRefreshing: Bool = false
1718
@State private var sortOption: SortOption = .dateAdded
@@ -204,10 +205,10 @@ struct AllReadingView: View {
204205
} else {
205206
ForEach(filteredAndSortedItems) { item in
206207
FullWidthContinueReadingCell(
207-
item: item,
208+
item: item,
208209
markAsRead: {
209210
markContinueReadingItemAsRead(item: item)
210-
},
211+
},
211212
removeItem: {
212213
removeContinueReadingItem(item: item)
213214
},
@@ -335,18 +336,12 @@ struct FullWidthContinueReadingCell: View {
335336
}
336337
}
337338
} else {
338-
NavigationLink(destination: ReaderView(
339-
moduleId: item.moduleId,
340-
chapterHref: item.href,
341-
chapterTitle: item.chapterTitle,
342-
mediaTitle: item.mediaTitle,
343-
chapterNumber: item.chapterNumber
344-
)) {
339+
Button(action: {
340+
presentReaderView()
341+
}) {
345342
cellContent
346343
}
347-
.simultaneousGesture(TapGesture().onEnded {
348-
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
349-
})
344+
.buttonStyle(PlainButtonStyle())
350345
}
351346
}
352347
.contextMenu {
@@ -445,4 +440,38 @@ struct FullWidthContinueReadingCell: View {
445440
}
446441
.frame(height: 157.03)
447442
}
448-
}
443+
444+
private func presentReaderView() {
445+
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
446+
447+
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
448+
let rootVC = windowScene.windows.first?.rootViewController {
449+
let topVC = findTopViewController.findViewController(rootVC)
450+
451+
if topVC is UIHostingController<ReaderView> {
452+
Logger.shared.log("ReaderView is already presented, skipping presentation", type: "Debug")
453+
return
454+
}
455+
}
456+
457+
let readerView = ReaderView(
458+
moduleId: item.moduleId,
459+
chapterHref: item.href,
460+
chapterTitle: item.chapterTitle,
461+
chapters: [],
462+
mediaTitle: item.mediaTitle,
463+
chapterNumber: item.chapterNumber
464+
)
465+
466+
let hostingController = UIHostingController(rootView: readerView)
467+
hostingController.modalPresentationStyle = .overFullScreen
468+
hostingController.modalTransitionStyle = .crossDissolve
469+
470+
hostingController.isModalInPresentation = true
471+
472+
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
473+
let rootVC = windowScene.windows.first?.rootViewController {
474+
findTopViewController.findViewController(rootVC).present(hostingController, animated: true)
475+
}
476+
}
477+
}

Sora/Views/LibraryView/ContinueReadingSection.swift

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// Created by paul on 26/06/25.
66
//
77

8-
import SwiftUI
8+
import UIKit
99
import NukeUI
10+
import SwiftUI
1011

1112
struct ContinueReadingSection: View {
1213
@Binding var items: [ContinueReadingItem]
@@ -67,14 +68,9 @@ struct ContinueReadingCell: View {
6768
}
6869

6970
var body: some View {
70-
NavigationLink(destination: ReaderView(
71-
moduleId: item.moduleId,
72-
chapterHref: item.href,
73-
chapterTitle: item.chapterTitle,
74-
chapters: [],
75-
mediaTitle: item.mediaTitle,
76-
chapterNumber: item.chapterNumber
77-
)) {
71+
Button(action: {
72+
presentReaderView()
73+
}) {
7874
ZStack {
7975
LazyImage(url: imageURL) { state in
8076
if let image = state.imageContainer?.image {
@@ -178,4 +174,38 @@ struct ContinueReadingCell: View {
178174
print("Progress: \(item.progress)")
179175
}
180176
}
177+
178+
private func presentReaderView() {
179+
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
180+
181+
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
182+
let rootVC = windowScene.windows.first?.rootViewController {
183+
let topVC = findTopViewController.findViewController(rootVC)
184+
185+
if topVC is UIHostingController<ReaderView> {
186+
Logger.shared.log("ReaderView is already presented, skipping presentation", type: "Debug")
187+
return
188+
}
189+
}
190+
191+
let readerView = ReaderView(
192+
moduleId: item.moduleId,
193+
chapterHref: item.href,
194+
chapterTitle: item.chapterTitle,
195+
chapters: [],
196+
mediaTitle: item.mediaTitle,
197+
chapterNumber: item.chapterNumber
198+
)
199+
200+
let hostingController = UIHostingController(rootView: readerView)
201+
hostingController.modalPresentationStyle = .overFullScreen
202+
hostingController.modalTransitionStyle = .crossDissolve
203+
204+
hostingController.isModalInPresentation = true
205+
206+
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
207+
let rootVC = windowScene.windows.first?.rootViewController {
208+
findTopViewController.findViewController(rootVC).present(hostingController, animated: true)
209+
}
210+
}
181211
}

Sora/Views/MediaInfoView/MediaInfoView.swift

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -728,21 +728,16 @@ struct MediaInfoView: View {
728728
if let href = chapter["href"] as? String,
729729
let number = chapter["number"] as? Int,
730730
let title = chapter["title"] as? String {
731-
NavigationLink(
732-
destination: ReaderView(
731+
Button(action: {
732+
presentReaderView(
733733
moduleId: module.id,
734734
chapterHref: href,
735735
chapterTitle: title,
736736
chapters: chapters,
737737
mediaTitle: self.title,
738738
chapterNumber: number
739739
)
740-
.onAppear {
741-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
742-
ChapterNavigator.shared.currentChapter = nil
743-
}
744-
}
745-
) {
740+
}) {
746741
ChapterCell(
747742
chapterNumber: String(number),
748743
chapterTitle: title,
@@ -751,17 +746,7 @@ struct MediaInfoView: View {
751746
href: href
752747
)
753748
}
754-
.simultaneousGesture(TapGesture().onEnded {
755-
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
756-
ChapterNavigator.shared.currentChapter = (
757-
moduleId: module.id,
758-
href: href,
759-
title: title,
760-
chapters: chapters,
761-
mediaTitle: self.title,
762-
chapterNumber: number
763-
)
764-
})
749+
.buttonStyle(PlainButtonStyle())
765750
.contextMenu {
766751
Button(action: {
767752
markChapterAsRead(href: href, number: number)
@@ -1295,10 +1280,10 @@ struct MediaInfoView: View {
12951280
let number = chapterToRead["number"] as? Int {
12961281

12971282
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
1298-
ChapterNavigator.shared.currentChapter = (
1283+
presentReaderView(
12991284
moduleId: module.id,
1300-
href: href,
1301-
title: title,
1285+
chapterHref: href,
1286+
chapterTitle: title,
13021287
chapters: chapters,
13031288
mediaTitle: self.title,
13041289
chapterNumber: number
@@ -1438,6 +1423,40 @@ struct MediaInfoView: View {
14381423
}
14391424

14401425

1426+
private func presentReaderView(moduleId: UUID, chapterHref: String, chapterTitle: String, chapters: [[String: Any]], mediaTitle: String, chapterNumber: Int) {
1427+
UserDefaults.standard.set(true, forKey: "navigatingToReaderView")
1428+
1429+
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
1430+
let rootVC = windowScene.windows.first?.rootViewController {
1431+
let topVC = findTopViewController.findViewController(rootVC)
1432+
1433+
if topVC is UIHostingController<ReaderView> {
1434+
Logger.shared.log("ReaderView is already presented, skipping presentation", type: "Debug")
1435+
return
1436+
}
1437+
}
1438+
1439+
let readerView = ReaderView(
1440+
moduleId: moduleId,
1441+
chapterHref: chapterHref,
1442+
chapterTitle: chapterTitle,
1443+
chapters: chapters,
1444+
mediaTitle: mediaTitle,
1445+
chapterNumber: chapterNumber
1446+
)
1447+
1448+
let hostingController = UIHostingController(rootView: readerView)
1449+
hostingController.modalPresentationStyle = .overFullScreen
1450+
hostingController.modalTransitionStyle = .crossDissolve
1451+
1452+
hostingController.isModalInPresentation = true
1453+
1454+
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
1455+
let rootVC = windowScene.windows.first?.rootViewController {
1456+
findTopViewController.findViewController(rootVC).present(hostingController, animated: true)
1457+
}
1458+
}
1459+
14411460
private func openSafariViewController(with urlString: String) {
14421461
guard let url = URL(string: urlString), UIApplication.shared.canOpenURL(url) else {
14431462
Logger.shared.log("Unable to open the webpage", type: "Error")

0 commit comments

Comments
 (0)