Skip to content

Commit 92e6cc7

Browse files
committed
what i've done so far
1 parent 727fd66 commit 92e6cc7

47 files changed

Lines changed: 298 additions & 271 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Sources/EeveeSpotify/DarkPopUps.x.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import SwiftUI
44

55
struct DarkPopUps: HookGroup { }
66

7-
private let popUpContainerViewController = EeveeSpotify.isOldSpotifyVersion
8-
? "SPTEncorePopUpContainer"
9-
: "EncoreConsumerMobile_Wrappers.PopUpPresentableContainer"
7+
private var popUpContainerViewController: String {
8+
switch EeveeSpotify.hookTarget {
9+
case .lastAvailableiOS14: return "SPTEncorePopUpContainer"
10+
default: return "EncoreConsumerMobile_Wrappers.PopUpPresentableContainer"
11+
}
12+
}
1013

1114
class EncoreLabelHook: ClassHook<UIView> {
1215
typealias Group = DarkPopUps

Sources/EeveeSpotify/DataLoaderServiceHooks.x.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SPTDataLoaderServiceHook: ClassHook<NSObject>, SpotifySessionDelegate {
3434
orig.URLSession(
3535
session,
3636
dataTask: task,
37-
didReceiveData: try getLyricsForCurrentTrack(
37+
didReceiveData: try getLyricsDataForCurrentTrack(
3838
originalLyrics: try? Lyrics(serializedBytes: buffer)
3939
)
4040
)
@@ -94,7 +94,7 @@ class SPTDataLoaderServiceHook: ClassHook<NSObject>, SpotifySessionDelegate {
9494
)!
9595

9696
do {
97-
let lyricsData = try getLyricsForCurrentTrack()
97+
let lyricsData = try getLyricsDataForCurrentTrack()
9898

9999
orig.URLSession(
100100
session,
@@ -109,9 +109,7 @@ class SPTDataLoaderServiceHook: ClassHook<NSObject>, SpotifySessionDelegate {
109109
return
110110
}
111111
catch {
112-
NSLog("[EeveeSpotify] Unable to load lyrics: \(error)")
113112
orig.URLSession(session, task: task, didCompleteWithError: error)
114-
115113
return
116114
}
117115
}

Sources/EeveeSpotify/HookedInstances.x.swift

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import Orion
2+
import UIKit
23

34
class SPTPlayerTrackHook: ClassHook<NSObject> {
45
typealias Group = LyricsGroup
56
static let targetName = "SPTPlayerTrack"
67

7-
func metadata() -> [String:String] {
8+
func metadata() -> [String: String] {
89
var meta = orig.metadata()
910

1011
meta["has_lyrics"] = "true"
@@ -14,14 +15,33 @@ class SPTPlayerTrackHook: ClassHook<NSObject> {
1415

1516
class LyricsScrollProviderHook: ClassHook<NSObject> {
1617
typealias Group = LyricsGroup
17-
18-
static var targetName: String {
19-
return EeveeSpotify.isOldSpotifyVersion
20-
? "Lyrics_CoreImpl.ScrollProvider"
21-
: "Lyrics_NPVCommunicatorImpl.ScrollProvider"
22-
}
18+
static var targetName = HookTargetNameHelper.lyricsScrollProvider
2319

2420
func isEnabledForTrack(_ track: SPTPlayerTrack) -> Bool {
2521
return true
2622
}
2723
}
24+
25+
class NowPlayingScrollViewControllerHook: ClassHook<NSObject> {
26+
typealias Group = LyricsGroup
27+
static var targetName = "NowPlaying_ScrollImpl.NowPlayingScrollViewController"
28+
29+
func nowPlayingScrollViewModelWithDidLoadComponentsFor(
30+
_ track: SPTPlayerTrack,
31+
withDifferentProviders: Bool,
32+
scrollEnabledValueChanged: Bool
33+
) -> NowPlayingScrollViewController {
34+
var controller = orig.nowPlayingScrollViewModelWithDidLoadComponentsFor(
35+
track,
36+
withDifferentProviders: withDifferentProviders,
37+
scrollEnabledValueChanged: scrollEnabledValueChanged
38+
)
39+
40+
if !scrollEnabledValueChanged {
41+
controller.scrollEnabled = true
42+
controller.nowPlayingScrollViewModelDidChangeScrollEnabledValue()
43+
}
44+
45+
return controller
46+
}
47+
}
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 LyricsFullscreenViewControllerHook: ClassHook<UIViewController> {
5+
typealias Group = LyricsGroup
6+
7+
static var targetName: String {
8+
switch EeveeSpotify.hookTarget {
9+
case .lastAvailableiOS14: return "Lyrics_CoreImpl.FullscreenViewController"
10+
default: return "Lyrics_FullscreenPageImpl.FullscreenViewController"
11+
}
12+
}
13+
14+
func viewDidLoad() {
15+
orig.viewDidLoad()
16+
17+
if UserDefaults.lyricsSource == .musixmatch
18+
&& lyricsState.fallbackError == nil
19+
&& !lyricsState.wasRomanized
20+
&& !lyricsState.isEmpty {
21+
return
22+
}
23+
24+
let headerView = Ivars<UIView>(target.view).headerView
25+
26+
if let reportButton = headerView.subviews(matching: "EncoreButton")[1] as? UIButton {
27+
reportButton.isEnabled = false
28+
}
29+
}
30+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import Orion
2+
import UIKit
3+
4+
class LyricsOnlyViewControllerHook: ClassHook<UIViewController> {
5+
typealias Group = LyricsGroup
6+
7+
static var targetName: String {
8+
switch EeveeSpotify.hookTarget {
9+
case .lastAvailableiOS14: return "Lyrics_CoreImpl.LyricsOnlyViewController"
10+
default: return "Lyrics_NPVCommunicatorImpl.LyricsOnlyViewController"
11+
}
12+
}
13+
14+
func viewDidLoad() {
15+
orig.viewDidLoad()
16+
17+
guard
18+
let lyricsHeaderViewController = target.parent?.children.first
19+
else {
20+
return
21+
}
22+
23+
guard let lyricsLabel = WindowHelper.shared.findFirstSubview(
24+
"SPTEncoreLabel",
25+
in: lyricsHeaderViewController.view
26+
) else {
27+
return
28+
}
29+
30+
let encoreLabel = Dynamic.convert(lyricsLabel, to: SPTEncoreLabel.self)
31+
32+
var text = [
33+
encoreLabel.text().firstObject
34+
]
35+
36+
let attributes = Dynamic.SPTEncoreAttributes
37+
.alloc(interface: SPTEncoreAttributes.self)
38+
.`init`({ attributes in
39+
attributes.setForegroundColor(.white.withAlphaComponent(0.5))
40+
})
41+
42+
let typeStyle = type(
43+
of: Dynamic[
44+
dynamicMember: EeveeSpotify.hookTarget == .lastAvailableiOS14
45+
? "SPTEncoreTypeStyle"
46+
: "SPTEncoreTextStyle"
47+
].alloc(interface: SPTEncoreTypeStyle.self)
48+
).bodyMediumBold()
49+
50+
//
51+
52+
if UserDefaults.lyricsOptions.showFallbackReasons,
53+
let description = lyricsState.fallbackError?.description
54+
{
55+
let attributedString = Dynamic.SPTEncoreAttributedString.alloc(
56+
interface: SPTEncoreAttributedString.self
57+
)
58+
59+
text.append(
60+
EeveeSpotify.hookTarget == .lastAvailableiOS14
61+
? attributedString.initWithString(
62+
"\n\("fallback_attribute".localized): \(description)",
63+
typeStyle: typeStyle,
64+
attributes: attributes
65+
)
66+
: attributedString.initWithString(
67+
"\n\("fallback_attribute".localized): \(description)",
68+
textStyle: typeStyle,
69+
attributes: attributes
70+
)
71+
)
72+
}
73+
74+
if lyricsState.wasRomanized {
75+
let attributedString = Dynamic.SPTEncoreAttributedString.alloc(
76+
interface: SPTEncoreAttributedString.self
77+
)
78+
79+
text.append(
80+
EeveeSpotify.hookTarget == .lastAvailableiOS14
81+
? attributedString.initWithString(
82+
"\n\("romanized_attribute".localized)",
83+
typeStyle: typeStyle,
84+
attributes: attributes
85+
)
86+
: attributedString.initWithString(
87+
"\n\("romanized_attribute".localized)",
88+
textStyle: typeStyle,
89+
attributes: attributes
90+
)
91+
)
92+
}
93+
94+
if EeveeSpotify.hookTarget == .lastAvailableiOS14 {
95+
encoreLabel.setNumberOfLines(text.count)
96+
}
97+
98+
encoreLabel.setText(text as NSArray)
99+
}
100+
}

0 commit comments

Comments
 (0)