ipad stuff and version section

This commit is contained in:
eevee
2024-06-16 18:07:20 +03:00
parent a2388eddd7
commit 398a11970a
9 changed files with 96 additions and 7 deletions
@@ -55,7 +55,7 @@ func getCurrentTrackLyricsData(originalLyrics: Lyrics? = nil) throws -> Data {
PopUpHelper.showPopUp(
delayed: false,
message: "The tweak is unable to load lyrics from Musixmatch due to Unauthorized error. Please check or update your Musixmatch token.",
message: "The tweak is unable to load lyrics from Musixmatch due to Unauthorized error. Please check or update your Musixmatch token. If you use an iPad, you should get the token from the Musixmatch app for iPad.",
buttonText: "OK"
)
break
@@ -1,4 +1,5 @@
import Foundation
import UIKit
struct MusixmatchLyricsDataSource {
@@ -14,7 +15,9 @@ struct MusixmatchLyricsDataSource {
var finalQuery = query
finalQuery["usertoken"] = UserDefaults.musixmatchToken
finalQuery["app_id"] = "mac-ios-v2.0"
finalQuery["app_id"] = UIDevice.current.isIpad
? "mac-ios-ipad-v1.0"
: "mac-ios-v2.0"
let queryString = finalQuery.queryString.addingPercentEncoding(
withAllowedCharacters: .urlHostAllowed
@@ -0,0 +1,7 @@
import UIKit
extension UIDevice {
var isIpad: Bool {
self.userInterfaceIdiom == .pad
}
}
@@ -0,0 +1,5 @@
import Foundation
struct GitHubReleaseInfo: Decodable {
var tag_name: String
}
@@ -0,0 +1,13 @@
import SwiftUI
struct ListRowSeparatorHidden: ViewModifier {
func body(content: Content) -> some View {
if #available(iOS 15.0, *) {
content
.listRowSeparator(.hidden)
}
else {
content
}
}
}
@@ -28,7 +28,6 @@ You can set a static color or a normalization factor based on the extracted trac
get: { Color(hex: lyricsColors.staticColor) },
set: { lyricsColors.staticColor = $0.hexString }
),
supportsOpacity: false
)
}
@@ -0,0 +1,48 @@
import SwiftUI
extension EeveeSettingsView {
func loadVersion() async throws {
let (data, _) = try await URLSession.shared.data(
from: URL(string: "https://api.github.com/repos/whoeevee/EeveeSpotify/releases/latest")!
)
let tag = try JSONDecoder().decode(GitHubReleaseInfo.self, from: data).tag_name
latestVersion = String(tag.dropFirst(5))
}
private var isUpdateAvailable: Bool {
guard
let latest = Double(latestVersion),
let current = Double(EeveeSpotify.version)
else {
return false
}
return latest > current
}
@ViewBuilder func VersionSection() -> some View {
Section {
if isUpdateAvailable {
Link(
"Update Available",
destination: URL(string: "https://github.com/whoeevee/EeveeSpotify/releases")!
)
}
} footer: {
VStack(alignment: .leading) {
Text("v\(EeveeSpotify.version)")
if latestVersion.isEmpty {
HStack(spacing: 10) {
ProgressView()
Text("Checking for Update...")
}
}
}
}
}
}
@@ -5,13 +5,17 @@ struct EeveeSettingsView: View {
@State var musixmatchToken = UserDefaults.musixmatchToken
@State var patchType = UserDefaults.patchType
@State var lyricsSource = UserDefaults.lyricsSource
@State var overwriteConfiguration = UserDefaults.overwriteConfiguration
@State var lyricsSource = UserDefaults.lyricsSource
@State var lyricsColors = UserDefaults.lyricsColors
@State var latestVersion = ""
var body: some View {
List {
VersionSection()
PremiumSections()
@@ -37,16 +41,22 @@ struct EeveeSettingsView: View {
Text("Reset Data")
}
}
if !UIDevice.current.isIpad {
Spacer()
.frame(height: 40)
.listRowBackground(Color.clear)
.modifier(ListRowSeparatorHidden())
}
}
.listStyle(GroupedListStyle())
.padding(.bottom, 60)
.ignoresSafeArea(.keyboard)
.animation(.default, value: lyricsSource)
.animation(.default, value: patchType)
.animation(.default, value: lyricsColors)
.animation(.default, value: latestVersion)
.onAppear {
UIView.appearance(
@@ -54,6 +64,10 @@ struct EeveeSettingsView: View {
).tintColor = UIColor(Color(hex: "#1ed760"))
WindowHelper.shared.overrideUserInterfaceStyle(.dark)
Task {
try await loadVersion()
}
}
}
}
@@ -58,7 +58,7 @@ LRCLIB: The most open service, offering time-synced lyrics. However, it lacks ly
Musixmatch: The service Spotify uses. Provides time-synced lyrics for many songs, but you'll need a user token to use this source.
If the tweak is unable to find a song or process the lyrics, you'll see a "Couldn't load the lyrics for this song" message. The lyrics might be wrong for some songs (e.g. another song, song article) when using Genius due to how the tweak searches songs. I've made it work in most cases.
If the tweak is unable to find a song or process the lyrics, you'll see a "Couldn't load the lyrics for this song" message. The lyrics might be wrong for some songs when using Genius due to how the tweak searches songs. I've made it work in most cases.
""")) {
Picker(
"Lyrics Source",