diff --git a/Sources/EeveeSpotify/DarkPopUps.x.swift b/Sources/EeveeSpotify/DarkPopUps.x.swift new file mode 100644 index 0000000..b0c0317 --- /dev/null +++ b/Sources/EeveeSpotify/DarkPopUps.x.swift @@ -0,0 +1,41 @@ +import Orion +import UIKit +import SwiftUI + +struct DarkPopUps: HookGroup {} + +class EncoreLabelHook: ClassHook { + + typealias Group = DarkPopUps + static let targetName = "SPTEncoreLabel" + + func intrinsicContentSize() -> CGSize { + + if String( + describing: WindowHelper.shared.viewController(for: target) + ) ~= "SPTEncorePopUpContainer" { + + let label = Dynamic.convert(target.subviews.first!, to: UILabel.self) + + if !(String(describing: target.superview?.superview?.superview) ~= "Primary") { + label.textColor = .white + } + } + + return orig.intrinsicContentSize() + } +} + +class SPTEncorePopUpDialogHook: ClassHook { + + typealias Group = DarkPopUps + static let targetName = "SPTEncorePopUpDialog" + + func uiView() -> UIView { + + let view = orig.uiView() + view.backgroundColor = UIColor(Color(hex: "#242424")) + + return view + } +} diff --git a/Sources/EeveeSpotify/Models/Extensions/UserDefaults+Extension.swift b/Sources/EeveeSpotify/Models/Extensions/UserDefaults+Extension.swift index 640a79d..425de43 100644 --- a/Sources/EeveeSpotify/Models/Extensions/UserDefaults+Extension.swift +++ b/Sources/EeveeSpotify/Models/Extensions/UserDefaults+Extension.swift @@ -7,6 +7,7 @@ extension UserDefaults { private static let lyricsSourceKey = "lyricsSource" private static let musixmatchTokenKey = "musixmatchToken" private static let geniusFallbackKey = "geniusFallback" + private static let darkPopUpsKey = "darkPopUps" static var lyricsSource: LyricsSource { get { @@ -38,4 +39,13 @@ extension UserDefaults { defaults.set(fallback, forKey: geniusFallbackKey) } } + + static var darkPopUps: Bool { + get { + defaults.object(forKey: darkPopUpsKey) as? Bool ?? true + } + set (fallback) { + defaults.set(fallback, forKey: darkPopUpsKey) + } + } } \ No newline at end of file diff --git a/Sources/EeveeSpotify/Tweak.x.swift b/Sources/EeveeSpotify/Tweak.x.swift index bb747df..a013315 100644 --- a/Sources/EeveeSpotify/Tweak.x.swift +++ b/Sources/EeveeSpotify/Tweak.x.swift @@ -27,6 +27,10 @@ struct EeveeSpotify: Tweak { do { + if UserDefaults.darkPopUps { + DarkPopUps().activate() + } + defer { NSFileCoordinator.addFilePresenter(OfflineObserver()) } diff --git a/Sources/EeveeSpotify/Views/EeveeSettingsView.swift b/Sources/EeveeSpotify/Views/EeveeSettingsView.swift index aa5cce0..8b0572e 100644 --- a/Sources/EeveeSpotify/Views/EeveeSettingsView.swift +++ b/Sources/EeveeSpotify/Views/EeveeSettingsView.swift @@ -48,7 +48,6 @@ struct EeveeSettingsView: View { var body: some View { List { - Section(footer: Text(""" You can select the lyrics source you prefer. @@ -95,9 +94,21 @@ If the tweak is unable to find a song or process the lyrics, you'll see the orig ) } } + + Section( + footer: Text("App restart is required to apply.") + ) { + Toggle( + "Dark PopUps", + isOn: Binding( + get: { UserDefaults.darkPopUps }, + set: { UserDefaults.darkPopUps = $0 } + ) + ) + } } - .padding(.bottom, 50) + .padding(.bottom, 40) .animation(.default, value: lyricsSource)