Convert Layout & Navigation settings to macOS-native helpers

Add SettingsNavigationRow helper that renders destination-pushing rows
as plain list rows with a trailing chevron on macOS, and drop the top
divider in headerless sections so they don't render a stray rule.
This commit is contained in:
Arkadiusz Fal
2026-04-20 23:34:43 +02:00
parent bb8fb28998
commit 9912327448
2 changed files with 64 additions and 44 deletions

View File

@@ -78,9 +78,9 @@ struct SettingsFormSection<Content: View>: View {
.padding(.horizontal, 16)
.padding(.top, 12)
.padding(.bottom, 4)
}
Divider()
Divider()
}
VStack(alignment: .leading, spacing: 10) {
content()
@@ -133,3 +133,47 @@ struct SettingsFormSection<Content: View>: View {
}
#endif
}
/// A settings row that pushes a destination view onto the navigation stack.
///
/// On macOS it renders as a plain full-width list row with a trailing
/// chevron, matching the native macOS System Settings look. On iOS/tvOS
/// it renders as a standard `NavigationLink` with a `Label`.
struct SettingsNavigationRow<Destination: View>: View {
let titleKey: LocalizedStringKey
let systemImage: String
@ViewBuilder var destination: () -> Destination
init(
_ titleKey: LocalizedStringKey,
systemImage: String,
@ViewBuilder destination: @escaping () -> Destination
) {
self.titleKey = titleKey
self.systemImage = systemImage
self.destination = destination
}
var body: some View {
NavigationLink {
destination()
} label: {
#if os(macOS)
HStack(spacing: 8) {
Label(titleKey, systemImage: systemImage)
Spacer()
Image(systemName: "chevron.right")
.font(.caption)
.foregroundStyle(.tertiary)
}
.frame(maxWidth: .infinity, alignment: .leading)
.contentShape(Rectangle())
#else
Label(titleKey, systemImage: systemImage)
#endif
}
#if os(macOS)
.buttonStyle(.plain)
#endif
}
}