mirror of
https://github.com/yattee/yattee.git
synced 2026-05-13 02:45:03 +00:00
Make unplayable tvOS media files focusable with unsupported alert
This commit is contained in:
@@ -22,6 +22,9 @@ struct MediaBrowserView: View {
|
||||
@State private var sortOrder: MediaBrowserSortOrder
|
||||
@State private var sortAscending: Bool
|
||||
@State private var showViewOptions = false
|
||||
#if os(tvOS)
|
||||
@State private var unsupportedFile: MediaFile?
|
||||
#endif
|
||||
|
||||
private var listStyle: VideoListStyle {
|
||||
appEnvironment?.settingsManager.listStyle ?? .inset
|
||||
@@ -165,7 +168,13 @@ struct MediaBrowserView: View {
|
||||
} else if file.isPlayable {
|
||||
playableFileRow(for: file)
|
||||
} else {
|
||||
#if os(tvOS)
|
||||
MediaFileTVOSUnsupportedButton(onTap: { unsupportedFile = file }) {
|
||||
MediaFileRow(file: file, sortOrder: sortOrder)
|
||||
}
|
||||
#else
|
||||
MediaFileRow(file: file, sortOrder: sortOrder)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,6 +183,20 @@ struct MediaBrowserView: View {
|
||||
.padding(.top, 16)
|
||||
}
|
||||
)
|
||||
#if os(tvOS)
|
||||
.alert(
|
||||
String(localized: "mediaBrowser.unsupportedFile.title"),
|
||||
isPresented: Binding(
|
||||
get: { unsupportedFile != nil },
|
||||
set: { if !$0 { unsupportedFile = nil } }
|
||||
),
|
||||
presenting: unsupportedFile
|
||||
) { _ in
|
||||
Button(String(localized: "common.ok"), role: .cancel) { unsupportedFile = nil }
|
||||
} message: { file in
|
||||
Text(String(localized: "mediaBrowser.unsupportedFile.message \(file.name)"))
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
||||
@@ -35,6 +35,17 @@ struct MediaFileTVOSTapButton<Label: View>: View {
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
|
||||
/// tvOS-only: wraps an unplayable row in a Button so the focus engine can land on it.
|
||||
struct MediaFileTVOSUnsupportedButton<Label: View>: View {
|
||||
let onTap: () -> Void
|
||||
@ViewBuilder let label: () -> Label
|
||||
|
||||
var body: some View {
|
||||
Button(action: onTap) { label() }
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
#else
|
||||
/// iOS/macOS: per-region gesture used by MediaFileRow's icon and text areas.
|
||||
/// Only attaches a gesture when the action differs from `.playVideo`, letting
|
||||
|
||||
Reference in New Issue
Block a user