Skip to content

Commit

Permalink
Add option to disable padding
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdifran committed Jun 29, 2024
1 parent c1bc0f4 commit b27ce96
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Sources/AppUI/Extensions/View/View+Shelf.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
import SwiftUI

struct ViewShelf<ShelfContent: View>: ViewModifier {
let spacing: CGFloat?
let shelfContent: ShelfContent
private let spacing: CGFloat?
private let includePadding: Bool
private let shelfContent: ShelfContent

init(spacing: CGFloat? = nil, @ViewBuilder shelfContent: () -> ShelfContent) {
init(
spacing: CGFloat? = nil,
includePadding: Bool = true,
@ViewBuilder shelfContent: () -> ShelfContent
) {
self.spacing = spacing
self.includePadding = includePadding
self.shelfContent = shelfContent()
}

Expand All @@ -23,7 +29,9 @@ struct ViewShelf<ShelfContent: View>: ViewModifier {
shelfContent
}
.horizontallyCentered()
.padding()
.if(includePadding) {
$0.padding()
}
.background {
Rectangle()
.fill(.bar)
Expand Down

0 comments on commit b27ce96

Please sign in to comment.