From b66ddb167982e57673183c80aac5bc768992a783 Mon Sep 17 00:00:00 2001 From: cranci1 <100066266+cranci1@users.noreply.github.com> Date: Thu, 12 Jun 2025 10:12:38 +0200 Subject: [PATCH] alright --- .../MediaInfoView/AnilistMatchPopupView.swift | 40 +++++++++---------- Sora/Views/MediaInfoView/MediaInfoView.swift | 2 +- .../SettingsSubViews/SettingsViewAbout.swift | 4 +- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/Sora/Views/MediaInfoView/AnilistMatchPopupView.swift b/Sora/Views/MediaInfoView/AnilistMatchPopupView.swift index 3799b67..6434ee8 100644 --- a/Sora/Views/MediaInfoView/AnilistMatchPopupView.swift +++ b/Sora/Views/MediaInfoView/AnilistMatchPopupView.swift @@ -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", diff --git a/Sora/Views/MediaInfoView/MediaInfoView.swift b/Sora/Views/MediaInfoView/MediaInfoView.swift index ec0a8c4..58073b1 100644 --- a/Sora/Views/MediaInfoView/MediaInfoView.swift +++ b/Sora/Views/MediaInfoView/MediaInfoView.swift @@ -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") diff --git a/Sora/Views/SettingsView/SettingsSubViews/SettingsViewAbout.swift b/Sora/Views/SettingsView/SettingsSubViews/SettingsViewAbout.swift index 4c0e357..f9537a7 100644 --- a/Sora/Views/SettingsView/SettingsSubViews/SettingsViewAbout.swift +++ b/Sora/Views/SettingsView/SettingsSubViews/SettingsViewAbout.swift @@ -59,8 +59,6 @@ fileprivate struct SettingsSection: 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