-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
323 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import JellyfinAPI | ||
|
||
extension RatingType: @retroactive Displayable { | ||
|
||
var displayTitle: String { | ||
switch self { | ||
case .score: | ||
return L10n.score | ||
case .likes: | ||
return L10n.likes | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...mEditorView/ItemImages/ItemImageDetailsView/Components/ItemImageDetailsDeleteButton.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import Defaults | ||
import JellyfinAPI | ||
import SwiftUI | ||
|
||
extension ItemImageDetailsView { | ||
|
||
struct DeleteButton: View { | ||
|
||
// MARK: - Defaults | ||
|
||
@Default(.accentColor) | ||
private var accentColor | ||
|
||
// MARK: - Delete Action | ||
|
||
let onDelete: () -> Void | ||
|
||
// MARK: - Header | ||
|
||
@ViewBuilder | ||
var body: some View { | ||
ListRowButton(L10n.delete) { | ||
onDelete() | ||
} | ||
.foregroundStyle( | ||
accentColor.overlayColor, | ||
.red | ||
) | ||
} | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
...ditorView/ItemImages/ItemImageDetailsView/Components/ItemImageDetailsDetailsSection.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import JellyfinAPI | ||
import SwiftUI | ||
|
||
extension ItemImageDetailsView { | ||
|
||
struct DetailsSection: View { | ||
|
||
let imageID: Int? | ||
let imageURL: URL? | ||
let imageIndex: Int? | ||
let imageLanguage: String? | ||
let imageWidth: Int? | ||
let imageHeight: Int? | ||
let provider: String? | ||
let rating: Double? | ||
let ratingType: RatingType? | ||
let ratingVotes: Int? | ||
|
||
// MARK: - Initializer | ||
|
||
init( | ||
imageID: Int? = nil, | ||
imageURL: URL? = nil, | ||
imageIndex: Int? = nil, | ||
imageLanguage: String? = nil, | ||
imageWidth: Int? = nil, | ||
imageHeight: Int? = nil, | ||
provider: String? = nil, | ||
rating: Double? = nil, | ||
ratingType: RatingType? = nil, | ||
ratingVotes: Int? = nil | ||
) { | ||
self.imageID = imageID | ||
self.imageURL = imageURL | ||
self.imageIndex = imageIndex | ||
self.imageLanguage = imageLanguage | ||
self.imageWidth = imageWidth | ||
self.imageHeight = imageHeight | ||
self.provider = provider | ||
self.rating = rating | ||
self.ratingType = ratingType | ||
self.ratingVotes = ratingVotes | ||
} | ||
|
||
// MARK: - Body | ||
|
||
@ViewBuilder | ||
var body: some View { | ||
Section(L10n.details) { | ||
if let provider { | ||
TextPairView(leading: L10n.provider, trailing: provider) | ||
} | ||
|
||
if let imageID { | ||
TextPairView(leading: L10n.id, trailing: imageID.description) | ||
} | ||
|
||
if let imageIndex { | ||
TextPairView(leading: L10n.index, trailing: imageIndex.description) | ||
} | ||
|
||
if let imageLanguage { | ||
TextPairView(leading: L10n.language, trailing: imageLanguage) | ||
} | ||
|
||
if let imageWidth, let imageHeight { | ||
TextPairView( | ||
leading: L10n.dimensions, | ||
trailing: "\(imageWidth) x \(imageHeight)" | ||
) | ||
} | ||
} | ||
|
||
if let rating { | ||
Section(L10n.ratings) { | ||
TextPairView(leading: L10n.rating, trailing: rating.formatted(.number.precision(.fractionLength(2)))) | ||
|
||
if let ratingType { | ||
TextPairView(leading: L10n.rating, trailing: ratingType.displayTitle) | ||
} | ||
|
||
if let ratingVotes { | ||
TextPairView(leading: L10n.votes, trailing: ratingVotes.description) | ||
} | ||
} | ||
} | ||
|
||
if let imageURL = imageURL { | ||
Section { | ||
Button { | ||
UIApplication.shared.open(imageURL) | ||
} label: { | ||
HStack { | ||
Text(L10n.imageSource) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.foregroundColor(.primary) | ||
|
||
Image(systemName: "arrow.up.forward") | ||
.font(.body.weight(.regular)) | ||
.foregroundColor(.secondary) | ||
} | ||
.foregroundStyle(.primary, .secondary) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...EditorView/ItemImages/ItemImageDetailsView/Components/ItemImageDetailsHeaderSection.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import Defaults | ||
import JellyfinAPI | ||
import SwiftUI | ||
|
||
extension ItemImageDetailsView { | ||
|
||
struct HeaderSection: View { | ||
|
||
// MARK: - Image Info | ||
|
||
let imageURL: URL? | ||
|
||
let imageType: PosterDisplayType | ||
|
||
// MARK: - Header | ||
|
||
@ViewBuilder | ||
var body: some View { | ||
Section { | ||
ImageView(imageURL) | ||
.placeholder { _ in | ||
Image(systemName: "circle") | ||
} | ||
.failure { | ||
Image(systemName: "circle") | ||
} | ||
.scaledToFill() | ||
.frame(maxWidth: .infinity) | ||
.posterStyle(imageType) | ||
.accessibilityIgnoresInvertColors() | ||
} | ||
.listRowBackground(Color.clear) | ||
.listRowCornerRadius(0) | ||
.listRowInsets(.zero) | ||
} | ||
} | ||
} |
Oops, something went wrong.