alright
Some checks are pending
Build and Release / Build IPA (push) Waiting to run
Build and Release / Build Mac Catalyst (push) Waiting to run

This commit is contained in:
cranci1 2025-06-12 10:12:38 +02:00
parent af8b1c1773
commit b66ddb1679
3 changed files with 22 additions and 24 deletions

View file

@ -11,23 +11,23 @@ import SwiftUI
struct AnilistMatchPopupView: View {
let seriesTitle: String
let onSelect: (Int) -> Void
@State private var results: [[String: Any]] = []
@State private var isLoading = true
@AppStorage("selectedAppearance") private var selectedAppearance: Appearance = .system
@Environment(\.colorScheme) private var colorScheme
private var isLightMode: Bool {
selectedAppearance == .light
|| (selectedAppearance == .system && colorScheme == .light)
|| (selectedAppearance == .system && colorScheme == .light)
}
@State private var manualIDText: String = ""
@State private var showingManualIDAlert = false
@Environment(\.dismiss) private var dismiss
var body: some View {
NavigationView {
ScrollView {
@ -36,7 +36,7 @@ struct AnilistMatchPopupView: View {
.font(.footnote)
.foregroundStyle(.gray)
.padding(.horizontal, 10)
VStack(spacing: 0) {
if isLoading {
ProgressView()
@ -52,7 +52,7 @@ struct AnilistMatchPopupView: View {
LazyVStack(spacing: 15) {
ForEach(results.indices, id: \.self) { index in
let result = results[index]
Button(action: {
if let id = result["id"] as? Int {
onSelect(id)
@ -76,19 +76,19 @@ struct AnilistMatchPopupView: View {
}
}
}
VStack(alignment: .leading, spacing: 2) {
Text(result["title"] as? String ?? "Unknown")
.font(.body)
.foregroundStyle(.primary)
if let english = result["title_english"] as? String {
Text(english)
.font(.caption)
.foregroundStyle(.secondary)
}
}
Spacer()
}
.padding(11)
@ -120,7 +120,7 @@ struct AnilistMatchPopupView: View {
.padding(.top, 16)
}
}
if !results.isEmpty {
Text("Tap a title to override the current match.")
.font(.footnote)
@ -166,7 +166,7 @@ struct AnilistMatchPopupView: View {
}
.onAppear(perform: fetchMatches)
}
private func fetchMatches() {
let query = """
query {
@ -184,18 +184,18 @@ struct AnilistMatchPopupView: View {
}
}
"""
guard let url = URL(string: "https://graphql.anilist.co") else { return }
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: ["query": query])
URLSession.shared.dataTask(with: request) { data, _, _ in
DispatchQueue.main.async {
self.isLoading = false
guard let data = data,
let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any],
let dataDict = json["data"] as? [String: Any],
@ -203,11 +203,11 @@ struct AnilistMatchPopupView: View {
let mediaList = page["media"] as? [[String: Any]] else {
return
}
self.results = mediaList.map { media in
let titleInfo = media["title"] as? [String: Any]
let cover = (media["coverImage"] as? [String: Any])?["large"] as? String
return [
"id": media["id"] ?? 0,
"title": titleInfo?["romaji"] ?? "Unknown",

View file

@ -675,7 +675,7 @@ struct MediaInfoView: View {
Label("Open in AniList", systemImage: "link")
}
}
if UserDefaults.standard.string(forKey: "metadataProviders") ?? "TMDB" == "AniList" {
Button(action: { isMatchingPresented = true }) {
Label("Match with AniList", systemImage: "magnifyingglass")

View file

@ -59,8 +59,6 @@ fileprivate struct SettingsSection<Content: View>: View {
}
struct SettingsViewAbout: View {
let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "ALPHA"
var body: some View {
ScrollView {
VStack(spacing: 24) {
@ -182,7 +180,7 @@ struct ContributorsView: View {
private func loadContributors() {
let url = URL(string: "https://api.github.com/repos/cranci1/Sora/contributors")!
URLSession.shared.dataTask(with: url) { data, response, error in
URLSession.custom.dataTask(with: url) { data, response, error in
DispatchQueue.main.async {
isLoading = false