Fix form on tvOS

This commit is contained in:
世界
2025-12-06 19:37:21 +08:00
parent 5c7df0d608
commit f1fa3cbbdf
3 changed files with 48 additions and 21 deletions
@@ -11,29 +11,49 @@ public func FormView(@ViewBuilder content: () -> some View) -> some View {
}
public func FormTextItem(_ name: LocalizedStringKey, _ value: String) -> some View {
HStack {
Text(name)
Spacer()
Text(value)
.multilineTextAlignment(.trailing)
.font(Font.system(.caption, design: .monospaced))
#if os(iOS) || os(macOS)
.textSelection(.enabled)
#endif
}
#if os(tvOS)
Button {} label: {
HStack {
Text(name)
Spacer()
Text(value)
.multilineTextAlignment(.trailing)
.font(Font.system(.caption, design: .monospaced))
}
}
#else
HStack {
Text(name)
Spacer()
Text(value)
.multilineTextAlignment(.trailing)
.font(Font.system(.caption, design: .monospaced))
.textSelection(.enabled)
}
#endif
}
public func FormTextItem(_ name: LocalizedStringKey, _ systemImage: String, @ViewBuilder _ value: () -> some View) -> some View {
HStack {
Label(name, systemImage: systemImage)
Spacer()
value()
.multilineTextAlignment(.trailing)
.font(Font.system(.caption, design: .monospaced))
#if os(iOS) || os(macOS)
.textSelection(.enabled)
#endif
}
#if os(tvOS)
Button {} label: {
HStack {
Label(name, systemImage: systemImage)
Spacer()
value()
.multilineTextAlignment(.trailing)
.font(Font.system(.caption, design: .monospaced))
}
}
#else
HStack {
Label(name, systemImage: systemImage)
Spacer()
value()
.multilineTextAlignment(.trailing)
.font(Font.system(.caption, design: .monospaced))
.textSelection(.enabled)
}
#endif
}
public func FormItem(_ title: String, @ViewBuilder content: () -> some View) -> some View {
@@ -35,7 +35,7 @@ public struct NavigationButtonsView: View {
#if os(tvOS)
private var tvOSBody: some View {
Group {
HStack {
if showConnectionsButton {
Button {
onConnectionsTap()
@@ -99,6 +99,13 @@ public struct ConnectionView: View {
.background {
NavigationLink(isActive: $showDetails) {
ConnectionDetailsView(connection)
#if os(tvOS)
.toolbar {
ToolbarItemGroup(placement: .topBarLeading) {
BackButton()
}
}
#endif
} label: {
EmptyView()
}