From c407874e93510f857a0c0d31d2ab0475382d6a27 Mon Sep 17 00:00:00 2001 From: eevee Date: Sat, 13 Jul 2024 12:06:58 +0300 Subject: [PATCH] default language & white popup background fix --- Sources/EeveeSpotify/DarkPopUps.x.swift | 18 ++++++++++-------- .../Extensions/UserDefaults+Extension.swift | 5 ++++- .../Models/Headers/SPTEncorePopUpDialog.swift | 3 ++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Sources/EeveeSpotify/DarkPopUps.x.swift b/Sources/EeveeSpotify/DarkPopUps.x.swift index 740523e..3866f6f 100644 --- a/Sources/EeveeSpotify/DarkPopUps.x.swift +++ b/Sources/EeveeSpotify/DarkPopUps.x.swift @@ -27,15 +27,17 @@ class EncoreLabelHook: ClassHook { } } -class SPTEncorePopUpDialogHook: ClassHook { +class SPTEncorePopUpContainerHook: ClassHook { typealias Group = DarkPopUps - static let targetName = "SPTEncorePopUpDialog" - - func uiView() -> UIView { - let view = orig.uiView() - view.backgroundColor = UIColor(Color(hex: "#242424")) - - return view + static let targetName = "SPTEncorePopUpContainer" + + func containedView() -> SPTEncorePopUpDialog { + return orig.containedView() + } + + func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { + containedView().uiView().backgroundColor = UIColor(Color(hex: "#242424")) + return orig.supportedInterfaceOrientations() } } diff --git a/Sources/EeveeSpotify/Models/Extensions/UserDefaults+Extension.swift b/Sources/EeveeSpotify/Models/Extensions/UserDefaults+Extension.swift index 525a750..e1cd174 100644 --- a/Sources/EeveeSpotify/Models/Extensions/UserDefaults+Extension.swift +++ b/Sources/EeveeSpotify/Models/Extensions/UserDefaults+Extension.swift @@ -53,7 +53,10 @@ extension UserDefaults { return lyricsOptions } - return LyricsOptions(romanization: false, musixmatchLanguage: "") + return LyricsOptions( + romanization: false, + musixmatchLanguage: Locale.current.languageCode ?? "" + ) } set (lyricsOptions) { defaults.set(try! JSONEncoder().encode(lyricsOptions), forKey: lyricsOptionsKey) diff --git a/Sources/EeveeSpotify/Models/Headers/SPTEncorePopUpDialog.swift b/Sources/EeveeSpotify/Models/Headers/SPTEncorePopUpDialog.swift index 48c29eb..660e092 100644 --- a/Sources/EeveeSpotify/Models/Headers/SPTEncorePopUpDialog.swift +++ b/Sources/EeveeSpotify/Models/Headers/SPTEncorePopUpDialog.swift @@ -1,7 +1,8 @@ -import Foundation +import UIKit @objc protocol SPTEncorePopUpDialog { func `init`() -> SPTEncorePopUpDialog + func uiView() -> UIView func update(_ popUpModel: SPTEncorePopUpDialogModel) func setEventHandler(_ handler: @escaping (_ state: ClickState) -> Void) }