mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
parent
491b7175b5
commit
42fb670abb
4 changed files with 21 additions and 68 deletions
|
|
@ -41,7 +41,6 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
var currentTimeVal: Double = 0.0
|
||||
var duration: Double = 0.0
|
||||
var isVideoLoaded = false
|
||||
var detachedWindow: UIWindow?
|
||||
|
||||
private var isHoldPauseEnabled: Bool {
|
||||
UserDefaults.standard.bool(forKey: "holdForPauseEnabled")
|
||||
|
|
@ -1828,15 +1827,16 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
}
|
||||
|
||||
@objc func dismissTapped() {
|
||||
dismiss(animated: true) { [weak self] in
|
||||
self?.detachedWindow = nil
|
||||
if let presentingViewController = self.presentingViewController {
|
||||
presentingViewController.dismiss(animated: true, completion: nil)
|
||||
} else {
|
||||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func watchNextTapped() {
|
||||
player.pause()
|
||||
dismiss(animated: true) { [weak self] in
|
||||
self?.detachedWindow = nil
|
||||
self?.onWatchNext()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ class VideoPlayerViewController: UIViewController {
|
|||
var episodeNumber: Int = 0
|
||||
var episodeImageUrl: String = ""
|
||||
var mediaTitle: String = ""
|
||||
var detachedWindow: UIWindow?
|
||||
|
||||
init(module: ScrapingModule) {
|
||||
self.module = module
|
||||
|
|
|
|||
|
|
@ -1370,7 +1370,11 @@ struct MediaInfoView: View {
|
|||
videoPlayerViewController.aniListID = itemID ?? 0
|
||||
videoPlayerViewController.modalPresentationStyle = .overFullScreen
|
||||
|
||||
presentPlayerWithDetachedContext(videoPlayerViewController: videoPlayerViewController)
|
||||
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
||||
let window = windowScene.windows.first,
|
||||
let currentVC = window.rootViewController?.presentedViewController ?? window.rootViewController {
|
||||
currentVC.present(videoPlayerViewController, animated: true, completion: nil)
|
||||
}
|
||||
return
|
||||
default:
|
||||
break
|
||||
|
|
@ -1408,7 +1412,11 @@ struct MediaInfoView: View {
|
|||
customMediaPlayer.modalPresentationStyle = .overFullScreen
|
||||
Logger.shared.log("Opening custom media player with stream URL: \(url), and subtitles URL: \(String(describing: subtitles))", type: "Stream")
|
||||
|
||||
presentPlayerWithDetachedContext(customMediaPlayer: customMediaPlayer)
|
||||
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
||||
let window = windowScene.windows.first,
|
||||
let currentVC = window.rootViewController?.presentedViewController ?? window.rootViewController {
|
||||
currentVC.present(customMediaPlayer, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1991,34 +1999,4 @@ struct MediaInfoView: View {
|
|||
}
|
||||
}.resume()
|
||||
}
|
||||
|
||||
private func presentPlayerWithDetachedContext(videoPlayerViewController: VideoPlayerViewController) {
|
||||
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else { return }
|
||||
|
||||
let detachedWindow = UIWindow(windowScene: windowScene)
|
||||
let hostingController = UIViewController()
|
||||
hostingController.view.backgroundColor = .clear
|
||||
detachedWindow.rootViewController = hostingController
|
||||
detachedWindow.backgroundColor = .clear
|
||||
detachedWindow.windowLevel = .normal + 1
|
||||
detachedWindow.makeKeyAndVisible()
|
||||
|
||||
videoPlayerViewController.detachedWindow = detachedWindow
|
||||
hostingController.present(videoPlayerViewController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
private func presentPlayerWithDetachedContext(customMediaPlayer: CustomMediaPlayerViewController) {
|
||||
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else { return }
|
||||
|
||||
let detachedWindow = UIWindow(windowScene: windowScene)
|
||||
let hostingController = UIViewController()
|
||||
hostingController.view.backgroundColor = .clear
|
||||
detachedWindow.rootViewController = hostingController
|
||||
detachedWindow.backgroundColor = .clear
|
||||
detachedWindow.windowLevel = .normal + 1
|
||||
detachedWindow.makeKeyAndVisible()
|
||||
|
||||
customMediaPlayer.detachedWindow = detachedWindow
|
||||
hostingController.present(customMediaPlayer, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,18 +62,8 @@ fileprivate struct SettingsSection<Content: View>: View {
|
|||
struct SettingsViewLogger: View {
|
||||
@State private var logs: String = ""
|
||||
@State private var isLoading: Bool = true
|
||||
@State private var showFullLogs: Bool = false
|
||||
@StateObject private var filterViewModel = LogFilterViewModel.shared
|
||||
|
||||
private let displayCharacterLimit = 50_000
|
||||
|
||||
var displayedLogs: String {
|
||||
if showFullLogs || logs.count <= displayCharacterLimit {
|
||||
return logs
|
||||
}
|
||||
return String(logs.suffix(displayCharacterLimit))
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
VStack(spacing: 24) {
|
||||
|
|
@ -89,26 +79,13 @@ struct SettingsViewLogger: View {
|
|||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.padding(.vertical, 20)
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
Text(displayedLogs)
|
||||
.font(.footnote)
|
||||
.foregroundColor(.secondary)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.textSelection(.enabled)
|
||||
|
||||
if logs.count > displayCharacterLimit && !showFullLogs {
|
||||
Button(action: {
|
||||
showFullLogs = true
|
||||
}) {
|
||||
Text("Show More (\(logs.count - displayCharacterLimit) more characters)")
|
||||
.font(.footnote)
|
||||
.foregroundColor(.accentColor)
|
||||
}
|
||||
.padding(.top, 8)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 12)
|
||||
Text(logs)
|
||||
.font(.footnote)
|
||||
.foregroundColor(.secondary)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.vertical, 12)
|
||||
.textSelection(.enabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -162,7 +139,6 @@ struct SettingsViewLogger: View {
|
|||
await Logger.shared.clearLogsAsync()
|
||||
await MainActor.run {
|
||||
self.logs = ""
|
||||
self.showFullLogs = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue