Skip to content

Commit

Permalink
[PBIOS-635] Update Padding Prop to PBNavItem (#475)
Browse files Browse the repository at this point in the history
**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?
  • Loading branch information
RachelRadford21 authored Dec 5, 2024
1 parent ee531a2 commit 9622c16
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions Sources/Playbook/Components/Nav/PBNavItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,28 @@ public struct PBNavItem<Content: View>: 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()
}

Expand Down Expand Up @@ -63,7 +72,7 @@ public struct PBNavItem<Content: View>: View {
.scaledToFill()
.frame(maxWidth: isFullWidth ? .infinity : nil, alignment: .center)
.foregroundColor(captionForegroundColor)
.padding(.horizontal, horizontalPadding)
.padding(.horizontal, orientationPadding)
.padding(.vertical, verticalPadding)
.background(backgroundColor)
.cornerRadius(cornerRadius)
Expand Down Expand Up @@ -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
}
}

Expand Down

0 comments on commit 9622c16

Please # to comment.