dark popups

This commit is contained in:
eevee
2024-05-15 23:00:24 +03:00
parent f2afc886fd
commit 845f691868
4 changed files with 68 additions and 2 deletions
+41
View File
@@ -0,0 +1,41 @@
import Orion
import UIKit
import SwiftUI
struct DarkPopUps: HookGroup {}
class EncoreLabelHook: ClassHook<UIView> {
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<NSObject> {
typealias Group = DarkPopUps
static let targetName = "SPTEncorePopUpDialog"
func uiView() -> UIView {
let view = orig.uiView()
view.backgroundColor = UIColor(Color(hex: "#242424"))
return view
}
}
@@ -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)
}
}
}
+4
View File
@@ -27,6 +27,10 @@ struct EeveeSpotify: Tweak {
do {
if UserDefaults.darkPopUps {
DarkPopUps().activate()
}
defer {
NSFileCoordinator.addFilePresenter(OfflineObserver())
}
@@ -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<Bool>(
get: { UserDefaults.darkPopUps },
set: { UserDefaults.darkPopUps = $0 }
)
)
}
}
.padding(.bottom, 50)
.padding(.bottom, 40)
.animation(.default, value: lyricsSource)