jellyflood/Swiftfin/Views/ItemEditorView/ItemMetadata/EditMetadataView/EditMetadataView.swift
Joe Kribs 0025422634
[iOS & tvOS] Upgrade SDK to 10.10 (#1463)
* Buildable!

* Update file names.

* Default sort to sort name NOT name.

* SessionInfoDto vs SessionInfo

* Targetting

* Fix many invalid `ItemSortBy` existing. Will need to revisit later to see which can still be used!

* ExtraTypes Patch.

* Move from Binding to OnChange. Tested and Working.

* Update README.md

Update README to use 10.10.6. Bumped up from 10.8.13

* Update to Main on https://github.com/jellyfin/jellyfin-sdk-swift.git

* Now using https://github.com/jellyfin/jellyfin-sdk-swift.git again!

* Paths.getUserViews() userId moved to parameters

* Fix ViewModels where -Dto suffixes were removed by https://github.com/jellyfin/Swiftfin/pull/1465 auto-merge.

* SupportedCaseIterable

* tvOS supportedCases fixes for build issue.

* cleanup

* update API to 0.5.1 and correct VideoRangeTypes.

* Remove deviceProfile.responseProfiles = videoPlayer.responseProfiles

* Second to last adjustment:
Resolved: // TODO: 10.10 - Filter to only valid SortBy's for each BaseItemKind.
Last outstanding item: // TODO: 10.10 - What should authenticationProviderID & passwordResetProviderID be?

* Trailers itemID must precede userID

* Force User Policy to exist.

---------

Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com>
2025-04-06 23:42:47 -04:00

131 lines
3.2 KiB
Swift

//
// 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 Combine
import JellyfinAPI
import SwiftUI
struct EditMetadataView: View {
// MARK: - Observed & Environment Objects
@EnvironmentObject
private var router: BasicNavigationViewCoordinator.Router
@ObservedObject
private var viewModel: ItemEditorViewModel<BaseItemDto>
// MARK: - Metadata Variables
@Binding
var item: BaseItemDto
@State
private var tempItem: BaseItemDto
private let itemType: BaseItemKind
// MARK: - Error State
@State
private var error: Error?
// MARK: - Initializer
init(viewModel: ItemEditorViewModel<BaseItemDto>) {
self.viewModel = viewModel
self._item = Binding(get: { viewModel.item }, set: { viewModel.item = $0 })
self._tempItem = State(initialValue: viewModel.item)
self.itemType = viewModel.item.type!
}
// MARK: - Body
@ViewBuilder
var body: some View {
ZStack {
switch viewModel.state {
case .initial, .content, .updating:
contentView
case let .error(error):
errorView(with: error)
}
}
.navigationBarTitle(L10n.metadata)
.navigationBarTitleDisplayMode(.inline)
.topBarTrailing {
Button(L10n.save) {
item = tempItem
viewModel.send(.update(tempItem))
router.dismissCoordinator()
}
.buttonStyle(.toolbarPill)
.disabled(viewModel.item == tempItem)
}
.navigationBarCloseButton {
router.dismissCoordinator()
}
.onReceive(viewModel.events) { events in
switch events {
case let .error(eventError):
error = eventError
default:
break
}
}
.errorMessage($error)
}
// MARK: - ErrorView
@ViewBuilder
private func errorView(with error: some Error) -> some View {
ErrorView(error: error)
.onRetry {
viewModel.send(.load)
}
}
// MARK: - Content View
@ViewBuilder
private var contentView: some View {
Form {
TitleSection(item: $tempItem)
DateSection(
item: $tempItem,
itemType: itemType
)
if itemType == .series {
SeriesSection(item: $tempItem)
} else if itemType == .episode {
EpisodeSection(item: $tempItem)
}
OverviewSection(
item: $tempItem,
itemType: itemType
)
ReviewsSection(item: $tempItem)
ParentalRatingSection(item: $tempItem)
if [.movie, .episode].contains(itemType) {
MediaFormatSection(item: $tempItem)
}
LocalizationSection(item: $tempItem)
LockMetadataSection(item: $tempItem)
}
}
}