From 9622c1645ed1697e67e5d2dd1f49ea9f055e11c3 Mon Sep 17 00:00:00 2001 From: Rachel Radford <54749071+RachelRadford21@users.noreply.github.com> Date: Thu, 5 Dec 2024 09:15:25 -0500 Subject: [PATCH] [PBIOS-635] Update Padding Prop to PBNavItem (#475) **What does this PR do?** [PBIOS-635] Update Padding Prop to PBNavItem ### Checklist - [x] **LABELS** - Add a label: `breaking`, `bug`, `improvement`, `documentation`, or `enhancement`. See [Labels](https://github.com/powerhome/playbook-apple/labels) for descriptions. - [x] **RELEASES** - Add the appropriate label: `Ready for Testing` / `Ready for Release` - [x] **TESTING** - Have you tested your story? --- .../Playbook/Components/Nav/PBNavItem.swift | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Sources/Playbook/Components/Nav/PBNavItem.swift b/Sources/Playbook/Components/Nav/PBNavItem.swift index 17cc8e0ed..12715dfb0 100644 --- a/Sources/Playbook/Components/Nav/PBNavItem.swift +++ b/Sources/Playbook/Components/Nav/PBNavItem.swift @@ -19,19 +19,28 @@ public struct PBNavItem: View { var icon: NavigationIcon? var accessory: FontAwesome? let isFullWidth: Bool + var horizontalOrientationPadding: CGFloat? + var vertOrientationPadding: CGFloat? + var vertPadding: CGFloat? var content: Content? - + public init( _ label: String? = nil, icon: NavigationIcon? = nil, accessory: FontAwesome? = nil, isFullWidth: Bool = false, + horizontalOrientationPadding: CGFloat? = nil, + vertOrientationPadding: CGFloat? = nil, + vertPadding: CGFloat? = nil, @ViewBuilder content: @escaping () -> Content = { EmptyView() } ) { self.label = label self.icon = icon self.accessory = accessory self.isFullWidth = isFullWidth + self.horizontalOrientationPadding = horizontalOrientationPadding + self.vertOrientationPadding = vertOrientationPadding + self.vertPadding = vertPadding self.content = content() } @@ -63,7 +72,7 @@ public struct PBNavItem: View { .scaledToFill() .frame(maxWidth: isFullWidth ? .infinity : nil, alignment: .center) .foregroundColor(captionForegroundColor) - .padding(.horizontal, horizontalPadding) + .padding(.horizontal, orientationPadding) .padding(.vertical, verticalPadding) .background(backgroundColor) .cornerRadius(cornerRadius) @@ -198,26 +207,26 @@ extension PBNavItem { } } - var horizontalPadding: CGFloat { + var orientationPadding: CGFloat { switch variant { case .normal: switch orientation { - case .horizontal: return Spacing.medium - case .vertical: return Spacing.small + case .horizontal: return horizontalOrientationPadding ?? Spacing.medium + case .vertical: return vertOrientationPadding ?? Spacing.small } case .subtle, .bold: switch orientation { - case .horizontal: return 14 - case .vertical: return 14 + case .horizontal: return horizontalOrientationPadding ?? 14 + case .vertical: return vertOrientationPadding ?? 14 } } } var verticalPadding: CGFloat { switch variant { - case .normal: return Spacing.small - case .subtle, .bold: return Spacing.xSmall + case .normal: return vertPadding ?? Spacing.small + case .subtle, .bold: return vertPadding ?? Spacing.xSmall } }