Give the empty tvOS import screens a focusable Done button

With nothing to import, the playlists and subscriptions import screens
had no focusable content; only the container's toolbar Done, which is
not a dependable focus target on tvOS.
This commit is contained in:
Arkadiusz Fal
2026-10-18 23:15:16 +02:00
parent 88551a1366
commit c19be0a0ef
2 changed files with 32 additions and 10 deletions

View File

@@ -11,6 +11,9 @@ struct ImportPlaylistsView: View {
let instance: Instance
@Environment(\.appEnvironment) private var appEnvironment
#if os(tvOS)
@Environment(\.dismiss) private var dismiss
#endif
@State private var playlists: [Playlist] = []
@State private var importedPlaylistIDs: Set<String> = []
@@ -177,11 +180,19 @@ struct ImportPlaylistsView: View {
}
private var emptyView: some View {
ContentUnavailableView(
String(localized: "import.playlists.emptyTitle"),
systemImage: "list.bullet.rectangle",
description: Text(String(localized: "import.playlists.emptyDescription"))
)
ContentUnavailableView {
Label(String(localized: "import.playlists.emptyTitle"), systemImage: "list.bullet.rectangle")
} description: {
Text(String(localized: "import.playlists.emptyDescription"))
} actions: {
#if os(tvOS)
// Nothing in the content is focusable here; the container's
// toolbar Done is not something to rely on to keep the remote free.
Button(String(localized: "common.done")) {
dismiss()
}
#endif
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.accessibilityIdentifier(AccessibilityID.emptyState)
}

View File

@@ -12,6 +12,9 @@ struct ImportSubscriptionsView: View {
let instance: Instance
@Environment(\.appEnvironment) private var appEnvironment
#if os(tvOS)
@Environment(\.dismiss) private var dismiss
#endif
@State private var channels: [Channel] = []
@State private var subscribedChannelIDs: Set<String> = []
@@ -133,11 +136,19 @@ struct ImportSubscriptionsView: View {
}
private var emptyView: some View {
ContentUnavailableView(
String(localized: "import.subscriptions.emptyTitle"),
systemImage: "person.2.slash",
description: Text(String(localized: "import.subscriptions.emptyDescription"))
)
ContentUnavailableView {
Label(String(localized: "import.subscriptions.emptyTitle"), systemImage: "person.2.slash")
} description: {
Text(String(localized: "import.subscriptions.emptyDescription"))
} actions: {
#if os(tvOS)
// Nothing in the content is focusable here; the container's
// toolbar Done is not something to rely on to keep the remote free.
Button(String(localized: "common.done")) {
dismiss()
}
#endif
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.accessibilityIdentifier(AccessibilityID.emptyState)
}