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 { public func FormTextItem(_ name: LocalizedStringKey, _ value: String) -> some View {
HStack { #if os(tvOS)
Text(name) Button {} label: {
Spacer() HStack {
Text(value) Text(name)
.multilineTextAlignment(.trailing) Spacer()
.font(Font.system(.caption, design: .monospaced)) Text(value)
#if os(iOS) || os(macOS) .multilineTextAlignment(.trailing)
.textSelection(.enabled) .font(Font.system(.caption, design: .monospaced))
#endif }
} }
#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 { public func FormTextItem(_ name: LocalizedStringKey, _ systemImage: String, @ViewBuilder _ value: () -> some View) -> some View {
HStack { #if os(tvOS)
Label(name, systemImage: systemImage) Button {} label: {
Spacer() HStack {
value() Label(name, systemImage: systemImage)
.multilineTextAlignment(.trailing) Spacer()
.font(Font.system(.caption, design: .monospaced)) value()
#if os(iOS) || os(macOS) .multilineTextAlignment(.trailing)
.textSelection(.enabled) .font(Font.system(.caption, design: .monospaced))
#endif }
} }
#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 { public func FormItem(_ title: String, @ViewBuilder content: () -> some View) -> some View {
@@ -35,7 +35,7 @@ public struct NavigationButtonsView: View {
#if os(tvOS) #if os(tvOS)
private var tvOSBody: some View { private var tvOSBody: some View {
Group { HStack {
if showConnectionsButton { if showConnectionsButton {
Button { Button {
onConnectionsTap() onConnectionsTap()
@@ -99,6 +99,13 @@ public struct ConnectionView: View {
.background { .background {
NavigationLink(isActive: $showDetails) { NavigationLink(isActive: $showDetails) {
ConnectionDetailsView(connection) ConnectionDetailsView(connection)
#if os(tvOS)
.toolbar {
ToolbarItemGroup(placement: .topBarLeading) {
BackButton()
}
}
#endif
} label: { } label: {
EmptyView() EmptyView()
} }