forked from jellyfin/Swiftfin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS & tvOS] Fix Version Selection (jellyfin#1429)
* iOS + tvOS Versioning * hasMultipleVersions Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com> * v1 * Button Witdh to avoid overflow. Fix build issues. * Let instead of Var. * cleanup --------- Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com>
- Loading branch information
Showing
6 changed files
with
82 additions
and
6 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
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
59 changes: 59 additions & 0 deletions
59
Swiftfin tvOS/Views/ItemView/Components/ActionButtons/VersionMenu.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,59 @@ | ||
// | ||
// 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 ItemView { | ||
|
||
struct VersionMenu: View { | ||
|
||
// MARK: - Focus State | ||
|
||
@FocusState | ||
private var isFocused: Bool | ||
|
||
@ObservedObject | ||
var viewModel: ItemViewModel | ||
|
||
let mediaSources: [MediaSourceInfo] | ||
|
||
// MARK: - Body | ||
|
||
var body: some View { | ||
Menu { | ||
ForEach(mediaSources, id: \.hashValue) { mediaSource in | ||
Button { | ||
viewModel.send(.selectMediaSource(mediaSource)) | ||
} label: { | ||
if let selectedMediaSource = viewModel.selectedMediaSource, selectedMediaSource == mediaSource { | ||
Label(selectedMediaSource.displayTitle, systemImage: "checkmark") | ||
} else { | ||
Text(mediaSource.displayTitle) | ||
} | ||
} | ||
} | ||
} label: { | ||
ZStack { | ||
RoundedRectangle(cornerRadius: 10) | ||
.fill(isFocused ? Color.white : Color.white.opacity(0.5)) | ||
|
||
Label(L10n.version, systemImage: "list.dash") | ||
.font(.title3) | ||
.fontWeight(.semibold) | ||
.foregroundStyle(.black) | ||
.labelStyle(.iconOnly) | ||
} | ||
} | ||
.focused($isFocused) | ||
.scaleEffect(isFocused ? 1.20 : 1.0) | ||
.animation(.easeInOut(duration: 0.15), value: isFocused) | ||
.menuStyle(.borderlessButton) | ||
} | ||
} | ||
} |
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