Polish AddSourceView layout on tvOS

Add a TVSourceRowLabelStyle for consistent icon/text spacing, switch
the Scan Network button to TVFormRowButtonStyle so it matches the
NavigationLink rows, and drop the duplicate navigationTitle in
AddWebDAV/AddSMB views since the title is already shown in the
TVSidebarDetailContainer sidebar.
This commit is contained in:
Arkadiusz Fal
2026-04-17 19:03:46 +02:00
parent 0fe7194d68
commit 5cbcceba9a
4 changed files with 32 additions and 1 deletions

View File

@@ -54,10 +54,12 @@ struct AddSMBView: View {
#if os(iOS) #if os(iOS)
.scrollDismissesKeyboard(.interactively) .scrollDismissesKeyboard(.interactively)
#endif #endif
#if !os(tvOS)
.navigationTitle(String(localized: "sources.addSMB")) .navigationTitle(String(localized: "sources.addSMB"))
#if os(iOS) #if os(iOS)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
#endif #endif
#endif
.onAppear { .onAppear {
if let prefillServer { if let prefillServer {
server = prefillServer server = prefillServer

View File

@@ -55,10 +55,12 @@ struct AddWebDAVView: View {
#if os(iOS) #if os(iOS)
.scrollDismissesKeyboard(.interactively) .scrollDismissesKeyboard(.interactively)
#endif #endif
#if !os(tvOS)
.navigationTitle(String(localized: "sources.addWebDAV")) .navigationTitle(String(localized: "sources.addWebDAV"))
#if os(iOS) #if os(iOS)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
#endif #endif
#endif
.onAppear { .onAppear {
if let url = prefillURL { if let url = prefillURL {
urlString = url.absoluteString urlString = url.absoluteString

View File

@@ -120,6 +120,9 @@ struct AddSourceView: View {
#endif #endif
} label: { } label: {
Label(String(localized: "sources.addWebDAV"), systemImage: "externaldrive.connected.to.line.below") Label(String(localized: "sources.addWebDAV"), systemImage: "externaldrive.connected.to.line.below")
#if os(tvOS)
.labelStyle(TVSourceRowLabelStyle())
#endif
} }
NavigationLink { NavigationLink {
@@ -135,6 +138,9 @@ struct AddSourceView: View {
#endif #endif
} label: { } label: {
Label(String(localized: "sources.addSMB"), systemImage: "server.rack") Label(String(localized: "sources.addSMB"), systemImage: "server.rack")
#if os(tvOS)
.labelStyle(TVSourceRowLabelStyle())
#endif
} }
NavigationLink { NavigationLink {
@@ -150,6 +156,9 @@ struct AddSourceView: View {
#endif #endif
} label: { } label: {
Label(String(localized: "sources.addRemoteServer"), systemImage: "globe") Label(String(localized: "sources.addRemoteServer"), systemImage: "globe")
#if os(tvOS)
.labelStyle(TVSourceRowLabelStyle())
#endif
} }
NavigationLink { NavigationLink {
@@ -178,6 +187,9 @@ struct AddSourceView: View {
.aspectRatio(contentMode: .fit) .aspectRatio(contentMode: .fit)
.frame(width: 24, height: 24) .frame(width: 24, height: 24)
} }
#if os(tvOS)
.labelStyle(TVSourceRowLabelStyle())
#endif
} }
} }
@@ -187,9 +199,12 @@ struct AddSourceView: View {
showingNetworkDiscovery = true showingNetworkDiscovery = true
} label: { } label: {
Label(String(localized: "discovery.scanNetwork"), systemImage: "wifi") Label(String(localized: "discovery.scanNetwork"), systemImage: "wifi")
#if os(tvOS)
.labelStyle(TVSourceRowLabelStyle())
#endif
} }
#if os(tvOS) #if os(tvOS)
.buttonStyle(TVSettingsButtonStyle()) .buttonStyle(TVFormRowButtonStyle())
#endif #endif
} footer: { } footer: {
Text(String(localized: "sources.footer.discovery")) Text(String(localized: "sources.footer.discovery"))

View File

@@ -144,6 +144,18 @@ struct TVSettingsToggle: View {
} }
} }
/// Label style for source rows - explicit icon/text spacing
struct TVSourceRowLabelStyle: LabelStyle {
func makeBody(configuration: Configuration) -> some View {
HStack(spacing: 20) {
configuration.icon
.frame(width: 36, height: 36)
configuration.title
Spacer(minLength: 0)
}
}
}
/// Button style for form rows (toggles, pickers) - matches form appearance /// Button style for form rows (toggles, pickers) - matches form appearance
struct TVFormRowButtonStyle: ButtonStyle { struct TVFormRowButtonStyle: ButtonStyle {
@Environment(\.isFocused) private var isFocused @Environment(\.isFocused) private var isFocused