Fix card management on tvOS

- Extract TVToolbarButton as shared component
- Implement tvOS-specific card row with native Toggle and reorder handle
- Add focus section and move command support for reordering
This commit is contained in:
世界
2025-12-04 15:41:17 +08:00
parent ad9a9ae6b4
commit ada4232f54
3 changed files with 135 additions and 55 deletions
@@ -953,46 +953,6 @@ private struct ProfilePickerRow: View {
// MARK: - Legacy iOS ProfilePickerRow (iOS < 26)
#if os(tvOS)
/// Workaround for tvOS SwiftUI bug where toolbar Button text labels fail to render properly.
/// Using UIButton via UIViewRepresentable bypasses this issue.
private struct TVToolbarButton: UIViewRepresentable {
let title: String
let action: () -> Void
func makeUIView(context: Context) -> UIButton {
let button = UIButton(type: .system)
button.setTitle(title, for: .normal)
button.setContentHuggingPriority(.required, for: .horizontal)
button.setContentCompressionResistancePriority(.required, for: .horizontal)
button.addTarget(context.coordinator, action: #selector(Coordinator.buttonTapped), for: .primaryActionTriggered)
return button
}
func updateUIView(_ uiView: UIButton, context: Context) {
uiView.setTitle(title, for: .normal)
uiView.invalidateIntrinsicContentSize()
uiView.sizeToFit()
context.coordinator.action = action
}
func makeCoordinator() -> Coordinator {
Coordinator(action: action)
}
class Coordinator: NSObject {
var action: () -> Void
init(action: @escaping () -> Void) {
self.action = action
}
@objc func buttonTapped() {
action()
}
}
}
#endif
#if os(iOS)
private struct LegacyProfilePickerRow: View {
@EnvironmentObject private var environments: ExtensionEnvironments