Skip to content

Commit

Permalink
fix crashes on 8.9.54
Browse files Browse the repository at this point in the history
  • Loading branch information
whoeevee committed Jul 10, 2024
1 parent 9dde89f commit 5a374cc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 21 deletions.
18 changes: 8 additions & 10 deletions Sources/EeveeSpotify/DarkPopUps.x.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EncoreLabelHook: ClassHook<UIView> {

let label = Dynamic.convert(target.subviews.first!, to: UILabel.self)

if !label.hasParent("Primary") {
if !label.hasParent(matching: "Primary") {
label.textColor = .white
}
}
Expand All @@ -27,17 +27,15 @@ class EncoreLabelHook: ClassHook<UIView> {
}
}

class SPTEncorePopUpDialogHook: ClassHook<UIView> {
class SPTEncorePopUpDialogHook: ClassHook<NSObject> {

typealias Group = DarkPopUps
static let targetName = "_TtCO12EncoreMobile5ViewsP33_5A611B064D744992F9E8B522D8DE459B10ScrollView"
static let targetName = "SPTEncorePopUpDialog"

func intrinsicContentSize() -> CGSize {

if target.accessibilityIdentifier == "PopUp.Dialog" {
target.backgroundColor = UIColor(Color(hex: "#242424"))
}

return orig.intrinsicContentSize()
func uiView() -> UIView {
let view = orig.uiView()
view.backgroundColor = UIColor(Color(hex: "#242424"))

return view
}
}
28 changes: 19 additions & 9 deletions Sources/EeveeSpotify/Lyrics/CustomLyrics.x.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,28 @@ class SPTPlayerTrackHook: ClassHook<NSObject> {
}
}

class EncoreButtonHook: ClassHook<UIButton> {
class LyricsFullscreenViewControllerHook: ClassHook<UIViewController> {

static let targetName = "_TtC12EncoreMobileP33_6EF3A3C098E69FB1E331877B69ACBF8512EncoreButton"

func intrinsicContentSize() -> CGSize {

if target.accessibilityIdentifier == "Components.UI.LyricsHeader.ReportButton",
UserDefaults.lyricsSource != .musixmatch {
target.isEnabled = false
static var targetName: String {
if #available(iOS 15.0, *) {
"Lyrics_FullscreenPageImpl.FullscreenViewController"
} else {
"Lyrics_CoreImpl.FullscreenViewController"
}
}

return orig.intrinsicContentSize()
func viewDidLoad() {
orig.viewDidLoad()

if UserDefaults.lyricsSource == .musixmatch {
return
}

let headerView = Ivars<UIView>(target.view).headerView

if let reportButton = headerView.subviews(matching: "EncoreButton")[1] as? UIButton {
reportButton.isEnabled = false
}
}
}

Expand Down
22 changes: 20 additions & 2 deletions Sources/EeveeSpotify/Models/Extensions/UIView+Extension.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit

extension UIView {
func hasParent(_ regex: String) -> Bool {
func hasParent(matching regex: String) -> Bool {
guard let parent = self.superview else {
return false
}
Expand All @@ -10,7 +10,25 @@ extension UIView {
if parentClassName ~= regex {
return true
} else {
return parent.hasParent(regex)
return parent.hasParent(matching: regex)
}
}

func subviews(matching regex: String) -> [UIView] {
var matchingSubviews = [UIView]()
var stack = [self]

while !stack.isEmpty {
let currentView = stack.removeLast()

for subview in currentView.subviews {
if NSStringFromClass(type(of: subview)) ~= regex {
matchingSubviews.append(subview)
}
stack.append(subview)
}
}

return matchingSubviews
}
}

0 comments on commit 5a374cc

Please sign in to comment.