mirror of
https://github.com/yattee/yattee.git
synced 2026-10-24 05:32:53 +00:00
Name the tvOS destination picker in its row
A tvOS menu picker shows only its value, so the collapsed control read as a bare account name. The menu's label is now the whole labelled row - 'Account' leading, the selection trailing, the same shape as the settings switcher row - with the choices as a checkmarked picker inside the menu. Other platforms keep the plain menu picker, which already carries its label.
This commit is contained in:
@@ -176,16 +176,50 @@ struct PlaylistSelectorSheet: View {
|
||||
}
|
||||
|
||||
private var destinationPicker: some View {
|
||||
Picker(String(localized: "accounts.switcher.title"), selection: $selectedDestination) {
|
||||
Text(DataContextSwitcherLabels.title(for: .local, in: appEnvironment))
|
||||
.tag(DataContext.local)
|
||||
|
||||
ForEach(remoteDestinations) { account in
|
||||
Text(DataContextSwitcherLabels.title(for: .account(account.id), in: appEnvironment))
|
||||
.tag(DataContext.account(account.id))
|
||||
#if os(tvOS)
|
||||
// A tvOS menu picker shows only its value; the name of the control has
|
||||
// to be the row's own, so the menu's label is the whole labelled row —
|
||||
// the same shape as the settings switcher row.
|
||||
Menu {
|
||||
destinationOptions
|
||||
} label: {
|
||||
HStack {
|
||||
Text(String(localized: "accounts.switcher.title"))
|
||||
Spacer(minLength: 8)
|
||||
Text(DataContextSwitcherLabels.title(for: selectedDestination, in: appEnvironment))
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
}
|
||||
}
|
||||
#else
|
||||
Picker(String(localized: "accounts.switcher.title"), selection: $selectedDestination) {
|
||||
destinationOptions
|
||||
}
|
||||
.pickerStyle(.menu)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if os(tvOS)
|
||||
/// The same choices, hosted by the labelled menu: a picker inside a menu
|
||||
/// renders as checkmarked items.
|
||||
private var destinationOptions: some View {
|
||||
Picker(selection: $selectedDestination) {
|
||||
destinationOptionRows
|
||||
} label: {}
|
||||
}
|
||||
#else
|
||||
private var destinationOptions: some View { destinationOptionRows }
|
||||
#endif
|
||||
|
||||
@ViewBuilder private var destinationOptionRows: some View {
|
||||
Text(DataContextSwitcherLabels.title(for: .local, in: appEnvironment))
|
||||
.tag(DataContext.local)
|
||||
|
||||
ForEach(remoteDestinations) { account in
|
||||
Text(DataContextSwitcherLabels.title(for: .account(account.id), in: appEnvironment))
|
||||
.tag(DataContext.account(account.id))
|
||||
}
|
||||
}
|
||||
|
||||
/// The pick the sheet opens on: the account the app is browsing as, when
|
||||
|
||||
Reference in New Issue
Block a user