Skip to content

Commit 241f5a3

Browse files
committed
hide lyrics on error
1 parent a994490 commit 241f5a3

7 files changed

Lines changed: 68 additions & 1 deletion

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Orion
2+
import UIKit
3+
4+
class fefewfwfwefewefw: ClassHook<UIViewController> {
5+
typealias Group = LyricsGroup
6+
7+
static var targetName: String {
8+
switch EeveeSpotify.hookTarget {
9+
case .lastAvailableiOS14: return "Lyrics_CoreImpl.ErrorViewController"
10+
default: return "Lyrics_NPVCommunicatorImpl.ErrorViewController"
11+
}
12+
}
13+
14+
func loadView() {
15+
orig.loadView()
16+
17+
guard UserDefaults.lyricsOptions.hideOnError, let controller = nowPlayingScrollViewController else {
18+
return
19+
}
20+
21+
var providers = controller.activeProviders
22+
23+
providers.removeAll(
24+
where: { NSStringFromClass(type(of: $0)) == HookTargetNameHelper.lyricsScrollProvider }
25+
)
26+
27+
controller.activeProviders = providers
28+
controller.collectionView().reloadData()
29+
}
30+
}

Sources/EeveeSpotify/Lyrics/Models/Extensions/NowPlayingScrollViewController+Extension.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ extension NowPlayingScrollViewController {
2424

2525
//
2626

27+
private var dataSource: NSObject {
28+
get {
29+
Ivars<NSObject>(nowPlayingScrollViewModel).dataSource
30+
}
31+
}
32+
33+
var activeProviders: Array<NSObject> {
34+
get {
35+
Ivars<Array<NSObject>>(dataSource).activeProviders
36+
}
37+
set {
38+
Ivars<Array<NSObject>>(dataSource).activeProviders = newValue
39+
}
40+
}
41+
42+
//
43+
2744
var backgroundViewController: SPTNowPlayingBackgroundViewController {
2845
get {
2946
Ivars<SPTNowPlayingBackgroundViewController>(self).backgroundViewController

Sources/EeveeSpotify/Lyrics/Models/Settings/LyricsOptions+UserDefaults.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ extension UserDefaults {
88
musixmatchLanguage: Locale.current.languageCode ?? "",
99
lrclibUrl: LrclibLyricsRepository.originalApiUrl,
1010
geniusFallback: true,
11-
showFallbackReasons: true
11+
showFallbackReasons: true,
12+
hideOnError: false
1213
)
1314
)
1415
static var lyricsOptions

Sources/EeveeSpotify/Lyrics/Models/Settings/LyricsOptions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ struct LyricsOptions: Codable, Hashable {
66
var lrclibUrl: String
77
var geniusFallback: Bool
88
var showFallbackReasons: Bool
9+
var hideOnError: Bool
910
}

Sources/EeveeSpotify/Settings/Sections/Lyrics/Views/EeveeLyricsSettingsView.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct EeveeLyricsSettingsView: View {
1212
geniusFallbackSection()
1313
}
1414

15+
hideOnErrorSection()
1516
romanizedLyricsSection()
1617

1718
if viewModel.lyricsSource == .musixmatch {
@@ -59,6 +60,17 @@ struct EeveeLyricsSettingsView: View {
5960
}
6061
}
6162

63+
@ViewBuilder private func hideOnErrorSection() -> some View {
64+
Section {
65+
Toggle(
66+
"hide_lyrics_on_error".localized,
67+
isOn: $viewModel.lyricsOptions.hideOnError
68+
)
69+
} footer: {
70+
Text("hide_lyrics_on_error_description".localized)
71+
}
72+
}
73+
6274
@ViewBuilder private func musixmatchLanguageSection() -> some View {
6375
Section {
6476
HStack {

layout/Library/Application Support/EeveeSpotify.bundle/en.lproj/Localizable.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ genius_fallback_description = "Load lyrics from Genius if there is a problem wit
5555

5656
show_fallback_reasons = "Show Fallback Reasons";
5757

58+
hide_lyrics_on_error = "Hide on Error";
59+
hide_lyrics_on_error_description = "Remove the lyrics component if lyrics fail to load.";
60+
5861
romanized_lyrics = "Romanized Lyrics";
5962
romanized_lyrics_description = "Display romanized lyrics for Japanese, Korean, and Chinese.";
6063

layout/Library/Application Support/EeveeSpotify.bundle/ru.lproj/Localizable.strings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ genius_fallback_description = "Загружать тексты из Genius пр
5454

5555
show_fallback_reasons = "Показывать проблемы";
5656

57+
hide_lyrics_on_error = "Скрывать при ошибке";
58+
hide_lyrics_on_error_description = "Скрывать компонент текста, если не удается загрузить текст.";
59+
5760
romanized_lyrics = "Латинизация текстов";
5861
romanized_lyrics_description = "Отображать латинизированный текст для японского, корейского и китайского языков.";
5962

0 commit comments

Comments
 (0)