mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-21 16:42:01 +00:00
idk doesnt build for me 😭
This commit is contained in:
parent
16976d8e00
commit
7dd09dabc8
1 changed files with 36 additions and 16 deletions
|
|
@ -8,6 +8,18 @@
|
|||
import SwiftUI
|
||||
import Kingfisher
|
||||
|
||||
extension String {
|
||||
var strippedHTML: String {
|
||||
guard let data = self.data(using: .utf8) else { return self }
|
||||
let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [
|
||||
.documentType: NSAttributedString.DocumentType.html,
|
||||
.characterEncoding: String.Encoding.utf8.rawValue
|
||||
]
|
||||
let attributedString = try? NSAttributedString(data: data, options: options, documentAttributes: nil)
|
||||
return attributedString?.string ?? self
|
||||
}
|
||||
}
|
||||
|
||||
struct MediaDetailItem: View {
|
||||
var title: String
|
||||
var value: String
|
||||
|
|
@ -102,7 +114,6 @@ struct AniListDetailsView: View {
|
|||
let month = endDate["month"] as? Int,
|
||||
let day = endDate["day"] as? Int {
|
||||
MediaDetailItem(title: "End Date", value: "\(year)-\(month)-\(day)")
|
||||
Divider()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -123,7 +134,7 @@ struct AniListDetailsView: View {
|
|||
}
|
||||
|
||||
if let synopsis = media["description"] as? String {
|
||||
Text(synopsis)
|
||||
Text(synopsis.strippedHTML)
|
||||
.padding(.horizontal)
|
||||
.foregroundColor(.secondary)
|
||||
.font(.system(size: 14))
|
||||
|
|
@ -174,11 +185,19 @@ struct AniListDetailsView: View {
|
|||
|
||||
if let stats = media["stats"] as? [String: Any],
|
||||
let scoreDistribution = stats["scoreDistribution"] as? [[String: Any]] {
|
||||
|
||||
let maxValue: Int = scoreDistribution.compactMap { $0["amount"] as? Int }.max() ?? 1
|
||||
|
||||
HStack(alignment: .center) {
|
||||
if let averageScore = media["averageScore"] as? Double {
|
||||
Text("Average Score: \(String(format: "%.1f", averageScore))")
|
||||
.font(.headline)
|
||||
.frame(width: 120, alignment: .leading)
|
||||
}
|
||||
VStack(alignment: .center) {
|
||||
Text("Score Distribution")
|
||||
.font(.headline)
|
||||
HStack(alignment: .bottom, spacing: 8) {
|
||||
let maxValue = scoreDistribution.compactMap { $0["amount"] as? Int }.max() ?? 1
|
||||
ForEach(Array(scoreDistribution.enumerated()), id: \.offset) { _, dataPoint in
|
||||
if let score = dataPoint["score"] as? Int,
|
||||
let amount = dataPoint["amount"] as? Int {
|
||||
|
|
@ -193,6 +212,7 @@ struct AniListDetailsView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue